1

When the Auto Scaling Group creates a new instances, the code from CodeDeploy is not downloaded and installed on a newly created EC2 instance.

I've followed the documentation here: https://docs.amazonaws.cn/en_us/codedeploy/latest/userguide/tutorials-auto-scaling-group-create-auto-scaling-group.html

And the last steps says

Install the CodeDeploy agent by following the steps in Install the CodeDeploy agent and using the Name=CodeDeployDemo instance tags.

My "user" script run on the new instance from the ASG (Auto Scaling Group) correctly installs and run the CodeDeploy agent (connecting to SSh to the machine and running a service codedeploy-agent status shows it's running), but from there, I don't know how to tell CodeDeploy to deploy the code to that instance. (Or to run CodePipeline for that instance?)

What should I do here?

halfer
  • 19,824
  • 17
  • 99
  • 186
Cyril N.
  • 38,875
  • 36
  • 142
  • 243
  • This should work out of the box. You linked only the first part of tutorial. What about the rest? – Marcin Jun 14 '21 at 00:18
  • What rest? The last part of the comment is blocking me : "and using the Name=CodeDeployDemo instance tags". Where do I set that Name in the code agent? – Cyril N. Jun 14 '21 at 05:59
  • You install it using [SSM run command](https://docs.aws.amazon.com/systems-manager/latest/userguide/execute-remote-commands.html) as explained in the [docs](https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-ssm.html) and this is where you would setup the Name tag. But you don't need to do this as you already installed it using `UserData`. – Marcin Jun 14 '21 at 06:10
  • Does installing the CD-Agent from SSM is different than from UserData (I do a wget from the latest version, setting chmod +x then running with "./install auto", that's all). I just tested again, by deleting the EC2 instance. The ASG correctly detected an invalid number of instances, started a new one, correctly run the UserData scripts (installing the code agent), but nothing more. I ssh'd in the instance, the agent was running, but no deployment were present. I can't find any logs that contain errors about what happened. – Cyril N. Jun 14 '21 at 07:30
  • This goes back to my first command. What about the rest of this tutorial? Did you complete [Step 2](https://docs.amazonaws.cn/en_us/codedeploy/latest/userguide/tutorials-auto-scaling-group-create-deployment.html)? – Marcin Jun 14 '21 at 07:33
  • Thank you. When doing [Step 2](https://docs.amazonaws.cn/en_us/codedeploy/latest/userguide/tutorials-auto-scaling-group-create-deployment.html#tutorials-auto-scaling-group-create-deployment-console), I haevn't done the last parts (from step 17 (via the Console)), which is "Create Deployment". Maybe I had to specify an initial deployment file to let CodeDeploy know what to deploy? But if I'm right here, how can I tell CodeDeploy to always deploy the latest "successful" data from Github that was previously deployed? – Cyril N. Jun 14 '21 at 07:54
  • Sorry, I don't know what you are doing. The tutorial you liked does not use github, so I don't know how it relates to the docs. If you don't mind I can provide answer based on the comments, if the comments helped you with the issue of "Install the CodeDeploy agent by following the steps in Install the CodeDeploy agent and using the Name=CodeDeployDemo instance tags."? – Marcin Jun 14 '21 at 08:20
  • 1
    Thank you for your help, I finally managed to find the issue: it was that the codedeploy scripts (appspec.yml) was running some scripts that failed silently, causing the server to not be ready and deleting the deployment... – Cyril N. Jun 14 '21 at 14:54

1 Answers1

1

Based on the comments.

The issue of being stuck at:

Install the CodeDeploy agent by following the steps in Install the CodeDeploy agent and using the Name=CodeDeployDemo instance tags.

was simply resolved by skipping this step. It is not needed, as OP uses UserData to setup CodeDeploy Agent.

Marcin
  • 215,873
  • 14
  • 235
  • 294