Reputation: 151
I am using the below line of codes, however the ACL of only 'owner-account' is applied and the one with 'child-account' doesn't get applied. how to get this fixed. this is more a question related to dictionary I guess..Any help is appreciated.
import json import boto3 import logging
def lambda_handler(event, context): s3 = boto3.resource('s3')
object_acl = s3.ObjectAcl('bucket_name','bucket_key')
response = object_acl.put(
AccessControlPolicy={
'Grants': [
{
'Grantee': {
'ID':'child-account',
'Type': 'CanonicalUser'
},
'Grantee': {
'ID':'owner-account',
'Type': 'CanonicalUser'
},
'Permission': 'FULL_CONTROL'
},
],
'Owner': {
'ID': 'ssm-service-internal-account'
}
})
print(response)
Upvotes: 0
Views: 53
Reputation: 12259
The dictionary structure is wrong. It should be like this
AccessControlPolicy={
'Grants': [
{
'Grantee': {
'ID':'child-account',
'Type': 'CanonicalUser'
},
'Permission': 'FULL_CONTROL'
},
{
'Grantee': {
'ID':'owner-account',
'Type': 'CanonicalUser'
},
'Permission': 'FULL_CONTROL'
}
],
'Owner': {
'ID': 'ssm-service-internal-account'
}
})
Upvotes: 1