我有一个非常简单的 AWS Lambda 函数 - 仅列出我所有的 CloudWatch 事件:
import boto3
def lambda_handler(event, context):
client = boto3.client("events")
return client.list_rules()
但是,当我尝试运行它时(使用空的测试事件:){}
,我得到以下权限异常:
An error occurred (AccessDeniedException) when calling the ListRules operation:
User: arn:aws:sts::123321123321:assumed-role/lambda+basicEvents/lambdaName
is not authorized to perform: events:ListRules
on resource: arn:aws:events:eu-west-1:123321123321:rule/*
我确实将此策略附加到 lambda 执行角色(并且我可以看到 lambda 的权限选项卡中列出的操作):
{
"document": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BasicCloudWatchEventsManager",
"Effect": "Allow",
"Action": [
"events:DescribeRule",
"events:EnableRule",
"events:PutRule",
"events:ListRules",
"events:DisableRule"
],
"Resource": "arn:aws:events:*:*:rule/[*/]*"
}
]
},
"name": "BasicCloudWatchEventsManager",
"id": "SOME7LONG7ID",
"type": "managed",
"arn": "arn:aws:iam::123321123321:policy/BasicCloudWatchEventsManager"
}
我已经使用他们提供的可视化编辑器构建了策略,只是sid
手动更改了。
任何线索可能会丢失什么?