serverless-components / express

⚡ Take existing Express.js apps and host them easily on cheap, auto-scaling, serverless infrastructure (AWS Lambda and AWS HTTP API).
https://serverless.com/components
Apache License 2.0
375 stars 34 forks source link

Some dynamic template variables don't work #69

Closed pss4281 closed 3 years ago

pss4281 commented 3 years ago

Hi there, I'm trying to read a config file and read its contents into an ENV variable, however what I'm getting is an original config string partially interpreted. The 'stage' variable gets replaced properly but everything else is not.

Here's my template:

component: express
name: api

inputs:
  roleName: ${output:api-distributions-permissions.name}
  src: ./src
  # domain: api.${env:domain}
  # Environment variables
  env:
    STAGE: ${stage}
    SCHEMA_NAME: ${file(../../environments.yml):environments.${stage}.dbSchemaName}

Resulting function (you may notice how 'stage' was properly replaced with the correct value):

Screenshot 2021-03-17 at 18 58 50

This exact ENV var definition works in a non-component based service, properly reading the file and putting its content as a ENV variable value. It appears that not all of the dynamic variables available for regular services can be used for component-based services. What are the best practices to solve this?

Framework Core: 2.30.3
Plugin: 4.5.1
SDK: 4.2.0
Components: 3.7.4

Thanks in advance!

pss4281 commented 3 years ago

Got a reply to this in slack group basically confirming that this is an expected behaviour of a component-based service and not all of the dynamic variables are supported at this time. Closing this for now 👍