Arpan Solanki
Arpan Solanki

Reputation: 855

How to inject environment variables in elastic beanstalk config.yml

In the link below

http://docs.shippable.com/deploy/aws-elastic-beanstalk/

it seems like environment variables are used in config.yml . How do we achieve that? It seems like official documentation of aws does not have details on using variables inside config.yml.

Any suggestions will be of great help.

I am looking to set something like default_platform using env variables and not application variables alone.

Upvotes: 0

Views: 596

Answers (1)

MVV90
MVV90

Reputation: 1

Yes, you won't find anything in AWS documentation because using environment variables for templating the config.yml is a Shippable feature not an AWS feature.

Shippable details how to add extra ENVs (environment variables) in the documentation you posted:

Which reads (highlighted in bold):


  1. Define deploy-eb-basic-params

Description: deploy-eb-basic-params is a params resource that defines variables we want to make easily configurable. These variables definitions replace the placeholders in the Dockerrun.aws.json and config.yml files.

Steps: Add the following yml block to the resources section in your shippable.yml file.

# shippable.yml
resources:

  - name: deploy-eb-basic-params
    type: params
    version:
      params:
        ENVIRONMENT: "sample"
        PORT: 80
        AWS_EB_ENVIRONMENT_SINGLE: "Sample-env"
        AWS_EB_APPLICATION: "deploy-eb-basic"
        CUSTOM_ENV_HERE: "some value" # <------------ your custom value here.

Then you should be able to reference that ENV CUSTOM_ENV_HERE in your config.yml

# config.yml
branch-defaults:
  default:
    environment: ${AWS_EB_ENVIRONMENT_SINGLE}
environment-defaults:
  ${AWS_EB_ENVIRONMENT_SINGLE}:
    branch: null
    repository: null
global:
  application_name: ${AWS_EB_APPLICATION}
  default_ec2_keyname: null
  default_platform: ${CUSTOM_ENV_HERE} # <------------ you reference ENV here.
  default_region: ${DEPLOYEBBASICCONFIG_POINTER_REGION}
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: null
  sc: null
  workspace_type: Application

Best of luck.

Upvotes: 0

Related Questions