AWS Toolkit for VS Code
User Guide

Interacting with Remote Lambda Functions

Using the Toolkit for VS Code, you can interact with AWS Lambda functions in various ways, as described later in this topic.

For more information about Lambda, see the AWS Lambda Developer Guide.

Note

If you have already created Lambda functions by using the AWS Management Console or in some other way, you can invoke them from the Toolkit. To create a new function (using VS Code) that you can deploy to AWS Lambda, you must first create a serverless application.

Prerequisites

  • If you haven't already done so, satisfy the prerequisites specified in Installing the Toolkit for VS Code.

  • Ensure that the credentials you configured in Establishing Credentials include appropriate read/write access to the AWS Lambda service. If in the AWS Explorer, under Lambda, you see a message similar to "Error loading Lambda resources", check the permissions attached to those credentials. Changes that you make to permissions will take a few minutes to affect the AWS Explorer in VS Code.

Invoke a Lambda Function

You can invoke a Lambda function on AWS from the Toolkit for VS Code.

  1. In the AWS Explorer, choose the name of the Lambda function you want to invoke, and then open its context menu.

    
            Context menu for Lambda function.
  2. Choose Invoke on AWS.

  3. In the invoke window that opens, enter the input that your Lambda function needs. The Lambda function might, for example, require a string as an input, as shown in the text box.

    
            Field for entering Lambda input as text.

You'll see the output of the Lambda function just like you would for any other project using VS Code.


        Output of Lambda function running.

Delete a Lambda Function

You can also delete a Lambda function using the same context menu.

Warning

Do not use this procedure to delete Lambda functions that are associated with AWS CloudFormation (for example, the Lambda function that was created when creating a serverless application earlier in this guide). These functions must be deleted through the AWS CloudFormation stack.

  1. In the AWS Explorer, choose the name of the Lambda function you want to delete, and then open its context menu.

    
            Context menu for Lambda function.
  2. Choose Delete.

  3. In the message that appears, choose Yes to confirm the delete.

    
            Delete Lambda confirmation dialog box

After the function is deleted, it's no longer listed in the AWS Explorer.