---
title: How can I use AWS SDK Environment Variables on Vercel?
description: How to use AWS SDK Environment Variables on Vercel
url: "https://vercel.com/kb/guide/how-can-i-use-aws-sdk-environment-variables-on-vercel"
published: 2025-11-03
last_updated: 2026-08-26
authors: Lee Robinson
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

Vercel allows the use of specific [environment variables](https://vercel.com/docs/concepts/projects/environment-variables) that can be used for your deployments. These can be used to configure the AWS credentials used by your Serverless Function as well as the region.

## Configuring credentials

To get started, add the following environment variables to your Vercel project:

- `AWS_ACCESS_KEY_ID`
  
- `AWS_SECRET_ACCESS_KEY`
  
- `AWS_SESSION_TOKEN`
  

The values for the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables are produced by AWS IAM when creating new access keys for an [IAM User](https://aws.amazon.com/iam/).

The `AWS_SESSION_TOKEN` environment variable is often used to provide a short-lived, temporary set of credentials and is not normally useful to set for static credentials. It may be useful for testing changes on preview or development branches.

## Configuring region

The AWS region corresponding to the Vercel region in which a Serverless Function is deployed is preset in the environment of the Serverless Functions. For example, a Serverless Function deployed in the Vercel region `sfo1` already has the `AWS_REGION` environment variable set to `us-west-1`. See [supported Vercel regions](https://vercel.com/docs/regions) for more information.

The AWS region can be overridden by setting one of two environment variables:

- `AWS_REGION`\_ (preferred)\_
  
- `AWS_DEFAULT_REGION`
  

The use of `AWS_DEFAULT_REGION` is not normally required for the AWS SDK, but is supported for completeness.

## Using the configured variables in code

By using these specially named environment variables, manual configuration of the AWS SDK can be avoided. For example, to use these variables to authenticate an S3 client from the AWS SDK, use the following code:

```javascript
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';

// The credentials are read from the environment automatically
const s3Client = new S3Client({});

const uploadCommand = new PutObjectCommand({
  Bucket: process.env.S3_BUCKET_NAME,
  Key: 'file-name',
  Body: 'file-body',
});
```

This works equally well with all AWS services supported by the SDK. For further examples, see [AWS S3 Image Upload](https://vercel.com/templates/next.js/aws-s3-image-upload-nextjs) and [Next.js Vercel app with Aurora DSQL](https://vercel.com/templates/next.js/next-js-vercel-app-with-aurora-dsql).

## Use of custom runtimes

All the [runtimes supported by Vercel](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes) can use the environment variables described above. The use of custom runtimes may result in use of these variables causing a build-time error.

Custom runtimes that set the value of `supportsWrapper` to `true` in the Serverless Function config can make use of the AWS credential environment variables. See [the Build API documentation](https://vercel.com/docs/build-output-api/v3#vercel-primitives/serverless-functions/configuration/base-config) for more details. Other runtimes must use alternative environment variable names and set up the AWS client manually.

## Related Documentation

- [Vercel Functions](/docs/functions)

## More Vercel Functions guides

- [Optimize Runtime Cache on Vercel](/kb/guide/optimize-runtime-cache-reads-on-vercel): Diagnose rising Runtime Cache usage, trace reads to tags and code paths, and reduce avoidable reads while checking write cost and origin traffic.
- [How to stop Vercel Functions from timing out](/kb/guide/what-can-i-do-about-vercel-serverless-functions-timing-out): Vercel Functions that time out usually trace back to a few causes. Learn how Fluid Compute fixes most of them and how to handle the edge cases.
- [The Complete Guide to Vercel Connect](/kb/guide/vercel-connect): Use Vercel Connect to call provider APIs like Slack, GitHub, Linear, Microsoft, Discord, Snowflake, and Salesforce from your agents and services with short-lived, scoped tokens instead of long-lived secrets.

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