【发布时间】:2021-06-22 12:51:27
【问题描述】:
我创建了一个 s3 存储桶,同时我向存储桶添加了一个策略,表示拒绝对规范用户执行 ListBucket 操作。这里的规范用户就是我。下面是我的代码..
s3_client.create_bucket(Bucket=bucket_name)
bucket_policy = {
'Version': '2012-10-17',
'Statement': [{
'Sid': 'AddPerm',
'Effect': 'Deny',
'Principal':
#I am denying ListBucket access to this canonical user id.
{"CanonicalUser":"1234567777777777777777544444444466666ac73d5bc7cd43619"},
'Action': ['s3:ListBucket'],
'Resource': f'arn:aws:s3:::{bucket_name}',
}]
}
# Convert the policy from JSON dict to string
bucket_policy = json.dumps(bucket_policy)
s3_client.put_bucket_policy(Bucket=bucket_name, Policy=bucket_policy)
s3_client.put_object(Bucket=bucket_name, Key="a/b/c/abc.txt")
#Still i am getting response for this list_objects operation.
response = s3_client.list_objects(Bucket=bucket_name)
print(response)
如何删除 root 用户的特定 s3 存储桶权限?
谢谢
【问题讨论】:
标签: amazon-web-services amazon-s3 boto3 amazon-iam