6

I know you can declare env_variables in your app.yaml as described in the app.yaml documentation. However, is it possible to include environment variables from your local environment into app.yaml when deploying.

As an example of what I'm trying to accomplish

# in app.yaml
runtime: python27
api_version:1
threadsafe: true
service: {{ $AN_ENVIRONMENT_VARIABLE }}
kjschiroo
  • 500
  • 5
  • 10

2 Answers2

9

Yes, you can use includes: to specify an array of files to be included. And in the included file, you can specify env_variables: just like you do in app.yaml. Example: app.yaml:

runtime: go
api_version: go1

env_variables:
  FIST_VAR: myFirstVar

includes:
- credentials.yaml

credentials.yaml:

env_variables:
  SECOND_VAR: mySecondVar
Raees Iqbal
  • 2,160
  • 1
  • 18
  • 15
4

No, no such templating support exists for the app.yaml configuration files.

Side note: the app.yaml file is not only used to extract deployment instructions information, it's also used to configure the operation of the respective service on GAE. Making the service name configurable in such manner doesn't make a lot of sense unless the services being deployed are identical in every aspect (other than their name) - highly unlikely.

One possible approach for environment-specific deployment would be to have different version control branches for the app code, one for each environment, each having the desired app.yaml content.

Another one would be to wrap the deployment command in a script and perform the enviroment substitutions inside that script.

As for passing credentials info to the app a clean, straight-forward solution is not yet available. But approaches exist:

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Yeah, I wouldn't actually intend to use it on `service` specifically. I just wanted a short example that conveys the desired behavior. My actual intention was to use it to include secrets as environment variables, but I thought environment variables inside environment variables would confuse the question. Thanks for the answer though! – kjschiroo Oct 25 '17 at 22:25
  • @voscausa That seems more targeted for being used by apps, but I don't see mentioning about being used for managing the apps themselves. I may have missed it, tho', I just glanced through it. Worth a closer look probably. – Dan Cornilescu Oct 26 '17 at 16:08