I need to access environment variables I created in AWS Lambda from my Chalice Python code but I am unable to find examples that make sense.
Thoughts?
I am using Python 3.6.
You just use the os environment variable access.
import os
print(os.environ["MY_VARIABLE"])
If your question is how to set the environment variables in Chalice. You set them in the Chalice config:
.chalice/config.json
{
"version": "2.0",
"app_name": "gtf",
"stages": {
"dev": {
"environment_variables": {
"MY_VARIABLE": "MY_VALUE"
}
}
}
}
https://chalice.readthedocs.io/en/latest/topics/configfile.html