
## Set up AWS Lambda

URL: https://docs.atlan.com/product/capabilities/build-apps/sdks/python/events/how-tos/aws-lambda/setup-lambda

> Set up AWS Lambda layers and functions with the Atlan Python SDK (pyatlan) for event-driven metadata processing.

# Set up AWS Lambda

:::tip[Requires an AWS account]
You will need an AWS account with access (and capacity) to manage AWS Lambda layers and functions.
:::

## Create base layer

Begin by setting up your environment with the base SDK you want to use for event handling:

### Java

We publish a `lambda-layer` artifact with the Java SDK, bundled and ready-to-use as a base layer for any Java-based Lambda functions.

1. Download the latest `lambda-layer` artifact.
2. Open the [AWS Lambda layers console](https://console.aws.amazon.com/lambda/home#/layers).
3. In the upper-right, click the **Create layer** button, and then:
 - Enter a *Name* for the layer, such as `atlan-java-sdk`.
 - Upload the file you downloaded in (1).
 - For *Compatible architectures* select **x86_64**.
 - For *Compatible runtimes* select **Java 17**.
 - In the lower-right, click the **Create** button to create the layer.

### Python

We publish a `lambda-layer` artifact with the Python SDK, bundled and ready-to-use as a base layer for any Python-based Lambda functions.

1. Download the latest `lambda-layer` artifact.
2. Open the [AWS Lambda layers console](https://console.aws.amazon.com/lambda/home#/layers).
3. In the upper-right, click the **Create layer** button, and then:
 - Enter a *Name* for the layer, such as `atlan-python-sdk`.
 - Upload the file you downloaded in (1).
 - For *Compatible architectures* select **x86_64**.
 - For *Compatible runtimes* select **Python 3.10**.
 - In the lower-right, click the **Create** button to create the layer.

## Create function

Now you are ready to create an AWS Lambda function:

### Java

1. Open the [AWS Lambda functions console](https://console.aws.amazon.com/lambda/home#/functions).
2. In the upper-right, click the **Create function** button, and then:
 - Use the default **Author from scratch** option.
 - Enter a *Function name* for your function, something that briefly describes its purpose.
 - For *Runtime* select **Java 17**.
 - For *Architecture* select **x86_64**.
 - In the lower-right, click the **Create function** button to create the function.

### Python

1. Open the [AWS Lambda functions console](https://console.aws.amazon.com/lambda/home#/functions).
2. In the upper-right, click the **Create function** button, and then:
 - Use the default **Author from scratch** option.
 - Enter a *Function name* for your function, something that briefly describes its purpose.
 - For *Runtime* select **Python 3.10**.
 - For *Architecture* select **x86_64**.
 - In the lower-right, click the **Create function** button to create the function.

## Configure function

Now you need to configure the function. Begin by opening your function in the AWS console, if it'sn't already open.

### Set base layer

On the **Code** tab of your function:

1. At the bottom of the page in the *Layers* table, click the **Add a layer** button.
2. For *Layer source* choose **Custom layers**.
3. From the *Custom layers* drop-down, select the layer you created in the steps above.
4. From the *Version* drop-down, select the most recent version (the one with the highest number).
5. In the lower-right, click the **Add** button.

### Enable function URL

To be able to receive webhooks, your Lambda function must be exposed on a URL. You can do this be enabling its function URL:

1. Change to the **Configuration** tab of your function.
2. From the left, click **Function URL**.
3. To the right, click the **Create function URL** button:
 - For *Auth type* choose **NONE**.
 - In the lower-right, click the **Save** button.
4. Copy the URL listed under *Function URL* - you will use this URL to configure the webhook in Atlan.

> *Won't this be insecure? — see full content on the documentation site.*

### Set environment variables

1. Still within the **Configuration** tab of your function...
2. From the left, click **Environment variables**.
3. To the right, click the **Edit** button.
4. Click the **Add environment variable** button to add each of these:

 | *Key* | *Value* |
 |---|---|
 | `ATLAN_API_KEY` | an Atlan API token your code should use for any further interaction with Atlan |
 | `ATLAN_BASE_URL` | the base URL of your tenant (for example `https://example.atlan.com`) |
 | `SIGNING_SECRET` | for now fill in any value, we will replace it later |

5. In the lower-right, click the **Save** button.

---
