How to deploy code using CodeDeploy with AutoScalingGroup containing multiple target group

1.4k Views Asked by At

This is my case.

  • one instance with three application [ 4000, 4001, 4002 ].

  • Created an ALB and redirected 3 domains to three target groups using rules

  • When I use to create an application in Code-deploy [Blue-green], it asks for only one target group at a time. But I have three target groups associated with the autoscaling group.

  • After Deployment it is not registering instances with other two target groups. I tried Creating Different ALB, i.e., three ALB with three target groups. But I end up in code deploy sending traffic to one target group.

I am deploying code directly from bitbucket. I need code to deploy [Blue-green] to register instance automatically with all three target groups. But as per AWS CodeDeploy documentation, only one target group can be selected at the time of code deploy. Any kind of help is much appreciated.

1

There are 1 best solutions below

2
On

At the moment, CodeDeploy does not support configuring multiple target groups in a single deployment. There are workarounds, but they're not awesome.

1. Break out each application into its own deployment group and deployment individually

You could deploy each application separately in a different deployment group, which would allow you to register/deregister to each target group. However, this approach would not work with blue/green deployments.

2. Register/deregister 2 target groups in your user scripts

You could configure your appspec to register and deregister from 2 targets groups using a script. There is a sample script on Github, though it's not not recommended for production use.

3. Break out your application into 3 sets of instances

Right now, you're running 3 different applications on the same hosts. You probably have good reason to do that, but if you could break out the applications into 3 different sets of hosts, you could break them into 3 different deployment groups and still use blue/green deployments.