Reference to env vars sitting outside main config yml causes error
See original GitHub issueError:
Serverless Plugin Error --------------------------------------
Cannot create property 'DYANMODB_TABLE' on string '${file(./serverless-env.yml):environment}'
configs:
serverless.yml
service: my-service
plugins:
- serverless-dotenv-plugin
provider:
name: aws
runtime: nodejs8.10
environment: ${file(./serverless-env.yml):environment}
serverless-env.yml
environment:
SLS_AWS_STAGE: ${env:DYANMODB_TABLE, 'xxvvv'}
No errors when moving environment
to outside the provider
. Verified that it’s working perfectly when it’s located outside provider
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Reference to env vars sitting outside main config yml ...
No errors when moving environment to outside the provider . Verified that it's working perfectly when it's located outside provider . The text...
Read more >Spring Boot App does not recognize environment variables ...
I'm new to Java Spring Boot and I'm trying to set environment variables in application.yml. I've added dotenv maven dependency: <!-- https:// ...
Read more >Introduction to environment variables
Use environment variables to set up various configuration options, and keep your set-up secure with secrets, private keys, and contexts.
Read more >Configuration | Grafana Loki documentation
Each variable reference is replaced at startup by the value of the environment variable. The replacement is case-sensitive and occurs before the YAML...
Read more >Use environment variables in the configuration | Filebeat ...
Each variable reference is replaced at startup by the value of the environment variable. The replacement is case-sensitive and occurs before the YAML...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can read from https://www.serverless.com/framework/docs/providers/aws/guide/plugins/#plugins/:
Variable references in the serverless instance are not resolved before a Plugin’s constructor is called, so if you need these, make sure to wait to access those from your hooks.
In this case the method loadEnv is being called in the constructor of the plugin, causing the known issue since the references have not been resolved at that point.
I agree. I will think some solution for this and let you know here.