在尝试使用dynamodb扫描时,我会得到以下错误:
“arn:aws:sts::747857903140:assumed-role/CodeStarWorker-helpbot-Lambda/awscodestar-helpbot-lambda-FindService-1L7IH17742JLR”:“调用扫描操作时发生了错误(AccessDeniedException):User: errorMessage未被授权执行:dynamodb:扫描资源: arn:aws:dynamodb:us-east-1:747857903140:table/HelpBot”
这在我的SAM模板中:
FindService:
Type: AWS::Serverless::Function
Properties:
Handler: find_service.handler
Runtime: python3.6
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Policies:
- AmazonDynamoDBFullAccess
我能做些什么来解决这个问题?
发布于 2018-10-03 23:05:12
此函数所需的AWS管理IAM策略或IAM策略文档或SAM策略模板的名称,这些名称应附加到该函数的默认角色中。如果设置了角色属性,则此属性没有任何意义。
您需要为包含两组权限的函数定义一个角色,并将其用作“角色”,或者将LambdaTrustRole的权限添加到“策略”中。
后者看起来是这样的:
Policies:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:Scan
Resource: arn:aws:dynamodb:region:account-id:table/table-name
- Effect: Allow
Action:
- ...
Resource: ...
发布于 2020-09-15 18:53:22
您需要向调用方添加新权限(例如lambda函数或.)像这样(例如,我有两个表):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:GetItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem"
],
"Resource": "arn:aws:dynamodb:eu-west-1:77777:table/order"
},
{
"Effect": "Allow",
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:GetItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem"
],
"Resource": "arn:aws:dynamodb:eu-west-1:777:table/ExecutionId"
},
{
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "arn:aws:logs:eu-west-1:777777:*"
},
{
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:eu-west-1:777777:log-group:/aws/lambda/MyReport:*"
]
}
]
}
https://stackoverflow.com/questions/52636564
复制相似问题