[cloud] Bugfix for aws_s3 empty directory creation (#32169)

* [cloud] Bugfix for aws_s3 empty directory creation

* Update integration tests
This commit is contained in:
Ryan Brown 2017-10-26 08:17:13 -04:00 committed by Sloane Hertel
commit 838c1ba6c7
3 changed files with 47 additions and 17 deletions

View file

@ -408,12 +408,10 @@ def create_dirkey(module, s3, bucket, obj):
if module.check_mode:
module.exit_json(msg="PUT operation skipped - running in check mode", changed=True)
try:
bucket = s3.Bucket(bucket)
key = bucket.new_key(obj)
key.set_contents_from_string('')
s3.put_object(Bucket=bucket, Key=obj, Body=b'')
for acl in module.params.get('permission'):
s3.put_object_acl(ACL=acl, Bucket=bucket, Key=obj)
module.exit_json(msg="Virtual directory %s created in bucket %s" % (obj, bucket.name), changed=True)
module.exit_json(msg="Virtual directory %s created in bucket %s" % (obj, bucket), changed=True)
except botocore.exceptions.ClientError as e:
module.fail_json(msg="Failed while creating object %s." % obj, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))