我在我的serverless.yml,上有这个serverless.yml,,它应该允许那些操作到我的lambda函数中:
- 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}"这是我的羔羊
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}在我的handle函数中,我尝试插入一个项,但是我得到了这个错误:
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) ...发布于 2021-11-06 20:41:19
除非您在错误消息中编辑/编辑了TABLE_NAME,否则我的猜测是您无意中试图写入可能不存在的表(TABLE_NAME)。
您还没有发布处理程序代码,但在您的处理程序代码试图使用DynamoDB API插入项之前,我会检查您的代码并验证您的实际表名是否被正确设置/插入。
https://stackoverflow.com/questions/69866414
复制相似问题