AWS Oracle

AWS Lambda using Python

Why AWS Lambda ?

AWS Lambda supports

  1. Transparent scalability and availability
  2. Developer friendly operations and no need to manage servers
  3. Native integration to AWS services
  4. No need to pay for idle time
  5. RESTful integration
  6. Monitoring the RESTful interface using AWS API gateway

Hello World – Lambda Function

This is one of the simplest lambda function. It is equivalent to Hello World program.

To create your first program follow the below mentioned steps.

  1. Login to AWS Console
  2. Click Lambda under compute
  3. Click create a Lambda Function

 

  1. Skip select blueprint section
  2. In configure trigger click on the dotted rectangle

  1. Select API Gateway
  2. Fill the required details as in the image.
READ ALSO
AWS Report

API Name is the name of your API you are going to build. Resource Pattern is the URL path which you can invoke your Lambda function. Select the required http method. In our example we choose GET. In AWS staging can be done in different ways like prod,dev … It will help you to differentiate the functions from prod and dev. For demo purpose lets choose security as Open(Its not recommended in production).Click next

API Name is the name of your API you are going to build. Resource Pattern is the URL path which you can invoke your Lambda function. Select the required http method. In our example we choose GET. In AWS staging can be done in different ways like prod,dev … It will help you to differentiate the functions from prod and dev. For demo purpose lets choose security as Open(Its not recommended in production).Click next

  1. Configure the function as below
READ ALSO
Getting started with AWS Lambda

Provide the function name , description of your function and runtime environment. We are choosing python as runtime environment.

  1. Modify the code.

Here we are printing the aws lambda event in cloudtrail which is free. It is also returning a string.

  1. Provide Lambda function handler and role

Make sure that the handler name should start with lambda_function.. Also create a new role for execute the lambda function. Select the amount of main memory required for execute your function. Select the default timeout and click next

  1. Click create function
  2. Now your function is ready to execute. Click the link provided by the aws

 

READ ALSO
AWS Snowball

When you click the link your lambda function will be executed in the background and you will get output in the browser.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.