cloudformation_facts: Connect boto3 using the module_utils AWS connection instead of calling boto3 directly

This commit is contained in:
Ryan S. Brown 2016-09-06 17:14:54 -04:00 committed by Matt Clay
parent 0d6073aa47
commit 215a591771

View file

@ -156,7 +156,9 @@ class CloudFormationServiceManager:
try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
self.client = boto3.client('cloudformation', region_name=region, **aws_connect_kwargs)
self.client = boto3_conn(module, conn_type='client',
resource='cloudformation', region=region,
endpoint=ec2_url, **aws_connect_kwargs)
except botocore.exceptions.NoRegionError:
self.module.fail_json(msg="Region must be specified as a parameter, in AWS_DEFAULT_REGION environment variable or in boto configuration file")
except Exception as e:
@ -268,7 +270,11 @@ def main():
facts['stack_events'] = service_mgr.describe_stack_events(stack_name)
result['changed'] = False
module.exit_json(ansible_facts=result)
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()