diff options
author | Dave Grochowski <ThePumpingLemma@users.noreply.github.com> | 2017-10-02 13:18:47 -0400 |
---|---|---|
committer | Ryan Brown <sb@ryansb.com> | 2017-10-02 13:18:47 -0400 |
commit | a7229df469a7fe4e147fea7edced84d4568e204c (patch) | |
tree | d10d601b12bcac96b66ff2e0c260e31769b7c359 | |
parent | 02b5c7a8a3db3a634b812d9925210e970f2df337 (diff) | |
download | ansible-a7229df469a7fe4e147fea7edced84d4568e204c.tar.gz |
[cloud] Fix handling of `encrypt` option in aws_s3 module (#30822)
-rw-r--r-- | lib/ansible/modules/cloud/amazon/aws_s3.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/ansible/modules/cloud/amazon/aws_s3.py b/lib/ansible/modules/cloud/amazon/aws_s3.py index 216d978d0e..a61273ed21 100644 --- a/lib/ansible/modules/cloud/amazon/aws_s3.py +++ b/lib/ansible/modules/cloud/amazon/aws_s3.py @@ -396,11 +396,12 @@ def upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, heade if module.check_mode: module.exit_json(msg="PUT operation skipped - running in check mode", changed=True) try: + extra = {} + if encrypt: + extra['ServerSideEncryption'] = 'AES256' if metadata: - extra = {'Metadata': dict(metadata)} - s3.upload_file(Filename=src, Bucket=bucket, Key=obj, ExtraArgs=extra) - else: - s3.upload_file(Filename=src, Bucket=bucket, Key=obj) + extra['Metadata'] = dict(metadata) + s3.upload_file(Filename=src, Bucket=bucket, Key=obj, ExtraArgs=extra) for acl in module.params.get('permission'): s3.put_object_acl(ACL=acl, Bucket=bucket, Key=obj) url = s3.generate_presigned_url(ClientMethod='put_object', |