Currently, I've got a workflow in AWS that goes as follows:
**Step Function -> SQS Queue -> Lambda function **
The Step Function State Machine, when executed, sends a message to an SQS queue which then kicks off a Lambda function based on an SQS trigger. Here's the simple Lambda (written in Python):
# Library Imports
import boto3
import json
import os
# Variables
sqs = boto3.resource('sqs')
queue_name = 'ExampleStandardQueue'
queue_url = os.environ['QUEUE_URL']
queue = sqs.get_queue_by_name(QueueName=queue_name)
# Handler
def lambda_handler(event, context):
# Receive messages from queue, one at a time
messages = queue.receive_messages()
for message in messages:
print('Processed message.')
print('Message Attributes: {0}'.format(message.attributes))
print('Message Body: {0}'.format(message.body))
When I remove the SQS trigger and send a message to the queue, then test the Lambda function I get the correct output:
START RequestId: fdf3dffe-0271-4b03-974e-9d8762f2b6b3 Version: $LATEST
Processed message.
Message Attributes: None
Message Body: {"MessageTitle":"Create Group","input":"Started."}
END RequestId: fdf3dffe-0271-4b03-974e-9d8762f2b6b3
REPORT RequestId: fdf3dffe-0271-4b03-974e-9d8762f2b6b3 Duration: 60.38 ms Billed Duration:
100 ms Memory Size: 128 MB Max Memory Used: 77 MB Init Duration: 397.80 ms
However, when I have the automated workflow where the Lambda is kicked off automatically when the State Machine sends a message to the SQS queue, the logs look like this:
START RequestId: 2fac6aa3-01ba-56dc-b077-3c41fdd731ec Version: $LATEST
END RequestId: 2fac6aa3-01ba-56dc-b077-3c41fdd731ec
REPORT RequestId: 2fac6aa3-01ba-56dc-b077-3c41fdd731ec Duration: 294.12 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 78 MB
Essentially, here the code outputs don't display or take affect even though the monitoring on the queue shows a message was processed and the lambda function kicked off. What am I missing here?