Skip to content

Commit 073575e

Browse files
Fix Bedrock IAM for cross-region inference profiles (#47)
## Summary Cross-region inference profiles (`eu.anthropic.*`) route to foundation models in EU destination regions (eu-central-1, eu-north-1, eu-west-1, eu-west-3). IAM requires explicit access to the destination foundation model ARNs, not just the inference profile. This was hidden by the old `*:*` infra role and has been a latent bug on the Lambda roles (slack-alert, cost-report) — they'd fail if Bedrock routed to eu-north-1. Adds a second IAM statement with foundation model ARNs for all EU destination regions, scoped via `bedrock:InferenceProfileArn` condition so they only work through our inference profiles. Fixes: ci-infra-plan role, slack-alert Lambda role, cost-report Lambda role. ## Test plan - [ ] Plan job succeeds with LLM review (Bedrock call works) - [ ] Apply creates the IAM policy changes on Lambda roles
1 parent 3093bc1 commit 073575e

3 files changed

Lines changed: 58 additions & 15 deletions

File tree

‎scripts/extract-review-risk.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ fi
2121

2222
echo "risk_level=${RISK}" >> "$GITHUB_OUTPUT"
2323
echo "LLM review risk: ${RISK}"
24+
25+
if [ "$RISK" = "FAILED" ]; then
26+
echo "LLM review failed — blocking pipeline."
27+
exit 1
28+
fi

‎terraform/platform/iam/main.tf‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,31 @@ resource "aws_iam_role_policy" "ci_infra_plan_extras" {
9494
Resource = "arn:aws:s3:::${var.project}-ci-plan-artifacts-${var.aws_account_id}/*"
9595
},
9696
{
97-
Sid = "BedrockForReview"
97+
Sid = "BedrockInferenceProfile"
9898
Effect = "Allow"
9999
Action = [
100100
"bedrock:InvokeModel",
101101
"bedrock:Converse",
102102
]
103103
Resource = "arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.anthropic.*"
104104
},
105+
{
106+
# Cross-region inference profiles route to foundation models in EU
107+
# destination regions. IAM requires access to destination model ARNs.
108+
# Condition scopes this to only work via our inference profiles.
109+
Sid = "BedrockFoundationModels"
110+
Effect = "Allow"
111+
Action = [
112+
"bedrock:InvokeModel",
113+
"bedrock:Converse",
114+
]
115+
Resource = "arn:aws:bedrock:eu-*::foundation-model/anthropic.*"
116+
Condition = {
117+
StringLike = {
118+
"bedrock:InferenceProfileArn" = "arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.anthropic.*"
119+
}
120+
}
121+
},
105122
{
106123
Sid = "SSMReadSlackWebhook"
107124
Effect = "Allow"

‎terraform/platform/lambdas/main.tf‎

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
locals {
77
lambda_src_path = "${path.module}/../../lambda-src"
88
github_org_url = "https://github.com/javaBin"
9+
10+
# EU cross-region inference profiles route to any eu-* region.
11+
# IAM requires foundation model access in destination regions.
12+
bedrock_eu_foundation_model_arns = "arn:aws:bedrock:eu-*::foundation-model/anthropic.*"
13+
bedrock_inference_profile_arn = "arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.anthropic.*"
914
}
1015

1116
################################################################################
@@ -159,13 +164,21 @@ resource "aws_iam_role_policy" "slack_alert" {
159164
]
160165
},
161166
{
162-
Sid = "Bedrock"
163-
Effect = "Allow"
164-
Action = [
165-
"bedrock:InvokeModel",
166-
"bedrock:Converse",
167-
]
168-
Resource = "arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.anthropic.*"
167+
Sid = "BedrockInferenceProfile"
168+
Effect = "Allow"
169+
Action = ["bedrock:InvokeModel", "bedrock:Converse"]
170+
Resource = local.bedrock_inference_profile_arn
171+
},
172+
{
173+
Sid = "BedrockFoundationModels"
174+
Effect = "Allow"
175+
Action = ["bedrock:InvokeModel", "bedrock:Converse"]
176+
Resource = local.bedrock_eu_foundation_model_arns
177+
Condition = {
178+
StringLike = {
179+
"bedrock:InferenceProfileArn" = local.bedrock_inference_profile_arn
180+
}
181+
}
169182
},
170183
{
171184
Sid = "PricingRead"
@@ -236,13 +249,21 @@ resource "aws_iam_role_policy" "cost_report" {
236249
Resource = "*"
237250
},
238251
{
239-
Sid = "Bedrock"
240-
Effect = "Allow"
241-
Action = [
242-
"bedrock:InvokeModel",
243-
"bedrock:Converse",
244-
]
245-
Resource = "arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.anthropic.*"
252+
Sid = "BedrockInferenceProfile"
253+
Effect = "Allow"
254+
Action = ["bedrock:InvokeModel", "bedrock:Converse"]
255+
Resource = local.bedrock_inference_profile_arn
256+
},
257+
{
258+
Sid = "BedrockFoundationModels"
259+
Effect = "Allow"
260+
Action = ["bedrock:InvokeModel", "bedrock:Converse"]
261+
Resource = local.bedrock_eu_foundation_model_arns
262+
Condition = {
263+
StringLike = {
264+
"bedrock:InferenceProfileArn" = local.bedrock_inference_profile_arn
265+
}
266+
}
246267
},
247268
]
248269
})

0 commit comments

Comments
 (0)