Env Variable in .ebextensions “files:” section

前端 未结 1 1116
别跟我提以往
别跟我提以往 2021-02-04 08:56

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

相关标签:
1条回答
  • 2021-02-04 10:01

    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.

    0 讨论(0)
提交回复
热议问题