Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does google app engine support environment variables?

I've noticed that the developer console doesn't seem to expose anywhere where I can configure static environment variables.

Is the expectation on GAE that I will bundle those variables as part of the deployment from my build server? If so, is there any documentation on GAE/Google Cloud that covers why or details the philosophy?

like image 688
Alexander Trauzzi Avatar asked Jun 29 '15 17:06

Alexander Trauzzi


1 Answers

Years have passed, and still it doesn't.

My workaround is to compile app.yaml during deployment process (locally or with CI). For example, I have a template file app.tml.yaml file

runtime: python37
handlers:
- url: /static
  static_dir: app/static/
- url: /.*
  script: auto
env_variables:
  DJANGO_GC_DATABASE_PASSWORD: ${DJANGO_GC_DATABASE_PASSWORD}

Then I call envsubst right before deployment envsubst < ./app.tml.yaml > app.yaml and after that gcloud app deploy as usual. After the deployment is done app.yaml with sensitive data is deleted. Variables are read from local .env file or are set in CI system.

There also other approaches I found listed in this post: https://dev.to/mungell/google-cloud-app-engine-environment-variables-5990 but for me they are not convienient or generic enough.

like image 173
Daniel Titkov Avatar answered Sep 29 '22 13:09

Daniel Titkov