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
asked a year ago2182 views
2 Answers
0
Accepted Answer

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
answered a year ago
profile picture
EXPERT
reviewed 24 days ago
  • 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
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions