We are trying to save environment-specific application configuration files in s3. Files are stored in different subdirectories named after the environment, and also have the environment as part of the file name.
Examples
dev/application-dev.properties stg/application-stg.properties prd/application-prd.properties
The elastic Beanstalk environments are called dev, stg, prd , and I also have an environment variable defined in Elastic Beanstalk called ENVIRONMENT, which can be dev, stg or prd ,
Now my question is: how do I refer to the environment name or the ENVIRONMENT variable when loading the configuration file from the configuration file in .ebextensions?
I tried to use the link {"Ref": "AWSEBEnvironmentName" } in .ebextensions / myapp.config, but when deploying I get a syntax error.
The contents of .ebextensions / myapp.config:
files: /config/application-`{"Ref": "AWSEBEnvironmentName" }`.properties: mode: "000666" owner: webapp group: webapp source: https://s3.amazonaws.com/com.mycompany.mybucket/`{"Ref": "AWSEBEnvironmentName" }`/application-`{"Ref": "AWSEBEnvironmentName" }`.properties authentication: S3Access Resources: AWSEBAutoScalingGroup: Metadata: AWS::CloudFormation::Authentication: S3Access: type: S3 roleName: aws-elasticbeanstalk-ec2-role buckets: com.mycompany.api.config
The error I am getting is:
The configuration file .ebextensions/myapp.config in application version manualtest-18 contains invalid YAML or JSON. YAML exception: Invalid Yaml: mapping values are not allowed here in "<reader>", line 6, column 85: ... .config/stg/application-`{"Ref": "AWSEBEnvironmentName" }`.prop ... ^ , JSON exception: Invalid JSON: Unexpected character (f) at position 0.. Update the configuration file.
What is the correct way to reference an environment variable in a .ebextensions configuration file in AWS Elastic Beanstalk?