Invoke Lambda From AWS Console

Invoke Lambda From AWS Console

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have created a deployment package for our lambda function.

https://cloudaffaire.com/create-a-deployment-package/

In this blog post, we are going to execute the lambda function from the console. So far in this lambda blog series, we have executed our lambda function automatically using events from other service or manually using AWS CLI. In this blog post, we will execute the lambda directly from AWS lambda console.

Invoke Lambda From AWS Console

Step 1: Login to AWS console and navigate to ‘Lambda’.

Invoke Lambda From AWS Console

Step 2: Click on the function name.

Invoke Lambda From AWS Console

Step 3: In the upper right pane, click ‘Configure test events’.

Invoke Lambda From AWS Console

Step 4: Create an event for the lambda function using below JSON and click ‘Create’.

{
"Records":[
{
"s3":{
"bucket":{
"name":"cloudaffaire"
},
"object":{
"key":"object_four"
}}}
]
}

Invoke Lambda From AWS Console

Note: Since our lambda function has been created with the trigger on S3 ‘create object’. Our function excepts the bucket and object name in the form of JSON. Hence in order to manually invoke the function, we are defining the bucket and object name in myevents.

Next, we are going to invoke our function

Step 5: Select ‘myevents’ from drop-down and click ‘Test’.

Invoke Lambda From AWS Console

Observe: Though we have not uploaded any object in S3 bucket, our function executed successfully and we can check the log in lambda console itself.

Check CloudWatch log

Invoke Lambda From AWS Console

Hope you have enjoyed this article. So far we have used push based (S3 for example) triggers for our lambda function. In the next blog post, we will configure the poll based trigger for Lambda function.

To get more details on Lambda, please refer below AWS documentation

https://docs.aws.amazon.com/lambda/index.html

 

Leave a Reply

Close Menu