mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
eb410a9987
commit
ad7798c26a
1 changed files with 2 additions and 1 deletions
|
@ -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…
Reference in a new issue