---
title: How can I use AWS SDK Environment Variables on Vercel?
description: How to use AWS SDK Environment Variables on Vercel
url: /kb/guide/how-can-i-use-aws-sdk-environment-variables-on-vercel
canonical_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
related:
  - /docs/concepts/projects/environment-variables
  - /docs/regions
  - /docs/concepts/functions/serverless-functions/runtimes
  - /docs/build-output-api/v3
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.

- [Reserved environment variables](https://vercel.com/docs/environment-variables/reserved-environment-variables?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Reserved environment variables are reserved by Vercel Vercel Function runtimes.
- [Environment variables](https://vercel.com/docs/environment-variables?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Learn more about environment variables on Vercel.
- [Managing environment variables](https://vercel.com/docs/environment-variables/managing-environment-variables?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Learn how to create and manage environment variables for Vercel.
- [Managing environment variables across environments](https://vercel.com/docs/environment-variables/manage-across-environments?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Add, sync, and verify environment variables across development, preview, production, and custom environments using the C
- [Connect to Amazon Web Services \\(AWS\\)](https://vercel.com/docs/oidc/aws?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Learn how to configure your AWS account to trust Vercel's OpenID Connect \\(OIDC\\) Identity Provider \\(IdP\\).
- [Environment Variables](https://docs.vercel.shop/docs/reference/env-vars?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Required and optional environment variables for Vercel Shop.
- [Environment Variables UI](https://vercel.com/blog/environment-variables-ui?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related)
- [How to add and manage environment variables on Vercel](https://vercel.com/kb/guide/how-to-add-vercel-environment-variables?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Add environment variables to Vercel through the dashboard, CLI, or REST API, scope them to each environment, and pull th
- [How can I use AWS S3 with Vercel?](https://vercel.com/kb/guide/how-can-i-use-aws-s3-with-vercel?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Example how to use AWS S3 library on Vercel
- [How do I use private dependencies with Vercel?](https://vercel.com/kb/guide/using-private-dependencies-with-vercel?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=related) — Information on how to use private dependencies with a Vercel deployment.

Full cross-link map for this page: [/kb/guide/how-can-i-use-aws-sdk-environment-variables-on-vercel.graph.md](/kb/guide/how-can-i-use-aws-sdk-environment-variables-on-vercel.graph.md?from=related&source_path=%2Fkb%2Fguide%2Fhow-can-i-use-aws-sdk-environment-variables-on-vercel&source_site=vercel-kb&relationship=graph)
<!-- /docsgraph:related -->


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.