- name: Create Auto Scaling Group
amazon.aws.autoscaling_group:
name: "asg"
launch_template:
launch_template_name: "launch-template"
health_check_period: 60
health_check_type: ELB
replace_all_instances: true
min_size: 1
max_size: 3
desired_capacity: 2
region: us-east-1
replace_all_instances: true
target_group_arns: "{{ target_group.target_group_arn }}"
vpc_zone_identifier: ["{{ private_subnet_info1.subnets[0].subnet_id }}", "{{ private_subnet_info2.subnets[0].subnet_id }}"]
wait_for_instances: false
wait_timeout: 1800
I can see that is correct in web console after this but no instances are in the target group, so to fix I have to unassign it in the web console and then re-assign it.
After running the ec2 will launch and be assigned to the target group.