I have connected a RabbitMQ queue based of Amazon MQ to a Lambda such that whenever there is a message added to the queue, the lambda is triggered. Here is my SAM configuration:
MQConsumer:
Type: AWS::Serverless::Function
Properties:
CodeUri: tasks/
Timeout: 900
Handler: task.lambda_handler
Runtime: python3.8
FunctionName: some-func-name
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Resource: '*'
Action:
- mq:*
- secretsmanager:GetSecretValue
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DescribeVpcs
- ec2:DeleteNetworkInterface
- ec2:DescribeSubnets
- ec2:DescribeSecurityGroups
- ses:SendRawEmail
Events:
MQEvent:
Type: MQ
Properties:
Broker: !GetAtt MQBroker.Arn
Queues:
- tasks
BatchSize: 1
Enabled: true
SourceAccessConfigurations:
- Type: BASIC_AUTH
URI: !FindInMap [EnvironmentVariables, SecretManagerArn, !Ref EnvironmentType]
Issues:
- While the invocation happens whenever a message is added to the queue, I still see the following error displayed under
Triggers
in my lambda.
- Every now and then, unpredictably the event source gets
Disabled
under the triggers and the workflow stops working. I would have to open console and manually re-enable it to process the unprocessed items in the queue.
How can I rectify this issue?