为什么我在使用 AWS CodeDeploy 时会收到 The deployment failed because no instances were found in your green fleet?

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

当我尝试部署到暂存环境时出现此错误。我有一个 运行 ec2 实例,我已将其正确设置为代码部署,但我在错误中看到我没有替换实例。我需要一个吗?

代码管道路径是 -

来源 (Github) -> CodeBuild -> 暂存 (codeDeploy) -> ManualApproval -> CodeBuild(用于生产) -> 生产 (codeDeploy)

错误图片

根据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.

您有部署 blue 端 a.k.a。您实例上当前的应用程序版本,但您没有绿色舰队 a.k.a。应该部署新版本应用程序的位置。

一种选择是指定绿色队列并自行创建这些实例(手动配置实例)。

另一种选择是您允许 CodeDeploy 为您配置这些实例,这也会创建一个 ASG(我推荐此选项,因为 blue/green 部署通常更好)。您已选择手动配置,因为第 1 步显示 已跳过实例配置

或者,执行 in-place deployment,cloud/onprem 中的 EC2 实例支持此操作。