Skip to content

Commit

Permalink
docs: lambda vs code extension (#860)
Browse files Browse the repository at this point in the history
* docs: lambda vs code extension

* fix few nits

* fix nits
  • Loading branch information
HarshCasper authored Oct 16, 2023
1 parent 913882c commit b76a21b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
13 changes: 2 additions & 11 deletions content/en/user-guide/aws/lambda/index.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
---
title: "Lambda"
linkTitle: "Lambda"
categories: ["LocalStack Community", "LocalStack Pro"]
description: >
Get started with AWS Lambdas on LocalStack
tags:
- lambda
- aws-lambda
- lambda-hot-reloading
- lambda-debugging
- localstack-lambda
- serverless
- lambda-layers
Get started with Lambda on LocalStack
aliases:
- /aws/lambda/
- /references/lambda-executors/
- /references/lambda-provider-v2/
- /references/lambda-asf-provider/
Expand Down Expand Up @@ -119,6 +109,7 @@ LocalStack provides various tools to help you develop, debug, and test your AWS

* **Hot reloading**: With Lambda hot reloading, you can continuously apply code changes to your Lambda functions without needing to redeploy them manually. To learn more about how to use hot reloading with LocalStack, check out our [hot reloading documentation]({{< ref "hot-reloading" >}}).
* **Remote debugging**: LocalStack's remote debugging functionality allows you to attach a debugger to your Lambda function using your preferred IDE. To get started with remote debugging in LocalStack, see our [debugging documentation]({{< ref "debugging" >}}).
* **Lambda VS Code Extension**: LocalStack's Lambda VS Code Extension supports deploying and invoking Python Lambda functions through AWS SAM or AWS CloudFormation. To get started with the Lambda VS Code Extension, see our [Lambda VS Code Extension documentation]({{< ref "user-guide/tools/lambda-tools/lambda-vscode-extension" >}}).

## Lambda Layers (Pro)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "Lambda VSCode Extension"
weight: 9
description: >
Deploy and invoke Lambda functions in LocalStack directly from VSCode
---

## Introduction

[LocalStack Lambda VSCode Extension](https://github.com/localstack/localstack-vscode-extension) supports deploying and invoking Python Lambda functions through [AWS SAM](https://github.com/aws/serverless-application-model) or [AWS CloudFormation](https://aws.amazon.com/cloudformation/resources/templates/).

## Prerequisites

- [VS Code](https://code.visualstudio.com/)
- [`samlocal`](https://github.com/localstack/aws-sam-cli-local) command line wrapper around the [AWS SAM CLI](https://github.com/aws/aws-sam-cli) for use with [LocalStack](https://github.com/localstack/localstack).
- [LocalStack](https://docs.localstack.cloud/getting-started/) running in the background.

## Getting Started

You can use a [sample project](https://github.com/joe4dev/lambda-python) to get started with the extension. The sample project contains a simple Lambda function and a SAM template. Clone the repository and open the project in VSCode.

{{< command >}}
$ git clone https://github.com/joe4dev/lambda-python.git
$ cd lambda-python
$ code .
{{< /command >}}

Install the [LocalStack VSCode Extension](https://marketplace.visualstudio.com/items?itemName=localstack.localstack) as recommended by the project.

You can now open the Python handler function under `app/hello_world.py`. Click the CodeLens **Deploy Lambda function**, select the `template.yaml`, and choose a stack name such as `my-stack`.


<img src="deploy-lambda-function.gif" alt="Deploying Lambda function via the VS Code Extension" title="Deploying Lambda function via the VS Code Extension" width="700" />
<br><br>


Click the CodeLens **Invoke Lambda function** and pick the stack name `my-stack` and the function `hello-world-function`.


<img src="invoke-lambda-function.gif" alt="Invoking Lambda function via the VS Code Extension" title="Invoking Lambda function via the VS Code Extension" width="700" />
<br>

## Limitations

- The CodeLens for **Deploy Lambda function** always appears at the first line of each Python file.
- **Invoke Lambda function** currently only works in the region `us-east-1` and with an empty payload.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b76a21b

Please sign in to comment.