---
title: "AWS YAML LangServe Example"
description: "A minimal Langserve AWS Python Pulumi program"
url: "https://www.pulumi.com/dev/examples/aws-py-langserve/"
image: "https://www.pulumi.com/assets/og/dev/examples/aws-py-langserve.png"
---

# AWS YAML LangServe Example

A minimal Langserve AWS Python Pulumi program

- Source on GitHub: https://github.com/pulumi/examples/tree/master/aws-py-langserve

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/aws-py-langserve) repo. Pull down just this directory to follow along:

```bash
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set aws-py-langserve
cd pulumi-examples/aws-py-langserve
```

This example demonstrates how to use deploy a simple app using Pulumi in YAML.

## Prerequisites

To run this example, you'll need the following tools installed on your machine:

1. [Install Pulumi](https://www.pulumi.com/docs/install/)
2. [Install Python](https://www.python.org/downloads/)
2. [Configure AWS](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/)
3. [Install Docker](https://docs.docker.com/get-docker/)
4. [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
5. [Install the LangChain CLI](https://python.langchain.com/docs/langserve#installation)

## Deploying to AWS using Pulumi

Set the region with the following command:

```bash
pulumi config set aws:region <region>
```

Run the following command to deploy your LangServe app to AWS:

```bash
git clone https://github.com/pulumi/examples.git
cd examples/aws-py-langserve
pulumi stack init <your-stack-name>
pulumi config set open-api-key --secret # Enter your OpenAI API key
pulumi up
```

This last command will show you a preview of the resources that will be created. After reviewing the changes, you will be prompted to continue. Once confirmed, Pulumi will deploy your LangServe app to AWS.

The whole deployoment process will take a couple of minutes. Once it's done, you will see the URL of your LangServe app in the output.

```bash
Outputs:
    url: "http://<dns>.elb.amazonaws.com"

Resources:
    + 27 created
```

You can now access the LangServe playground by adding `/openai/playground` to the URL you got from the output.

> [!NOTE]  
> It may take a few minutes for the load balancer to be ready to accept requests. If you see a 503 error, wait a few minutes and try again.

## Clean up

To clean up the resources created by this example, run the following command:

```bash
pulumi destroy
```

You will be prompted to confirm the deletion of the resources. Once confirmed, Pulumi will delete all the resources created by this example.
