From ad7798c26a2ea15ef4229b58584bdd66071de632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Lambert?= Date: Fri, 30 Nov 2018 04:29:12 +0100 Subject: [PATCH] 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 --- lib/ansible/modules/cloud/amazon/aws_s3.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/aws_s3.py b/lib/ansible/modules/cloud/amazon/aws_s3.py index 00ef2581250..13b5934766a 100644 --- a/lib/ansible/modules/cloud/amazon/aws_s3.py +++ b/lib/ansible/modules/cloud/amazon/aws_s3.py @@ -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.