“ I have checked the documents of AWS to create a s3 trigger to invoke lambda function . So I found that it can be possible using cloudformation stack to automate purpose. Pricing of S3 bucket as per storage size and lambda function costs cheaper.”
Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code on a high-availability compute infrastructure and performs all of the administration of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, code monitoring and logging. With Lambda, you can run code for virtually any type of application or backend service.
S3 events occur when someone modifies the content of an s3 bucket. Altering the content can be achieved by either creating, removing or updating a file. S3 events are asynchronous, which means your lambda function only has to handle the event and does not have to respond with anything. There is no client involved like with API Gateway, so nobody is waiting for your function to send a response. S3 will send an event that triggers your lambda function but it won’t check what it did afterward.
In this post, you will get to know how to customize s3 trigger to invoke lambda function through cloudformation. Here I have created a s3 bucket, iam role and s3 trigger with lambda function through a cloudformation stack with customized parameters.
You’ll need an AWS Identity and Access Management for this post. Getting started with AWS Identity and Access Management provides instructions on how to create an IAM role with required permission policy.
You’ll need an Amazon Simple Storage Service for this post. Getting started with Amazon Simple Storage Service provides instructions on how to create a bucket in simple storage service.
The blog post consist of the following phases:
- Create of Lambda Function and S3 Trigger On It through Cloudformation
- Output of Stack as Lambda Function and S3 Trigger
- Open the cloudformation console and create a stack for the lambda function and s3 trigger on it. In the template file various parameters are defined: lambda function code and configuration, Iam role configuration and s3 trigger with lambda invoke permission configuration.
- Open the lambda console and check the created lambda functions. Also check the s3 trigger on lambda.
Delete S3 Bucket, IAM Role and Cloudformation Stack.
I review the pricing and estimated cost of this example.
Cost of Data Transfer = $0.0
Cost of Lambda Function = $0.0
Cost of S3 = $0.575
Total Cost = $0.575
In this post, I showed “how to customize s3 trigger to invoke lambda function through cloudformation”.
Thanks for reading!
Connect with me: Linkedin