- Newest
- Most votes
- Most comments
As you said, CodeDeploy requires a running instance to deploy successfully to before it will mark the new application revision as good and use it for further deployments.
For your situation where you need to have 0 instances, there's 2 ways to do this:
- A Blue/Green deployment might work (although, not supported in CFN, so not an option if you're using that)
- You can configure deployment to an EC2 instance based on a Tag. The deployment would go through, and then you could spin the ASG back up with the new revision getting deployed
Hello,
Please try this solution,
Scale down the Auto Scaling Group to 0 instances:
In the AWS Management Console, go to the EC2 Auto Scaling section.
Select the desired Auto Scaling Group.
Set the desired capacity to 0. This will terminate all running instances in the ASG.
Run the necessary actions (like DB migration):
Ensure that all required pre-deployment actions are executed. This can be done manually or using an automation tool like AWS Systems Manager, AWS Lambda, or a custom script.
Update the Launch Configuration or Launch Template:
If using a Launch Configuration:
Create a new Launch Configuration with the new version of the application.
Update the ASG to use the new Launch Configuration.
If using a Launch Template:
Create a new version of the Launch Template with the new version of the application.
Update the ASG to use the new version of the Launch Template.
Scale up the Auto Scaling Group:
Increase the desired capacity of the ASG to the required number of instances. The ASG will launch new instances using the updated Launch Configuration or Launch Template.
The new instances will have the new version of the application.
https://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-auto-scaling.html
https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-auto-scaling.html
Relevant content
- asked 5 years ago
- Accepted Answerasked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago