(aws-bedrockagentcore): Gateway OAuth/API-key IAM grants use mixed-case workload identity ARNs
Describe the bug
The aws-bedrockagentcore Gateway OAuth and API-key credential providers generate workload-identity IAM resource ARNs using the Gateway's case-preserving name. AgentCore creates the Gateway's workload identity with a lowercase name prefix.
For mixed-case Gateway names, the generated role therefore does not authorize the actual workload identity. A live OAuth tool call failed with GetWorkloadAccessToken denied on the lowercase identity ARN. Adding a test-only grant for the actual identity ARN restored the call without changing the OAuth client or target configuration.
This is reproducible using only aws-cdk-lib, without AgentCore CLI or any third-party/L3 constructs. The synthesis defect affects both OAuth and API-key providers.
Regression Issue
- This is a confirmed regression.
Last Known Working CDK Library Version
Unknown. Reproduced with both 2.269.0 and 2.270.0.
Expected Behavior
For a Gateway named OrdersGateway, the generated role should authorize its service-created workload identity, whose name starts with ordersgateway-.
For the existing name-prefix grant approach, the expected IAM resource is:
arn:aws:bedrock-agentcore:us-west-2:123456789012:workload-identity-directory/default/workload-identity/ordersgateway-*The Gateway's configured resource name should remain unchanged, and permissions should stay scoped to that Gateway rather than all workload identities.
Current Behavior
The generated role instead allows:
arn:aws:bedrock-agentcore:us-west-2:123456789012:workload-identity-directory/default/workload-identity/OrdersGateway-*IAM resource matching is case-sensitive, so this does not match the actual lowercase identity.
The same incorrect identity ARN is used for:
- OAuth:
GetWorkloadAccessToken,GetWorkloadAccessTokenForJWT,GetWorkloadAccessTokenForUserId,CompleteResourceTokenAuth, andGetResourceOauth2Token. - API key:
GetWorkloadAccessTokenandGetResourceApiKey.
The standalone reproduction below exits with status 1 and prints lowercase identity granted = false for both provider types on 2.270.0.
Reproduction Steps
No AWS credentials, deployment, or real credential providers are needed. All ARNs and the endpoint below are placeholders used only for synthesis.
npm install [email protected] [email protected]
node repro.cjsrepro.cjs:
const { App, Stack, ArnFormat, aws_bedrockagentcore: agentcore } = require('aws-cdk-lib');
const { Template } = require('aws-cdk-lib/assertions');
const { isDeepStrictEqual } = require('node:util');
for (const auth of ['OAUTH', 'API_KEY']) {
const stack = new Stack(new App(), 'TestStack', {
env: { account: '123456789012', region: 'us-west-2' },
});
const gateway = new agentcore.Gateway(stack, 'Gateway', {
gatewayName: 'OrdersGateway',
authorizerConfiguration: agentcore.GatewayAuthorizer.usingAwsIam(),
});
const secretArn = 'arn:aws:secretsmanager:us-west-2:123456789012:secret:example-abcdef';
const provider = auth === 'OAUTH'
? agentcore.GatewayCredentialProvider.fromOauthIdentityArn({
providerArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:token-vault/default/oauth2credentialprovider/example',
secretArn,
scopes: ['read'],
})
: agentcore.GatewayCredentialProvider.fromApiKeyIdentityArn({
providerArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:token-vault/default/apikeycredentialprovider/example',
secretArn,
});
gateway.addMcpServerTarget('Orders', {
gatewayTargetName: 'orders',
endpoint: 'https://example.com/mcp',
credentialProviderConfigurations: [provider],
});
const statements = Object.values(Template.fromStack(stack).findResources('AWS::IAM::Policy'))
.flatMap(resource => resource.Properties.PolicyDocument.Statement);
const grant = statements.find(statement =>
[statement.Action].flat().includes('bedrock-agentcore:GetWorkloadAccessToken')
);
const expectedIdentity = stack.resolve(stack.formatArn({
service: 'bedrock-agentcore',
resource: 'workload-identity-directory',
resourceName: 'default/workload-identity/ordersgateway-*',
arnFormat: ArnFormat.SLASH_RESOURCE_NAME,
}));
const matches = [grant.Resource].flat().some(resource => isDeepStrictEqual(resource, expectedIdentity));
console.log(`${auth}: lowercase identity granted = ${matches}`);
console.log(JSON.stringify(grant.Resource, null, 2));
if (!matches) process.exitCode = 1;
}Possible Solution
Construct the workload-identity resource ARN using the service-normalized Gateway identity name in both credential providers, while preserving the actual Gateway resource name.
For a concrete Gateway name, the problematic expression is:
`${directoryArn}/workload-identity/${gateway.gatewayName}-*`The name component needs lowercase normalization. An upstream implementation should also handle auto-generated/tokenized Gateway names safely rather than lowercasing the encoding of an unresolved CDK token.
Apply the correction to every statement that uses this identity ARN, not only GetWorkloadAccessToken. Add mixed-case regression coverage for both OAuth and API-key providers.
Additional Information/Context
Verified on September 21, 2026:
- The latest npm release,
2.270.0, still reproduces the defect. - Current main at
0870fcf1432156a300aa43db7522de146bba7c39still contains the same expression in OAuth and API key. - IAM simulation against the observed lowercase workload identity changed from denied to allowed when only the identity prefix casing in the generated OAuth grants was corrected. An unrelated project's identity remained denied.
- The API-key impact was verified through synthesis; the live tool-call failure and recovery were verified for OAuth.
A local, correctly scoped IAM grant can mitigate this without renaming an existing Gateway. Lowercasing a Gateway's configured name also avoids the mismatch for new resources, but changes customer-visible naming and should not be required.
AWS CDK Library version (aws-cdk-lib)
2.269.0 and 2.270.0.
AWS CDK CLI version
Not required for this reproduction; synthesis uses Template.fromStack directly.
Node.js Version
v24.20.0.
OS
Linux x86_64.
Language
JavaScript (CommonJS reproduction of the TypeScript library).
Language Version
Node.js v24.20.0; constructs 10.7.0.
Other information
This report concerns the Gateway execution role's outbound credential permissions, not the Gateway role trust policy or inbound authorization.
Source: aws/aws-cdk