我希望在我的AWS函数(python3.6环境)中获得S3桶对象标记。我正在本地环境中成功地获得对象标记,但是当我在AWS函数中运行它时,我会收到以下错误:
"errorMessage":“调用GetObjectTagging操作时发生错误(AccessDenied):访问被拒绝”,
尽管我已经创建了包含s3桶和对象的所有写操作的IAM角色。
IAM作用政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"elastictranscoder:*",
"s3:*"
],
"Resource": "*"
}
]
} 守则是:
python
import boto3
s3 = boto3.client('s3')
bucket = 'bucket_name'
key = 'SampleVideo_360x240_2mb (1)----swae.mp4'
response = s3.get_object_tagging(
Bucket=bucket,
Key=key,
)
tag_set = response.get("TagSet")
print(tag_set)发布于 2019-05-05 05:55:51
为了测试这种情况,我执行了以下操作:
Lambda代码位于一个函数中:
import boto3
def lambda_handler(event, context):
s3 = boto3.client('s3')
bucket = 'my-bucket'
key = 'foo.jpg'
response = s3.get_object_tagging(
Bucket=bucket,
Key=key,
)
tag_set = response.get("TagSet")
print(tag_set)我以测试的形式调用了该函数,它成功地运行并产生了以下输出:
START RequestId: 9e21b6b5-5456-4ec7-9488-0c11c1d52fca Version: $LATEST
[{'Key': 'cheese', 'Value': 'gruyere'}]
END RequestId: 9e21b6b5-5456-4ec7-9488-0c11c1d52fca
REPORT RequestId: 9e21b6b5-5456-4ec7-9488-0c11c1d52fca Duration: 1218.70 ms Billed Duration: 1300 ms Memory Size: 128 MB Max Memory Used: 60 MB 所以,对我来说一切顺利!
https://stackoverflow.com/questions/55950396
复制相似问题