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
- )