# cloudformation module: list resources in results?

**URL:** <https://forum.ansible.com/t/cloudformation-module-list-resources-in-results/16582>\
**Category:** Ansible Developer\
**Created:** [October 22, 2014, 2:44pm UTC](https://forum.ansible.com/t/cloudformation-module-list-resources-in-results/16582 "2014-10-22T14:44:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Farrell](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@Dan\_Farrell](https://forum.ansible.com/u/Dan_Farrell)\
**Post date:** [October 22, 2014, 2:44pm UTC](https://forum.ansible.com/t/cloudformation-module-list-resources-in-results/16582/1 "2014-10-22T14:44:11Z")

</div>

As a cloudformation user, I usually interact with stack resources via their Logical Resource ID (that is to day, their ‘name’ in the cloud formation template). However, the cloudformation module doesn’t seem to provide this information as part of the result. Thus currently, if I wish to easily save cloudformation results in a register and work with them later, I must add an output for the logicalID and phyiscal ID of each resource. I feel this information should be included as part of the results of the cloudformation module.

Let me point out right now, that I’m not a python developer and also new to ansible, so perhaps there’s better ways. But I want this functionality, so I figured I’d ask and see if it’s something the ansible development community would want.

Here’s the change I made to get it working for me. It’s pretty simple, just iterates over the stack attributes and grabs a few interesting tidbits, and sticks them in a dict under ‘stack\_resources’ in result.

My question is: would something like this be welcome as a PR, assuming the testing/doc/whatever is provided?

diff --git a/library/cloud/cloudformation b/library/cloud/cloudformation  
index 6a7838a..92cea61 100644  
— a/library/cloud/cloudformation  
+++ b/library/cloud/cloudformation  
@@ -285,6 +285,13 @@ def main():  
for output in stack.outputs:  
stack\_outputs[output.key] = output.value  
result[‘stack\_outputs’] = stack\_outputs

- result[‘stack\_resources’] = {}
- for resource in cfn.list\_stack\_resources(stack\_name):
- result[‘stack\_resources’][resource.logical\_resource\_id] = dict(
- physical\_resource\_id= resource.physical\_resource\_id,
- logical\_resource\_id = resource.logical\_resource\_id,
- resource\_type = resource.resource\_type
- )

# absent state is different because of the way delete\_stack works.

# problem is it it doesn’t give an error if stack isn’t found

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [October 23, 2014, 5:07pm UTC](https://forum.ansible.com/t/cloudformation-module-list-resources-in-results/16582/2 "2014-10-23T17:07:33Z")

</div>

Hi Dan,

Yes, I think that’s a sane request. Feel free to send us a PR.

Thanks!

---

<div class="post-metadata">

**Author:** ![Mick\_Bass](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mick\_Bass](https://forum.ansible.com/u/Mick_Bass)\
**Post date:** [October 25, 2014, 3:51am UTC](https://forum.ansible.com/t/cloudformation-module-list-resources-in-results/16582/3 "2014-10-25T03:51:33Z")

</div>

+1. As an Ansible consumer and extensive user of CloudFormation, this would be quite useful!
