2

We have auto-scaling group behind an Application load balancer which launches instances if the avg. CPU Utilization goes beyond 70%.

We have created a base AMI for the auto-scaling group.

But the problem is that our website updates almost on a regular or weekly basis so what we can configure to allow AWS code-deploy to automatically deploy our latest revision from github on those instances created via auto-scaling group?

If any more information is required please let me know.

Axel
  • 323
  • 1
  • 6
  • 17
  • Are you able to elaborate which aspect specifically you are struggling with? Have you read this for example: https://docs.aws.amazon.com/codedeploy/latest/userguide/tutorials-auto-scaling-group.html – Alex Moore May 18 '19 at 08:33
  • According to docs, what I understood is that I just have to point the deployment group to Auto-scaling group. Is that it? How will the code-deploy know which revision or commit to deploy on the auto-scaling instances? – Axel May 18 '19 at 09:08
  • For that you should use CodePipeline to trigger the CodeDeploy if you want it automated. – Alex Moore May 18 '19 at 09:15
  • Check out this article: https://medium.com/@ariklevliber/continuous-deployment-with-aws-codepipeline-codedeploy-and-github-on-ec2-36eeccfb7a5e – Alex Moore May 18 '19 at 09:17
  • Nice! I didn't indulge in Codepipeline because I didn't want to complicate things too much and I was manually deploying the latest commit by going to code-deploy in the console or via aws CLI and using the latest githun commit ID for deployment. Codepipeline looks better. – Axel May 18 '19 at 09:24
  • I'm new to aws environment. It's been a week only that I've started using AWS so things get confusing for me pretty easily. – Axel May 18 '19 at 09:35
  • Easy to do, they have a crazy number of services. – Alex Moore May 18 '19 at 10:20
  • Is there a way that I can directly connect to you for any help? Discord or anything? If that's okay with you. – Axel May 18 '19 at 10:22
  • You can reach me here: https://uk.linkedin.com/in/alexjmoore – Alex Moore May 18 '19 at 10:31
  • Thank you! One thing more, when I'm manually deploying my code via aws code-deploy console using the latest github commit id, code deployment process is getting stuck at "allow traffic" step. Do you have any idea, why? I searched about this on google but didn't found anything to solve the problem. – Axel May 18 '19 at 11:14
  • 1) you don't need Pipelines, 2) to avoid getting stuck at "allow traffic", set your `Deployment type` to `In-place` – Yevgeniy Afanasyev Aug 23 '19 at 01:47

2 Answers2

0

Code Deploy fully supports Auto Scaling.

Here are the steps to integrate these two services: Integrating CodeDeploy with Amazon EC2 Auto Scaling

Hope that helps :)

MLu
  • 23,798
  • 5
  • 54
  • 81
0

You just have to point the deployment group to Auto-scaling group.

It is a horrifying implicit magic.

However, to make it work you need to set Deployment type In-place, or you will get a new auto scaling group instead. And it mean that you still need 2 instances at least.

Initiating event on each 'Deployment' can tell you more. If your autoScaling group would start a new instance, you will have a new deployment in your CodeDeploy and the Initiating event would say autoScaling, when normally it would say user.

Also look into Auto Scaling Group Lifecycle Hook. The Code deploy creates the hook and name it like so

CodeDeploy-managed-automatic-launch-deployment-hook-Your-Deployment-Group-name-some_numbers

and it somehow knows the Revision. Documentetion.

I could not trace of how SQS Notification from Auto Scaling Group Lifecycle Hook connected to exact CodeDeploy Deployment group and that is why I call it magic.