Reputation: 10285
I was wondering if it possible to access local environment variables within the app.yaml
file of an app engine project and then use those in python code?
For example, say in my .bash_profile
I have two variables defined:
export [email protected]
export GOOGLE_PASSWORD=password
Inside my app.yaml
file, I try to access them like this:
env_variables:
GOOGLE_EMAIL: {$GOOGLE_EMAIL}
GOOGLE_PASSWORD: {$GOOGLE_PASSWORD}
And then in the python code, I again try to access them by invoking the following:
import os
email = os.environ.get("GOOGLE_EMAIL")
password = os.environ.get("GOOGLE_PASSWORD")
Is this possible and did I just screw up? I believe I had this working last week, but it's fallen apart as of recently. Any help would be great!
Upvotes: 5
Views: 4855
Reputation: 39824
Yes, you can define variables in your app.yaml
file which you can later access in your programs via os.environ
, see https://cloud.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Defining_environment_variables:
Upvotes: 3