CamHart
CamHart

Reputation: 4335

AWS Codedeploy when Autoscaling Group set to 0 instances

I'm using Codedeploy to push to my ec2 instances within an auto scaling group. At times, that auto scaling group doesn't have any existing instances running. When I deploy in that situation, codedeploy ALWAYS fails, even though I've set the minimum healthy hosts to 0 instances.

Is there anyway I can get code deploy to say "success" when there are 0 instances?

It appears when codedeploy fails, it doesn't update the revision. This is a real pain in my situation.

Upvotes: 4

Views: 1992

Answers (2)

RLThomaz
RLThomaz

Reputation: 121

I know it's been over two years, but I faced this same issue. My workaround was creating my own Lifecycle Hook for my Auto Scaling Group and an SNS + Lambda for deploying my revisions.

The catch is, you should first Register a Revision for the application without deploying it. As soon as a new instance is created by the Auto Scaling Group the hook will send an SNS message to the Lambda and then you can (based on the message received + Environment variables) look for revisions (already created) and deploy them to the new instances.

I've linked all this by using CloudFormation - which I extremely recommend for this workaround and all other AWS related services.

Upvotes: 0

Surya Bala
Surya Bala

Reputation: 261

You need to have at least a single instance in your deployment group for the deployment to succeed. After you hook the Autoscaling group (containing at least 1 instance) with CodeDeploy, you should do a successful deployment to update the target revision of the deployment group. After this, any new instance scale up should automatically pick up the target revision.

You could also set the :min property of your autoscaling group to 1 to always keep a single instance in it.

Upvotes: 1

Related Questions