Deleting AWS Lambda function will remove the AWS Lambda from the AWS console. There are 2 ways to delete AWS Lambda function.
This chapter discusses these two ways in detail.
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.
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 −
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 −
aws lambda invoke --function-name "lambdatestcli" --log-type Tail C:\demotest\outputfile.txt
This command will give you the output as shown −
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 −