From d2ae4db0bae402248ab4e50bb03b4d3c20528877 Mon Sep 17 00:00:00 2001 From: mandar242 Date: Wed, 21 Jul 2021 16:56:52 -0400 Subject: [PATCH] Add metadata options support --- plugins/modules/ec2_instance.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/modules/ec2_instance.py b/plugins/modules/ec2_instance.py index f4138bc8ff6..e6dced12e06 100644 --- a/plugins/modules/ec2_instance.py +++ b/plugins/modules/ec2_instance.py @@ -1195,6 +1195,12 @@ def build_top_level_options(params): spec['CpuOptions'] = {} spec['CpuOptions']['ThreadsPerCore'] = params.get('cpu_options').get('threads_per_core') spec['CpuOptions']['CoreCount'] = params.get('cpu_options').get('core_count') + if params.get('metadata_options'): + spec['MetadataOptions'] = {} + spec['MetadataOptions']['HttpEndpoint'] = params.get( + 'metadata_options').get('metadata_accessible') + spec['MetadataOptions']['HttpTokens'] = 'optional' if params.get( + 'metadata_options').get('metadata_version') == 'v1 and v2' else 'required' return spec @@ -1737,6 +1743,7 @@ def main(): instance_ids=dict(default=[], type='list', elements='str'), network=dict(default=None, type='dict'), volumes=dict(default=None, type='list', elements='dict'), + metadata_options=dict(type='dict', options=dict(metadata_accessible=dict(type='str', choices=['enabled', 'disabled'], default='enabled'), metadata_version=dict(type='str', choices=['v1 and v2', 'v2'], default='v1 and v2'))), ) # running/present are synonyms # as are terminated/absent