# Source: https://planetscale.com/docs/vitess/tutorials/aws-lambda-connection-strings.md

# AWS Lambda connection strings

> In this guide, you'll learn how to properly store and use PlanetScale MySQL connection strings for use in AWS Lambda Functions.

## Introduction

We'll use a [pre-built NodeJS](https://github.com/planetscale/aws-connection-strings-example) app for this example, but you can follow along using your own application as well.

## Prerequisites

* An AWS account
* A [PlanetScale account](https://auth.planetscale.com/sign-up)

## Set up the database

<Note>
  If you already have a database with a production branch, skip to [the next section](#configure-the-lambda-function).
</Note>

Let's start by creating the database. In the PlanetScale dashboard, click the "**New database**" button followed by "**Create new database**". Name the database **lambda-connection-strings,** or any other name that you prefer. Click "**Create database**".

Once your database has finished initializing, you'll need to enable the web console on production branches. To do this, go to the "**Settings**" tab, check "**Allow web console access to production branches**", and click "**Save database settings**".

Now, access the console of the main branch by clicking "**Console**", then "**Connect**".

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=32e2d97aeee544127e39ea25c03dd991" alt="The console" data-og-width="1512" width="1512" data-og-height="1105" height="1105" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=f8784bafd3c7fe5452787a3fcc524360 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=1aad292e1280e623754c6348264f96c7 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=aa4ddccca932f787cfc92f2db3fba5cb 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=ac8ebc37ab9aada2cdfd91a27dd27a62 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=70bd7fadd625c6506c8a877c4a5867c0 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/console-3.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=fbd84b69c41cfe7b0a5779408aacc597 2500w" />
</Frame>

Create a simple table & insert some data using the following script:

```sql  theme={null}
CREATE TABLE Tasks(
	Id int PRIMARY KEY AUTO_INCREMENT,
	Name varchar(100),
	IsDone bit
);

INSERT INTO Tasks (Name) VALUES ('Clean the kitchen');
INSERT INTO Tasks (Name) VALUES ('Fold the laundry');
INSERT INTO Tasks (Name) VALUES ('Watch the sportsball game');
```

You may run `SELECT * FROM Tasks` to ensure the data was properly added from the console.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=bcbc6ad2ec884cb2f288977d72965f5d" alt="Records from the console" data-og-width="1262" width="1262" data-og-height="331" height="331" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=acafedcd63a83be6fc2240b0527efc05 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=76b4af47d878a192d4e71a0aab75e7a9 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=c88b98c3699cd77fefddeec60183893f 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=af94a7ad7926483dbabcb7004145c256 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=26d550adfeb3f27abfcfc44907cfdbdf 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/select.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8f938ac234303f0960da67f6184db94d 2500w" />
</Frame>

Now we need to enable [**safe migrations**](/docs/vitess/schema-changes/safe-migrations) on the **main** branch. Click the **Dashboard** tab, then click the **cog** icon in the upper right of the infrastructure card.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=9b84747eb949e5e638b2b77d383c5199" alt="The option to promote a branch" data-og-width="1653" width="1653" data-og-height="671" height="671" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=7d4f46b1ddde97ba216b29c90ebc0101 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=76d54458ac5f71191b35874aef5a48eb 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=318fb175f28b1328076b956b8ea5ae36 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8be5cbbd881cd798634c30cb76bfd8c9 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=ac85219097d32abbeb33907dff66e88c 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/production-2.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=5e46f0222e5a6fefe0def8307871faa5 2500w" />
</Frame>

Toggle on the "**Enable safe migrations**" option and click the "**Enable safe migrations**" button.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=9d4f4c8d6bf945328a5d398acdf244a5" alt="Enable safe migrations" data-og-width="943" width="943" data-og-height="781" height="781" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=55033b4de736fde0f6dbf9465cf121f9 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e1cb8cad14d9e5cc682d0cc8606867f4 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=7181e052522173617c6e51dc1c7e0634 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=2135d1fe1c78f1ab7fb6f38f7202f2ba 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=262929c883a474e37c9b3b5df8c4457a 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/safe-migrations-2.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=13ba9bcdd74f0c9c22c0faf583435905 2500w" />
</Frame>

Before moving on from the PlanetScale dashboard, grab the connection details to be used in the next step. Click on the **Connect** button to go to the Connect page. Enter a name for your password, and click the **Create password** button to generate a new password.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=f9923b79a5807dc0c71084428f30aed6" alt="The dashboard after the database has been promoted" data-og-width="1627" width="1627" data-og-height="809" height="809" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e3869738f18adb0b375d83a913fd7835 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8970420f55754b87718113dbb572ab64 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=d49893a3aaf475245d3f5c95c670f8bb 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=05fcd7f8446b04ed1f7b1aa9c110dca4 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=4fe2686698e387f6774ad074345bcd6d 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/promoted-2.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=f962cbc0107db8aec93e8d3958a7f55d 2500w" />
</Frame>

In the **Select your language or framework** section, select **Node.js** and note the details in the `.env` section of the guide. These details will be required to connect to the database.

## Configure the Lambda function

Secrets in AWS Lambda functions, which include database connection strings, are often stored as environment variables with the Lambda function. We’ll be uploading a sample NodeJS app that has been provided and storing the connection string from the previous section as an environment variable to test.

Start by cloning the following Git repository:

```bash  theme={null}
git clone https://github.com/planetscale/aws-connection-strings-example.git
```

Log into the AWS Console, use the universal search to search for ‘**Lambda**’, and select it from the list of services.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e0d641fbcd2f007f9dbdf89e34e84712" alt="Search for Lambda in the AWS Console" data-og-width="1111" width="1111" data-og-height="492" height="492" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=0c479568bb6916940d92ecf5ada66c92 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=d573cc912889dff8bc4f93afdd007f99 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=94684e86d61b47a28717b8fd57cd0713 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=81e6d4ea7b850c794a4883e5bc3aaa84 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=b678df7902df2af63defc0524a589a08 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/aws.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=1916c057f5c31a587f0a2e75e103243b 2500w" />
</Frame>

Create a new function using the **Create function** button in the upper right of the console.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=4d76e5576ef02650b7eefff877ae3655" alt="The default view of Lambda functions" data-og-width="1850" width="1850" data-og-height="659" height="659" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=d2fd58373cbfad63b642826ab8ca483e 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=2739a82e045c4b1f3b519659e5a6c46e 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=f1d60ec76215718be80f7338e2a2445b 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8b2a9725aa3bbd2c854f4649eec27632 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=19c2f6cb703d106e5ef7eae17ae90eaa 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/functions.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=2a6c9150763d1feb9ceb143fcf1a7001 2500w" />
</Frame>

Name your function **lambda-connection-strings** (or any other name that suits you) and select **NodeJS** under **Runtime**. The other fields can be left as default. Click **Create function** to finish the initial setup of your Lambda.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8c94601c5c6dae6c8cd81ab3ee93579d" alt="The view to create a Lambda function" data-og-width="1286" width="1286" data-og-height="920" height="920" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=713b5dc49d6db763204b156aa376db10 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=2ea1256c900b19e4e31526874b415f19 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=2d66434e81793799d654f877512d2376 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=27aec53074ddbfdd9c41242db4cfbda7 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=eb33526b70663a2ed07f94bfb10fdf2e 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/create-function.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=dae4102b4b7579b9c0f0373c78007bdd 2500w" />
</Frame>

On the next view, about halfway down the page you’ll see a section called **Code source**. Click the **Upload from** button, then **.zip file**.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e8ebb493bcc5503172fd493dccf70799" alt="The default NodeJS Lambda function" data-og-width="1272" width="1272" data-og-height="1023" height="1023" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=494e9418acf8bb6b22f39d610b8b47b0 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8d92df49593698671c4ad9d240493acd 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e354356192a597cfe6085193e3cb610d 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=273bc6ae88eefe4320c57545a3edc11d 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e419fed1a6bddc10143919df0d9d80b3 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/node.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=d3b29e8af04915518252574c49c7759f 2500w" />
</Frame>

Click the **Upload** button which will display a file browser. Select the **aws-connection-strings-example.zip** file from the **dist** folder of the provided repository. Click **Save** once it’s been selected.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=2687c7afb107aaec165086be63b1d2a4" alt="The modal to upload code" data-og-width="825" width="825" data-og-height="275" height="275" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?w=280&fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=b0b2b66ef0d502510e2e5e4b0c1ddcc0 280w, https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?w=560&fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=1996c15bd45c99245fa9fb527790f716 560w, https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?w=840&fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=09017097e29e997717bf048ac0baee80 840w, https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?w=1100&fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=3e05ea641fafa113a4e011217b1fbb0c 1100w, https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?w=1650&fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=772ad58492b6b6d21d23776cdca6e5a3 1650w, https://mintcdn.com/planetscale-cad1a68a/FWWWKZleEvIA3gmW/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/upload.png?w=2500&fit=max&auto=format&n=FWWWKZleEvIA3gmW&q=85&s=66cbe6e371b6288d5b72ae67c33ff40c 2500w" />
</Frame>

The contents of the code editor under **Code source** should have updated to show the code stored in the zip file.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=5b21336279bbc7f4967cfe39fb603db8" alt="The code of the Lambda function that was uploaded" data-og-width="1157" width="1157" data-og-height="761" height="761" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=349f34235bb2f183b632b6dde1983099 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=63787a92fc837d801a3ed5adf410a0fc 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=bb1bdfa8829251f9a754f19ecc35d9b5 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=23ec9201f727e04888439b9d092615b8 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=6a3a0716994bd87721befe84cb77d91a 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/source.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=5ac9bb89fdbe969e2e3d7b3fcc342747 2500w" />
</Frame>

### Configure environment variables

Next, you need to set the PlanetScale `DATABASE_URL` environment variable that you copied earlier. Select the **Configuration** tab, and click **Edit**.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=56bdd6a0aa450a5049d228dba651bd64" alt="The configuration tab" data-og-width="1167" width="1167" data-og-height="820" height="820" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=a50aa9ffa465979939ec88e2ad52233c 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=1b9398cd409dd4e0856e872720a9f7f6 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=291392c11145a663dc8f0bf374686913 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=f90ab0df281e1bbf9a112f98be786022 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=373c5b64a0e16f0c1922d6a86eecef66 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/configuration.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=d45fa4363f839910ae25c5e8aeb0bfd2 2500w" />
</Frame>

You’ll be presented with a view to add or update environment variables. Click **Add environment variable** and the view will update with a row to add an environment variable. Set the **Key** field to **DATABASE\_URL** and the **Value** to the connection string taken from the previous section. Click **Save** once finished.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=e54594c9eecf831239996c63d55fc058" alt="The view to manage environment variables" data-og-width="841" width="841" data-og-height="525" height="525" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=32161f1978438d0f9a93dc25ca944d68 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=6cbda497900c200f4440e58a424ae064 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=700f496dda7c57e81b5eb47227b2ac4f 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=26c1654f54f4d5d87ecb1b9971030adc 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=2ee2f7903f7d3007d8900f5db59ba8fc 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/environment-variables.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=bd405918f62d9ff4c55b44439a7fb801 2500w" />
</Frame>

Finally, test the function by selecting the **Test** tab, and then clicking the **Test** button.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=fdeec770fd58e2678c831e128356a34f" alt="The test tab" data-og-width="1148" width="1148" data-og-height="494" height="494" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=38c1e06b2be30c04c922f62dc1b507c7 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=aaf3e248a51c92c4940963070a2fb6d0 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=fd529ea977ab1ee131d0e5432d817846 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=04f3d7a4b86f18343459b8521e290f9d 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=b5a0cdca2c77c5b97b1cdd7edb5401c2 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/test.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=47f8db938bcf2c5c5286fffa1a9687e3 2500w" />
</Frame>

An **Execution results** box will display above the **Test event** section. If the box is green, it likely means everything executed as expected. Click the dropdown next to **Details** to see the results of the query. Since the results of the query were logged out to the console, they will be displayed in the **Log output** section.

<Frame>
    <img src="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=7caa9b033396ad878bb7c3f7653e402d" alt="The execution results" data-og-width="1163" width="1163" data-og-height="906" height="906" data-path="docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?w=280&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=1df0c2700c78329e510790fdee8b0c18 280w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?w=560&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=06664ca9aaccfd9953610d6bacf4d757 560w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?w=840&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=8d81a620acc75be1a43ec24b8f9d5bbd 840w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?w=1100&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=54116be91398f050cc3b1ff3335568f1 1100w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?w=1650&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=399a8192a4f5f148316f3244a47a4b02 1650w, https://mintcdn.com/planetscale-cad1a68a/KejcMcI0BguxMNLm/docs/images/assets/docs/tutorials/aws-lambda-connection-strings/success.png?w=2500&fit=max&auto=format&n=KejcMcI0BguxMNLm&q=85&s=ce597713a77ccc23506c640be2223ce5 2500w" />
</Frame>

## Need help?

Get help from [the PlanetScale Support team](https://support.planetscale.com/), or join our [GitHub discussion board](https://github.com/planetscale/discussion/discussions) to see how others are using PlanetScale.


---

> To find navigation and other pages in this documentation, fetch the llms.txt file at: https://planetscale.com/llms.txt