Cloud9 does not expose bash_profile exports in nodejs lambda
Cloud9 does not expose bash_profile exports in nodejs lambda
I have a Cloud9 environment spun up and have modified my ~/.bash_profile to export a value at the end of the file.
export foo="hello world"
export foo="hello world"
I run . ~/.bash_profile and then echo $foo and I see hello world output in the terminal.
. ~/.bash_profile
echo $foo
hello world
I then created a NodeJS Lambda with API Gateway. I run the API Gateway locally in Cloud 9 and attempt to read the environment variables
console.log(process.env)
console.log(process.env)
I see a list of variables available to me that AWS has defined. My export is not listed there however. Since I will be using environment variables when my Lambda is deployed, I want to test it with environment variables defined in the Cloud9 environment.
Is there something specific I have to do in order to get the Lambda to read my .bash_profile exports?
1 Answer
1
AWS Cloud9's Lambda plugin is backed by SAM Local, which uses Docker: https://github.com/awslabs/aws-sam-cli . By default, this means that the ~/.bash_profile file is not used by Lambda; you'll want to load this in manually.
~/.bash_profile
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Are there examples some place on how to do that manually? I'm coming from a Windows world with Visual Studio, so Docker, Linux and SAM are unfamiliar to me.
– Johnathon Sullinger
2 days ago