- AWS Lambda Tutorial
- AWS Lambda - Home
- AWS Lambda - Overview
- AWS Lambda - Environment Setup
- AWS Lambda - Introduction
- Building the Lambda function
- Function in NODEJS
- Function in Java
- Function in Python
- Function in Go
- Function in C#
- Configuring Lambda Function
- Creating & Deploying using AWS Console
- Creating & Deploying using AWS CLI
- Creating & Deploying using Serverless Framework
- AWS Executing & Invoking Lambda Function
- Deleting Lambda Function
- Working with Amazon API Gateway
- Lambda Function with Amazon S3
- Lambda Function with Amazon DynamoDB
- Lambda Function with Scheduled Events
- Lambda Function with Amazon SNS
- Lambda Function with CloudTrail
- Lambda Function with Amazon Kinesis
- Lambda Function with Custom User Applications
- AWS Lambda@Edge with CloudFront
- Monitoring and TroubleShooting using Cloudwatch
- AWS Lambda - Additional Example
- AWS Lambda Useful resources
- AWS Lambda - Quick Guide
- AWS Lambda - Useful resources
- AWS Lambda - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Deleting Lambda Function
Deleting AWS Lambda function will remove the AWS Lambda from the AWS console. There are 2 ways to delete AWS Lambda function.
- Using AWS console.
- Using AWS CLI command
This chapter discusses these two ways in detail.
Using AWS Console
For deleting a Lambda function using AWS console, follow the steps given below −
Login to AWS console and go to AWS Lambda service. You can find that AWS lambda functions created so far are listed in AWS console as shown below −
The list shows that there are 23 AWS Lambda functions created so far. You can view them using the pagination provided on the top or search the AWS Lambda by using the search box.
Observe that there is a radio button across each of the AWS Lambda function. Select the function you want to delete. Observe the screenshot shown below −
Once you select the AWS Lambda function, the Action dropdown which was earlier grayed out is highlighted now. Now, open the combo box and it will display options as shown −
Select the Delete button to delete the AWS Lambda function. Once you click Delete, it displays the message as follows −
Read the message carefully and later click Delete button to remove the AWS lambda function permanently.
Note − Deleting aws lambda will not delete the role linked. To remove the role, you need to go to IAM and remove the role.
The list of roles created so far is shown below. Observe that there is a Create role button and Delete role button.
Click the checkbox across the role you want to delete. You can also select multiple roles to delete at a time.
You will see a confirmation message as shown below once you click Delete button −
Now, read the details mentioned carefully and later click Yes, delete button.
Using AWS CLI command
Let us first create a Lambda function using aws cli and delete the same using the same command. Follow the Steps given below for this purpose −
Step 1The command with values for create-function is as follows −
aws lambda create-function --function-name "lambdatestcli" --runtime "nodejs8.10" --role "arn:aws:iam::625297745038:role/lambdaapipolicy" --handler "index.handler" --timeout 5 --memory-size 256 --zip-file "fileb://C:\demotest\index.zip"
The corresponding output is shown here −
The AWS Lambda function created is lambdatestcli. We have used existing role arn to create the lambda function.
Then you can find this function displayed in AWS console as shown below −
Step 3Now, let us invoke the function to test the output using the command shown −
aws lambda invoke --function-name "lambdatestcli" --log-type Tail C:\demotest\outputfile.txt
This command will give you the output as shown −
Step 4You can observe logs from cloudwatch for lambda function lambdatestcli
Step 5Now, let us come to the actual part of deleting the AWS function. Delete aws cli api will delete the function given. The details of command used for this purpose is given below −
delete-function --function-name <value> [--qualifier <value>] [--cli-input-json <value>] [--generate-cli-skeleton <value>]
--function-name(string) − This will take the Lambda function name or the arn of the AWS Lambda function.
--qualifier (string) − This is optional. Here you can specify the version of AWS Lambda that needs to be deleted.
-- cli-input-json(string) − Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values.
--generate-cli-skeleton(string) − it prints json skeleton to standard output without sending the API request.
Command with values
aws lambda delete-function --function-name "lambdatestcli"
The corresponding output is shown below −