Search code examples
bashamazon-web-servicesamazon-ec2aws-code-deploy

Determine Deployment Group from appspec.yml


I am using the elb scripts from https://github.com/awslabs/aws-codedeploy-samples/tree/master/load-balancing/elb to remove my ec2 instances from the load balancer before I do my code updates.

I need to define the load balancer in the ELB_LIST variable of the common_functions.sh bash script. This load balancer will be different for each environment (or deployment group).

Is there a way I can set this variable based on which deployment group I am deploying too from within this bash script?

The application artifacts will be the same, but deployed to different environments or groups and hence, different load balancers.


Solution

  • Well then, after searching the forums on aws, I see they now support deployment specific environment variables.

    So I can reference the deployment group from within bash and set the load balancer:

    if [ "$DEPLOYMENT_GROUP_NAME" == "Staging" ]
    then
        ELB_LIST="STAGING-ELB"
    fi
    

    RE http://blogs.aws.amazon.com/application-management/post/Tx1PX2XMPLYPULD/Using-CodeDeploy-Environment-Variables