---
title: Connecting to AWS with Vercel Connect
description: Create an AWS connector to get temporary IAM role credentials in your Vercel project without storing access keys, and receive Amazon SNS messages as...
url: "https://vercel.com/docs/connect/services/aws"
last_updated: 2018-10-20
related:
  - /docs/connect/concepts/triggers
  - /docs/connect/concepts/tokens
  - /docs/cli
  - /docs/cli/link
  - /docs/cli/connect
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# Connecting to AWS with Vercel Connect

An AWS connector gives your code temporary credentials for an AWS Identity and Access Management (IAM) role. You don't store AWS access keys in environment variables. The same connector can also receive Amazon Simple Notification Service (SNS) messages and forward them to your project as [triggers](/docs/connect/concepts/triggers).

## How it works

Each AWS connector has its own OpenID Connect (OIDC) issuer at `https://connect.vercel.com/issuers/<connector-id>`. Your AWS account trusts that issuer through an IAM OIDC identity provider.

When your code requests a token, Vercel Connect:

1. Signs a short-lived web identity token for the connector's issuer and audience.
2. Calls AWS Security Token Service (STS) `AssumeRoleWithWebIdentity` for the requested IAM role.
3. Returns the temporary credentials.

AWS connectors support the `app` [subject type](/docs/connect/concepts/tokens#subject-types) only. The role's IAM policies decide what the credentials can do, so you grant permissions in AWS, not in Vercel.

## Choose a setup path

You can create the connector in two ways:

| | With the Vercel AWS integration | Manual setup |
| --- | --- | --- |
| **Use it when** | Your team has an AWS account installed through the [Vercel AWS integration](/marketplace/aws) | You manage the AWS account yourself |
| **OIDC provider** | Vercel creates it in your AWS account | You create it with the AWS CLI |
| **IAM role** | You create it | You create it |
| **Permissions policies** | You add them | You add them |
| **Create with** | `vercel connect create` or the dashboard | `vercel connect create` or the dashboard |

In both cases, Vercel never grants application permissions. You attach the policies your app needs.

## Before you begin

You need:

- [Vercel CLI](/docs/cli) installed and logged in, with your project [linked](/docs/cli/link)
- The [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) with credentials that can manage IAM identity providers, roles, and role policies
- Your 12-digit AWS account ID

## Create a connector manually

This path creates the connector with the CLI, then registers it in AWS. The examples use a connector named `my-app-aws`, a role named `my-app`, and the account ID `123456789012`. Replace them with your values.

### Create the connector

Choose the role name up front so you can set it as the connector's default role. Run this command:

```bash filename="terminal"
vercel connect create aws --name my-app-aws --connector-type aws-oidc --json \
  --data '{"defaultRoleArn":"arn:aws:iam::123456789012:role/my-app","allowedRoleArns":["arn:aws:iam::123456789012:role/my-app"],"region":"us-east-1"}'
```

The JSON output includes the connector's `id` (for example, `scl_abc123`) and `uid` (for example, `aws/my-app-aws`). You need the ID for the AWS commands below.

The `--data` object accepts these fields:

| Field | Required | Description |
| --- | --- | --- |
| `allowedRoleArns` | Yes | Role ARNs that token requests can ask for, up to 100. Pass `"*"` to allow any role that trusts the connector. |
| `defaultRoleArn` | No | Role to assume when a token request doesn't name one. Without it, every request must pass a role ARN. |
| `region` | No | AWS region for STS calls. Defaults to `us-east-1`. |
| `maxSessionDuration` | No | Lifetime of the credentials in seconds, from 900 to 43,200. Defaults to 3,600 (1 hour). |
| `audience` | No | Audience claim in the web identity token, 1 to 255 characters. Defaults to `https://connect.vercel.com/issuers/<connector-id>`. |

### Create the OIDC provider in AWS

Register the connector's issuer as an identity provider. Replace `scl_abc123` with your connector ID:

```bash filename="terminal"
aws iam create-open-id-connect-provider \
  --url 'https://connect.vercel.com/issuers/scl_abc123' \
  --client-id-list 'https://connect.vercel.com/issuers/scl_abc123' \
  --query OpenIDConnectProviderArn \
  --output text
```

If you set a custom `audience`, pass that value to `--client-id-list` instead.

### Create the IAM role

Create the role with a trust policy that accepts tokens from this connector's provider and audience:

```bash filename="terminal"
aws iam create-role \
  --role-name 'my-app' \
  --max-session-duration 3600 \
  --assume-role-policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Federated": "arn:aws:iam::123456789012:oidc-provider/connect.vercel.com/issuers/scl_abc123"
        },
        "Action": "sts:AssumeRoleWithWebIdentity",
        "Condition": {
          "StringEquals": {
            "connect.vercel.com/issuers/scl_abc123:aud": "https://connect.vercel.com/issuers/scl_abc123"
          }
        }
      }
    ]
  }' \
  --query 'Role.Arn' \
  --output text
```

The command prints the role ARN. It must match the `defaultRoleArn` you set on the connector. The role's `--max-session-duration` must be at least the connector's `maxSessionDuration`. If your account requires a permissions boundary, add `--permissions-boundary` with an approved policy ARN.

Repeat this step for each additional role in `allowedRoleArns`.

Next, [grant permissions to the role](#grant-permissions-to-the-role).

## Create a connector with the Vercel AWS integration

If your team installed an AWS account through the [Vercel AWS integration](/marketplace/aws), Vercel can create the OIDC provider in that account for you. You skip the `create-open-id-connect-provider` step, and Vercel removes the provider when you delete the connector.

You need permission to create connectors and to update integrations on the team. The installation must be active.

### Use the CLI

Create the connector and follow the prompts to select the installed AWS account:

```bash filename="terminal"
vercel connect create aws --name my-app-aws
```

### Use the dashboard

1. Open [**Connect**](https://vercel.com/d?to=%2F%5Bteam%5D%2F%5Bproject%5D%2Fconnect\&title=Open+Vercel+Connect+Project) in the Vercel Dashboard and start a new AWS connector.
2. Enter a name.
3. Under **AWS Account**, select the installed account. If the list is empty, select **Install AWS Account** to add one, then select **Refresh Accounts**.
4. Select **Create Connector**.

The connector opens with a **Create Role and Policies** guide. It contains the `aws iam create-role` command with this connector's provider and audience already filled in.

### Create and set the default role

Vercel doesn't create an IAM role, so the new connector has no default role. Create the role yourself:

1. Run the `aws iam create-role` command from [Create the IAM role](#create-the-iam-role) with your connector ID. The connector's **Create Role and Policies** guide in the dashboard shows the same command with your values filled in.
2. Open the connector's settings and set the returned role ARN as the default role.

If you skip the second step, pass the role ARN as `roleArn` on every token request.

## Grant permissions to the role

A new role can't access anything. Add an inline policy with the minimum permissions your app needs. This example grants read access to objects under one S3 prefix:

```bash filename="terminal"
aws iam put-role-policy \
  --role-name 'my-app' \
  --policy-name 'my-app-permissions' \
  --policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::<bucket-name>/<prefix>/*"
      }
    ]
  }'
```

To call Amazon Bedrock models instead, grant the invocation actions:

```bash filename="terminal"
aws iam put-role-policy \
  --role-name 'my-app' \
  --policy-name 'BedrockInvokeModel' \
  --policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "bedrock:InvokeModel",
          "bedrock:InvokeModelWithResponseStream",
          "bedrock:GetInferenceProfile"
        ],
        "Resource": "*"
      }
    ]
  }'
```

To restrict Bedrock access, replace `*` with the model and inference profile ARNs your app uses. You must also enable model access in your AWS account.

Each connector's page in the dashboard includes these guides with your connector's values filled in.

## Attach the connector to a project

A project can request credentials only after you attach the connector to it:

```bash filename="terminal"
vercel connect attach aws/my-app-aws
```

This enables the Production, Preview, and Development environments for the linked project. Pass `--environment` to limit them, or `--project` to attach a different project. See [`vercel connect attach`](/docs/cli/connect#vercel-connect-attach).

## Use the credentials in your code

Install the Vercel Connect SDK and the AWS SDK client you need:

```bash package-manager
pnpm add @vercel/connect @aws-sdk/client-s3
```

Pass `connectAwsCredentialsProvider` from `@vercel/connect/aws` to any AWS SDK client. The AWS SDK calls it again when the credentials are about to expire:

```ts filename="app/api/report/route.ts"
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { connectAwsCredentialsProvider } from '@vercel/connect/aws';

const s3 = new S3Client({
  region: 'us-east-1',
  credentials: connectAwsCredentialsProvider('aws/my-app-aws'),
});

export async function GET() {
  const response = await s3.send(
    new GetObjectCommand({
      Bucket: '<bucket-name>',
      Key: '<prefix>/example.txt',
    }),
  );

  return new Response(await response.Body?.transformToString());
}
```

To assume a role other than the default, or when the connector has no default role, pass `roleArn`:

```ts filename="app/lib/aws.ts"
import { connectAwsCredentialsProvider } from '@vercel/connect/aws';

export const credentials = connectAwsCredentialsProvider('aws/my-app-aws', {
  roleArn: 'arn:aws:iam::123456789012:role/my-app-readonly',
});
```

The role must be the connector's default role or appear in its allowed roles. Otherwise the request fails with a `403` status. Each request can name one role.

For a one-off call, `getAwsCredentials` from the same module takes the same arguments and returns `accessKeyId`, `secretAccessKey`, and `sessionToken` directly.

### Call Amazon Bedrock

The same provider works with the Bedrock Runtime client:

```ts filename="app/api/chat/route.ts"
import {
  BedrockRuntimeClient,
  ConverseCommand,
} from '@aws-sdk/client-bedrock-runtime';
import { connectAwsCredentialsProvider } from '@vercel/connect/aws';

const bedrock = new BedrockRuntimeClient({
  region: 'us-east-1',
  credentials: connectAwsCredentialsProvider('aws/my-app-aws'),
});

export async function POST() {
  const response = await bedrock.send(
    new ConverseCommand({
      modelId: 'amazon.nova-lite-v1:0',
      messages: [
        {
          role: 'user',
          content: [{ text: 'Explain OpenID Connect in one sentence.' }],
        },
      ],
      inferenceConfig: { maxTokens: 256 },
    }),
  );

  return Response.json(response.output?.message?.content ?? []);
}
```

### Test from the terminal

To check the setup without deploying, request a token with the CLI:

```bash filename="terminal"
vercel connect token aws/my-app-aws --subject app
```

The output is a JSON string with `accessKeyId`, `secretAccessKey`, and `sessionToken`. To assume a specific role, pass its ARN with `--scopes`.

## Receive SNS messages as triggers

With triggers enabled, Vercel Connect verifies each SNS message signature, confirms the subscription for you, and forwards messages to your project. Only standard topics work, because FIFO topics don't support HTTPS subscriptions.

SNS triggers need an allowlist of topic ARNs, so you enable them after you create the connector.

### Create a topic

Create a standard topic with SHA-256 signatures:

```bash filename="terminal"
aws sns create-topic \
  --region 'us-east-1' \
  --name 'my-app-events' \
  --attributes SignatureVersion=2
```

The command prints the topic ARN, such as `arn:aws:sns:us-east-1:123456789012:my-app-events`. Use it in the commands below. You can also use the ARN of an existing standard topic. The connector's IAM role doesn't need any SNS permissions to receive triggers.

### Enable triggers and allow the topic

Enable triggers on the connector and pass your topic ARN in the allowlist:

```bash filename="terminal"
vercel connect update aws/my-app-aws \
  --triggers \
  --trigger-input '{
    "verification": {
      "allowedSnsTopicArns": [
        "arn:aws:sns:us-east-1:123456789012:my-app-events"
      ]
    }
  }'
```

You can also do this in the dashboard. Open the connector's settings, select **Triggers**, turn on **Enable Triggers**, add the ARN under **Allowed SNS Topic ARNs**, and save.

The allowlist takes 1 to 100 exact topic ARNs. Wildcards aren't accepted. Vercel Connect rejects messages from any other topic.

### Register a trigger destination

Tell the connector which project and path receive the messages:

```bash filename="terminal"
vercel connect attach aws/my-app-aws --triggers --trigger-path /api/sns
```

Without `--git-branch` or `--trigger-environment`, the destination targets Production. See [Registering a destination](/docs/connect/concepts/triggers#registering-a-destination) for Preview branches and Custom Environments.

### Subscribe the topic

Subscribe the topic to the connector's trigger URL. Replace `scl_abc123` with your connector ID. Enable triggers before you run this command, or the confirmation fails:

```bash filename="terminal"
aws sns subscribe \
  --region 'us-east-1' \
  --topic-arn 'arn:aws:sns:us-east-1:123456789012:my-app-events' \
  --protocol https \
  --notification-endpoint 'https://connect.vercel.com/trigger/scl_abc123' \
  --attributes RawMessageDelivery=false \
  --return-subscription-arn
```

Vercel Connect confirms the subscription with SNS. It doesn't forward the confirmation message to your project. Keep raw message delivery disabled so SNS includes its signed envelope.

### Handle the message

Your route receives the complete SNS envelope with `Type`, `TopicArn`, `MessageId`, `Message`, and the signature fields unchanged. Verify the forwarded request, then parse the body. SNS usually sends JSON with a `text/plain` content type, so read the body as text:

```ts filename="app/api/sns/route.ts"
import { createConnectWebhookVerifier } from '@vercel/connect/chat';

const verify = createConnectWebhookVerifier();

export async function POST(request: Request) {
  const body = await request.text();

  try {
    await verify(request, body);
  } catch {
    return new Response('Unauthorized', { status: 401 });
  }

  const envelope = JSON.parse(body);

  if (envelope.Type === 'Notification') {
    // `Message` is a string. Parse it again if your publisher sends JSON.
    const message = JSON.parse(envelope.Message);
    console.log(envelope.TopicArn, envelope.MessageId, message);
  }

  return Response.json({ ok: true });
}
```

SNS can deliver the same message more than once, so deduplicate on `TopicArn` and `MessageId`. Vercel Connect also forwards `UnsubscribeConfirmation` messages and doesn't re-subscribe for you. The `x-amz-sns-message-type`, `x-amz-sns-message-id`, `x-amz-sns-topic-arn`, and `x-amz-sns-subscription-arn` headers arrive with the request.

### Publish a test message

Send a message to confirm the whole path works:

```bash filename="terminal"
aws sns publish \
  --region 'us-east-1' \
  --topic-arn 'arn:aws:sns:us-east-1:123456789012:my-app-events' \
  --message '{"event":"demo","message":"Hello from SNS"}'
```

Check your deployment's [runtime logs](/docs/logs/runtime) for the request.

### Stop receiving messages

Disabling triggers on the connector stops confirmation and forwarding. Your AWS subscription stays in place, so SNS keeps sending requests that Vercel Connect rejects. Remove the subscription in SNS to stop them:

```bash filename="terminal"
aws sns unsubscribe --region 'us-east-1' --subscription-arn '<subscription-arn>'
```

## Update the connector

In the connector's settings you can change the default role, the allowed roles, the session duration, the region, and the audience. These settings change how Vercel Connect requests credentials. They don't change anything in AWS:

- A role you add still needs a trust policy for the connector's provider and audience.
- The role's maximum session duration in AWS must be at least the connector's session duration.
- If you change the audience, update the OIDC provider's client ID list and each role's trust policy to match.

Changes don't revoke credentials that AWS already issued. They stay valid until they expire. To change the AWS account or the issuer, create a new connector.

## Related

- [Tokens](/docs/connect/concepts/tokens): Subject types, caching, and expiry.
- [Triggers](/docs/connect/concepts/triggers): Destinations, verification, and retries.
- [`vercel connect` CLI reference](/docs/cli/connect): Every subcommand and option.
- [OIDC federation with AWS](/docs/oidc/aws): Use your project's own OIDC token with AWS, without Vercel Connect.
- [AWS: Create an OIDC identity provider](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html)
- [AWS: Verify SNS message signatures](https://docs.aws.amazon.com/sns/latest/dg/sns-verify-signature-of-message.html)

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
