Describe the bug
When using a.generation() with newer Claude models (e.g. Claude Haiku 4.5, Claude Sonnet 4), the auto-generated AppSync IAM role only grants bedrock:InvokeModel on the foundation model ARN, but AWS routes requests through a cross-region inference profile (global.* or us.* prefix). This results in an AccessDeniedException at runtime.
Error message
User: arn:aws:sts::263556453558:assumed-role/GenerationBedrockDat.../APPSYNC_ASSUME_ROLE
is not authorized to perform: bedrock:InvokeModel on resource:
arn:aws:bedrock:us-west-2:263556453558:inference-profile/global.anthropic.claude-haiku-4-5-20251001-v1:0
because no identity-based policy allows the bedrock:InvokeModel action
Root cause
In grapqhl-generation-transformer.js, createBedrockDataSourceRole() only adds a policy for the foundation model ARN:
resources: [`arn:${partition}:bedrock:${region}::foundation-model/${bedrockModelId}`]
It does not include the account-scoped inference profile ARN (arn:aws:bedrock:*:ACCOUNT:inference-profile/*), which AWS requires when routing through cross-region inference.
This is the same root cause as #3162 (which affects a.conversation() + InvokeModelWithResponseStream) but affects a.generation() + InvokeModel.
Workaround (CDK escape hatch in backend.ts)
import { Role } from "aws-cdk-lib/aws-iam"
backend.data.node.findAll().forEach((construct) => {
if (
construct instanceof Role &&
construct.node.id.startsWith("GenerationBedrockDataSource") &&
construct.node.id.endsWith("IAMRole")
) {
construct.addToPolicy(new PolicyStatement({
effect: Effect.ALLOW,
actions: ["bedrock:InvokeModel"],
resources: [
`arn:aws:bedrock:*:${backend.stack.account}:inference-profile/*`,
`arn:aws:bedrock:*::foundation-model/anthropic.*`,
],
}))
}
})
Expected behavior
The auto-generated role should include both foundation model and inference profile ARNs, consistent with what is needed for current Bedrock model routing behavior.
Related issues
Describe the bug
When using
a.generation()with newer Claude models (e.g.Claude Haiku 4.5,Claude Sonnet 4), the auto-generated AppSync IAM role only grantsbedrock:InvokeModelon the foundation model ARN, but AWS routes requests through a cross-region inference profile (global.*orus.*prefix). This results in anAccessDeniedExceptionat runtime.Error message
Root cause
In
grapqhl-generation-transformer.js,createBedrockDataSourceRole()only adds a policy for the foundation model ARN:It does not include the account-scoped inference profile ARN (
arn:aws:bedrock:*:ACCOUNT:inference-profile/*), which AWS requires when routing through cross-region inference.This is the same root cause as #3162 (which affects
a.conversation()+InvokeModelWithResponseStream) but affectsa.generation()+InvokeModel.Workaround (CDK escape hatch in
backend.ts)Expected behavior
The auto-generated role should include both foundation model and inference profile ARNs, consistent with what is needed for current Bedrock model routing behavior.
Related issues