loading...
Cover image for [Intro] How to trigger a Lambda function when a file is uploaded to an existing S3 bucket using Amazon EventBridge and AWS CDK

[Intro] How to trigger a Lambda function when a file is uploaded to an existing S3 bucket using Amazon EventBridge and AWS CDK

upupkenchoong profile image Ken Choong ・2 min read

*In this series of blog post, what we gonna to do is: *

  1. Observe a file is uploaded to an existing S3 bucket using Amazon EventBridge
  2. When Amazon EventBridge notice a file is uploaded to S3 bucket, it will trigger a Lambda function.
  3. Provision our Lambda Function, Amazon EventBridge, Policy and all other resources using AWS CDK.

Scenario

You using Aws Amplify for Android app.

Now you need storage
so you can store the images, video or audio your user upload from you app.

So you do this:

amplify add storage

Answer a few question in Amplify CLI like showing here

Amplify provisioned a S3 bucket for you. Nice and easy. Now you can upload your user file into this bucket.

Follow with this scenario:

  • Now you have an existing S3 bucket which generated by Aws Amplify
  • When user upload the file to this bucket, you want to trigger a Lambda function which you can use other AWS service.

For example,

  • When an image is uploaded to the bucket, you want to use AWS Rekognition to do face recognition
  • When an audio file uploaded to the bucket, you want to use AWS Transcribe to transcribe the audio file to words.

The problem is how?

Stay Tuned.

[Part 1]What is Amazon EventBridge and How to provision Logging S3 bucket, and bucket policy using AwsCDK

Follow me on Twitter: @upupkenchoong

My upcoming product(If you interested): @sarah_assistant

Discussion

pic
Editor guide