Deleting Lambda Function


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 −

Step 1

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 −

AWS Console Using

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.

Step 2

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 −

Radio Button

Step 3

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 −

Action

Step 4

Select the Delete button to delete the AWS Lambda function. Once you click Delete, it displays the message as follows −

Display Date

Step 5

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.

Step 6

The list of roles created so far is shown below. Observe that there is a Create role button and Delete role button.

Delete Role

Click the checkbox across the role you want to delete. You can also select multiple roles to delete at a time.

Delete Time

Step 7

You will see a confirmation message as shown below once you click Delete button −

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 1

The 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:demotestindex.zip"

The corresponding output is shown here −

CLI command

Step 2

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 −

Lambda Test

Step 3

Now, let us invoke the function to test the output using the command shown −

aws lambda invoke --function-name "lambdatestcli" --log-type Tail 
C:demotestoutputfile.txt

This command will give you the output as shown −

Command Output

Step 4

You can observe logs from cloudwatch for lambda function lambdatestcli
Observe Log

Step 5

Now, 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 −

Command

delete-function
--function-name <value>
[--qualifier <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

–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 −

Lambda Delete Function

Step 6

If you check now, you can observe that the function will not be seen in AWS Lambda function list as shown in the screenshot given below −
Date Display

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *