question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reference to env vars sitting outside main config yml causes error

See original GitHub issue

Error:

 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
RaydelMirandacommented, Feb 2, 2021

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.

1reaction
RaydelMirandacommented, Feb 22, 2021

I agree. I will think some solution for this and let you know here.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found