[ec2_ami] Ensure name or image_id is provided for state=present (#38972)

Add integration tests for backward compatibility and ensuring name or image_id is provided
This commit is contained in:
Sloane Hertel 2018-04-18 19:28:25 -04:00 committed by Will Thames
commit e2aa1155ba
2 changed files with 30 additions and 2 deletions

View file

@ -656,7 +656,7 @@ def main():
virtualization_type=dict(default='hvm'),
root_device_name=dict(),
delete_snapshot=dict(default=False, type='bool'),
name=dict(default=''),
name=dict(),
wait=dict(type='bool', default=False),
wait_timeout=dict(default=900, type='int'),
description=dict(default=''),
@ -680,6 +680,11 @@ def main():
]
)
# Using a required_one_of=[['name', 'image_id']] overrides the message that should be provided by
# the required_if for state=absent, so check manually instead
if not any([module.params['image_id'], module.params['name']]):
module.fail_json(msg="one of the following is required: name, image_id")
try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
connection = boto3_conn(module, conn_type='client', resource='ec2', region=region, endpoint=ec2_url, **aws_connect_kwargs)