Create A Lambda Function With AWS Console

Create a Lambda function with the console

  • Open a function page of the Lambda console.
  • Choose to Create function highlighted in orange color,

Create a Lambda function with AWS console

Then select Use a blueprint option,

This option will help you to build your lambda application from sample code, and configuration presets for common use cases.

  1. Open a Select blueprint name dropdown option and select for Hello World function.
  2. Select the nodejs14.x or python3.7 version of the blueprint, whichever you preferred.
  3. Then Enter the Function name.

Create a Lambda function with AWS console

If you want to select the Execution role, then For Execution role, choose the option Create a new role with basic Lambda permissions.

Lambda generally creates an execution role granting permission to upload logs to Amazon CloudWatch. When you invoke your function Lambda function assumes an execution role and uses the same execution role to create credentials for the AWS SDK and to read the data from event sources.

Click on Create Function.

Create a Lambda function with AWS console

When your AWS Lambda function is created successfully, it will look like this, and a toast message will come on top with a green banner.

Create a Lambda function with AWS console

Next, we will see how to Invoke the function

Invoke the Function

You need to create a test event to Invoke the function from the AWS console.

  1. Choose the Test tab at the bottom of the screen.
  2. For Test event action, Choose to Create new event option.
  3. For the event name, enter any name you choose for the test event.
  4. Select the event sharing settings option, and choose Private.

Create a Lambda function with AWS console

Then for the Template, leave the default hello-world option as is.

In the Event Json, replace value1 with hello, world! And change the value; don’t change the key1 or the event structure. Example,

{
    "key1": "hello, world!",
    "key2": "value2",
    "key3": "value3"
}

Create a Lambda function with AWS console

Now Click on Save, and then choose Test. Now Lambda invokes the function on your behalf. The function handler receives and then processes the sample event.

Create a Lambda function with AWS console

Now Review your execution result. Under Details, you will see the value you entered in the above step No 6, “hello world!”. The execution result includes the following information,

  • The summary section shows the key information from the REPORT Line in the invocation log.
  • The Log Output section shows up the complete invocation log.
  • Lambda usually writes all invocation logs to Amazon CloudWatch.

Choose Test to invoke a function repeatedly, a few more times, which will help you gather additional metrics you can see in the next step.

Choose the monitor tab. This page shows up the graph of metrics that lambda sends to CloudWatch.

Create a Lambda function with AWS console

Create a Lambda function with AWS console

This is how you can create a function and test your function.


Similar Articles