mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudformation_facts: Connect boto3 using the module_utils AWS connection instead of calling boto3 directly
This commit is contained in:
parent
0d6073aa47
commit
215a591771
1 changed files with 15 additions and 9 deletions
|
@ -156,7 +156,9 @@ class CloudFormationServiceManager:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
|
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:
|
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")
|
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:
|
except Exception as e:
|
||||||
|
@ -268,7 +270,11 @@ def main():
|
||||||
facts['stack_events'] = service_mgr.describe_stack_events(stack_name)
|
facts['stack_events'] = service_mgr.describe_stack_events(stack_name)
|
||||||
|
|
||||||
result['changed'] = False
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
Reference in a new issue