---
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: /kb/guide/integrating_aws_secrets_manager_with_vercel_using_terraform
canonical_url: "https://vercel.com/kb/guide/integrating_aws_secrets_manager_with_vercel_using_terraform"
published: 2025-11-03
last_updated: 2026-07-16
authors: Jason Wiker
related: []
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Integrating Terraform with Vercel](https://vercel.com/kb/guide/integrating-terraform-with-vercel?from=related) — Understand the benefits of Terraform and how to set up the Integration with Vercel.
- [Contentful](https://vercel.com/docs/integrations/cms/contentful?from=related) — Integrate Vercel with Contentful to deploy your content.
- [OIDC](https://vercel.com/docs/oidc?from=related) — Secure the access to your backend using OIDC Federation to enable auto-generated, short-lived, and non-persistent creden
- [Sitecore](https://vercel.com/docs/integrations/cms/sitecore?from=related) — Integrate Vercel with Sitecore XM Cloud to deploy your content.
- [Getting Started](https://vercel.com/docs/getting-started-with-vercel?from=related) — Install the Vercel CLI, add the Vercel Plugin or agent skills, and deploy your first project.
- [Overview](https://vercel.com/docs/integrations?from=related) — Learn how to extend Vercel's capabilities by integrating with your preferred providers for AI, databases, headless conte
- [Integrate Vercel and Contentstack for your Headless CMS](https://vercel.com/kb/guide/integrate-vercel-and-contentstack?from=related) — Integrate Vercel with Contentstack, a headless CMS, to build and deploy dynamic, high-performance websites.
- [Migrate a TanStack Start app from Cloudflare to Vercel](https://vercel.com/kb/guide/migrate-a-tanstack-start-app-from-cloudflare-to-vercel?from=related) — Move your TanStack Start app off Cloudflare Workers and onto Vercel Functions, where Fluid compute scales it automatical
- [How can I use AWS SDK Environment Variables on Vercel?](https://vercel.com/kb/guide/how-can-i-use-aws-sdk-environment-variables-on-vercel?from=related) — How to use AWS SDK Environment Variables on Vercel
- [Using coding agents to procure Vercel Marketplace integrations](https://vercel.com/kb/guide/using-coding-agents-to-procure-vercel-marketplace-integrations?from=related) — Coding agents can now discover, provision, and manage third-party services from the Vercel Marketplace using the Vercel

Full cross-link map for this page: [/kb/guide/integrating_aws_secrets_manager_with_vercel_using_terraform.graph.md](/kb/guide/integrating_aws_secrets_manager_with_vercel_using_terraform.graph.md)
<!-- /docsgraph:related -->


## 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.