Connect to Amazon Web Services (AWS)
Secure backend access with OIDC federation is available on all plans
To understand how AWS supports OIDC, and for a detailed user guide on creating an OIDC identity provider with AWS, consult the AWS OIDC documentation.
- Navigate to the AWS Console
- Navigate to IAM then Identity Providers
- Select Add Provider
- Select OpenID Connect from the provider type
- Enter the Provider URL, the URL will depend on the issuer mode setting:
- Team: , replacing with the path from your Vercel team URL
- Global:
- Enter in the Audience field, replacing with the path from your Vercel team URL
- Select Add Provider
![Add provider values for the Global issuer mode setting. For the Team issuer mode setting, set the Provider URL to https://vercel.com/[TEAM_SLUG]](/vc-ap-vercel-docs/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fconcepts%2Foidc-tokens%2Faws-create-id-provider.png&w=1080&q=75)
![Add provider values for the Global issuer mode setting. For the Team issuer mode setting, set the Provider URL to https://vercel.com/[TEAM_SLUG]](/vc-ap-vercel-docs/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fconcepts%2Foidc-tokens%2Faws-create-id-provider.png&w=1080&q=75)
Add provider values for the Global issuer mode setting. For the Team issuer mode setting, set the Provider URL to https://vercel.com/[TEAM_SLUG] To use AWS OIDC Federation you must have an IAM role. IAM roles require a "trust relationship" (also known as a "trust policy") that describes which "Principal(s)" are allowed to assume the role under certain "Condition(s)".
Here is an example of a trust policy using the Team issuer mode:
The above policy's conditions are quite strict. It requires the sub claims to match exactly, but it's possible to configure less strict trust policies conditions:
This policy allows any project matched by the that are targeted to and but not .
Once you have created the role, copy the role's ARN and declare it as an environment variable in your Vercel project with key name .
You are now ready to connect to your AWS resource in your project's code. Review the examples below.
In the following examples, you create a Vercel function in the Vercel project where you have defined the OIDC role ARN environment variable. The function will connect to a specific resource in your AWS backend using OIDC and perform a specific action using the AWS SDK.
Install the following packages:
In the API route for the function, use the AWS SDK for JavaScript to list objects in an S3 bucket with the following code:
Vercel sends the OIDC token to the SDK using the function from .
Install the following packages:
In the API route for the function, use the AWS SDK for JavaScript to perform a database query from an AWS RDS instance with the following code:
Was this helpful?