我正在尝试使用无服务器框架创建一个与名为'sendExportJob‘的AWS Lambda函数相关联的AWS SQS事件,但在部署之后,我在AWS控制台中看不到SQS触发器。显然,我可以通过控制台手动添加此事件,它可以按预期工作。
下面是serverless.yml中的Lambda函数配置:
sendExportJob:
handler: src/sendExportJob.handler
role: sendExportJobIAM
memorySize: ${self:custom.config.send-exportjob-lambda-settings.memorySize}
timeout: ${self:custom.config.send-exportjob-lambda-settings.timeout}
environment:
lambdaName: ${self:custom.config.send-exportjob-lambda-settings.name}
pendingqueueUrl: https://sqs.${self:custom.config.region}.amazonaws.com/${self:custom.config.account-id}/${self:custom.config.sqs-pending-exports-queue-name}
region: ${self:custom.config.region}
events:
- schedule: rate(${self:custom.config.send-exportjob-lambda-settings.schedule-rate-minutes} minutes)
- pendingsqs:
arn: arn:aws:sqs:${self:custom.config.region}:${self:custom.config.account-id}:${self:custom.config.sqs-pending-exports-queue-name}
batchSize: 1
以下是此特定函数的IAM配置:
sendExportJobIAM:
Type: AWS::IAM::Role
Properties:
RoleName: sendExportJobRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: sendExportJobIAMAll
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
- logs:CreateLogGroup
Resource: '*'
- Effect: Allow
Action:
- sqs:ChangeMessageVisibility
- sqs:ChangeMessageVisibilityBatch
- sqs:DeleteMessage
- sqs:DeleteMessageBatch
- sqs:GetQueueAttributes
- sqs:ReceiveMessage
Resource: arn:aws:sqs:${self:custom.config.region}:${self:custom.config.account-id}:${self:custom.config.sqs-pending-exports-queue-name}
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: '*'
我使用的是最新版本的无服务器框架,并且我已经检查了配置文件中的缩进。
之前已经部署了SQS资源,因此在将其添加为事件之前它已经存在。
https://stackoverflow.com/questions/56209473
复制相似问题