从 Elastic Beanstalk .ebextensions 配置文件中引用环境变量 [英] Referencing env variables from Elastic Beanstalk .ebextensions config files
问题描述
是否可以从 .ebextensions 配置文件中引用 PARAM1/PARAM2 等容器环境属性.如果是这样,如何?我试过 $PARAM1 但它似乎是一个空值.
Is it posssible to reference the PARAM1 / PARAM2 etc.. container environment properties from the .ebextensions config files. If so, how? I tried $PARAM1 but it seemed to be an empty value.
我想在启动时将主机名设置为包含 DEV、QA 或 PROD,我通过 PARAM1 环境变量将其传递给我的容器.
I want to set the hostname on startup to contain DEV, QA or PROD, which I pass to my container via the PARAM1 environment variable.
commands:
01-set-correct-hostname:
command: hostname myappname{$PARAM1}.com
推荐答案
事实证明您只能在 container_commands
部分执行此操作,而不能在 commands
部分执行此操作.
It turns out you can only do this in the container_commands
section, not the commands
section.
这有效:
container_commands:
01-set-correct-hostname:
command: "hostname myappname{$PARAM1}.com"
See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands for more details.
这篇关于从 Elastic Beanstalk .ebextensions 配置文件中引用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!