2

How can I pass environment variables to Managed VM instances on Google App Engine? Is it possible?

  • have you looked at metadata service? – Zig Mandel Jul 23 '15 at 00:52
  • I saw it, but it requires special coding to get some values and so it is not what I want. I am looking for something like the [one for Python App Engine](https://cloud.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Defining_environment_variables) – Kaz Nishimura Jul 23 '15 at 01:24
  • do you start the instances from appengine? – Zig Mandel Jul 23 '15 at 02:20
  • 1
    I started my Docker container as an App Engine Managed VM instance for evaluation. I can make a Dockerfile customized for App Engine but I would like to be able to reuse an existing Dockerfile and to change sensible application settings without redeploying a new version. – Kaz Nishimura Jul 24 '15 at 23:56

2 Answers2

1

There are 2 places you can set Environmental Variables for Managed VM instances:

That is the order of precedence as well.

Now it sounds like you already have a Dockerfile and you don't want to alter it to run in Managed VM's. But you will have to add a app.yaml to get your setup to work with Managed VM's, so add your environmental variables to your app.yaml like so:

env_variables:
  TESTENV: 'setinappyaml 
Terry Ryan
  • 1,911
  • 15
  • 13
  • Thank you for the information. Since Managed VMs documentation is not clear about setting environment variables in app.yaml, I thought it was not implemented yet as they must be passed to `docker run`. I will try it. – Kaz Nishimura Aug 11 '15 at 23:49
  • I tested env_variables in app.yaml and it appeared to work. Is looks just missing from the Managed VMs documentation. – Kaz Nishimura Aug 12 '15 at 10:22
  • Does this work when running locally? For example, in python if I start my web server `gunicorn -b :8080 main:app` this isn't reading app.yaml so Im not getting the env_variables. – sthomps Mar 26 '16 at 00:32
0

If you're running completely locally it won't work. You have to run via the sdk, otherwise the app.yaml isn't even part of the equation.

Terry Ryan
  • 1,911
  • 15
  • 13