Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

feat(iam): seed Amazon Bedrock managed policies (#2034)

lex0058743487a799
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<String> attached = iamService.listAttachedRolePolicies("BedrockRole", null).stream()
+ .map(IamPolicy::getArn).toList();
+ assertTrue(attached.contains("arn:aws:iam::aws:policy/AmazonBedrockFullAccess"));
}
@Test