Light, fluffy, and always free - The AWS Local Emulator alternative
feat(iam): seed standard EKS cluster and node group managed policies (#1216)
Ben Younese3c19461dbb1
diff --git a/docs/services/iam.md b/docs/services/iam.mdindex 64cd338597..f9685f0a84 100644--- a/docs/services/iam.md+++ b/docs/services/iam.md@@ -51,6 +51,9 @@ Floci seeds a catalog of commonly-used AWS managed policies at startup. These ar**ECS / EKS execution roles**`AmazonECSTaskExecutionRolePolicy` · `AmazonEKSFargatePodExecutionRolePolicy`+**EKS cluster & node groups**+`AmazonEKSClusterPolicy` · `AmazonEKSServicePolicy` · `AmazonEKSVPCResourceController` · `AmazonEKSWorkerNodePolicy` · `AmazonEKS_CNI_Policy`+**Other execution roles**`AmazonS3ObjectLambdaExecutionRolePolicy` · `CloudWatchLambdaInsightsExecutionRolePolicy` · `CloudWatchLambdaApplicationSignalsExecutionRolePolicy` · `AWSConfigRulesExecutionRole` · `AWSMSKReplicatorExecutionRole` · `AWS-SSM-DiagnosisAutomation-ExecutionRolePolicy` · `AWS-SSM-RemediationAutomation-ExecutionRolePolicy` · `AmazonSageMakerGeospatialExecutionRole` · `AmazonSageMakerCanvasEMRServerlessExecutionRolePolicy` · `SageMakerStudioBedrockFunctionExecutionRolePolicy` · `SageMakerStudioDomainExecutionRolePolicy` · `SageMakerStudioQueryExecutionRolePolicy` · `AmazonDataZoneDomainExecutionRolePolicy` · `AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy` · `AWSPartnerCentralSellingResourceSnapshotJobExecutionRolePolicy`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.javaindex a0449e4572..45d353c016 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@@ -72,6 +72,19 @@ final class AwsManagedPolicies {new ManagedPolicyDef("AmazonEKSFargatePodExecutionRolePolicy", "/","Provides access to other AWS service resources required to run Amazon EKS pods on AWS Fargate."),+ // EKS cluster and node group policies (required by the EKS console/SDK and+ // the terraform-aws-modules/eks module — see #1092).+ new ManagedPolicyDef("AmazonEKSClusterPolicy", "/",+ "Provides Kubernetes the permissions it requires to manage resources on your behalf."),+ new ManagedPolicyDef("AmazonEKSServicePolicy", "/",+ "This policy allows Amazon Elastic Container Service for Kubernetes to create and manage the necessary resources to operate EKS Clusters."),+ new ManagedPolicyDef("AmazonEKSVPCResourceController", "/",+ "Policy used by VPC Resource Controller to manage ENI and IPs for worker nodes."),+ new ManagedPolicyDef("AmazonEKSWorkerNodePolicy", "/",+ "This policy allows Amazon EKS worker nodes to connect to Amazon EKS Clusters."),+ new ManagedPolicyDef("AmazonEKS_CNI_Policy", "/",+ "Provides the Amazon VPC CNI Plugin the permissions it requires to modify the IP address configuration on your EKS worker nodes."),+// S3 Object Lambda execution role policynew ManagedPolicyDef("AmazonS3ObjectLambdaExecutionRolePolicy", "/service-role/","Provides write permissions to CloudWatch Logs for S3 Object Lambda access points."),diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.javaindex fb90de79df..73a5714948 100644--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java@@ -6,6 +6,8 @@ import org.junit.jupiter.api.MethodOrderer;import org.junit.jupiter.api.Order;import org.junit.jupiter.api.Test;import org.junit.jupiter.api.TestMethodOrder;+import org.junit.jupiter.params.ParameterizedTest;+import org.junit.jupiter.params.provider.ValueSource;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.*;@@ -149,6 +151,32 @@ class IamIntegrationTest {equalTo("arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"));}+ // The standard EKS managed policies the EKS console/SDK and the+ // terraform-aws-modules/eks module attach to cluster and node roles (#1092).+ @ParameterizedTest+ @Order(6)+ @ValueSource(strings = {+ "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy",+ "arn:aws:iam::aws:policy/AmazonEKSServicePolicy",+ "arn:aws:iam::aws:policy/AmazonEKSVPCResourceController",+ "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy",+ "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",+ })+ void getEksManagedPolicy(String arn) {+ String expectedName = arn.substring(arn.lastIndexOf('/') + 1);+ given()+ .formParam("Action", "GetPolicy")+ .formParam("PolicyArn", arn)+ .header("Authorization",+ "AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("GetPolicyResponse.GetPolicyResult.Policy.PolicyName", equalTo(expectedName))+ .body("GetPolicyResponse.GetPolicyResult.Policy.Arn", equalTo(arn));+ }+@Test@Order(35)void attachManagedPolicyToRole() {