如何通过Elasticbeanstalkconfiguration文件(使用Docker)访问环境variables?

例如,如果我希望装入由环境variables定义的特定卷。

我结束了使用下面的代码:

--- files: "/opt/elasticbeanstalk/hooks/appdeploy/pre/02my_setup.sh": owner: root group: root mode: "000755" content: | #!/bin/bash set -e . /opt/elasticbeanstalk/hooks/common.sh EB_CONFIG_APP_CURRENT=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir) EB_SUPPORT_FILES_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_files_dir) # load env vars eval $($EB_SUPPORT_FILES_DIR/generate_env | sed 's/$/;/') 

如果您需要从Elastic Beanstalkconfiguration文件中访问环境variables,则可以执行以下操作:

 commands: 01-vars: command: | $(/opt/elasticbeanstalk/containerfiles/support/generate_env | grep PARAM -v | sed 's/^/export/') && # do stuff 

这假设你不需要默认的PARAM环境variables。