I am implementing Amazon EC2 Auto Scaling and AWS CodeDeploy (blue green deployment). I have assigned a baked AMI to the Auto Scaling group.
Auto Scaling works with no problem without CodeDeploy.
AWS CodeDeploy for blue green deployment works with no problem. I have assigned the autoscaling group in the deployment group.
However, In order to test Blue Green deployment, I terminate one of the instances manually so that Auto Scaling can launch one more instance. However, the instance starts and terminates abruptly.
I see that AWS CodeDeploy has an error:
The deployment failed because a specified file already exists at this location: webserver/server.js
The AWS CodeDeploy configuration I am using is OneAtTime
and content options: Overwrite the content
.
I only have 1 deployment group for the application.
Currently, I have removed the Auto Scaling group from the AWS CodeDeploy by changing the "Automatically copy Amazon EC2 Auto Scaling group" to "Manually provision instances", which has stopped terminating the instances. However, the new instance created by Auto Scaling does not have the new code. Does CodeDeploy not update or replace the AMI with the new code?
Questions:
Why do I get the error "The deployment failed because a specified file already exists at this location: webserver/server.js"?
The EC2 instance created from autoscaling does not have the latest deployment code?
Is there a better approach to do blue green deployment and autoscaling. or any issues with the above approach?
I have read the AWS CodeDeploy tutorial but have missed something.