有没有办法在Google App Engine的app.yaml中导入环境变量? [英] Is there a way to import environment variables in Google App Engine's 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:存储秘密密钥的最佳做法?
- 如何设置环境变量/应用Google App Engine中的秘密
- Google应用程序引擎:隐藏Rails的最佳做法秘密密钥?
- 如何处理部署应用程序引擎应用程序时获取敏感的配置信息?
- 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屋!