1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[cloud] Fix handling of encrypt option in aws_s3 module (#30822)

This commit is contained in:
Dave Grochowski 2017-10-02 13:18:47 -04:00 committed by Ryan Brown
parent 02b5c7a8a3
commit a7229df469

View file

@ -396,11 +396,12 @@ def upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, heade
if module.check_mode: if module.check_mode:
module.exit_json(msg="PUT operation skipped - running in check mode", changed=True) module.exit_json(msg="PUT operation skipped - running in check mode", changed=True)
try: try:
extra = {}
if encrypt:
extra['ServerSideEncryption'] = 'AES256'
if metadata: if metadata:
extra = {'Metadata': dict(metadata)} extra['Metadata'] = dict(metadata)
s3.upload_file(Filename=src, Bucket=bucket, Key=obj, ExtraArgs=extra) s3.upload_file(Filename=src, Bucket=bucket, Key=obj, ExtraArgs=extra)
else:
s3.upload_file(Filename=src, Bucket=bucket, Key=obj)
for acl in module.params.get('permission'): for acl in module.params.get('permission'):
s3.put_object_acl(ACL=acl, Bucket=bucket, Key=obj) s3.put_object_acl(ACL=acl, Bucket=bucket, Key=obj)
url = s3.generate_presigned_url(ClientMethod='put_object', url = s3.generate_presigned_url(ClientMethod='put_object',