从 .ebextensions 配置文件访问 Elastic Beanstalk 环境 属性
Accessing an Elastic Beanstalk environment property from an .ebextensions config file
在 Elastic Beanstalk 中,是否可以从 .ebextensions *.config 文件中引用环境 属性?
例如,使用 Cloud Formation 我已将以下环境 属性 添加到创建的环境中 -
- Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: "LOAD_USER_PROFILE"
Value: !Ref "LoadUserProfile"
此 属性 已添加并按预期显示在我的环境的“软件配置”的“环境属性”部分下 -
但是,当我尝试通过 .ebextensions *.config 文件访问 属性 时,它失败并出现以下错误 -
Error occurred during build: Command loaduserprofile failed
这是我的 *.config 文件中的命令(来自给出的答案 here),如果我硬编码 true
或 false
代替 [=15],它就可以工作=] -.
container_commands:
loaduserprofile:
command: appcmd set apppool "DefaultAppPool" -processModel.loadUserProfile:"{$LOAD_USER_PROFILE}"
cwd: C:\Windows\System32\inetsrv
我想要实现的目标是否可行?如果可行,我做错了什么?
将它们作为环境变量传递到应用程序的说法可能会产生误导。
它们实际上作为属性传递给您的应用程序,因此这取决于您在 EB 中部署的应用程序。看来您使用的是 IIS/.Net,因此 属性 名称和值已按照以下答案添加到 web.config:
在 Elastic Beanstalk 中,是否可以从 .ebextensions *.config 文件中引用环境 属性?
例如,使用 Cloud Formation 我已将以下环境 属性 添加到创建的环境中 -
- Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: "LOAD_USER_PROFILE"
Value: !Ref "LoadUserProfile"
此 属性 已添加并按预期显示在我的环境的“软件配置”的“环境属性”部分下 -
但是,当我尝试通过 .ebextensions *.config 文件访问 属性 时,它失败并出现以下错误 -
Error occurred during build: Command loaduserprofile failed
这是我的 *.config 文件中的命令(来自给出的答案 here),如果我硬编码 true
或 false
代替 [=15],它就可以工作=] -.
container_commands:
loaduserprofile:
command: appcmd set apppool "DefaultAppPool" -processModel.loadUserProfile:"{$LOAD_USER_PROFILE}"
cwd: C:\Windows\System32\inetsrv
我想要实现的目标是否可行?如果可行,我做错了什么?
将它们作为环境变量传递到应用程序的说法可能会产生误导。
它们实际上作为属性传递给您的应用程序,因此这取决于您在 EB 中部署的应用程序。看来您使用的是 IIS/.Net,因此 属性 名称和值已按照以下答案添加到 web.config: