[英]Serverless invoke error: "is not authorized to perform: dynamodb:BatchWriteItem on resource: arn:aws:..."
I have this iamRoleStatements on my serverless.yml , which should allow those actions to my lambda functions:我有我的serverless.yml,这应该允许那些动作我lambda函数这个iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
- dynamodb:BatchReadItem
Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/${self:custom.tableName}"
And this my lambda yml:这是我的 lambda yml:
functions:
scraping:
handler: handler.scraping
memorySize: 1536
layers:
- !Sub 'arn:aws:lambda:${AWS::Region}:764866452798:layer:chrome-aws-lambda:22'
timeout: 15
events:
- schedule:
rate: ${self:custom.scheduleRate}
name: schedule-scraping-${self:provider.stage}
description: scraping each 5 minute
enabled: ${self:custom.enabled}
In my handle function, I try to insert an item, but I'm getting this error:在我的句柄函数中,我尝试插入一个项目,但出现此错误:
AccessDeniedException: User: arn:aws:sts::006977245882:assumed-role/BestSellers-qa-us-east-1-lambdaRole/BestSellers-qa-scraping is not authorized to perform: dynamodb:BatchWriteItem on resource: arn:aws:dynamodb:us-east-1:006977245882:table/TABLE_NAME
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20) ...
Unless you've edited/redacted TABLE_NAME
in the error message, my guess is that you're inadvertently attempting to write to a table which probably doesn't exist ( TABLE_NAME
).除非您在错误消息中编辑/编辑了
TABLE_NAME
,否则我的猜测是您无意中尝试写入可能不存在的表( TABLE_NAME
)。
You haven't posted your handler code, but I'd check your code and verify that your actual table name is being set/interpolated correctly before your handler code attempts to insert an item with the DynamoDB API.您尚未发布处理程序代码,但在您的处理程序代码尝试使用 DynamoDB API 插入项目之前,我会检查您的代码并验证您的实际表名是否已正确设置/插入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.