From 58743487a799c46beeb5276bf40f88e7eda4103f Mon Sep 17 00:00:00 2001 From: lex00 <121451605+lex00@users.noreply.github.com> Date: Tue, 4 Aug 2026 20:38:22 -0600 Subject: [PATCH] feat(iam): seed Amazon Bedrock managed policies (#2034) * feat(iam): seed Amazon Bedrock managed policies AmazonBedrockFullAccess and AmazonBedrockReadOnly were absent from the seeded AWS-managed policy catalog. CloudFormation attaches managed policies inline when creating a role, so it never noticed; Terraform (and the raw IAM API) call AttachRolePolicy, which validates the policy exists and 404'd with NoSuchEntity on these two. Seed them alongside the existing Bedrock AgentCore policy, matching the pattern used for the RDS (#1559) and EKS (#1216) additions. * fix(iam): match the AWS-published Bedrock policy descriptions --- .../services/iam/AwsManagedPolicies.java | 7 ++++++- .../floci/services/iam/IamServiceTest.java | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/AwsManagedPolicies.java b/src/main/java/io/github/hectorvent/floci/services/iam/AwsManagedPolicies.java index c6a0f91343..d65067fba6 100644 --- a/src/main/java/io/github/hectorvent/floci/services/iam/AwsManagedPolicies.java +++ b/src/main/java/io/github/hectorvent/floci/services/iam/AwsManagedPolicies.java @@ -161,7 +161,12 @@ final class AwsManagedPolicies { new ManagedPolicyDef("AmazonDataZoneDomainExecutionRolePolicy", "/service-role/", "Provides permissions for the Amazon DataZone domain execution role."), - // Amazon Bedrock execution role policy + // Amazon Bedrock policies + new ManagedPolicyDef("AmazonBedrockFullAccess", "/", + "Provides full access to Amazon Bedrock as well as limited access to related services " + + "that are required by it"), + new ManagedPolicyDef("AmazonBedrockReadOnly", "/", + "Provides read only access to Amazon Bedrock"), new ManagedPolicyDef("AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy", "/", "Provides Bedrock Model inference permissions to Bedrock agent core memory."), diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamServiceTest.java index 9f03ff0b31..ee64d3c8c8 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/IamServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamServiceTest.java @@ -622,6 +622,27 @@ class IamServiceTest { "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"); assertEquals("AmazonRDSEnhancedMonitoringRole", rdsMonitoring.getPolicyName()); assertEquals("/service-role/", rdsMonitoring.getPath()); + + IamPolicy bedrock = iamService.getPolicy("arn:aws:iam::aws:policy/AmazonBedrockFullAccess"); + assertEquals("AmazonBedrockFullAccess", bedrock.getPolicyName()); + assertEquals("/", bedrock.getPath()); + + IamPolicy bedrockReadOnly = iamService.getPolicy("arn:aws:iam::aws:policy/AmazonBedrockReadOnly"); + assertEquals("AmazonBedrockReadOnly", bedrockReadOnly.getPolicyName()); + assertEquals("/", bedrockReadOnly.getPath()); + } + + @Test + void attachAmazonBedrockFullAccessToRole() { + // Regression: AmazonBedrockFullAccess was absent from the seed catalog, so + // AttachRolePolicy (the Terraform path — CloudFormation attaches inline and + // never calls it) 404'd with NoSuchEntity. Attaching it must now succeed. + iamService.createRole("BedrockRole", "/", "{}", null, 0, null); + iamService.attachRolePolicy("BedrockRole", "arn:aws:iam::aws:policy/AmazonBedrockFullAccess"); + + List attached = iamService.listAttachedRolePolicies("BedrockRole", null).stream() + .map(IamPolicy::getArn).toList(); + assertTrue(attached.contains("arn:aws:iam::aws:policy/AmazonBedrockFullAccess")); } @Test