<p>What you're going to do is only calling for inconsistencies between your nodes.</p>
<p>I wouldn't do <em>any</em> deployment during the instance boot-up, instead install <a href="https://aws.amazon.com/codedeploy/" rel="nofollow noreferrer"><strong>AWS CodeDeploy</strong></a> as part of your boot-up (or bake it into the AMI) and once the instance boots up it contacts the CodeDeploy service and obtains the newest code version.</p>
<p>Likewise if you need to roll-out a newer code version push it to CodeDeploy and it will take care of updating all the servers in your Auto-Scaling Group in a consistent, predictable way.</p>
<p>With ASG you really really want to prevent inconsistencies between the nodes and this is one of the ways to do it.</p>
<p>Hope that helps :)</p>

CC BY-SA 4.0
2020-08-19T03:30:24.730Z
Thank you. By the way, how do yo learn about techniques and services you don't even realize you should be asking about? Is there a modern book that treats AWS best practices, or do you just read the docs from start to end?
piojo
CC BY-SA 4.0
2020-08-19T03:48:14.383Z
@piojo Heh, that's a million dollar question. I don't know every detail of every service but it's useful to know what exists out there. To stay up to date you can for example subscribe to AWS blog, attend Cloud / DevOps / etc meetups, watch conference keynotes where they announce new services (e.g. AWS re:Invent keynotes on YouTube), etc. Also try to get AWS certified - you'll learn a lot while preparing for it.
MLu
CC BY-SA 4.0
2020-08-19T01:59:14.580Z
2020-08-19T01:59:14.580Z
MLu
<p>I'm converting some servers from manual scaling (with a load balancer) to auto-scaling. I'm currently using an Ansible  script to manage upgrades, and I wouldn't want an automatically created instance to not be using the newest version of the software. I created an AMI that will download the newest commit from a chosen branch on first boot.</p>
<p>I've since realized my approach is somewhat like &quot;cowboy coding&quot;, since AWS provides a mechanism to replace auto-scaling instances when there should be an update. (If using that, my existing update script would become obsolete, and I guess the update would entail creating a new AMI containing the new server version.)</p>
<p>Are there any serious problems with using the &quot;cowboy&quot; approach? I realize auto-created servers might end up with newer code than the other servers (if someone pushes but does not deploy their code changes). I wonder whether auto-scaling will cause Ansible scripts to fail if servers are terminated while being processed by Ansible. What have I missed?</p>

<amazon-web-services><ansible><autoscaling>
Are there serious problems with an EC2 auto-scaling AMI that automatically downloads newest server from git?
piojo
# Are there serious problems with an EC2 auto-scaling AMI that automatically downloads newest server from git?

(Asked by: username_0 on 2020-08-06)

I'm converting some servers from manual scaling (with a load balancer) to auto-scaling. I'm currently using an Ansible script to manage upgrades, and I wouldn't want an automatically created instance to not be using the newest version of the software. I created an AMI that will download the newest commit from a chosen branch on first boot.

I've since realized my approach is somewhat like "cowboy coding", since AWS provides a mechanism to replace auto-scaling instances when there should be an update. (If using that, my existing update script would become obsolete, and I guess the update would entail creating a new AMI containing the new server version.)

Are there any serious problems with using the "cowboy" approach? I realize auto-created servers might end up with newer code than the other servers (if someone pushes but does not deploy their code changes). I wonder whether auto-scaling will cause Ansible scripts to fail if servers are terminated while being processed by Ansible. What have I missed?

**Tags:** amazon-web-services, ansible, autoscaling


---

## 1 answers

### Answer by username_1 on 2020-08-19. Score: 2

What you're going to do is only calling for inconsistencies between your nodes.

I wouldn't do *any* deployment during the instance boot-up, instead install [**AWS CodeDeploy**](https://aws.amazon.com/codedeploy/) as part of your boot-up (or bake it into the AMI) and once the instance boots up it contacts the CodeDeploy service and obtains the newest code version.

Likewise if you need to roll-out a newer code version push it to CodeDeploy and it will take care of updating all the servers in your Auto-Scaling Group in a consistent, predictable way.

With ASG you really really want to prevent inconsistencies between the nodes and this is one of the ways to do it.

Hope that helps :)

> **Comments:**
> **username_0**: Thank you. By the way, how do yo learn about techniques and services you don't even realize you should be asking about? Is there a modern book that treats AWS best practices, or do you just read the docs from start to end?  
> **username_1**: @username_0 Heh, that's a million dollar question. I don't know every detail of every service but it's useful to know what exists out there. To stay up to date you can for example subscribe to AWS blog, attend Cloud / DevOps / etc meetups, watch conference keynotes where they announce new services (e.g. AWS re:Invent keynotes on YouTube), etc. Also try to get AWS certified - you'll learn a lot while preparing for it.  

---

