What if the codedeploy agent is not installed when deploying with autoscaling?

0

I am distributing ec2 auto scaling through code deploy.

I was deploying without a problem, but suddenly I got an error saying "CodeDeploy agent was not able to receive the lifecycle event. Check the CodeDeploy agent logs on your host and make sure the agent is running and can connect to the CodeDeploy server".

When I searched for the cause of the problem, the codedeploy agent was not installed and executed within ec2. After installing and running it, deploying again worked normally.

There is nothing related to the installation of the codedeploy agent in my deployment process. What is the cause of this sudden error and how can I deal with it?

joker
已提问 1 年前2228 查看次数
2 回答
0
已接受的回答

For your first question "What if its not installed" the answer is: Nothing deploys. Normally:

  1. When you attach the AutoScaling Group (ASG) to the Deployment group, Code Deploy will create a lifecycle hook on the ASG
  2. When an instance is launched, the ASG will trigger this lifecycle hook to notify Code Deploy
  3. The agent within the instance then starts the deployment

As for why it stopped working, hard to tell without being inside your environment. Maybe it was baked into the AMI and the AMI was updated, or the agent version became too old to function? Regardless, to fix the issue you need to make sure the agent is running as part of the instance boostrapping. There's multiple options on how you can accomplish that listed in this doc: https://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-auto-scaling.html

AWS
已回答 1 年前
profile picture
专家
已审核 1 个月前
  • What if we use Instance Refresh? Will CodeDeploy also know to deploy the application there?

  • Yes, any time the ASG launches an instance, the lifecycle hook created by CodeDeploy will be triggered. So as long as the Agent is installed and running, there will be a deployment to the new instance

0

The issue has been resolved. Initially, I added the "iam_user_arn" parameter in the "/etc/codedeploy-agent/conf/codedeployagent.yml" configuration file, which caused the agent to always connect to the specified IAM user. Even though the IAM user had the necessary permissions, the EC2 instance was unable to deploy, and the reason for this issue was unclear.

In the end, I reverted the configuration file to its default settings, and the EC2 instance was associated with the role that had the required permissions. This resolved the problem, and deployment proceeded as expected.

DD-Boom
已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则