Skip to content

fix: grant CreateTokenVault and wire OAuth providers table to app-api#179

Merged
philmerrell merged 1 commit intodevelopfrom
feature/agentcore-credential-provider-iam
Apr 27, 2026
Merged

fix: grant CreateTokenVault and wire OAuth providers table to app-api#179
philmerrell merged 1 commit intodevelopfrom
feature/agentcore-credential-provider-iam

Conversation

@philmerrell
Copy link
Copy Markdown
Contributor

Summary

  • Add bedrock-agentcore:CreateTokenVault to the AppApi task role. The first CreateOauth2CredentialProvider call in a region implicitly provisions the default token vault, so without this action the very first connector creation returns 500 with AccessDeniedException. Once the vault exists, subsequent calls would have succeeded — but the dev environment hit this on the first attempt.
  • Wire DYNAMODB_OAUTH_PROVIDERS_TABLE_NAME into the AppApi container env. The IAM grant (line 883) and SSM lookup (line 220) were already there from feat: external MCP connectors via AgentCore Identity #174; only the env passthrough was missing. Without it, OAuthProviderRepository logs WARNING: ... repository is disabled at startup and the post-AgentCore DB write in create_provider() would fail, triggering the orphan-rollback path.

Context

Found while debugging a 500 on POST /admin/oauth-providers/ in the dev-ai account. CloudWatch (/ecs/dev-boisestateai-v2/app-api) showed:

botocore.errorfactory.AccessDeniedException: ... is not authorized to perform:
bedrock-agentcore:CreateTokenVault on resource:
arn:aws:bedrock-agentcore:us-west-2:490617140655:token-vault/default

Test plan

  • cd infrastructure && npm install (local node_modules is on aws-cdk-lib@2.220.0 but pinned to 2.248.0; pre-existing, blocks cdk synth until synced)
  • npx cdk diff dev-boisestateai-v2-AppApiStack --profile dev-ai — confirm only the IAM policy and env var change
  • npx cdk deploy dev-boisestateai-v2-AppApiStack --profile dev-ai
  • Retry POST /admin/oauth-providers/ from the admin UI — expect 201 and a row in the OAuth providers DynamoDB table
  • Verify in CloudWatch that the DYNAMODB_OAUTH_PROVIDERS_TABLE_NAME not set warning is gone on next task start

🤖 Generated with Claude Code

The first CreateOauth2CredentialProvider call in a region implicitly
provisions the `default` token vault, so the AppApi task role needs
`bedrock-agentcore:CreateTokenVault` in addition to the provider CRUD
actions. Without it, creating the very first connector returned a 500
with `AccessDeniedException` from bedrock-agentcore-control.

Also pass `DYNAMODB_OAUTH_PROVIDERS_TABLE_NAME` to the container env.
The IAM grant and SSM lookup were already in place; only the env wiring
was missing, which caused the OAuth provider repository to silently
disable itself and would have failed the DB write after AgentCore
succeeded — triggering the orphan-rollback path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@philmerrell philmerrell merged commit 2508ce1 into develop Apr 27, 2026
14 checks passed
@philmerrell philmerrell deleted the feature/agentcore-credential-provider-iam branch April 27, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant