---
title: Integrating AWS Secrets Manager with Vercel Using Terraform
description: Learn how to seamlessly integrate AWS Secrets Manager with Vercel for enhanced security and efficiency in your web deployments using Terraform with our comprehensive guide.
url: "https://vercel.com/kb/guide/integrating_aws_secrets_manager_with_vercel_using_terraform"
published: 2025-11-03
last_updated: 2026-10-02
authors: Jason Wiker
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

## Introduction

This guide provides step-by-step instructions on how to integrate AWS Secrets Manager with Vercel using [Terraform](https://registry.terraform.io/). Terraform, an infrastructure as code tool, enables developers to define and provision infrastructure using configuration files. You will leverage Terraform to manage both AWS and Vercel resources, ensuring a seamless integration for managing secrets and deploying applications.

See the [Integrating Terraform with Vercel](https://vercel.com/guides/integrating-terraform-with-vercel) guide for more detail on how to integrate terraform with Vercel.

## Prerequisites

- Basic understanding of Terraform, AWS, and Vercel
  
- Terraform installed on your machine
  
- AWS CLI installed and configured with necessary permissions
  
- Vercel account and CLI installed
  

## Step 1: Setting up your Terraform configuration

Start by creating a Terraform configuration file, **`main.tf`**. This file will define the required providers and resources.

### Providers setup

**1\. Define the AWS and Vercel providers**: Specify the version and source for both [AWS](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) and [Vercel](https://registry.terraform.io/providers/vercel/vercel/latest/docs) providers.

```javascript
terraform {
  required_providers {
    vercel = {
      source = "vercel/vercel"
      version = "~> 0.3"
    }
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}
```

2\. **Configure the providers**: Set your Vercel team and AWS region.

```javascript
provider "vercel" {
  team = ""  // Replace with your team ID
}

provider "aws" {
  region = "us-west-2"  // Replace with your preferred region
}
```

### AWS Secrets Manager resource

**1\. Create a secret in AWS Secrets Manager**: Define a resource for creating a secret. Note that you'll manually set the secret value in the AWS console after you create the resource. You will need to complete that before you are able to subsequently pull the value.

```javascript
resource "aws_secretsmanager_secret" "example" {
  name = "example"
}
```

**2\. Retrieve the secret value**: Use a data source to get the latest version of the secret after setting it manually in AWS.

```javascript
data "aws_secretsmanager_secret_version" "example" {
  secret_id = aws_secretsmanager_secret.example.id
}
```

## Step 2: Setting up Vercel project with Terraform

### Vercel project resource

**1\. Create a Vercel project**: Define a Vercel project resource. This example uses a Next.js project.

```javascript
resource "vercel_project" "example" {
  name      = "example-project"  // Replace with your project name
  framework = "nextjs"
}
```

**2\. Add environment variable from AWS Secrets Manager**: Define a Vercel project environment variable resource. It uses the secret string from AWS Secrets Manager.

```javascript
resource "vercel_project_environment_variable" "example" {
  project_id = vercel_project.example.id
  key        = "foo"  // Replace with your desired env var name
  value      = data.aws_secretsmanager_secret_version.example.secret_string
  target     = ["production"]
}
```

## Step 3: Deploying your configuration

1. **Initialize Terraform**: Run **`terraform init`** in your terminal within the directory containing your **`main.tf`** file. This will initialize Terraform and download the necessary provider plugins.
   
2. **Apply configuration**: Run **`terraform apply`** to create the resources defined in your configuration. Confirm the action when prompted.
   

## Conclusion

You have now successfully integrated AWS Secrets Manager with your Vercel project using Terraform. This setup allows you to securely manage environment variables and integrate them into your Vercel deployments.

## Related Documentation

- [Next.js](/docs/frameworks/full-stack/nextjs)

## More Next.js guides

- [Build an AI Chat Agent with Weather API Tool Calling](/kb/guide/build-ai-agent-weather-api): Build an intelligent conversational agent that fetches real-time weather data using the AI SDK, tool calling, and a backend weather API powered by Express, FastAPI or Nitro
- [Human-in-the-Loop with Chat SDK and Workflow SDK](/kb/guide/human-in-the-loop-with-chat-sdk-and-workflow-sdk): Combine Chat SDK and Workflow SDK to suspend workflows on approval cards in a chat platform, then resume on click via createWebhook.
- [Build with Vercel Blob on Next.js](/kb/guide/vercel-blob-nextjs): Deploy the Vercel Blob Next.js Starter and learn how client uploads store images securely in a private Blob store.

## Reference Architecture

Choose a stack and work through the decisions behind it, with curated documentation, guides, templates, and courses to help you build.

- [Agent stack](/kb/architecture/agents): Build and operate agents with models, tools, and durable workflows.
- [Web applications](/kb/architecture/web): Choose rendering, data, authentication, and caching approaches.
- [Backends](/kb/architecture/backends): Choose a runtime, connect services, and run background work.

[Browse all stacks](/kb/architecture)

## Build with prompts

Build an app, extend an agent, or improve your project with ready-to-use prompts for your coding agent.

[Browse the prompt library](/kb/prompts) · [Read the Markdown index](/kb/prompts.md)
