# Not able to access snapshot\_id, created using module ec2\_snapshot

**URL:** <https://forum.ansible.com/t/not-able-to-access-snapshot-id-created-using-module-ec2-snapshot/24029>\
**Category:** Ansible Project\
**Created:** [March 22, 2017, 5:43am UTC](https://forum.ansible.com/t/not-able-to-access-snapshot-id-created-using-module-ec2-snapshot/24029 "2017-03-22T05:43:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhavin\_Parmar](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@Bhavin\_Parmar](https://forum.ansible.com/u/Bhavin_Parmar)\
**Post date:** [March 22, 2017, 5:43am UTC](https://forum.ansible.com/t/not-able-to-access-snapshot-id-created-using-module-ec2-snapshot/24029/1 "2017-03-22T05:43:22Z")

</div>

Hello all,

I am giving a list of EC2 instance IDs and mounted the volume name to take a snapshot. It is taking snapshots perfectly, but not returning snapshot IDs.

**My code is:**

— # Take Snapshot of EC2s

- name: Take snapshot of EC2s  
hosts: local  
become: no  
connection: local  
gather\_facts: no  
vars:  
region: “us-east-1”  
awsec2id: [“i-037b596065XXXXXXX”,“i-04452f010eXXXXXXX”]  
devname: “/dev/sda1”  
date: “{{ lookup(‘pipe’, ‘date +%Y/%m/%d-%H:%M’) }}”  
tasks:
- name: Create Root snapshots  
ec2\_snapshot:  
region: ‘{{ region }}’  
instance\_id: ‘{{ item }}’  
device\_name: ‘{{ devname }}’  
description: ‘snapshot of /dev/sda1 from {{ item }} taken {{ date }}’  
state: present  
snapshot\_tags:  
frequency: daily  
source: ‘{{ devname }}’  
register: ec2\_snap  
with\_items: ‘{{ awsec2id }}’
- debug:  
msg: ‘{{ ec2\_snap.snapshot\_id }}’  
…

**My Error is:**

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
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: ‘dict object’ has no attribute ‘snapshot\_id’\n\nThe error appears to have been in ‘/home/ansible/playbooks/rol1.yml’: line 25, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n with\_items: ‘{{ awsec2id }}’\n - debug:\n ^ here\n”}

**Usual output of registered variable (ec2\_snap) is as follow:**

ok: [localhost] =\> {  
“changed”: false,  
“msg”: {  
“changed”: true,  
“msg”: “All items completed”,  
“results”: [  
{  
“\_ansible\_item\_result”: true,  
“\_ansible\_no\_log”: false,  
“\_ansible\_parsed”: true,  
“changed”: true,  
“invocation”: {  
“module\_args”: {  
“aws\_access\_key”: null,  
“aws\_secret\_key”: null,  
“description”: “snapshot of /dev/sda1 from i-037b5960651891XXX taken 2017/03/22-05:13”,  
“device\_name”: “/dev/sda1”,  
“ec2\_url”: null,  
“instance\_id”: “i-037b5960651891XXX”,  
“last\_snapshot\_min\_age”: 0,  
“profile”: null,  
“region”: “us-east-1”,  
“security\_token”: null,  
“snapshot\_id”: null,  
“snapshot\_tags”: {},  
“state”: “present”,  
“validate\_certs”: true,  
“volume\_id”: null,  
“wait”: true,  
“wait\_timeout”: 0  
}  
},  
“item”: “i-037b5960651891XXX”,  
“snapshot\_id”: “snap-080407c817cce8XXX”,  
“tags”: {},  
“volume\_id”: “vol-09aec429dfcf28XXX”,  
“volume\_size”: 8  
},  
{  
“\_ansible\_item\_result”: true,  
“\_ansible\_no\_log”: false,  
“\_ansible\_parsed”: true,  
“changed”: true,  
“invocation”: {  
“module\_args”: {  
“aws\_access\_key”: null,  
“aws\_secret\_key”: null,  
“description”: “snapshot of /dev/sda1 from i-04452f010e4cacXXX taken 2017/03/22-05:13”,  
“device\_name”: “/dev/sda1”,  
“ec2\_url”: null,  
“instance\_id”: “i-04452f010e4cacXXX”,  
“last\_snapshot\_min\_age”: 0,  
“profile”: null,  
“region”: “us-east-1”,  
“security\_token”: null,  
“snapshot\_id”: null,  
“snapshot\_tags”: {},  
“state”: “present”,  
“validate\_certs”: true,  
“volume\_id”: null,  
“wait”: true,  
“wait\_timeout”: 0  
}  
},  
“item”: “i-04452f010e4cacXXX”,  
“snapshot\_id”: “snap-0e0cd7819920fdXXX”,  
“tags”: {},  
“volume\_id”: “vol-0aac75ea6d2434XXX”,  
“volume\_size”: 15  
}  
]  
}  
}

**Looking for guidance/help to perform:**  
I would like to store them as a key value pair (i.e. : ) in another YAML file. So I can perform a lookup, based on instance id on newly created YAML file.
