Add the ability to download a specific version of an S3 object (#47867)

Add the ability to download a specific version of a S3 Object

Fixes: #47864
pull/49350/head
Gaël Lambert 6 years ago committed by Abhijeet Kasurde
parent eb410a9987
commit ad7798c26a

@ -583,9 +583,10 @@ def download_s3file(module, s3, bucket, obj, dest, retries, version=None):
except botocore.exceptions.BotoCoreError as e:
module.fail_json_aws(e, msg="Could not find the key %s." % obj)
optional_kwargs = {'ExtraArgs': {'VersionId': version}} if version else {}
for x in range(0, retries + 1):
try:
s3.download_file(bucket, obj, dest)
s3.download_file(bucket, obj, dest, **optional_kwargs)
module.exit_json(msg="GET operation complete", changed=True)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
# actually fail on last pass through the loop.

Loading…
Cancel
Save