AWS Lambda walk-through
Amazon has a trait of keep on surprising us with it’s extremely impressive services that makes our life a lot easier. In AWS re:invent 2014, it launches loads of astonishing services, including a preview of AWS Lambda, a service that would reduce loads of our efforts to build applications that run in the Cloud.
AWS Lambda is a compute service that requires zero-administration, it gives you freedom from launching, configuring or monitoring an EC2 instance, it runs your code in response to events and automatically manages the compute resources for you. You just need to create a Lambda function, give it permission to access specific AWS resources, and then connect the function to your AWS resources. Whenever objects uploaded to Amazon Simple Storage Service (S3) buckets are modified, messages arrived in Amazon Kinesis streams, or tables are updated in Amazon DynamoDB, Lambda will automatically run the code.
Let us walk through an example to get an overview of Lambda, suppose you want to execute a function whenever your S3 buckets are modified. In order to do so, you have to follow below steps :
- Create your desired function in Node.js
- Create a zip file of it
- Upload that zip file to AWS Lambda, creating the Lambda function.
- Once you’re done with your code, you need to create an IAM role for Lambda and S3, that can assume to invoke your Lambda function
- After that, configure notifications to the Bucket, publishing events of the S3 bucket to Lambda.
Now if you will modify your s3 bucket, bucket notification will publish events to Lambda and Lambda then executes the function you’ve created on your behalf.
Similarly, you can use Lambda function with other AWS services. When a resource changes, Lambda will execute any functions that are associated with it. It will launch and manage compute resources on your behalf
Thanks
————————————–
Nikhil Kumar Sharma