有没有办法在Google App Engine的app.yaml中导入环境变量? [英] Is there a way to import environment variables in Google App Engine's app.yaml?

查看:66
本文介绍了有没有办法在Google App Engine的app.yaml中导入环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以按照

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 }}

推荐答案

否,app.yaml配置文件不存在这种模板支持.

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

侧面说明:app.yaml文件不仅用于提取部署指令信息,还用于在GAE上配置相应服务的操作.除非所部署的服务在各个方面(名称除外)在各个方面都是相同的,否则以这种方式配置服务名称没有多大意义.

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.

针对特定环境的部署的一种可能方法是为应用程序代码提供不同的版本控制分支,为每个环境提供一个版本控制分支,每个分支都具有所需的app.yaml内容.

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:

  • GAE: best practices for storing secret keys?
  • How to set environment variables/app secrets in Google App Engine
  • Google app engine: Best practice for hiding Rails secret keys?
  • How to handle sensitive configuration information when deploying app-engine applications?

这篇关于有没有办法在Google App Engine的app.yaml中导入环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆