Search code examples
amazon-web-servicesaws-codepipelineaws-code-deployaws-code-deploy-appspec

Why do I get The deployment failed because no instances were found in your green fleet when using AWS CodeDeploy?


This error is coming up when I try to deploy to my staging environment. I have a running ec2 instance and I have it correctly set to code deploy, but I see that in the error I have no replacement instances. Do I need one?

The code-pipeline path is -

Source (Github) -> CodeBuild -> Staging (codeDeploy) -> ManualApproval -> CodeBuild (for production) -> Production (codeDeploy)

Picture of the error

enter image description here

enter image description here


Solution

  • As per AWS CodeDeploy User Guide:

    A blue/green deployment is used to update your applications while minimizing interruptions caused by the changes of a new application version. CodeDeploy provisions your new application version alongside the old version before rerouting your production traffic.

    All AWS Lambda and Amazon ECS deployments are blue/green.

    An EC2/On-Premises deployment can be in-place or blue/green.

    You have the blue side of the deployment a.k.a. your current version of the application on your instances but you don't have the green fleet a.k.a. where the new version of the application should be deployed.

    One option is to specify the green fleet and create those instances yourself (manual provisioning of instances).

    Another option is that you allow CodeDeploy to provision these instances for you, which will also create an ASG (I would recommend this option as blue/green deployments are normally better). You've selected manual provision as step 1 shows Instance provisioning skipped.

    Alternatively, do an in-place deployment, which is supported for EC2 instances in the cloud/onprem.