I am trying to create an AWS SQS event associated with an AWS Lambda function called 'sendExportJob' using Serverless framework but after the deploy I can not see in the AWS console the SQS trigger. Obviously, I can add this event manually through the console and it works as expected.
Here is the Lambda function configuration in the serverless.yml:
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
Here is the IAM configuration for this particular function:
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: '*'
I am using the latest version of the Serverless framework and I have checked the indentation in the configuration file.
The SQS resource has been deployed previously so it already exists before adding it as an event.