# ec2-asg Module - AWS Autoscaling groups going over the desired instance count and then scaling back

**URL:** <https://forum.ansible.com/t/ec2-asg-module-aws-autoscaling-groups-going-over-the-desired-instance-count-and-then-scaling-back/22320>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [August 18, 2016, 6:31pm UTC](https://forum.ansible.com/t/ec2-asg-module-aws-autoscaling-groups-going-over-the-desired-instance-count-and-then-scaling-back/22320 "2016-08-18T18:31:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecoutin\_boingo](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ecoutin\_boingo](https://forum.ansible.com/u/ecoutin_boingo)\
**Post date:** [August 18, 2016, 6:31pm UTC](https://forum.ansible.com/t/ec2-asg-module-aws-autoscaling-groups-going-over-the-desired-instance-count-and-then-scaling-back/22320/1 "2016-08-18T18:31:16Z")

</div>

Hello,

I’m wondering if anyone else has observed that when using this Ansible module the AWS API does the following:

1.-Sets the number of instances to be over the desired count, even the maximum if all values are 1.  
2.-Rolls back the number of instances.

This of course turns into having to pay for one hour of instances that are immediately terminated.

In the example below the desired capacity is less than the maximum still, the asg goes over the desired capacity when it is instantiated using this module:

[![](https://lh3.googleusercontent.com/-AfDCXMVmUu0/V7X-61ocEZI/AAAAAAAAAEk/go2neRCIKLsrfUE_2npRYZ1wjK7biuCdwCLcB/s320/Screen%2BShot%2B2016-08-17%2Bat%2B6.58.18%2BPM.png)](https://lh3.googleusercontent.com/-AfDCXMVmUu0/V7X-61ocEZI/AAAAAAAAAEk/go2neRCIKLsrfUE_2npRYZ1wjK7biuCdwCLcB/s1600/Screen%2BShot%2B2016-08-17%2Bat%2B6.58.18%2BPM.png)

Code:

`

- name: create autoscale groups  
ec2\_asg:  
name: my\_asg  
load\_balancers: my\_elb  
launch\_config\_name: my\_lc  
min\_size: 1  
max\_size: 8  
desired\_capacity: 2  
region: us-west-1  
vpc\_zone\_identifier: subnet-090909  
health\_check\_type: EC2  
replace\_all\_instances: yes  
replace\_batch\_size: '1  
lc\_check: false  
default\_cooldown: 1200  
health\_check\_period: 1200

`

---

<div class="post-metadata">

**Author:** ![rybrown](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rybrown](https://forum.ansible.com/u/rybrown)\
**Post date:** [August 19, 2016, 6:44pm UTC](https://forum.ansible.com/t/ec2-asg-module-aws-autoscaling-groups-going-over-the-desired-instance-count-and-then-scaling-back/22320/2 "2016-08-19T18:44:51Z")

</div>

Hi, can you attach your Ansible and modules version? I believe there were some changes to this behavior released with 2.1, so upgrading may solve your problem.

Thanks,  
Ryan
