I have a playbook that gets user's ec2_asg_facts and gets everything about a particular AWS auto scaling group. I also want to fetch the IP address of the instance. When I execute the following playbook, I get an error
---
- 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') }}"
**ERROR**
TASK [EC2 facts] ********************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'list object' has no attribute 'instances'\n\nThe error appears to have been in '/root/ec2-asg.yml': line 25, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n ec2_asg_instance_ids: \"{{ ec2_asg_facts_results.results[0].instances | map(attribute='instance_id') | list }}\"\n - name: EC2 facts\n