Skip to content

Commit 04b6977

Browse files
fix(infra): scope Vercel backend role trust to one project and production (#193)
Co-authored-by: Jarod Stewart <949393+stewartjarod@users.noreply.github.com> Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com>
1 parent e386d34 commit 04b6977

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

‎cloudformation/vercel-oidc-role.yaml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ Parameters:
1313
Description: "Your Vercel Team ID (found in Team Settings, e.g., 'team_xxxxx')"
1414
MinLength: 1
1515

16-
VercelProjectId:
16+
VercelProjectName:
1717
Type: String
18-
Description: "Your Vercel Project ID (found in Project Settings, e.g., 'prj_xxxxx')"
18+
Description: "Your Vercel Project Name (from the project URL or Project Settings, e.g., 'wraps-web')"
1919
MinLength: 1
20+
Default: "wraps-web"
2021

2122
Resources:
2223
# OIDC Identity Provider for Vercel (Team Mode)
@@ -54,10 +55,10 @@ Resources:
5455
# Audience uses team slug (not team ID)
5556
"oidc.vercel.com/wraps:aud": !Sub "https://vercel.com/${VercelTeamSlug}"
5657
StringLike:
57-
# Subject uses owner:teamSlug with wildcards for any project/environment
58-
"oidc.vercel.com/wraps:sub":
59-
- !Sub "owner:${VercelTeamSlug}:project:*:environment:preview"
60-
- !Sub "owner:${VercelTeamSlug}:project:*:environment:production"
58+
# Subject is owner:<team-slug>:project:<project-name>:environment:<environment>.
59+
# Scope to this single project and to the production environment only:
60+
# a preview deployment of any project in the team must not assume this role.
61+
"oidc.vercel.com/wraps:sub": !Sub "owner:${VercelTeamSlug}:project:${VercelProjectName}:environment:production"
6162
ManagedPolicyArns:
6263
- !Ref VercelBackendPolicy
6364
Tags:

‎docs/VERCEL_OIDC_SETUP.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ Instead of storing long-lived AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_
1414
## Prerequisites
1515

1616
- Wraps AWS account (905130073023)
17-
- Vercel Team ID and Project ID
17+
- Vercel Team slug and Project name
1818
- AWS CLI configured with Wraps account credentials
1919

20-
## Step 1: Get Vercel IDs
20+
## Step 1: Get Vercel identifiers
2121

2222
### Get Team ID
2323
1. Go to https://vercel.com/account
2424
2. Click on your team settings
2525
3. Copy the Team ID (format: `team_xxxxx`)
2626

27-
### Get Project ID
27+
### Get Project Name
2828
1. Go to your Vercel project settings
29-
2. Navigate to "General" tab
30-
3. Copy the Project ID (format: `prj_xxxxx`)
29+
2. Navigate to the "General" tab
30+
3. Copy the Project Name (for example, `wraps-web`)
3131

3232
## Step 2: Deploy CloudFormation Stack
3333

3434
Deploy the OIDC provider and IAM role to your Wraps AWS account:
3535

3636
```bash
37-
# Set your Vercel IDs
37+
# Set your Vercel identifiers
3838
VERCEL_TEAM_ID="team_xxxxx"
39-
VERCEL_PROJECT_ID="prj_xxxxx"
39+
VERCEL_PROJECT_NAME="wraps-web"
4040

4141
# Deploy the stack
4242
AWS_PROFILE=wraps aws cloudformation create-stack \
4343
--stack-name wraps-vercel-oidc \
4444
--template-body file://cloudformation/vercel-oidc-role.yaml \
4545
--parameters \
4646
ParameterKey=VercelTeamId,ParameterValue=${VERCEL_TEAM_ID} \
47-
ParameterKey=VercelProjectId,ParameterValue=${VERCEL_PROJECT_ID} \
47+
ParameterKey=VercelProjectName,ParameterValue=${VERCEL_PROJECT_NAME} \
4848
--capabilities CAPABILITY_NAMED_IAM \
4949
--region us-east-1
5050

@@ -117,8 +117,8 @@ Call STS AssumeRoleWithWebIdentity
117117
Vercel OIDC Provider validates token
118118
↓
119119
Check trust policy conditions:
120-
- aud = "vercel"
121-
- sub = "team:xxx:project:xxx:environment:production"
120+
- aud = "https://vercel.com/<team-slug>"
121+
- sub = "owner:<team-slug>:project:<project-name>:environment:production"
122122
↓
123123
Return temporary credentials (valid ~1 hour)
124124
↓
@@ -151,7 +151,7 @@ After deployment, check that OIDC is working:
151151

152152
**Cause**: Trust policy doesn't match your Vercel team/project.
153153

154-
**Fix**: Verify the Team ID and Project ID in the CloudFormation parameters:
154+
**Fix**: Verify the team slug and project name in the CloudFormation parameters:
155155
```bash
156156
AWS_PROFILE=wraps aws cloudformation describe-stacks \
157157
--stack-name wraps-vercel-oidc \

0 commit comments

Comments
 (0)