Environment variable parsing of CDK lambda is not working properly
See original GitHub issue🐛 Bug Report
What is the problem?
When using environment variables to define lambda function, the value will become totally different in AWS console panel.
Reproduction Steps
-
Define a
TIMETABLE
variable with17:00
string.const lambdaFn = new lambda.Function(this, 'Singleton', { environment: {VALUE: 123, 'TIMETABLE': '17:00'} });
-
Generate
template.yaml
.cdk synth --no-staging > template.yaml
And the
TIMETABLE
seems weird from here.SingletonXXXXXXX: Type: AWS::Lambda::Function Environment: Variables: VALUE: "123" TIMETABLE: 17:00
-
Go to lambda function of AWS console panel, and the value of environment variable
TIMETABLE
is1020
.
Environment
- CDK CLI Version: 1.6.1
- Module Version: 1.6.1
- OS: OSX Mojave
- Language: TypeScript
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Troubleshooting common AWS CDK issues
This topic describes how to troubleshoot the following issues with the AWS CDK.
Read more >AWS Lambda Environment Variables Best Practices
This blog will show you how to correctly parse, validate, and use your environment variables in your Python AWS Lambda both in deployment ......
Read more >AWS Lambda Environment Variables Best Practices
In this blog, I will show you how to properly parse, validate and use your environment variables in your Python AWS Lambda. And...
Read more >Homepage - AWS Lambda Powertools for Python
Utilities might work with web frameworks and non-Lambda environments, though they are not officially supported. Eases the adoption of best practices. The main ......
Read more >Getting the most of AWS Lambda free compute - wrapper scripts
Tagged with serverless, lambda, aws, cdk. ... The Node.js problem ... Since the environment variables specified for the AWS Lambda function ...
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 FreeTop 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
Top GitHub Comments
It’s possible that it was fixed in the underlying YAML package we use - https://github.com/eemeli/yaml/.
Possibly this - https://github.com/eemeli/yaml/commit/884fe078566a3c569e3da1112ff21f45830df2fe ?
As @rhboyd pointed out, this is coming from the serializing function of the underlying YAML library.
You could use the
--json
option ofcdk synth
to generate the output in JSON, or use the one we generate for every synth command that you can find in thecdk.out
folder. @tpai - Would this sufficiently mitigate what you’re trying to do here?cdk deploy
uses the JSON format, so this shouldn’t occur when the stack is deployed via thedeploy
command.