Closed mdial89f closed 2 years ago
Hey @mdial89f - thanks a lot for reporting and sorry you've run into trouble. We've had a report of this issue already and it has been fixed today - I just published a new version that includes the fix - https://github.com/serverless/compose/releases/tag/v1.2.3
Let me know if that solves the problem for you.
Hey @mdial89f - thanks a lot for reporting and sorry you've run into trouble. We've had a report of this issue already and it has been fixed today - I just published a new version that includes the fix - https://github.com/serverless/compose/releases/tag/v1.2.3
Let me know if that solves the problem for you.
That fixed it! Shame on me, it turns out I was NOT on the latest version. Closing. Thanks for all the work you put into this project.
Ha, you actually were on the latest at the time, as I published the v1.2.3 release a few minutes after your ticket was created.
Thanks for the confirmation that everything now works as expected 🙇
@mdial89f @pgrzesik I'm tagging here because it seems envs worked for you.
I'm trying to use the env:XXX
syntax. I know there's already an issue #185 asking about useDotenv
support but here I see you did not use it (and compose will cry if you try to).
Did serverless compose
stop supporting this syntax? The documentation says it still can use it but after creating .env
file, it does not recognize defined values.
# .env
AWS_REGION=us-west-2
# serverless-compose.yml
services:
serviceA:
path: ...
region: ${env:AWS_REGION}
I'm only getting the The environment variable "AWS_REGION" is referenced but is not defined
error. Can you share if you did anything else to get this working?
I'm on serverless 3.34.0
and serverless-compose 1.3.0
@ada-cienciala What you have should work, provided that your .env file is being properly loaded. I'm not sure if serverless-compose has built in support for loading a .env file located in the current directory. We use a tool called direnv to load our .env files.. can't recommend it enough! It hooks into your shell and keeps people correctly configured.
Oh, I assumed serverless loads the .env
files because of the To automatically load environment variables from .env files (with the help of the dotenv package), set useDotenv: true in serverless.yml
line in the documentation.
But it makes sense they would not load it if you cannot use the useDonenv
in the compose file. So you just load it yourself. That's super useful info, I did not think of that, thank you so much! 🤍
Are you certain it's a bug?
Are you using the latest version?
Is there an existing issue for this?
Issue description
I have created a public repo to demonstrate the issue: https://github.com/mdial89f/env-issue
To summarize: a compose file with the following contents will FAIL with "(node:69391) UnhandledPromiseRejectionWarning: ServerlessError: Unrecognized configuration variable sources: "env":
But if you comment out one of the params calling env, like the following contents, deployment succeeds:
So, it seems you can only call env once in the compose file, for whatever reason.
To demonstrate the issue:
git clone git@github.com:mdial89f/env-issue.git
npm run test
This will fail, as the compose file in source has two parameters both defined with 'env:'npm run test
. This will succeedService configuration (serverless-compose.yml) content
See repo linked above for more info.