无法使用 codedeploy 在 ec2 实例上部署代码

Unable to deploy code on ec2 instance using codedeploy

我在 ubuntu 服务器上有一个 ec2 实例 运行,我正在尝试使用 codedeploy 实现 CI/CD 流程,源是 bit-bucket.I jave 还安装了 codedeploy -agent 在 ec2 实例上安装并且 运行 成功但是每当我在 ec2 上部署代码时部署失败并显示如下错误:

The overall deployment failed because too many individual instances failed deployment, too few 
healthy instances are available for deployment, or some instances in your deployment group are 
experiencing problems.

在我使用 less /var/log/aws/codedeploy-agent/codedeploy-agent.log 访问的 CodeDeploy 代理日志文件中显示以下错误:

ERROR [codedeploy-agent(31598)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: 
Missing credentials - please check if this instance was started with an IAM instance profile

我无法理解如何克服这个错误有人告诉我。

CodeDeploy 代理需要您实例的 IAM role/profile 提供的 IAM 权限。 AWS 文档中给出了所需的确切权限: