# ec2 asg does not spin or replace instances when existing auto scaling group is modified with new launch configuration

**URL:** <https://forum.ansible.com/t/ec2-asg-does-not-spin-or-replace-instances-when-existing-auto-scaling-group-is-modified-with-new-launch-configuration/32178>\
**Category:** Ansible Project\
**Created:** [February 7, 2020, 7:47pm UTC](https://forum.ansible.com/t/ec2-asg-does-not-spin-or-replace-instances-when-existing-auto-scaling-group-is-modified-with-new-launch-configuration/32178 "2020-02-07T19:47:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivani](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@shivani](https://forum.ansible.com/u/shivani)\
**Post date:** [February 7, 2020, 7:47pm UTC](https://forum.ansible.com/t/ec2-asg-does-not-spin-or-replace-instances-when-existing-auto-scaling-group-is-modified-with-new-launch-configuration/32178/1 "2020-02-07T19:47:43Z")

</div>

Hi I am facing an issue with ec2\_asg module when I use target group arn it does not spin or replace instances. I I use classic load balancer it works fine replaces the instances.  
When new asg is created it spins up the instances. If existing asg is modified to use new launch configuration then it does not spin or replaces instances but module throws an error.

```auto
ERROR

```

```auto

```

```auto
"msg": "Waited too long for ELB instances to be healthy

```

- elb\_target\_group:  
name: test-target-group  
protocol: http  
port: 80  
vpc\_id: “{{ vpc-id }}”  
health\_check\_path: /login  
successful\_response\_codes: “200”  
state: present  
region: us-east-1  
register: target\_group

- elb\_application\_lb:  
name: test-alb  
subnets: “{{ subnets }}”  
security\_groups: “{{ securitygroups }}”  
scheme: internet-facing  
purge\_listeners: no  
purge\_rules: no  
region: us-east-1  
listeners:

- Protocol: HTTP  
Port: 80  
DefaultActions:

- Type: forward  
TargetGroupName: test-target-group  
Rules:

- Conditions:

- Field: path-pattern  
Values:

- ‘/test’  
Priority: ‘1’  
Actions:

- TargetGroupName: test-target-group  
Type: forward  
state: present

- name: create launch configuration  
ec2\_lc:  
name: “test-lc-{{ ansible\_date\_time.iso8601\_basic\_short }}”  
image\_id: ami-id  
key\_name: “{{ keypair }}”  
security\_groups: “{{ securitygroups }}”  
instance\_type: “{{ instancetype }}”  
region: us-east-1  
volumes:

- device\_name: /dev/sda1  
volume\_size: 8  
volume\_type: gp2  
delete\_on\_termination: true  
register: launch\_config

- name: create or update autoscaling group  
ec2\_asg:  
name: test-asg  
launch\_config\_name: “{{ launch\_config.result.launch\_configuration\_name }}”  
vpc\_zone\_identifier: “{{ subnets }}”  
health\_check\_period: 90  
health\_check\_type: ELB  
min\_size: 1  
max\_size: 3  
desired\_capacity: 1  
region: us-east-1  
termination\_policies: OldestInstance  
wait\_for\_instances: yes  
default\_cooldown: 60  
wait\_timeout: 200  
lc\_check: yes  
replace\_all\_instances: yes  
target\_group\_arns: “{{ target\_group.target\_group\_arn }}”

Intially when I run it creates everything but when I run second time it creates new launch configuration modifies the asg with with new launch configuration name but does not replace or spin any instances by throwing above error.
