I defined an environment variable called MY_ENVIRONMENT_VARIABLE in AWS Elastic Beanstalk\'s Software Configuration tab.
Now I would like to use this environment variab
Use Fn::GetOptionSetting to retreive environment variables. Environment variables are in aws:elasticbeanstalk:application:environment
namespace
files:
"/tmp/application.properties" :
mode: "000644"
owner: root
group: root
source: '`{"Fn::GetOptionSetting": {"Namespace": "aws:elasticbeanstalk:application:environment", "OptionName": "MY_ENVIRONMENT_VARIABLE", "DefaultValue": "file_path"}}`'
authentication: S3Auth
Note the backtick
which perform the command substitution. DefaultValue
attribute is optional, which is used in case environment variable is not found.
Above config file will create file /tmp/application.properties
with content from the file referenced in environment variable MY_ENVIRONMENT_VARIABLE
.