S3 Notifications using Lambda and SQS

Bhushan Patil
1 min readSep 9, 2019
s3 triggers an event to lambda when a new file is uploaded to S3 bucket and upon processing the file lambda sends a notification to sqs queue

Terraform code to fetch the existing bucket details:

Terraform code for setting up Lambda function and its IAM role, policies :

Terraform code for setting up s3 Event trigger:

Terraform code for setting up SQS Queue:

The key concepts to understand:

  1. Create a Lambda function with IAM role and s3 access permissions attached to it.
  2. Set up an s3 Event trigger to existing s3 bucket so then Lambda will get triggered when a new file is uploaded in this bucket.
  3. Create an SQS Queue in which we want to send the file details.

Verifying the Setup:

  1. Login to AWS console and upload any file in the bucket under input-data folder.
  2. Which will trigger the Lambda and lambda will send the file name to SQS
  3. Go to the SQS console and select your SQS queue.
  4. You will find the file name with the folder name in SQS.

--

--

Bhushan Patil

A Passionate DevOps engineer with deep knowledge of configuration, deployment, and monitoring of applications and services.