def setup_bucket_policy(cls):
sts_client = boto3.client('sts', region_name='eu-west-1')
account_id = sts_client.get_caller_identity()['Account']
policy_document = {
"Version": "2008-10-17",
"Statement": [
{
"Sid": "GiveSESPermissionToWriteEmail",
"Effect": "Allow",
"Principal": {
"Service": "ses.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::{0}/*".format(cls.s3_bucket),
"Condition": {
"StringEquals": {
"aws:Referer": account_id
}
}
}
]
}
s3 = boto3.resource('s3')
policy = s3.BucketPolicy(cls.s3_bucket)
policy.put(Policy=json.dumps(policy_document))
ses_tests.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录