

# Working with AWS Lambda from the AWS Toolkit for JetBrains
<a name="building-lambda"></a>

The following topics describe how to work with AWS Lambda functions from the AWS Toolkit for JetBrains.

**Topics**
+ [Lambda Runtimes](lambda-runtimes.md)
+ [Creating a function](create-new-lambda.md)
+ [Running (invoking) or debugging a local function](invoke-lambda.md)
+ [Running (invoking) a remote function](lambda-remote.md)
+ [Changing (updating) function settings](lambda-update.md)
+ [Deleting a function](lambda-delete.md)

# AWS Lambda runtimes and support in the AWS Toolkit for JetBrains
<a name="lambda-runtimes"></a>

AWS Lambda supports multiple languages through the use of runtimes. A runtime provides a language-specific environment that relays invocation events, context information, and responses between Lambda and the function. For detailed information about the Lambda service and supported runtimes, see the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-support-policy) topic in the *AWS Lambda User Guide*.

The following describes runtime environments currently supported for use with the AWS Toolkit for JetBrains.


| Name | Identifier | Operating System | Architecture | 
| --- | --- | --- | --- | 
|  Node.js 18  |  nodejs18.x  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Node.js 16  |  nodejs16.x  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Node.js 14  |  nodejs14.x  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Python 3.11  |  python3.11  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Python 3.10  |  python3.10  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Python 3.9  |  python3.9  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Python 3.8  |  python3.8  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Python 3.7  |  python3.7  |  Amazon Linux 2  |  x86\$164  | 
|  Java 17  |  java17  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Java 11  |  java11  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Java 8  |  java8.al2  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Java 8  |  java8  |  Amazon Linux 2  |  x86\$164  | 
|  .NET 6  |  dotnet6  |  Amazon Linux 2  |  x86\$164, arm64  | 
|  Go 1.x  |  go1.x  |  Amazon Linux 2  |  x86\$164  | 

# Creating an AWS Lambda function by using the AWS Toolkit for JetBrains
<a name="create-new-lambda"></a>

You can use the AWS Toolkit for JetBrains to create an AWS Lambda function that is part of an AWS serverless application. Or you can create a standalone Lambda function.

To create a Lambda function that is part of an AWS serverless application, skip the rest of this topic and see [Creating an application](deploy-serverless-app.md) instead.

To create a standalone Lambda function, you must first install the AWS Toolkit for JetBrains and, if you haven't yet, connect to an AWS account for the first time. Then, with IntelliJ IDEA, PyCharm, WebStorm, or JetBrains Rider already running, do one of the following:
+ Open AWS Explorer, if it isn't already open. If you need to switch to a different AWS Region to create the function in, do that now. Then right-click **Lambda**, and choose **Create new AWS Lambda**.  
![\[Creating an AWS Lambda function by starting from AWS Explorer\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-create-aws-explorer.png)

  Complete the [Create Function](create-function-dialog.md) dialog box, and then choose **Create Function**. The AWS Toolkit for JetBrains creates a corresponding AWS CloudFormation stack for the deployment, and adds the function name to the **Lambda** list in **AWS Explorer**. If the deployment fails, you can try to determine why by viewing event logs for the stack.
+ Create a code file that implements a function handler for [Java](https://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-handler-types.html), [Python](https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html), [Node.js](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html), or [C\$1](https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html). 

  If you need to switch to a different AWS Region to create the remote function to be run (invoked), do that now. Then in the code file, choose the **Lambda** icon in the gutter next to the function handler, and then choose **Create new AWS Lambda**. Complete the [Create Function](create-function-dialog.md) dialog box, and then choose **Create Function**.  
![\[Creating an AWS Lambda function by starting from an existing function handler in a code file\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-create-code-file.png)
**Note**  
If the **Lambda** icon isn't displayed in the gutter next to the function handler, try displaying it for the current project by selecting the following box in **Settings**/**Preferences**: **Tools**, **AWS**, **Project settings**, **Show gutter icons for all potential AWS Lambda handlers**. Also, if the function handler is already defined in the corresponding AWS SAM template, the **Create new AWS Lambda** command won't appear.

  After you choose **Create Function**, the AWS Toolkit for JetBrains creates a corresponding function in the Lambda service for the connected AWS account. If the operation succeeds, after you refresh **AWS Explorer**, the **Lambda** list displays the name of the new function.
+ If you already have a project that contains an AWS Lambda function, and if you need to first switch to a different AWS Region to create the function in, do that now. Then in the code file that contains the function handler for [Java](https://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-handler-types.html), [Python](https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html), [Node.js](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html), or [C\$1](https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html), choose the **Lambda** icon in the gutter next to the function handler. Choose **Create new AWS Lambda**, complete the [Create Function](create-function-dialog.md) dialog box, and then choose **Create Function**.  
![\[Creating an AWS Lambda function by starting from an existing function handler in a code file\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-create-code-file.png)
**Note**  
If the **Lambda** icon isn't displayed in the gutter next to the function handler, try displaying it for the current project by selecting the following box in **Settings**/**Preferences**: **Tools**, **AWS**, **Project settings**, **Show gutter icons for all potential AWS Lambda handlers**. Also, the **Create new AWS Lambda** command won't be displayed if the function handler is already defined in the corresponding AWS SAM template.

  After you choose **Create Function**, the AWS Toolkit for JetBrains creates a corresponding function in the Lambda service for the connected AWS account. If the operation succeeds, after you refresh **AWS Explorer**, the new function's name appears in the **Lambda** list.

After you create the function, you can run (invoke) or debug the local version of the function or run (invoke) the remote version.

# Running (invoking) or debugging the local version of an AWS Lambda function by using the AWS Toolkit for JetBrains
<a name="invoke-lambda"></a>

To complete this procedure, you must create the AWS Lambda function that you want to run (invoke) or debug, if you have not created it already.
**Note**  
To run (invoke) or debug the local version of a Lambda function, and run (invoke) or debug that function locally with any nondefault or optional properties, you must first set those properties in the function's corresponding AWS SAM template file (for example, in a file named `template.yaml` within the project). For a list of available properties, see [AWS::Serverless::Function](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction) in the [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model/) repository on GitHub.

1. Do one of the following:
   + In the code file that contains the function handler for [Java](https://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-handler-types.html), [Python](https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html), [Node.js](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html), or [C\$1](https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html), choose the Lambda icon in the gutter next to the function handler. Choose **Run '[Local]'** or **Debug '[Local]'**.   
![\[Running or debugging the local version of a Lambda function by starting from the function handler in the code file\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-local-code.png)
   + With the **Project** tool window already open and displaying the project that contains the function, open the project's `template.yaml` file. Choose the **Run** icon in the gutter next to the function's resource definition, and then choose **Run '[Local]'** or **Debug '[Local]'**.  
![\[Running or debugging the local version of a Lambda function by starting from the function definition in the AWS SAM template file\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-local-template.png)

1. Complete the [Edit configuration (local function settings)](run-debug-configurations-dialog-local.md) dialog box if it's displayed, and then choose **Run** or **Debug**. Results are displayed in the **Run** or **Debug** tool window.
   + If the **Edit configuration** dialog box doesn't appear and you want to change the existing configuration, first change its configuration, and then repeat this procedure from the beginning. 
   + If the configuration details are missing, expand **Templates**, **AWS Lambda**, and then choose **Local**. Choose **OK**, and then repeat this procedure from the beginning. 

# Running (invoking) the remote version of an AWS Lambda function by using the AWS Toolkit for JetBrains
<a name="lambda-remote"></a>

A *remote* version of an AWS Lambda function is a function whose source code already exists inside of the Lambda service for an AWS account.

To complete this procedure, you must first install the AWS Toolkit for JetBrains and, if you haven't yet, connect to an AWS account for the first time. Then with IntelliJ IDEA, PyCharm, WebStorm, or JetBrains Rider running, do the following.

1. Open AWS Explorer, if it isn't already open. If you need to switch to a different AWS Region that contains the function, do that now.

1. Expand **Lambda**, and confirm that the name of the function is listed. If it is, skip ahead to step 3 in this procedure.

   If the name of the function isn't listed, create the Lambda function that you want to run (invoke). 

   If you created the function as part of an AWS serverless application, you must also deploy that application.

   If you created the function by creating a code file that implements a function handler for [Java](https://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-handler-types.html), [Python](https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html), [Node.js](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html), or [C\$1](https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html), then in the code file, choose the Lambda icon next to the function handler. Then choose **Create new AWS Lambda**. Complete the [Create Function](create-function-dialog.md) dialog box, and then choose **Create Function**.

1. With **Lambda** open in **AWS Explorer**, right-click the name of the function, and then choose **Run '[Remote]'**.  
![\[Running the remote version of a Lambda function by starting from AWS Explorer\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-remote.png)

1. Complete the [Edit configuration (remote function settings)](run-debug-configurations-dialog-remote.md) dialog box if it's displayed, and then choose **Run** or **Debug**. Results are displayed in the **Run** or **Debug** tool window.
   + If the **Edit configuration** dialog box doesn't appear and you want to change the existing configuration, first change its configuration, and then repeat this procedure from the beginning. 
   + If the configuration details are missing, expand **Templates**, **AWS Lambda**, and then choose **Local**. Choose **OK**, and then repeat this procedure from the beginning. 

# Changing (updating) AWS Lambda function settings by using the AWS Toolkit for JetBrains
<a name="lambda-update"></a>

To use the AWS Toolkit for JetBrains to change (update) the settings for an AWS Lambda function, do one of the following.
+ With the code file open that contains the function handler for [Java](https://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-handler-types.html), [Python](https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html), [Node.js](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html), or [C\$1](https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html), on the main menu, choose **Run**, **Edit Configurations**. Complete the [Run/Debug Configurations](run-debug-configurations-dialog.md) dialog box, and then choose **OK**.
+ Open AWS Explorer, if it isn't already open. If you need to switch to a different AWS Region that contains the function, do that now. Expand **Lambda**, choose the name of the function to change the configuration for, and then do one of the following:
  + **Change settings such as the timeout, memory, environment variables, and execution role –** Right-click the name of the function, and then choose **Update Function Configuration**.  
![\[Choosing the Update Function Configuration command\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/update-function-configuration.png)

    Complete the [Update Configuration](update-configuration-dialog.md) dialog box, and then choose **Update**. 
  + **Change settings such as the input payload** – On the main menu, choose **Run**, **Edit Configurations**. Complete the [Run/Debug Configurations](run-debug-configurations-dialog.md) dialog box, and then choose **OK**.  
![\[Choosing the Edit Configurations command\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/edit-configurations.png)

    If the configuration details are missing, first expand **Templates**, **AWS Lambda**, and then choose **Local** (for the local version of the function) or **Remote** (for the remote version of that same function). Choose **OK**, and then repeat this procedure from the beginning.)
  + **Change settings such as the function handler name or Amazon Simple Storage Service (Amazon S3) source bucket** – Right-click the function name, and then choose **Update Function Code**.  
![\[Choosing the Update Function Code command\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/update-function-code.png)

    Complete the [Update Code](update-code-dialog.md) dialog box, and then choose **Update**.
  + **Change other available property settings that aren't listed in the preceding bullets** – Change those settings in the function's corresponding AWS SAM template file (for example, in a file named `template.yaml` within the project). 

    For a list of available property settings, see [AWS::Serverless::Function](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction) in the [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model/) repository on GitHub. 

# Deleting an AWS Lambda function by using the AWS Toolkit for JetBrains
<a name="lambda-delete"></a>

You can use the AWS Toolkit to delete an AWS Lambda function that is part of an AWS serverless application, or you can delete a standalone Lambda function.

**Note**  
The deleted Lambda function cannot be recovered. You must be diligent with the resource name, such as the Lambda function and version you intend on deleting.

To delete a Lambda function that is part of an AWS serverless application, skip the rest of this topic and see [Deleting an application](sam-delete.md) instead.

To delete a standalone Lambda function, do the following.

1. Open AWS Explorer, if it isn't already open. If you need to switch to a different AWS Region that contains the function, do that now.

1. Expand **Lambda**.

1. Right-click the name of the function to delete, and then choose **Delete Function**.  
![\[Choosing the Delete Function command\]](http://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/images/lambda-delete.png)

1. Enter the function's name to confirm the deletion, and then choose **OK**. If the function deletion succeeds, the AWS Toolkit for JetBrains removes the function name from the **Lambda** list.