A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/lambda-remote-debug.html below:

AWS Lambda remote debugging - AWS Toolkit for VS Code

AWS Lambda remote debugging

The AWS Toolkit for Visual Studio Code enables you to debug your AWS Lambda functions that are running in the cloud, directly in VS Code. With AWS Lambda remote debugging you can inspect running functions, set breakpoints, examine variables, and step-through debugging without modifying their existing development workflow.

The following sections describe how to work with Lambda remote debugging in the AWS Toolkit for Visual Studio Code.

How Lambda remote debugging works

The AWS Toolkit enables remote debugging by temporarily modifying your Lambda functions with an additional Lambda debugging layer and extending the Lambda invoke timeout limit to 900 seconds. A secure connection is established between your local debugger and the Lambda runtime environment using AWS IoT Secure Tunneling. This connection allows you to use your local-code breakpoints to step through the function as it executes remotely. After your debugging session is complete, all of the temporary modifications are automatically reverted to their original settings.

Getting Started Supported runtimes

The following runtimes are supported by Lambda remote debugging.

Prerequisites

Before you begin, the following prerequisites must be met.

Accessing Lambda remote debugging

There are two main paths to access Lambda remote debugging in the AWS Toolkit: the AWS explorer or the Application Builder explorer. From the AWS explorer, you can access Lambda remote debugging through your AWS Lambda nodes. From the Application Builder explorer, you can access Lambda remote debugging through your local AWS SAM projects.

Accessing Lambda remote debugging from the AWS explorer
  1. From VS Code, open the AWS Toolkit extension.

  2. From the AWS Toolkit, expand the AWS explorer.

  3. From the explorer, expand the Lambda node.

  4. Navigate to the function you want to debug, then choose the Invoke remotely icon from the context menu to open the Remote invoke configuration screen.

Accessing Lambda remote debugging from the Application Builder explorer.
  1. From VS Code, open the AWS Toolkit extension.

  2. From the AWS Toolkit, expand the application builder explorer.

  3. From the explorer expand the AWS SAM project that contains the Lambda project you want to debug.

  4. Expand the deployed Lambda function that you want to debug.

  5. Navigate to the function remote, then choose the Invoke remotely icon from the context menu to open the Remote invoke configuration screen.

Working with Lambda remote debugging

The following sections describe how to work with Lambda remote debugging in the AWS Toolkit for Visual Studio Code.

Note

Lambda functions have a 5-layer limit and a 250MB combined limit for function code and all attached layers. Lambda remote debugging requires at least 1 free layer to run.

Setting up a debugging session

Before you begin, configure your debugging session by completing the following procedure.

  1. Open the Remote invoke configuration menu by completing the Accessing Lambda remote debug from the AWS explorer or the Accessing Lambda remote debug from the Application Builder explorer procedure, located in the previous section.

  2. From the Remote invoke configuration menu, select the Remote Debugging check box to display the remote debugging properties.

  3. Specify the Local Root Path to your local handler file.

    Note

    The local root path is the location of your source code that matches the deployed Lambda function. If you're working from a deployed function in the Application Builder explorer, your local root path is automatically detected.

    If you don't have the source code stored locally, choose the Download remote code button to retrieve your Lambda function source code. This will open your handler file in the VS Code editor.

  4. From the Payload section, specify where your test-event data is obtained.

Setting breakpoints and debugging

Set breakpoints and begin debugging by completing the following procedure.

  1. From your handler file in the VS Code editor, click in the gutter-margin to set breakpoints at the line numbers where you want to pause debugging.

  2. When you're satisfied with the breakpoints, return to the Remote invoke configuration menu to verify that your settings are configured correctly, then choose the Remote invoke button to start debugging.

  3. The AWS Toolkit updates your Lambda function with debugging capabilities, establishes a secure tunnel for the debugging session, invokes your function with the specified payload, then pauses the process when it reaches a breakpoint.

  4. At a breakpoint pause, use the RUN AND DEBUG pane to view your VARIABLES, CALL STACK, and BREAKPOINTS.

Updating and testing your function

To modify your code and test changes with a quick deployment, complete the following procedure.

  1. With your debugging session active, make changes to your handler file in the VS Code editor.

  2. Save your changes (Command+S on macOS,Ctrl+S on Windows)

  3. When prompted, confirm that you wish to proceed to deploy your changes. The AWS Toolkit will update your Lambda function with the modified code.

  4. Continue debugging and testing your changes by setting new breakpoints and selecting the Remote invoke button again.

    Note

    Alternatively, you can deselect the Attach debugger option in the VS Code debugging controls and choose the Remote invoke button to run your function without debugging.

Ending a debugging session

Each of the following options ends your remote debugging session and removes the debug layer from your project.

Note

Take note of the following:

Troubleshooting and advanced use cases

If your debug session fails, start the troubleshooting process by completing these steps.

  1. Update the AWS Toolkit to the latest version.

  2. Refresh the web view by closing the Remote invoke configuration web view and reopening it.

  3. Restart VS Code by closing it completely and reopening it.

  4. Open the VS Code Command Palette and enter the command AWS: Reset Lambda Remote Debugging Snapshot, select it when it populates in the results to reset your Lambda remote debugging snapshot.

  5. If you're not able to troubleshoot the problem, submit an issue to AWS Toolkit for Visual Studio Code GitHub Issues.

Advanced use case: code-signing configuration

Remote debugging requires attaching a debug layer to your Lambda function. If your function has code-signing configuration enabled and enforced, the AWS Toolkit can't automatically attach the debug layer to your function.

There are two options to resolve the code-signing configuration issue.

Temporarily removing code signing

Update the code-signing configuration by setting UntrustedArtifactOnDeployment : Warn, then re-enable it back to Enforced after the debugging process is complete.

For more information, see the UpdateCodeSigningConfig reference in the AWS Lambda API Reference.

Using a signed debug layer
  1. From Lambda remote debugging in the AWS Toolkit, expand the Remote debug additional configuration section.

  2. From the Remote debug additional configuration section, copy your Region layer ARN from the Layer override field.

  3. From the AWS CLI, use the following command to download the layer version aws lambda get-layer-version-by-arn --arn layer-arn, replacing layer-arn with your layer ARN. For detailed instructions on how to download the signed debug layer, see the get-layer-version-by-arn reference in the AWS CLI Command Reference.

  4. Sign the layer with your code-signing configuration and publish it to your account. For signing and publishing guidance, see the Set up code signing for your AWS SAM application topic in the AWS Serverless Application Model Developer Guide.

  5. After the layer has been signed and published to your account, return to the Remote debug additional configuration section of Lambda remote debugging, then enter the new layer ARN into the Layer override field. When the process is complete, Lambda remote debugging uses your signed layer instead of the default layer.

Supported regions

The following error occurs when a region doesn't support remote debugging.

Region ${region} doesn't support remote debugging yet

The following is a list of supported regions.

Lambda RequestEntityTooLargeException

Lambda functions have a 5-layer limit and a 250MB combined limit for function code and all attached layers. The remote debugging layer is approximately 40MB, which may cause your function to exceed this limit if you have a large function package or multiple layers. For additional details, see the Lambda: InvalidParameterValueException or RequestEntityTooLargeException topic section in the AWS Lambda Developer Guide.

The following list describes ways to troubleshoot and correct this error.

IoT secure tunneling quota exceeded

The following is an example of the tunnel quota exceeded error that occurs when you've reached the daily limit for AWS IoT secure tunneling connections in Lambda remote debugging.

Error creating/reusing tunnel: LimitExceededException: Exceeded quota of Lambda debugging tunnels

AWS IoT Secure Tunneling connection have the following quotas:

If you encounter the AWS IoT secure tunneling error, wait for the daily quota reset or contact AWS support to request a quota-limit increase. For AWS support contact info, see the AWS support contact portal. For detailed information about AWS IoT secure tunneling, see the AWS IoT secure tunneling topic in the AWS IoT Developer Guide.

Debugging TypeScript Lambda functions with source maps

The following sections describe how to debug your TypeScript Lambda functions with source maps.

Prerequisites

To debug your TypeScript Lambda functions, the following prerequisites must be met.

Configuration

To configure Lambda remote debugging for TypeScript Lambda functions in the AWS Toolkit, complete the following steps.

  1. From the AWS Toolkit, expand the AWS explorer.

  2. From the explorer, expand the Lambda node.

  3. Navigate to the function you want to configure for TypeScript, then choose the Invoke remotely icon from the context menu to open the Remote invoke configuration screen.

  4. Enable remote debugging by select the Remote debugging check box.

  5. Configure your Local Root Path by pointing to the directory containing your TypeScript handler file.

    Note

    The TypeScript handler file is where you set your debugging breakpoints.

  6. Expand Remote debug additional configuration settings.

  7. Enable source mapping by selecting the Source map check box.

  8. Set the Out files field to the local directory of your Lambda function copy.

    If app.js and app.map are in .aws-sam/build/HelloWorldFunction, then make the Out files location /Users/user/project/aws-sam/build/HelloWorldFunction/*.

    Note

    The Out file path should be an absolute path.

  9. When you're satisfied with the settings, choose the Remote invoke button to begin debugging your TypeScript function.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4