Amazon S3 to Amazon SQS to AWS Lambda

Amazon S3 → Amazon SQS → AWS Lambda

Create a Lambda function that resizes images uploaded to S3 via SQS.

The SAM template contains all the information to deploy AWS resources(one S3 bucket, one SQS queue and one Lambda function) and also the permission required by these service to communicate.
You will be able to create and delete the CloudFormation stack using the CLI commands.
The S3 will send notifications to an SQS queue when .png objects are deleted. The SQS will trigger and invoke a Lambda function which will display the object deleted as events.
This is fully functional example implemented in Java 11.

< 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/s3-sqs-lambda-sam-java

Deploy

sam deploy --guided --capabilities CAPABILITY_IAM


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Razvan Minciuna

Razvan Minciuna

Software Architect.

Follow on LinkedIn