AWS Lambda to Amazon Comprehend

AWS Lambda → Amazon Comprehend

Create a Lambda function that uses Amazon Comprehend for sentiment analysis.

This pattern shows how to deploy a SAM template that builds a Lambda function which triggers Comprehend for sentiment analysis.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-comprehend

Deploy

sam deploy --guided


Testing

Use the AWS CLI to invoke the Lambda function. The function name is in the outputs of the AWS SAM deployment (the key is QueuePublisherFunction):
1. Invoke the Lambda function to publish a message to the SQS queue: aws lambda invoke --function-name ENTER_YOUR_FUNCTION_NAME outfile.txt.
2. Retrieve the message from the SQS queue, using the queue URL from the AWS SAM deployment outputs: aws sqs receive-message --queue-url ENTER_YOUR_QUEUE_URL

Cleanup

See the GitHub repo for testing instructions.

Created by:

Tommy Whelan

Tommy Whelan

Data/ ML Engineer @ AWS