Amazon web services 无服务器框架提供的执行角色没有在SQS上调用SendMessage的权限
我正在尝试使用无服务器框架创建AWS SQS队列,Amazon web services 无服务器框架提供的执行角色没有在SQS上调用SendMessage的权限,amazon-web-services,amazon-sqs,serverless-framework,Amazon Web Services,Amazon Sqs,Serverless Framework,我正在尝试使用无服务器框架创建AWS SQS队列, 但是我在部署severless.yaml时遇到以下错误 The provided execution role does not have permissions to call SendMessage on SQS 问题是IAM角色是由无服务器框架创建的,我无法控制框架向角色添加的权限, 理想情况下,如果函数触发器是SQS,或需要配置DLQ, 我希望该框架将向角色添加发送和接收消息权限,但我猜它没有 servless.yaml- servi
但是我在部署
severless.yaml时遇到以下错误
The provided execution role does not have permissions to call SendMessage on SQS
问题是IAM角色是由无服务器框架创建的,我无法控制框架向角色添加的权限,
理想情况下,如果函数触发器是SQS,或需要配置DLQ,
我希望该框架将向角色添加发送和接收消息权限,但我猜它没有
servless.yaml-
service: dlq
provider:
name: aws
runtime: nodejs12.x
profile: csStage
region: ap-southeast-1
plugins:
- serverless-plugin-lambda-dead-letter
functions:
dlqFunction:
handler: handler.hello
deadLetter:
sqs: dl-queue
您可以完全控制添加到该角色的权限。您可以将iarolestatements
部分添加到provider
下的serverless.yml文件中,该部分描述了您希望应用于应用于函数的角色的权限。它看起来像:
provider:
iamRoleStatements:
- Effect: Allow
Action:
- "sqs:SendMessage"
Resource:
- arn:aws:sqs:region:accountid:queueid
您可以在这里的官方文档中找到更多信息:您可以完全控制添加到该角色的权限。您可以将iarolestatements
部分添加到provider
下的serverless.yml文件中,该部分描述了您希望应用于应用于函数的角色的权限。它看起来像:
provider:
iamRoleStatements:
- Effect: Allow
Action:
- "sqs:SendMessage"
Resource:
- arn:aws:sqs:region:accountid:queueid
您可以在这里的官方文档中找到更多信息:您可以使用来授予Lambda函数该权限。以下模板适用于我:
service: dlq
provider:
name: aws
runtime: nodejs12.x
profile: csStage
region: ap-southeast-1
iamRoleStatements:
- Effect: Allow
Action:
- sqs:SendMessage
Resource: !GetAtt DLQ.Arn
plugins:
- serverless-plugin-lambda-dead-letter
functions:
dlqFunction:
handler: handler.hello
deadLetter:
targetArn:
GetResourceArn: DLQ
resources:
Resources:
DLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: dl-queue
您可以使用为Lambda函数授予该权限。以下模板适用于我:
service: dlq
provider:
name: aws
runtime: nodejs12.x
profile: csStage
region: ap-southeast-1
iamRoleStatements:
- Effect: Allow
Action:
- sqs:SendMessage
Resource: !GetAtt DLQ.Arn
plugins:
- serverless-plugin-lambda-dead-letter
functions:
dlqFunction:
handler: handler.hello
deadLetter:
targetArn:
GetResourceArn: DLQ
resources:
Resources:
DLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: dl-queue