Why use OIDC
| Stored credentials | OIDC |
|---|---|
| Long-lived keys that never expire | Tokens expire automatically (~1 hour) |
| Must be rotated manually | Rotation is automatic |
| Key ID visible in CloudTrail | CloudTrail shows exactly which Vercel deployment assumed the role |
| Can be used from anywhere if leaked | Role can only be assumed by your specific Vercel project |
Prerequisites
- Vercel Team ID (
team_xxxxx) — found in Vercel → Account → Settings - Vercel Project ID (
prj_xxxxx) — found in Project → Settings → General - AWS CLI configured locally (only needed for the one-time stack deployment)
Setup
Get your Vercel IDs
Team ID
- Go to vercel.com/account
- Click on your team name → Settings
- Copy the Team ID (format:
team_xxxxx)
- Open your Vercel project
- Navigate to Settings → General
- Copy the Project ID (format:
prj_xxxxx)
Deploy the CloudFormation stack
This one-time command creates an OIDC provider and IAM role in your AWS account.
Configure Vercel environment variables
Go to your Vercel project → Settings → Environment Variables and add:
| Variable | Value |
|---|---|
AWS_REGION | us-east-1 (or your deployment region) |
AWS_ROLE_ARN | The ARN from the previous step |
Vercel automatically sets
AWS_WEB_IDENTITY_TOKEN_FILE. Do not set this manually — it will break the OIDC flow.Remove old credentials
Delete these variables from Vercel if they exist:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_PROFILE(only needed for local dev)
How it works
Local development
OIDC only works inside Vercel deployments. For local development, continue using a named AWS profile:AWS_ROLE_ARN is not set.
Verification
After redeploying, verify that OIDC is working:- Check Vercel build logs — look for a successful deployment with no AWS credential errors
- Check CloudTrail (optional):
Troubleshooting
"Not authorized to perform sts:AssumeRoleWithWebIdentity"
"Not authorized to perform sts:AssumeRoleWithWebIdentity"
"Invalid identity token"
"Invalid identity token"
Cause: Vercel isn’t providing the OIDC token, usually because
AWS_ROLE_ARN is missing.Fix:- Confirm
AWS_ROLE_ARNis set in Vercel environment variables - Confirm
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYhave been removed - Redeploy the project
"Failed to assume role: No credentials returned"
"Failed to assume role: No credentials returned"
Cause: The AWS SDK can’t find any usable credentials.Fix:
- Check that both
AWS_REGIONandAWS_ROLE_ARNare set in Vercel - Verify the CloudFormation stack completed successfully:
- Confirm the OIDC provider exists:
Security properties
- Environment-specific — the trust policy only allows production Vercel deployments
- Project-specific — only your exact Vercel project can assume the role
- Least privilege — the role only has
sts:AssumeRolepermission - Short-lived — tokens expire after approximately 1 hour
- Auditable — every assumption is logged in AWS CloudTrail
