appengine and OS environment variables

2,309 views
Skip to first unread message

Fabio Caritas Barrionuevo da Luz

unread,
May 21, 2017, 8:39:02 PM5/21/17
to Google App Engine
Hello, i would like to deploy an application based on https://github.com/pydanny/cookiecutter-django project template. 

cookiecutter-django based project use environment variables to define various configurations, following the pattern based on https://12factor.net/config 


I would like to versioning app.yaml file in a public git repository, however, there is some information that I can not let public.

Is there any way to set environment variables for an app engine application without explicitly setting the values of those variables in app.yaml?


Heroku-cli gives me a simple way (see below) for defining environment variables. Does Google App Engine have any similar functionality?


# display the config vars for an app
heroku config --app myapp

# display a config value for an app
heroku config:get KEY --app myapp

# set one or more config vars
heroku config:set --app myapp

# unset one or more config vars
heroku config:unset --app myapp


# Writes the contents of heroku config into a local file
heroku config:pull --app myapp

# Writes the contents of a local file into heroku config
heroku config:push --app myapp


George (Cloud Platform Support)

unread,
May 24, 2017, 10:45:09 AM5/24/17
to Google App Engine
Hello Fabio, 

Best way to do it with Python, as recommended by a Google App Engine Python developer in his reply to "Securely storing environment variables in GAE with app.yaml" question on stackoverflow, were by storing the keys in a client_secrets.json file, and excluding that file from being uploaded to git by listing it in your .gitignore file. 

It may be worthwhile mentioning here that Cookiecutter Django does not offer App Engine support. 

Vitaly Bogomolov

unread,
May 25, 2017, 12:26:36 AM5/25/17
to Google App Engine
Hi, All.

In my opinion, the best solution would be allow "env_variables" into "includes" files. Now only builtins, includes, handlers and skip_files may be in "includes", according this:

WBR, Vitaly

George (Cloud Platform Support)

unread,
May 25, 2017, 10:30:21 AM5/25/17
to Google App Engine
Your proposal for env_variables in includes files is quite interesting. Still, it needs a good use case to support it, were it to become a feature request. Why do you think this is better than the one mentioned in the previous reply? What is the essential advantage your solution would offer? A good use case is needed to give the feature request a chance of being implemented. 

Vitaly Bogomolov

unread,
May 25, 2017, 11:12:43 AM5/25/17
to Google App Engine
Hi, George.

if this proposal wil be implemented, the answer for topic starter may be somthing like this:

1. create secret.yaml with content:

env_variables:
  CLIENT_SECRET: you_secret_key

2. add 'secret.yaml' line to you .gitignore file

3. add to you app.yaml:

includes:
- secret.yaml

it's simple and don't need any additional code in gae project

WBR, Vitaly

George (Cloud Platform Support)

unread,
May 29, 2017, 10:04:10 AM5/29/17
to Google App Engine
Hi Vitaly, 

You are encouraged to open a corresponding issue on issuetracker, so all developments and eventual solution may be easily followed. 

Vitaly Bogomolov

unread,
May 29, 2017, 11:39:06 AM5/29/17
to Google App Engine

You are encouraged to open a corresponding issue on issuetracker, so all developments and eventual solution may be easily followed.

WBR, Vitaly.
 

George (Cloud Platform Support)

unread,
May 30, 2017, 9:17:40 AM5/30/17
to Google App Engine
Hi Vitaly, 

As stated in the issue thread itself, you can follow all progress there. 
Reply all
Reply to author
Forward
0 new messages