# cannot access ec2.instances data

**URL:** <https://forum.ansible.com/t/cannot-access-ec2-instances-data/14954>\
**Category:** Ansible Project\
**Created:** [April 7, 2014, 12:45pm UTC](https://forum.ansible.com/t/cannot-access-ec2-instances-data/14954 "2014-04-07T12:45:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fred\_Badel](https://avatars.discourse-cdn.com/v4/letter/f/f07891/32.png) [@Fred\_Badel](https://forum.ansible.com/u/Fred_Badel)\
**Post date:** [April 7, 2014, 12:45pm UTC](https://forum.ansible.com/t/cannot-access-ec2-instances-data/14954/1 "2014-04-07T12:45:00Z")

</div>

Hello,

I am sure that I miss something obvious… but after having tried for a few hours, I just don’t know where to look for a solution …

I have the following playbook to create a new amazon instance and do a few things with it.  
The instance is created correctly, but when I try to access to ec2\_info.instances. private\_ip variables, the playbook fail with an undefined variable error …

Does any one have an idea?

Many thanks in advance.

Fred

\*\* playbook:

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [April 7, 2014, 9:42pm UTC](https://forum.ansible.com/t/cannot-access-ec2-instances-data/14954/2 "2014-04-07T21:42:07Z")

</div>

Hi,

“fatal: [127.0.0.1] =\> One or more undefined variables: ‘list’ object has no attribute ‘private\_ip’”

That’s because ec2\_info.instances is a list, not a dict.

If you use ec2\_info.instances[0] you’ll get the first (and in your case only) instance returned by ec2 (which can create multiple instances)

So ec2\_info.instances[0].private\_ip will get you what you’re after.

Will

---

<div class="post-metadata">

**Author:** ![Fred\_Badel](https://avatars.discourse-cdn.com/v4/letter/f/f07891/32.png) [@Fred\_Badel](https://forum.ansible.com/u/Fred_Badel)\
**Post date:** [April 8, 2014, 8:44am UTC](https://forum.ansible.com/t/cannot-access-ec2-instances-data/14954/3 "2014-04-08T08:44:55Z")

</div>

Hi Will,

I knew it was something obvious!  
It is working much better now.

Thank you very much.

Fred
