Configuration options for debugging serverless applications
When you open the launch.json
file to edit debug configurations, you
can use the VS Code IntelliSense
IntelliSense enables you to find and define properties for invoking Lambda functions
directly or with the AWS SAM template. You can also define properties for
"lambda"
(how the function runs), "sam"
(how the AWS SAM CLI
builds the application), and "aws"
(how AWS connection information is
provided).
Property | Description |
---|---|
|
Specifies which extension manages the launch configuration. Always set
to |
|
Specifies a reader-friendly name to appear in the Debug launch configuration list. |
|
Specifies the type of configuration
to
be performed by the designated extension
( |
|
Specifies the entry point for invoking the resource. For invoking the Lambda function directly, set values for the following
For invoking the Lambda resources with the AWS SAM template, set values
for the following
|
Property | Description |
---|---|
|
Passes operational parameters to your Lambda function. For example, if you're writing to an Amazon S3 bucket, instead of hard-coding the bucket name that you're writing to, configure the bucket name as an environment variable. NoteWhen specifying environment variables for a serverless
application, you must add configurations to both the AWS SAM template
( Example of formatting for an environment variable in the AWS SAM template:
Example of formatting for an environment variable in the
|
|
Provides two options for the event payload that you provide to your Lambda function as input.
|
|
Specifies megabytes (MB) of memory provided for running an invoked Lambda function. |
|
Specifies the runtime that the Lambda function uses. For more information, see AWS Lambda runtimes. |
|
Sets the time allowed, in seconds, before the debug session times out. |
|
Specifies where local code is in relation to where it runs in the container. By default, the Toolkit for VS Code sets Example of formatting for
Caveats:
|
The Toolkit for VS Code uses the AWS SAM CLI to build and debug serverless applications
locally. You can configure the behavior of AWS SAM CLI commands using properties of the
"sam"
configuration in the launch.json
file.
Property | Description | Default value |
---|---|---|
|
Configures how the |
Empty string |
|
Indicates whether to build your function inside a Lambda-like Docker container. |
|
|
Specifies the name or ID of an existing Docker network that the Lambda Docker containers should connect to, along with the default bridge network. If not specified, the Lambda containers connect only to the default bridge Docker network. |
Empty string |
|
Specifies additional local invoke arguments. |
Empty string |
|
Specifies whether the command should skip pulling down the latest Docker image for Lambda runtime. |
|
|
Customizes your AWS SAM template using parameters to input customer values. For more information, see Parameters in the AWS CloudFormation User Guide. |
|
Property | Description | Default value |
---|---|---|
|
Selects a specific profile (for example,
|
The AWS credentials that your existing shared AWS config file or shared AWS credentials file provide to the Toolkit for VS Code. |
|
Sets the AWS Region of the service (for example, us-east-1). |
The default AWS Region associated with the active credentials profile. |
Example: Template launch configuration
Here is an example launch configuration file for an AWS SAM template target:
{ "configurations": [ { "type": "aws-sam", "request": "direct-invoke", "name": "my-example:HelloWorldFunction", "invokeTarget": { "target": "template", "templatePath": "template.yaml", "logicalId": "HelloWorldFunction" }, "lambda": { "payload": {}, "environmentVariables": {} } } ] }
Example: Code launch configuration
Here is an example launch configuration file for a Lambda function target:
{ "configurations": [ { "type": "aws-sam", "request": "direct-invoke", "name": "my-example:app.lambda_handler (python3.7)", "invokeTarget": { "target": "code", "projectRoot": "hello_world", "lambdaHandler": "app.lambda_handler" }, "lambda": { "runtime": "python3.7", "payload": {}, "environmentVariables": {} } } ] }