Skip to content

Commit

Permalink
docs: lambda vs code extension
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshCasper committed Oct 15, 2023
1 parent e777f49 commit caf8ffe
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions content/en/user-guide/tools/lambda-vscode-extension/index.md
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="CloudFormation Output on Former2 Dashboard" title="CloudFormation Output on Former2 Dashboard" 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="CloudFormation Output on Former2 Dashboard" title="CloudFormation Output on Former2 Dashboard" 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 caf8ffe

Please sign in to comment.