Create AWS Lambda function and Trigger Step by Step

Create AWS Lambda function and Trigger Step by Step

·

3 min read

Log on to AWS Console

  1. Log in to the AWS console(aws.amazon.com/console) with your username and password, If you don't have an account already created on AWS, you can create one.
    Steps to create the account first-time repost.aws/knowledge-center/create-and-acti..

  2. If you created an account on AWS first time then it will be a root and admin account, you should not use this account for all the operations. Rather than create a new IAM user with admin permission and perform all the operations using an IAM user. Follow the steps to create the IAM admin user docs.aws.amazon.com/streams/latest/dev/sett..

Create Lambda Function

Once you log in to the AWS console using your IAM user, It will land you on the AWS console Home page then follow the below-mentioned steps to create the Lambda Function:

Search for Lambda in the services search

    1. Click on Lambda which is shown in the above picture and it will open the Lambda Function dashboard then click on Create function which is displayed below the screenshot

      1. Enter the Lambda function name then choose the runtime language from the drop-down, I have entered the function name as testfunction and chosen the runtime language as Python 3.8

      2. The next step is to create a new role for the execution of the lambda function, if created a role already then you can choose "use an existing role" As I have an existing role with the permission of Lambda execution and S3 full permission so I am using my existing role and choose it from the drop-down of Existing role

      3. Leave the other option as default and click on the Create function which is on the right side of your screen at the end, your function will get created.

      4. upon clicking on the function, your function will get created and it will be displayed like below:

        Create Trigger to integrate S3 bucket Lambda Function

        1. Click on add trigger button which in the almost upper left side of the screen

  1. Then select a source, click on the drop-down and type s3 in the search then choose these services here I have selected S3

  1. Then choose the bucket from the bucket search, I have chosen test-ramkumar-bucket then select the Event type, where I selected "put"

    1. Then add the prefix and suffix which are optional.I have chosen Prefix as input as I want to get trigger the lambda function when a file added into the input folder of my bucket test-ramkumar-bucket click on I acknowledge which is the last option on the page and finally click on ADD