Hey @Neya, try something like this:
---
- name: Create a new Demo EC2 instance
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Find ASG in AWS
ec2_asg_facts:
aws_access_key: ------------------------
aws_secret_key: ----------------------
region: us-east-1
register: auto_scaling_group
register: ec2_asg_facts_results
- name: Create list of instance_ids
set_fact:
ec2_asg_instance_ids: "{{ ec2_asg_facts_results.results[0].instances | map(attribute='instance_id') | list }}"
- name: EC2 facts
ec2_remote_facts:
region: us-east-1
aws_access_key: ---------------------------------
aws_secret_key: ---------------------------------
filters:
instance-id: "{{ ec2_asg_instance_ids.instances[0].interfaces | map(attribute='id') }}"