3 (A1, A2, A3) 3 (canonical_user_account_A1, canonical_user_account_A2, canonical_user_account_A3) 1 IAM (R1), A3.
A2 canonical_user_account_A1 ( ). , , , ,
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden
I added the resolution Listand Getfor R1politics basket and resolutions role in this case that's not enough, if the account in which a bucket is not the owner, can not afford to users from another account get(download) files. So I needed to make sure that when downloading files I use:
access_control_policy = {
'Grants': [
{
'Grantee': {
'ID': canonical_user_account_A2,
'Type': 'CanonicalUser'
},
'Permission': 'READ'
},
{
'Grantee': {
'ID': canonical_user_account_A3,
'Type': 'CanonicalUser'
},
'Permission': 'READ'
},
],
'Owner': {
'ID': canonical_user_account_A1
}
}
upload_extra_args = {'ACL': 'bucket-owner-full-control'}
s3_client.upload_file(file_path, bucket_name, s3_file_path, ExtraArgs=upload_extra_args)
s3_client.put_object_acl(AccessControlPolicy=access_control_policy, Bucket=bucket_name, Key=s3_file_path)
This allows both canonical_user_account_A2and canonical_user_account_A3read and download the file.
source
share