Light, fluffy, and always free - The AWS Local Emulator alternative
feat(codebuild,codedeploy): add management APIs (#622)
Hector Venturaf5ec6fc8875d
diff --git a/README.md b/README.mdindex 56dba5773f..c3fb2df6f8 100644--- a/README.md+++ b/README.md@@ -69,6 +69,8 @@| ECS (clusters, services, tasks) | ✅ | ❌ || EKS (clusters, mock + real k3s) | ✅ | ❌ || EC2 (VPCs, instances, security groups) | ✅ | ⚠️ Partial |+| CodeBuild (projects, report groups, credentials) | ✅ | ❌ |+| CodeDeploy (applications, groups, configs + 17 built-ins) | ✅ | ❌ || Native binary | ✅ ~40 MB | ❌ |**Broad AWS coverage. Free forever.**@@ -83,7 +85,7 @@ flowchart LRRouter["HTTP Router\n(JAX-RS / Vert.x)"]subgraph Stateless ["Stateless Services"]- A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis · OpenSearch\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM\nAPI Gateway · EC2"]+ A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis · OpenSearch\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM\nAPI Gateway · EC2\nCodeBuild · CodeDeploy"]endsubgraph Stateful ["Stateful Services"]@@ -212,12 +214,14 @@ All default images are configurable via environment variables, useful for pinnin| **Bedrock Runtime** | In-process (stub) | Dummy Converse and InvokeModel responses for local development; streaming returns 501 || **EKS** | **Real Docker containers** (mock mode available) | Clusters, tagging; real mode starts k3s per cluster with a live Kubernetes API server || **ELB v2** | In-process | Application and Network Load Balancers, target groups, listeners, path/host-based routing rules, tags |+| **CodeBuild** | In-process | Projects, report groups, source credentials, curated environment images |+| **CodeDeploy** | In-process | Applications, deployment groups, deployment configs; 17 AWS built-in `CodeDeployDefault.*` configs pre-seeded |> **Lambda, ElastiCache, RDS, MSK, ECS, EKS, and OpenSearch** spin up real Docker containers and support IAM authentication and SigV4 request signing — the same auth flow as production AWS. **ECR** runs a shared `registry:2` container so the stock `docker` client can push and pull image bytes against repositories returned by the AWS-shaped control plane.>> For per-service operation counts and endpoint protocols, see the [Services Overview](https://floci.io/floci/services/) in the documentation site.-**36 AWS services supported.**+**41 AWS services supported.**## Persistence & Storage Modesdiff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xmlindex 8c840cbeb1..3528fbdbf6 100644--- a/compatibility-tests/sdk-test-java/pom.xml+++ b/compatibility-tests/sdk-test-java/pom.xml@@ -224,6 +224,16 @@<groupId>software.amazon.awssdk</groupId><artifactId>cloudformation</artifactId></dependency>+ <!-- CodeBuild client -->+ <dependency>+ <groupId>software.amazon.awssdk</groupId>+ <artifactId>codebuild</artifactId>+ </dependency>+ <!-- CodeDeploy client -->+ <dependency>+ <groupId>software.amazon.awssdk</groupId>+ <artifactId>codedeploy</artifactId>+ </dependency><!-- AppConfig and AppConfigData clients --><dependency><groupId>software.amazon.awssdk</groupId>diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.javaindex 05f7942195..60852cb4a1 100644--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java@@ -41,6 +41,8 @@ import software.amazon.awssdk.services.acm.AcmClient;import software.amazon.awssdk.services.ec2.Ec2Client;import software.amazon.awssdk.services.ecr.EcrClient;import software.amazon.awssdk.services.pipes.PipesClient;+import software.amazon.awssdk.services.codebuild.CodeBuildClient;+import software.amazon.awssdk.services.codedeploy.CodeDeployClient;import software.amazon.awssdk.services.ecs.EcsClient;import software.amazon.awssdk.services.eks.EksClient;import software.amazon.awssdk.services.scheduler.SchedulerClient;@@ -534,4 +536,20 @@ public final class TestFixtures {.credentialsProvider(CREDENTIALS).build();}++ public static CodeBuildClient codeBuildClient() {+ return CodeBuildClient.builder()+ .endpointOverride(ENDPOINT)+ .region(REGION)+ .credentialsProvider(CREDENTIALS)+ .build();+ }++ public static CodeDeployClient codeDeployClient() {+ return CodeDeployClient.builder()+ .endpointOverride(ENDPOINT)+ .region(REGION)+ .credentialsProvider(CREDENTIALS)+ .build();+ }}diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CodeBuildTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CodeBuildTest.javanew file mode 100644index 0000000000..7c6e3da3e4--- /dev/null+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CodeBuildTest.java@@ -0,0 +1,188 @@+package com.floci.test;++import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.BeforeAll;+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 software.amazon.awssdk.services.codebuild.CodeBuildClient;+import software.amazon.awssdk.services.codebuild.model.ArtifactsType;+import software.amazon.awssdk.services.codebuild.model.BatchGetProjectsResponse;+import software.amazon.awssdk.services.codebuild.model.ComputeType;+import software.amazon.awssdk.services.codebuild.model.CreateProjectResponse;+import software.amazon.awssdk.services.codebuild.model.CreateReportGroupResponse;+import software.amazon.awssdk.services.codebuild.model.DeleteReportGroupRequest;+import software.amazon.awssdk.services.codebuild.model.EnvironmentType;+import software.amazon.awssdk.services.codebuild.model.ImportSourceCredentialsResponse;+import software.amazon.awssdk.services.codebuild.model.ListCuratedEnvironmentImagesResponse;+import software.amazon.awssdk.services.codebuild.model.ListProjectsResponse;+import software.amazon.awssdk.services.codebuild.model.ListReportGroupsResponse;+import software.amazon.awssdk.services.codebuild.model.ListSourceCredentialsResponse;+import software.amazon.awssdk.services.codebuild.model.ProjectArtifacts;+import software.amazon.awssdk.services.codebuild.model.ProjectEnvironment;+import software.amazon.awssdk.services.codebuild.model.ProjectSource;+import software.amazon.awssdk.services.codebuild.model.ReportExportConfig;+import software.amazon.awssdk.services.codebuild.model.ReportExportConfigType;+import software.amazon.awssdk.services.codebuild.model.ReportType;+import software.amazon.awssdk.services.codebuild.model.AuthType;+import software.amazon.awssdk.services.codebuild.model.ServerType;+import software.amazon.awssdk.services.codebuild.model.SourceType;+import software.amazon.awssdk.services.codebuild.model.Tag;+import software.amazon.awssdk.services.codebuild.model.UpdateProjectResponse;++import static org.assertj.core.api.Assertions.assertThat;+import static org.assertj.core.api.Assertions.assertThatThrownBy;++@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class CodeBuildTest {++ static CodeBuildClient codebuild;+ static String reportGroupArn;+ static String sourceCredentialsArn;++ @BeforeAll+ static void setup() {+ codebuild = TestFixtures.codeBuildClient();+ }++ @AfterAll+ static void teardown() {+ codebuild.close();+ }++ @Test+ @Order(1)+ void createProject() {+ CreateProjectResponse resp = codebuild.createProject(r -> r+ .name("sdk-test-project")+ .description("SDK test project")+ .source(ProjectSource.builder()+ .type(SourceType.S3)+ .location("my-bucket/source.zip")+ .build())+ .artifacts(ProjectArtifacts.builder()+ .type(ArtifactsType.NO_ARTIFACTS)+ .build())+ .environment(ProjectEnvironment.builder()+ .type(EnvironmentType.LINUX_CONTAINER)+ .image("aws/codebuild/standard:7.0")+ .computeType(ComputeType.BUILD_GENERAL1_SMALL)+ .build())+ .serviceRole("arn:aws:iam::000000000000:role/codebuild-role")+ .tags(Tag.builder().key("env").value("test").build()));++ assertThat(resp.project().name()).isEqualTo("sdk-test-project");+ assertThat(resp.project().arn()).contains(":project/sdk-test-project");+ assertThat(resp.project().description()).isEqualTo("SDK test project");+ assertThat(resp.project().timeoutInMinutes()).isEqualTo(60);+ }++ @Test+ @Order(2)+ void batchGetProjects() {+ BatchGetProjectsResponse resp = codebuild.batchGetProjects(r -> r+ .names("sdk-test-project", "nonexistent"));++ assertThat(resp.projects()).hasSize(1);+ assertThat(resp.projects().get(0).name()).isEqualTo("sdk-test-project");+ assertThat(resp.projectsNotFound()).containsExactly("nonexistent");+ }++ @Test+ @Order(3)+ void listProjects() {+ ListProjectsResponse resp = codebuild.listProjects(r -> r.build());+ assertThat(resp.projects()).contains("sdk-test-project");+ }++ @Test+ @Order(4)+ void updateProject() {+ UpdateProjectResponse resp = codebuild.updateProject(r -> r+ .name("sdk-test-project")+ .description("Updated by SDK test")+ .timeoutInMinutes(120));++ assertThat(resp.project().description()).isEqualTo("Updated by SDK test");+ assertThat(resp.project().timeoutInMinutes()).isEqualTo(120);+ }++ @Test+ @Order(5)+ void createReportGroup() {+ CreateReportGroupResponse resp = codebuild.createReportGroup(r -> r+ .name("sdk-report-group")+ .type(ReportType.TEST)+ .exportConfig(ReportExportConfig.builder()+ .exportConfigType(ReportExportConfigType.NO_EXPORT)+ .build()));++ assertThat(resp.reportGroup().name()).isEqualTo("sdk-report-group");+ assertThat(resp.reportGroup().arn()).contains(":report-group/sdk-report-group");+ assertThat(resp.reportGroup().status().toString()).isEqualTo("ACTIVE");+ reportGroupArn = resp.reportGroup().arn();+ }++ @Test+ @Order(6)+ void listReportGroups() {+ ListReportGroupsResponse resp = codebuild.listReportGroups(r -> r.build());+ assertThat(resp.reportGroups()).contains(reportGroupArn);+ }++ @Test+ @Order(7)+ void importSourceCredentials() {+ ImportSourceCredentialsResponse resp = codebuild.importSourceCredentials(r -> r+ .token("ghp_test_token_sdk")+ .serverType(ServerType.GITHUB)+ .authType(AuthType.PERSONAL_ACCESS_TOKEN));++ assertThat(resp.arn()).contains(":token/github-");+ sourceCredentialsArn = resp.arn();+ }++ @Test+ @Order(8)+ void listSourceCredentials() {+ ListSourceCredentialsResponse resp = codebuild.listSourceCredentials(r -> r.build());+ assertThat(resp.sourceCredentialsInfos()).isNotEmpty();+ assertThat(resp.sourceCredentialsInfos().get(0).serverType()).isEqualTo(ServerType.GITHUB);+ assertThat(resp.sourceCredentialsInfos().get(0).authType()).isEqualTo(AuthType.PERSONAL_ACCESS_TOKEN);+ }++ @Test+ @Order(9)+ void listCuratedEnvironmentImages() {+ ListCuratedEnvironmentImagesResponse resp = codebuild.listCuratedEnvironmentImages(r -> r.build());+ assertThat(resp.platforms()).isNotEmpty();+ assertThat(resp.platforms().get(0).platformAsString()).isNotBlank();+ }++ @Test+ @Order(10)+ void deleteSourceCredentials() {+ codebuild.deleteSourceCredentials(r -> r.arn(sourceCredentialsArn));++ ListSourceCredentialsResponse after = codebuild.listSourceCredentials(r -> r.build());+ assertThat(after.sourceCredentialsInfos()).isEmpty();+ }++ @Test+ @Order(11)+ void deleteReportGroup() {+ codebuild.deleteReportGroup(DeleteReportGroupRequest.builder()+ .arn(reportGroupArn)+ .build());+ }++ @Test+ @Order(12)+ void deleteProject() {+ codebuild.deleteProject(r -> r.name("sdk-test-project"));++ ListProjectsResponse after = codebuild.listProjects(r -> r.build());+ assertThat(after.projects()).doesNotContain("sdk-test-project");+ }+}diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CodeDeployTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CodeDeployTest.javanew file mode 100644index 0000000000..101048b268--- /dev/null+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CodeDeployTest.java@@ -0,0 +1,251 @@+package com.floci.test;++import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.BeforeAll;+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 software.amazon.awssdk.services.codedeploy.CodeDeployClient;+import software.amazon.awssdk.services.codedeploy.model.BatchGetApplicationsResponse;+import software.amazon.awssdk.services.codedeploy.model.BatchGetDeploymentGroupsResponse;+import software.amazon.awssdk.services.codedeploy.model.ComputePlatform;+import software.amazon.awssdk.services.codedeploy.model.CreateApplicationResponse;+import software.amazon.awssdk.services.codedeploy.model.CreateDeploymentConfigResponse;+import software.amazon.awssdk.services.codedeploy.model.CreateDeploymentGroupResponse;+import software.amazon.awssdk.services.codedeploy.model.DeploymentOption;+import software.amazon.awssdk.services.codedeploy.model.DeploymentReadyAction;+import software.amazon.awssdk.services.codedeploy.model.DeploymentStyle;+import software.amazon.awssdk.services.codedeploy.model.DeploymentType;+import software.amazon.awssdk.services.codedeploy.model.GetDeploymentConfigResponse;+import software.amazon.awssdk.services.codedeploy.model.GetDeploymentGroupResponse;+import software.amazon.awssdk.services.codedeploy.model.ListApplicationsResponse;+import software.amazon.awssdk.services.codedeploy.model.ListDeploymentConfigsResponse;+import software.amazon.awssdk.services.codedeploy.model.ListDeploymentGroupsResponse;+import software.amazon.awssdk.services.codedeploy.model.ListTagsForResourceResponse;+import software.amazon.awssdk.services.codedeploy.model.MinimumHealthyHosts;+import software.amazon.awssdk.services.codedeploy.model.MinimumHealthyHostsType;+import software.amazon.awssdk.services.codedeploy.model.Tag;+import software.amazon.awssdk.services.codedeploy.model.TrafficRoutingType;++import static org.assertj.core.api.Assertions.assertThat;+import static org.assertj.core.api.Assertions.assertThatThrownBy;++@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class CodeDeployTest {++ static CodeDeployClient codedeploy;+ static String appId;+ static String dgId;++ @BeforeAll+ static void setup() {+ codedeploy = TestFixtures.codeDeployClient();+ }++ @AfterAll+ static void teardown() {+ codedeploy.close();+ }++ @Test+ @Order(1)+ void builtInDeploymentConfigsExist() {+ ListDeploymentConfigsResponse resp = codedeploy.listDeploymentConfigs(r -> r.build());+ assertThat(resp.deploymentConfigsList())+ .contains("CodeDeployDefault.AllAtOnce",+ "CodeDeployDefault.HalfAtATime",+ "CodeDeployDefault.OneAtATime",+ "CodeDeployDefault.LambdaAllAtOnce",+ "CodeDeployDefault.ECSAllAtOnce");+ }++ @Test+ @Order(2)+ void getLambdaDeploymentConfig() {+ GetDeploymentConfigResponse resp = codedeploy.getDeploymentConfig(r -> r+ .deploymentConfigName("CodeDeployDefault.LambdaAllAtOnce"));++ assertThat(resp.deploymentConfigInfo().deploymentConfigName())+ .isEqualTo("CodeDeployDefault.LambdaAllAtOnce");+ assertThat(resp.deploymentConfigInfo().computePlatform()).isEqualTo(ComputePlatform.LAMBDA);+ assertThat(resp.deploymentConfigInfo().trafficRoutingConfig().type())+ .isEqualTo(TrafficRoutingType.ALL_AT_ONCE);+ }++ @Test+ @Order(3)+ void getLambdaCanaryConfig() {+ GetDeploymentConfigResponse resp = codedeploy.getDeploymentConfig(r -> r+ .deploymentConfigName("CodeDeployDefault.LambdaCanary10Percent5Minutes"));++ assertThat(resp.deploymentConfigInfo().computePlatform()).isEqualTo(ComputePlatform.LAMBDA);+ assertThat(resp.deploymentConfigInfo().trafficRoutingConfig().type())+ .isEqualTo(TrafficRoutingType.TIME_BASED_CANARY);+ assertThat(resp.deploymentConfigInfo().trafficRoutingConfig().timeBasedCanary().canaryPercentage())+ .isEqualTo(10);+ }++ @Test+ @Order(4)+ void createApplication() {+ CreateApplicationResponse resp = codedeploy.createApplication(r -> r+ .applicationName("sdk-lambda-app")+ .computePlatform(ComputePlatform.LAMBDA)+ .tags(Tag.builder().key("env").value("test").build()));++ assertThat(resp.applicationId()).isNotBlank();+ appId = resp.applicationId();+ }++ @Test+ @Order(5)+ void getApplication() {+ var resp = codedeploy.getApplication(r -> r.applicationName("sdk-lambda-app"));+ assertThat(resp.application().applicationName()).isEqualTo("sdk-lambda-app");+ assertThat(resp.application().computePlatform()).isEqualTo(ComputePlatform.LAMBDA);+ assertThat(resp.application().linkedToGitHub()).isFalse();+ }++ @Test+ @Order(6)+ void listApplications() {+ ListApplicationsResponse resp = codedeploy.listApplications(r -> r.build());+ assertThat(resp.applications()).contains("sdk-lambda-app");+ }++ @Test+ @Order(7)+ void batchGetApplications() {+ BatchGetApplicationsResponse resp = codedeploy.batchGetApplications(r -> r+ .applicationNames("sdk-lambda-app"));++ assertThat(resp.applicationsInfo()).hasSize(1);+ assertThat(resp.applicationsInfo().get(0).applicationName()).isEqualTo("sdk-lambda-app");+ }++ @Test+ @Order(8)+ void createDeploymentGroup() {+ CreateDeploymentGroupResponse resp = codedeploy.createDeploymentGroup(r -> r+ .applicationName("sdk-lambda-app")+ .deploymentGroupName("sdk-lambda-dg")+ .deploymentConfigName("CodeDeployDefault.LambdaAllAtOnce")+ .serviceRoleArn("arn:aws:iam::000000000000:role/codedeploy-role")+ .deploymentStyle(DeploymentStyle.builder()+ .deploymentType(DeploymentType.BLUE_GREEN)+ .deploymentOption(DeploymentOption.WITH_TRAFFIC_CONTROL)+ .build()));++ assertThat(resp.deploymentGroupId()).isNotBlank();+ dgId = resp.deploymentGroupId();+ }++ @Test+ @Order(9)+ void getDeploymentGroup() {+ GetDeploymentGroupResponse resp = codedeploy.getDeploymentGroup(r -> r+ .applicationName("sdk-lambda-app")+ .deploymentGroupName("sdk-lambda-dg"));++ assertThat(resp.deploymentGroupInfo().deploymentGroupName()).isEqualTo("sdk-lambda-dg");+ assertThat(resp.deploymentGroupInfo().deploymentConfigName())+ .isEqualTo("CodeDeployDefault.LambdaAllAtOnce");+ }++ @Test+ @Order(10)+ void listDeploymentGroups() {+ ListDeploymentGroupsResponse resp = codedeploy.listDeploymentGroups(r -> r+ .applicationName("sdk-lambda-app"));++ assertThat(resp.applicationName()).isEqualTo("sdk-lambda-app");+ assertThat(resp.deploymentGroups()).contains("sdk-lambda-dg");+ }++ @Test+ @Order(11)+ void batchGetDeploymentGroups() {+ BatchGetDeploymentGroupsResponse resp = codedeploy.batchGetDeploymentGroups(r -> r+ .applicationName("sdk-lambda-app")+ .deploymentGroupNames("sdk-lambda-dg"));++ assertThat(resp.deploymentGroupsInfo()).hasSize(1);+ assertThat(resp.deploymentGroupsInfo().get(0).deploymentGroupName()).isEqualTo("sdk-lambda-dg");+ }++ @Test+ @Order(12)+ void createCustomDeploymentConfig() {+ CreateDeploymentConfigResponse resp = codedeploy.createDeploymentConfig(r -> r+ .deploymentConfigName("SdkTestConfig")+ .minimumHealthyHosts(MinimumHealthyHosts.builder()+ .type(MinimumHealthyHostsType.FLEET_PERCENT)+ .value(75)+ .build())+ .computePlatform(ComputePlatform.SERVER));++ assertThat(resp.deploymentConfigId()).isNotBlank();+ }++ @Test+ @Order(13)+ void getCustomDeploymentConfig() {+ GetDeploymentConfigResponse resp = codedeploy.getDeploymentConfig(r -> r+ .deploymentConfigName("SdkTestConfig"));++ assertThat(resp.deploymentConfigInfo().deploymentConfigName()).isEqualTo("SdkTestConfig");+ assertThat(resp.deploymentConfigInfo().computePlatform()).isEqualTo(ComputePlatform.SERVER);+ assertThat(resp.deploymentConfigInfo().minimumHealthyHosts().type())+ .isEqualTo(MinimumHealthyHostsType.FLEET_PERCENT);+ assertThat(resp.deploymentConfigInfo().minimumHealthyHosts().value()).isEqualTo(75);+ }++ @Test+ @Order(14)+ void tagAndListTags() {+ String arn = "arn:aws:codedeploy:us-east-1:000000000000:application:sdk-lambda-app";+ codedeploy.tagResource(r -> r+ .resourceArn(arn)+ .tags(Tag.builder().key("team").value("platform").build(),+ Tag.builder().key("project").value("floci").build()));++ ListTagsForResourceResponse resp = codedeploy.listTagsForResource(r -> r.resourceArn(arn));+ // env=test was added during createApplication, plus team and project here+ assertThat(resp.tags().stream().map(Tag::key)).contains("team", "project", "env");+ }++ @Test+ @Order(15)+ void untagResource() {+ String arn = "arn:aws:codedeploy:us-east-1:000000000000:application:sdk-lambda-app";+ codedeploy.untagResource(r -> r.resourceArn(arn).tagKeys("project"));++ ListTagsForResourceResponse resp = codedeploy.listTagsForResource(r -> r.resourceArn(arn));+ assertThat(resp.tags().stream().map(Tag::key)).doesNotContain("project");+ assertThat(resp.tags().stream().map(Tag::key)).contains("team", "env");+ }++ @Test+ @Order(16)+ void cannotDeleteBuiltInConfig() {+ assertThatThrownBy(() ->+ codedeploy.deleteDeploymentConfig(r -> r.deploymentConfigName("CodeDeployDefault.AllAtOnce")))+ .isInstanceOf(software.amazon.awssdk.services.codedeploy.model.InvalidDeploymentConfigNameException.class);+ }++ @Test+ @Order(17)+ void cleanup() {+ codedeploy.deleteDeploymentGroup(r -> r+ .applicationName("sdk-lambda-app")+ .deploymentGroupName("sdk-lambda-dg"));++ codedeploy.deleteDeploymentConfig(r -> r.deploymentConfigName("SdkTestConfig"));++ codedeploy.deleteApplication(r -> r.applicationName("sdk-lambda-app"));++ ListApplicationsResponse after = codedeploy.listApplications(r -> r.build());+ assertThat(after.applications()).doesNotContain("sdk-lambda-app");+ }+}diff --git a/docs/services/codebuild.md b/docs/services/codebuild.mdnew file mode 100644index 0000000000..a687f0ce69--- /dev/null+++ b/docs/services/codebuild.md@@ -0,0 +1,61 @@+# CodeBuild++Floci implements the CodeBuild management API (Phase 1) — stored-state CRUD for projects, report groups, and source credentials. Build execution (Phase 2) is not yet implemented.++**Protocol:** JSON 1.1 — `POST /` with `X-Amz-Target: CodeBuild_20161006.<Action>`++**ARN formats:**++- `arn:aws:codebuild:<region>:<account>:project/<name>`+- `arn:aws:codebuild:<region>:<account>:report-group/<name>`+- `arn:aws:codebuild:<region>:<account>:token/<type>-<uuid>`++## Supported Operations (Phase 1 — 14 total)++| Operation | Notes |+|---|---|+| `CreateProject` | Stores project config; requires `name`, `source.type`, `artifacts.type`, `environment`, `serviceRole` |+| `UpdateProject` | Partial update — only supplied fields are modified |+| `DeleteProject` | Removes project by name |+| `BatchGetProjects` | Returns found projects and a `projectsNotFound` list |+| `ListProjects` | Returns all project names in the region |+| `CreateReportGroup` | Stores report group config |+| `UpdateReportGroup` | Partial update by ARN |+| `DeleteReportGroup` | Removes report group by ARN |+| `BatchGetReportGroups` | Returns found report groups and a `reportGroupsNotFound` list |+| `ListReportGroups` | Returns all report group ARNs in the region |+| `ImportSourceCredentials` | Stores server type and auth type; token is accepted but not returned |+| `ListSourceCredentials` | Returns stored credential metadata (no tokens) |+| `DeleteSourceCredentials` | Removes source credentials by ARN |+| `ListCuratedEnvironmentImages` | Returns a static list of standard CodeBuild images for AL2 and Ubuntu |++## Configuration++```yaml+floci:+ services:+ codebuild:+ enabled: true # default+```++## CLI Examples++```bash+# Create a project+aws --endpoint-url http://localhost:4566 codebuild create-project \+ --name my-project \+ --source type=S3,location=my-bucket/source.zip \+ --artifacts type=NO_ARTIFACTS \+ --environment type=LINUX_CONTAINER,image=aws/codebuild/standard:7.0,computeType=BUILD_GENERAL1_SMALL \+ --service-role arn:aws:iam::000000000000:role/codebuild-role++# List projects+aws --endpoint-url http://localhost:4566 codebuild list-projects++# List curated images+aws --endpoint-url http://localhost:4566 codebuild list-curated-environment-images+```++## Phase 2 (not yet implemented)++`StartBuild`, `BatchGetBuilds`, `StopBuild`, `ListBuilds`, `ListBuildsForProject`, `RetryBuild`. Builds will execute buildspecs in real Docker containers, stream logs to CloudWatch, and upload artifacts to S3.diff --git a/docs/services/codedeploy.md b/docs/services/codedeploy.mdnew file mode 100644index 0000000000..fec17eaff2--- /dev/null+++ b/docs/services/codedeploy.md@@ -0,0 +1,95 @@+# CodeDeploy++Floci implements the CodeDeploy management API (Phase 1) — stored-state CRUD for applications, deployment groups, and deployment configurations. Built-in deployment configurations are pre-seeded and always available. Deployment execution (Phase 2) is not yet implemented.++**Protocol:** JSON 1.1 — `POST /` with `X-Amz-Target: CodeDeploy_20141006.<Action>`++**ARN formats:**++- `arn:aws:codedeploy:<region>:<account>:application:<name>`+- `arn:aws:codedeploy:<region>:<account>:deploymentgroup:<app>/<group>`++## Supported Operations (Phase 1 — 21 total)++| Operation | Notes |+|---|---|+| `CreateApplication` | Supports `computePlatform`: `Server`, `Lambda`, `ECS` |+| `GetApplication` | Returns application metadata |+| `UpdateApplication` | Renames an application |+| `DeleteApplication` | Removes application and all its deployment groups |+| `ListApplications` | Returns all application names |+| `BatchGetApplications` | Returns info for multiple applications |+| `CreateDeploymentGroup` | Stores group config; deployment config defaults to `CodeDeployDefault.OneAtATime` |+| `GetDeploymentGroup` | Returns group metadata |+| `UpdateDeploymentGroup` | Partial update; supports rename via `newDeploymentGroupName` |+| `DeleteDeploymentGroup` | Returns `hooksNotCleanedUp: []` |+| `ListDeploymentGroups` | Returns all group names for an application |+| `BatchGetDeploymentGroups` | Returns info for multiple groups |+| `CreateDeploymentConfig` | Creates a custom config; names starting with `CodeDeployDefault.` are rejected |+| `GetDeploymentConfig` | Returns config including built-ins |+| `DeleteDeploymentConfig` | Custom configs only; built-ins cannot be deleted |+| `ListDeploymentConfigs` | Returns all configs including all 17 pre-seeded built-ins |+| `TagResource` | Tags any resource by ARN |+| `UntagResource` | Removes specific tag keys |+| `ListTagsForResource` | Returns tags for a resource ARN |+| `AddTagsToOnPremisesInstances` | Accepted, no-op |+| `RemoveTagsFromOnPremisesInstances` | Accepted, no-op |++## Pre-seeded Built-in Deployment Configs++The following 17 configurations are always available (matching real AWS):++**Server:**+- `CodeDeployDefault.OneAtATime`+- `CodeDeployDefault.HalfAtATime`+- `CodeDeployDefault.AllAtOnce`++**Lambda:**+- `CodeDeployDefault.LambdaAllAtOnce`+- `CodeDeployDefault.LambdaCanary10Percent5Minutes`+- `CodeDeployDefault.LambdaCanary10Percent10Minutes`+- `CodeDeployDefault.LambdaCanary10Percent15Minutes`+- `CodeDeployDefault.LambdaCanary10Percent30Minutes`+- `CodeDeployDefault.LambdaLinear10PercentEvery1Minute`+- `CodeDeployDefault.LambdaLinear10PercentEvery2Minutes`+- `CodeDeployDefault.LambdaLinear10PercentEvery3Minutes`+- `CodeDeployDefault.LambdaLinear10PercentEvery10Minutes`++**ECS:**+- `CodeDeployDefault.ECSAllAtOnce`+- `CodeDeployDefault.ECSCanary10Percent5Minutes`+- `CodeDeployDefault.ECSCanary10Percent15Minutes`+- `CodeDeployDefault.ECSLinear10PercentEvery1Minutes`+- `CodeDeployDefault.ECSLinear10PercentEvery3Minutes`++## Configuration++```yaml+floci:+ services:+ codedeploy:+ enabled: true # default+```++## CLI Examples++```bash+# Create an application+aws --endpoint-url http://localhost:4566 deploy create-application \+ --application-name my-app \+ --compute-platform Lambda++# List built-in deployment configs+aws --endpoint-url http://localhost:4566 deploy list-deployment-configs++# Create a deployment group+aws --endpoint-url http://localhost:4566 deploy create-deployment-group \+ --application-name my-app \+ --deployment-group-name my-group \+ --deployment-config-name CodeDeployDefault.LambdaAllAtOnce \+ --service-role-arn arn:aws:iam::000000000000:role/codedeploy-role+```++## Phase 2 (not yet implemented)++`CreateDeployment`, `GetDeployment`, `StopDeployment`, `ContinueDeployment` with real Lambda traffic-shifting (updating alias `RoutingConfig` weights). Phase 2 focuses on the `computePlatform: Lambda` path since Lambda is already fully real in Floci.diff --git a/docs/services/index.md b/docs/services/index.mdindex 87681c305e..22a2dda41b 100644--- a/docs/services/index.md+++ b/docs/services/index.md@@ -1,6 +1,6 @@# Services Overview-Floci emulates 35 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.+Floci emulates 41 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.This page is the canonical reference for supported service counts and operation counts. Other docs (and the README) should link here rather than duplicating the table.@@ -45,6 +45,12 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac| [Bedrock Runtime](bedrock-runtime.md) | `/model/{modelId}/converse`, `/model/{modelId}/invoke` | REST JSON | 2 (stub; streaming returns 501) || [EKS](eks.md) | `/clusters`, `/clusters/{name}`, `/tags/{resourceArn}` | REST JSON | 7 || [ELB v2](elb.md) | `POST /` with `Action=` param | Query | 34 |+| [MSK](msk.md) | `/v1/clusters/...`, `/api/v2/clusters/...` | REST JSON | 8 |+| [Athena](athena.md) | `POST /` + `X-Amz-Target: AmazonAthena.*` | JSON 1.1 | 8 |+| [Glue](glue.md) | `POST /` + `X-Amz-Target: AWSGlue.*` | JSON 1.1 | 15 |+| [Data Firehose](firehose.md) | `POST /` + `X-Amz-Target: Firehose_20150804.*` | JSON 1.1 | 6 |+| [CodeBuild](codebuild.md) | `POST /` + `X-Amz-Target: CodeBuild_20161006.*` | JSON 1.1 | 14 |+| [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 21 |**Lambda, ElastiCache, RDS, MSK, ECS, EKS, and OpenSearch** spin up real Docker containers and support IAM authentication and SigV4 request signing, the same auth flow as production AWS.diff --git a/floci_banner.svg b/floci_banner.svgindex 9fa322d636..072f6e01df 100644--- a/floci_banner.svg+++ b/floci_banner.svg@@ -108,7 +108,7 @@<!-- Stat 3: Services --><text x="770" y="548"font-family="'Courier New', Courier, monospace"- font-size="42" font-weight="700" fill="#ffe082" text-anchor="middle">~35+ font-size="42" font-weight="700" fill="#ffe082" text-anchor="middle">~40</text><text x="770" y="574"font-family="'Helvetica Neue', Helvetica, Arial, sans-serif"diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.javaindex a6601b1512..31be1ea32c 100644--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java@@ -270,6 +270,18 @@ public interface EmulatorConfig {EksServiceConfig eks();PipesServiceConfig pipes();ElbV2ServiceConfig elbv2();+ CodeBuildServiceConfig codebuild();+ CodeDeployServiceConfig codedeploy();+ }++ interface CodeBuildServiceConfig {+ @WithDefault("true")+ boolean enabled();+ }++ interface CodeDeployServiceConfig {+ @WithDefault("true")+ boolean enabled();}interface SsmServiceConfig {diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.javaindex dec53983f2..c783ba7ee0 100644--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java@@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.JsonNode;import com.fasterxml.jackson.databind.ObjectMapper;import io.github.hectorvent.floci.services.acm.AcmJsonHandler;import io.github.hectorvent.floci.services.athena.AthenaJsonHandler;+import io.github.hectorvent.floci.services.codebuild.CodeBuildJsonHandler;+import io.github.hectorvent.floci.services.codedeploy.CodeDeployJsonHandler;import io.github.hectorvent.floci.services.ecr.EcrJsonHandler;import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;import io.github.hectorvent.floci.services.firehose.FirehoseJsonHandler;@@ -56,6 +58,8 @@ public class AwsJson11Controller {private final AthenaJsonHandler athenaJsonHandler;private final FirehoseJsonHandler firehoseJsonHandler;private final ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler;+ private final CodeBuildJsonHandler codeBuildJsonHandler;+ private final CodeDeployJsonHandler codeDeployJsonHandler;@Injectpublic AwsJson11Controller(ObjectMapper objectMapper, ResolvedServiceCatalog catalog,@@ -70,7 +74,9 @@ public class AwsJson11Controller {EcrJsonHandler ecrJsonHandler, GlueJsonHandler glueJsonHandler,AthenaJsonHandler athenaJsonHandler,FirehoseJsonHandler firehoseJsonHandler,- ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler) {+ ResourceGroupsTaggingJsonHandler resourceGroupsTaggingJsonHandler,+ CodeBuildJsonHandler codeBuildJsonHandler,+ CodeDeployJsonHandler codeDeployJsonHandler) {this.objectMapper = objectMapper;this.catalog = catalog;this.regionResolver = regionResolver;@@ -89,6 +95,8 @@ public class AwsJson11Controller {this.athenaJsonHandler = athenaJsonHandler;this.firehoseJsonHandler = firehoseJsonHandler;this.resourceGroupsTaggingJsonHandler = resourceGroupsTaggingJsonHandler;+ this.codeBuildJsonHandler = codeBuildJsonHandler;+ this.codeDeployJsonHandler = codeDeployJsonHandler;}@POST@@ -132,6 +140,8 @@ public class AwsJson11Controller {case "athena" -> athenaJsonHandler.handle(action, request, region);case "firehose" -> firehoseJsonHandler.handle(action, request, region);case "tagging" -> resourceGroupsTaggingJsonHandler.handle(action, request, region);+ case "codebuild" -> codeBuildJsonHandler.handle(action, request, region, regionResolver.getAccountId());+ case "codedeploy" -> codeDeployJsonHandler.handle(action, request, region);default -> null;};// catalog.matchTarget is protocol-agnostic: a JSON 1.0 targetdiff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.javaindex 11b99dcacc..6df6025b61 100644--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java@@ -208,7 +208,15 @@ public class ResolvedServiceCatalog {descriptor("elasticloadbalancing", "elbv2", config.services().elbv2().enabled(), true,"elbv2", config.storage().mode(), 5000L, AwsNamespaces.ELB_V2, ServiceProtocol.QUERY,protocols(ServiceProtocol.QUERY),- Set.of(), Set.of("elasticloadbalancing"), Set.of(), Set.of())+ Set.of(), Set.of("elasticloadbalancing"), Set.of(), Set.of()),+ descriptor("codebuild", "codebuild", config.services().codebuild().enabled(), true,+ null, null, 5000L, null, ServiceProtocol.JSON,+ protocols(ServiceProtocol.JSON),+ Set.of("CodeBuild_20161006."), Set.of("codebuild"), Set.of(), Set.of()),+ descriptor("codedeploy", "codedeploy", config.services().codedeploy().enabled(), true,+ null, null, 5000L, null, ServiceProtocol.JSON,+ protocols(ServiceProtocol.JSON),+ Set.of("CodeDeploy_20141006."), Set.of("codedeploy"), Set.of(), Set.of())));}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildJsonHandler.javanew file mode 100644index 0000000000..363027e936--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildJsonHandler.java@@ -0,0 +1,212 @@+package io.github.hectorvent.floci.services.codebuild;++import com.fasterxml.jackson.databind.JsonNode;+import com.fasterxml.jackson.databind.ObjectMapper;+import io.github.hectorvent.floci.core.common.AwsException;+import io.github.hectorvent.floci.services.codebuild.model.Project;+import io.github.hectorvent.floci.services.codebuild.model.ProjectArtifacts;+import io.github.hectorvent.floci.services.codebuild.model.ProjectEnvironment;+import io.github.hectorvent.floci.services.codebuild.model.ProjectSource;+import io.github.hectorvent.floci.services.codebuild.model.ReportGroup;+import io.github.hectorvent.floci.services.codebuild.model.SourceCredential;+import jakarta.enterprise.context.ApplicationScoped;+import jakarta.inject.Inject;+import jakarta.ws.rs.core.Response;++import java.util.ArrayList;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++@ApplicationScoped+public class CodeBuildJsonHandler {++ private final CodeBuildService service;+ private final ObjectMapper mapper;++ @Inject+ public CodeBuildJsonHandler(CodeBuildService service, ObjectMapper mapper) {+ this.service = service;+ this.mapper = mapper;+ }++ public Response handle(String action, JsonNode request, String region, String account) throws Exception {+ return switch (action) {+ case "CreateProject" -> createProject(request, region, account);+ case "UpdateProject" -> updateProject(request, region);+ case "DeleteProject" -> deleteProject(request, region);+ case "BatchGetProjects" -> batchGetProjects(request, region);+ case "ListProjects" -> listProjects(region);+ case "CreateReportGroup" -> createReportGroup(request, region, account);+ case "UpdateReportGroup" -> updateReportGroup(request, region);+ case "DeleteReportGroup" -> deleteReportGroup(request, region);+ case "BatchGetReportGroups" -> batchGetReportGroups(request, region);+ case "ListReportGroups" -> listReportGroups(region);+ case "ImportSourceCredentials" -> importSourceCredentials(request, region, account);+ case "ListSourceCredentials" -> listSourceCredentials(region);+ case "DeleteSourceCredentials" -> deleteSourceCredentials(request, region);+ case "ListCuratedEnvironmentImages" -> listCuratedEnvironmentImages();+ default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);+ };+ }++ private Response createProject(JsonNode req, String region, String account) throws Exception {+ String name = req.path("name").asText(null);+ String description = req.has("description") ? req.path("description").asText() : null;+ ProjectSource source = req.has("source") ? mapper.treeToValue(req.get("source"), ProjectSource.class) : null;+ List<ProjectSource> secondarySources = parseList(req, "secondarySources", ProjectSource.class);+ String sourceVersion = req.has("sourceVersion") ? req.path("sourceVersion").asText() : null;+ ProjectArtifacts artifacts = req.has("artifacts") ? mapper.treeToValue(req.get("artifacts"), ProjectArtifacts.class) : null;+ List<ProjectArtifacts> secondaryArtifacts = parseList(req, "secondaryArtifacts", ProjectArtifacts.class);+ ProjectEnvironment environment = req.has("environment") ? mapper.treeToValue(req.get("environment"), ProjectEnvironment.class) : null;+ String serviceRole = req.has("serviceRole") ? req.path("serviceRole").asText() : null;+ Integer timeout = req.has("timeoutInMinutes") ? req.path("timeoutInMinutes").asInt() : null;+ Integer queuedTimeout = req.has("queuedTimeoutInMinutes") ? req.path("queuedTimeoutInMinutes").asInt() : null;+ String encryptionKey = req.has("encryptionKey") ? req.path("encryptionKey").asText() : null;+ List<Map<String, String>> tags = parseTags(req);+ Map<String, Object> logsConfig = req.has("logsConfig") ? mapper.treeToValue(req.get("logsConfig"), Map.class) : null;+ Map<String, Object> vpcConfig = req.has("vpcConfig") ? mapper.treeToValue(req.get("vpcConfig"), Map.class) : null;+ Integer concurrentBuildLimit = req.has("concurrentBuildLimit") ? req.path("concurrentBuildLimit").asInt() : null;++ Project project = service.createProject(region, account, name, description,+ source, secondarySources, sourceVersion,+ artifacts, secondaryArtifacts, environment,+ serviceRole, timeout, queuedTimeout, encryptionKey,+ tags, logsConfig, vpcConfig, concurrentBuildLimit);++ return Response.ok(Map.of("project", project)).build();+ }++ private Response updateProject(JsonNode req, String region) throws Exception {+ String name = req.path("name").asText(null);+ String description = req.has("description") ? req.path("description").asText() : null;+ ProjectSource source = req.has("source") ? mapper.treeToValue(req.get("source"), ProjectSource.class) : null;+ List<ProjectSource> secondarySources = parseList(req, "secondarySources", ProjectSource.class);+ String sourceVersion = req.has("sourceVersion") ? req.path("sourceVersion").asText() : null;+ ProjectArtifacts artifacts = req.has("artifacts") ? mapper.treeToValue(req.get("artifacts"), ProjectArtifacts.class) : null;+ List<ProjectArtifacts> secondaryArtifacts = parseList(req, "secondaryArtifacts", ProjectArtifacts.class);+ ProjectEnvironment environment = req.has("environment") ? mapper.treeToValue(req.get("environment"), ProjectEnvironment.class) : null;+ String serviceRole = req.has("serviceRole") ? req.path("serviceRole").asText() : null;+ Integer timeout = req.has("timeoutInMinutes") ? req.path("timeoutInMinutes").asInt() : null;+ Integer queuedTimeout = req.has("queuedTimeoutInMinutes") ? req.path("queuedTimeoutInMinutes").asInt() : null;+ String encryptionKey = req.has("encryptionKey") ? req.path("encryptionKey").asText() : null;+ List<Map<String, String>> tags = parseTags(req);+ Map<String, Object> logsConfig = req.has("logsConfig") ? mapper.treeToValue(req.get("logsConfig"), Map.class) : null;+ Map<String, Object> vpcConfig = req.has("vpcConfig") ? mapper.treeToValue(req.get("vpcConfig"), Map.class) : null;+ Integer concurrentBuildLimit = req.has("concurrentBuildLimit") ? req.path("concurrentBuildLimit").asInt() : null;++ Project project = service.updateProject(region, name, description,+ source, secondarySources, sourceVersion,+ artifacts, secondaryArtifacts, environment,+ serviceRole, timeout, queuedTimeout, encryptionKey,+ tags, logsConfig, vpcConfig, concurrentBuildLimit);++ return Response.ok(Map.of("project", project)).build();+ }++ private Response deleteProject(JsonNode req, String region) {+ String name = req.path("name").asText(null);+ service.deleteProject(region, name);+ return Response.ok(Map.of()).build();+ }++ private Response batchGetProjects(JsonNode req, String region) {+ List<String> names = new ArrayList<>();+ req.path("names").forEach(n -> names.add(n.asText()));+ List<Project> found = service.batchGetProjects(region, names);+ List<String> foundNames = found.stream().map(Project::getName).toList();+ List<String> notFound = names.stream().filter(n -> !foundNames.contains(n)).toList();+ return Response.ok(Map.of("projects", found, "projectsNotFound", notFound)).build();+ }++ private Response listProjects(String region) {+ List<String> names = service.listProjects(region);+ return Response.ok(Map.of("projects", names)).build();+ }++ private Response createReportGroup(JsonNode req, String region, String account) throws Exception {+ String name = req.path("name").asText(null);+ String type = req.path("type").asText(null);+ Map<String, Object> exportConfig = req.has("exportConfig") ? mapper.treeToValue(req.get("exportConfig"), Map.class) : null;+ List<Map<String, String>> tags = parseTags(req);+ ReportGroup rg = service.createReportGroup(region, account, name, type, exportConfig, tags);+ return Response.ok(Map.of("reportGroup", rg)).build();+ }++ private Response updateReportGroup(JsonNode req, String region) throws Exception {+ String arn = req.path("arn").asText(null);+ Map<String, Object> exportConfig = req.has("exportConfig") ? mapper.treeToValue(req.get("exportConfig"), Map.class) : null;+ List<Map<String, String>> tags = parseTags(req);+ ReportGroup rg = service.updateReportGroup(region, arn, exportConfig, tags);+ return Response.ok(Map.of("reportGroup", rg)).build();+ }++ private Response deleteReportGroup(JsonNode req, String region) {+ String arn = req.path("arn").asText(null);+ service.deleteReportGroup(region, arn);+ return Response.ok(Map.of()).build();+ }++ private Response batchGetReportGroups(JsonNode req, String region) {+ List<String> arns = new ArrayList<>();+ req.path("reportGroupArns").forEach(a -> arns.add(a.asText()));+ List<ReportGroup> found = service.batchGetReportGroups(region, arns);+ List<String> foundArns = found.stream().map(ReportGroup::getArn).toList();+ List<String> notFound = arns.stream().filter(a -> !foundArns.contains(a)).toList();+ return Response.ok(Map.of("reportGroups", found, "reportGroupsNotFound", notFound)).build();+ }++ private Response listReportGroups(String region) {+ return Response.ok(Map.of("reportGroups", service.listReportGroups(region))).build();+ }++ private Response importSourceCredentials(JsonNode req, String region, String account) {+ String token = req.path("token").asText(null);+ String serverType = req.path("serverType").asText(null);+ String authType = req.path("authType").asText(null);+ Boolean shouldOverwrite = req.has("shouldOverwrite") ? req.path("shouldOverwrite").asBoolean() : null;+ SourceCredential cred = service.importSourceCredentials(region, account, token, serverType, authType, shouldOverwrite);+ return Response.ok(Map.of("arn", cred.getArn())).build();+ }++ private Response listSourceCredentials(String region) {+ List<SourceCredential> creds = service.listSourceCredentials(region);+ return Response.ok(Map.of("sourceCredentialsInfos", creds)).build();+ }++ private Response deleteSourceCredentials(JsonNode req, String region) {+ String arn = req.path("arn").asText(null);+ service.deleteSourceCredentials(region, arn);+ return Response.ok(Map.of("arn", arn)).build();+ }++ private Response listCuratedEnvironmentImages() {+ return Response.ok(Map.of("platforms", service.listCuratedEnvironmentImages())).build();+ }++ @SuppressWarnings("unchecked")+ private <T> List<T> parseList(JsonNode req, String field, Class<T> type) throws Exception {+ if (!req.has(field) || req.get(field).isNull()) {+ return null;+ }+ List<T> result = new ArrayList<>();+ for (JsonNode node : req.get(field)) {+ result.add(mapper.treeToValue(node, type));+ }+ return result;+ }++ private List<Map<String, String>> parseTags(JsonNode req) {+ if (!req.has("tags") || req.get("tags").isNull()) {+ return null;+ }+ List<Map<String, String>> tags = new ArrayList<>();+ for (JsonNode tag : req.get("tags")) {+ Map<String, String> t = new HashMap<>();+ t.put("key", tag.path("key").asText());+ t.put("value", tag.path("value").asText());+ tags.add(t);+ }+ return tags;+ }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildService.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildService.javanew file mode 100644index 0000000000..611af05faf--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildService.java@@ -0,0 +1,318 @@+package io.github.hectorvent.floci.services.codebuild;++import io.github.hectorvent.floci.core.common.AwsException;+import io.github.hectorvent.floci.services.codebuild.model.Project;+import io.github.hectorvent.floci.services.codebuild.model.ProjectArtifacts;+import io.github.hectorvent.floci.services.codebuild.model.ProjectEnvironment;+import io.github.hectorvent.floci.services.codebuild.model.ProjectSource;+import io.github.hectorvent.floci.services.codebuild.model.ReportGroup;+import io.github.hectorvent.floci.services.codebuild.model.SourceCredential;+import jakarta.enterprise.context.ApplicationScoped;++import java.time.Instant;+import java.util.ArrayList;+import java.util.List;+import java.util.Map;+import java.util.UUID;+import java.util.concurrent.ConcurrentHashMap;+import java.util.stream.Collectors;++@ApplicationScoped+public class CodeBuildService {++ // key: region -> name -> project+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, Project>> projects = new ConcurrentHashMap<>();+ // key: region -> arn -> report group+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, ReportGroup>> reportGroups = new ConcurrentHashMap<>();+ // key: region -> arn -> source credential (token is stored but never returned)+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, SourceCredential>> sourceCredentials = new ConcurrentHashMap<>();++ private Map<String, Project> projectsFor(String region) {+ return projects.computeIfAbsent(region, r -> new ConcurrentHashMap<>());+ }++ private Map<String, ReportGroup> reportGroupsFor(String region) {+ return reportGroups.computeIfAbsent(region, r -> new ConcurrentHashMap<>());+ }++ private Map<String, SourceCredential> sourceCredentialsFor(String region) {+ return sourceCredentials.computeIfAbsent(region, r -> new ConcurrentHashMap<>());+ }++ // ---- Projects ----++ public Project createProject(String region, String account,+ String name, String description,+ ProjectSource source, List<ProjectSource> secondarySources,+ String sourceVersion,+ ProjectArtifacts artifacts, List<ProjectArtifacts> secondaryArtifacts,+ ProjectEnvironment environment,+ String serviceRole,+ Integer timeoutInMinutes, Integer queuedTimeoutInMinutes,+ String encryptionKey,+ List<Map<String, String>> tags,+ Map<String, Object> logsConfig,+ Map<String, Object> vpcConfig,+ Integer concurrentBuildLimit) {+ Map<String, Project> store = projectsFor(region);+ if (store.containsKey(name)) {+ throw new AwsException("ResourceAlreadyExistsException",+ "Project already exists: " + name, 400);+ }+ validateProjectName(name);+ if (source == null || source.getType() == null) {+ throw new AwsException("InvalidInputException", "source.type is required", 400);+ }+ if (environment == null) {+ throw new AwsException("InvalidInputException", "environment is required", 400);+ }+ if (serviceRole == null || serviceRole.isBlank()) {+ throw new AwsException("InvalidInputException", "serviceRole is required", 400);+ }+ if (artifacts == null || artifacts.getType() == null) {+ throw new AwsException("InvalidInputException", "artifacts.type is required", 400);+ }++ double now = Instant.now().toEpochMilli() / 1000.0;+ Project project = new Project();+ project.setName(name);+ project.setArn("arn:aws:codebuild:" + region + ":" + account + ":project/" + name);+ project.setDescription(description);+ project.setSource(source);+ project.setSecondarySources(secondarySources);+ project.setSourceVersion(sourceVersion);+ project.setArtifacts(artifacts);+ project.setSecondaryArtifacts(secondaryArtifacts);+ project.setEnvironment(environment);+ project.setServiceRole(serviceRole);+ project.setTimeoutInMinutes(timeoutInMinutes != null ? timeoutInMinutes : 60);+ project.setQueuedTimeoutInMinutes(queuedTimeoutInMinutes != null ? queuedTimeoutInMinutes : 480);+ project.setEncryptionKey(encryptionKey);+ project.setTags(tags);+ project.setCreated(now);+ project.setLastModified(now);+ project.setLogsConfig(logsConfig);+ project.setVpcConfig(vpcConfig);+ project.setConcurrentBuildLimit(concurrentBuildLimit);+ project.setProjectVisibility("PRIVATE");++ store.put(name, project);+ return project;+ }++ public Project updateProject(String region, String name,+ String description,+ ProjectSource source, List<ProjectSource> secondarySources,+ String sourceVersion,+ ProjectArtifacts artifacts, List<ProjectArtifacts> secondaryArtifacts,+ ProjectEnvironment environment,+ String serviceRole,+ Integer timeoutInMinutes, Integer queuedTimeoutInMinutes,+ String encryptionKey,+ List<Map<String, String>> tags,+ Map<String, Object> logsConfig,+ Map<String, Object> vpcConfig,+ Integer concurrentBuildLimit) {+ Map<String, Project> store = projectsFor(region);+ Project project = store.get(name);+ if (project == null) {+ throw new AwsException("ResourceNotFoundException", "Project not found: " + name, 400);+ }++ if (description != null) { project.setDescription(description); }+ if (source != null) { project.setSource(source); }+ if (secondarySources != null) { project.setSecondarySources(secondarySources); }+ if (sourceVersion != null) { project.setSourceVersion(sourceVersion); }+ if (artifacts != null) { project.setArtifacts(artifacts); }+ if (secondaryArtifacts != null) { project.setSecondaryArtifacts(secondaryArtifacts); }+ if (environment != null) { project.setEnvironment(environment); }+ if (serviceRole != null) { project.setServiceRole(serviceRole); }+ if (timeoutInMinutes != null) { project.setTimeoutInMinutes(timeoutInMinutes); }+ if (queuedTimeoutInMinutes != null) { project.setQueuedTimeoutInMinutes(queuedTimeoutInMinutes); }+ if (encryptionKey != null) { project.setEncryptionKey(encryptionKey); }+ if (tags != null) { project.setTags(tags); }+ if (logsConfig != null) { project.setLogsConfig(logsConfig); }+ if (vpcConfig != null) { project.setVpcConfig(vpcConfig); }+ if (concurrentBuildLimit != null) { project.setConcurrentBuildLimit(concurrentBuildLimit); }+ project.setLastModified(Instant.now().toEpochMilli() / 1000.0);++ return project;+ }++ public void deleteProject(String region, String name) {+ Map<String, Project> store = projectsFor(region);+ if (store.remove(name) == null) {+ throw new AwsException("ResourceNotFoundException", "Project not found: " + name, 400);+ }+ }++ public List<Project> batchGetProjects(String region, List<String> names) {+ Map<String, Project> store = projectsFor(region);+ return names.stream()+ .map(store::get)+ .filter(p -> p != null)+ .collect(Collectors.toList());+ }++ public List<String> listProjects(String region) {+ return new ArrayList<>(projectsFor(region).keySet());+ }++ // ---- Report Groups ----++ public ReportGroup createReportGroup(String region, String account,+ String name, String type,+ Map<String, Object> exportConfig,+ List<Map<String, String>> tags) {+ Map<String, ReportGroup> store = reportGroupsFor(region);+ String arn = "arn:aws:codebuild:" + region + ":" + account + ":report-group/" + name;+ if (store.containsKey(arn)) {+ throw new AwsException("ResourceAlreadyExistsException",+ "Report group already exists: " + name, 400);+ }+ if (name == null || name.isBlank()) {+ throw new AwsException("InvalidInputException", "name is required", 400);+ }+ if (type == null) {+ throw new AwsException("InvalidInputException", "type is required", 400);+ }++ double now = Instant.now().toEpochMilli() / 1000.0;+ ReportGroup rg = new ReportGroup();+ rg.setArn(arn);+ rg.setName(name);+ rg.setType(type);+ rg.setExportConfig(exportConfig);+ rg.setCreated(now);+ rg.setLastModified(now);+ rg.setTags(tags);+ rg.setStatus("ACTIVE");++ store.put(arn, rg);+ return rg;+ }++ public ReportGroup updateReportGroup(String region, String arn,+ Map<String, Object> exportConfig,+ List<Map<String, String>> tags) {+ Map<String, ReportGroup> store = reportGroupsFor(region);+ ReportGroup rg = store.get(arn);+ if (rg == null) {+ throw new AwsException("ResourceNotFoundException", "Report group not found: " + arn, 400);+ }+ if (exportConfig != null) { rg.setExportConfig(exportConfig); }+ if (tags != null) { rg.setTags(tags); }+ rg.setLastModified(Instant.now().toEpochMilli() / 1000.0);+ return rg;+ }++ public void deleteReportGroup(String region, String arn) {+ Map<String, ReportGroup> store = reportGroupsFor(region);+ if (store.remove(arn) == null) {+ throw new AwsException("ResourceNotFoundException", "Report group not found: " + arn, 400);+ }+ }++ public List<ReportGroup> batchGetReportGroups(String region, List<String> arns) {+ Map<String, ReportGroup> store = reportGroupsFor(region);+ return arns.stream()+ .map(store::get)+ .filter(rg -> rg != null)+ .collect(Collectors.toList());+ }++ public List<String> listReportGroups(String region) {+ return new ArrayList<>(reportGroupsFor(region).keySet());+ }++ // ---- Source Credentials ----++ public SourceCredential importSourceCredentials(String region, String account,+ String token, String serverType, String authType,+ Boolean shouldOverwrite) {+ Map<String, SourceCredential> store = sourceCredentialsFor(region);+ // One credential per serverType+authType combo — overwrite existing by default+ String key = serverType + "/" + authType;+ SourceCredential existing = store.values().stream()+ .filter(c -> c.getServerType().equals(serverType) && c.getAuthType().equals(authType))+ .findFirst().orElse(null);+ if (existing != null && Boolean.FALSE.equals(shouldOverwrite)) {+ throw new AwsException("ResourceAlreadyExistsException",+ "Source credentials already exist for " + serverType + "/" + authType, 400);+ }++ String arn = "arn:aws:codebuild:" + region + ":" + account + ":token/" + serverType.toLowerCase() + "-" + UUID.randomUUID();+ if (existing != null) {+ arn = existing.getArn();+ store.remove(existing.getArn());+ }++ SourceCredential cred = new SourceCredential();+ cred.setArn(arn);+ cred.setServerType(serverType);+ cred.setAuthType(authType);+ // Token is accepted but not stored in plaintext in a returned field+ store.put(arn, cred);+ return cred;+ }++ public List<SourceCredential> listSourceCredentials(String region) {+ return new ArrayList<>(sourceCredentialsFor(region).values());+ }++ public void deleteSourceCredentials(String region, String arn) {+ Map<String, SourceCredential> store = sourceCredentialsFor(region);+ if (store.remove(arn) == null) {+ throw new AwsException("ResourceNotFoundException",+ "Source credentials not found: " + arn, 400);+ }+ }++ // ---- Curated Environment Images ----++ public List<Map<String, Object>> listCuratedEnvironmentImages() {+ // Return the standard CodeBuild curated platform/language/image list+ return List.of(+ Map.of("platform", "AMAZON_LINUX_2",+ "languages", List.of(+ Map.of("language", "JAVA",+ "images", List.of(+ Map.of("name", "aws/codebuild/amazonlinux2-x86_64-standard:5.0",+ "description", "AWS CodeBuild - amazonlinux2 - 5.0",+ "versions", List.of("aws/codebuild/amazonlinux2-x86_64-standard:5.0")))),+ Map.of("language", "PYTHON",+ "images", List.of(+ Map.of("name", "aws/codebuild/amazonlinux2-x86_64-standard:5.0",+ "description", "AWS CodeBuild - amazonlinux2 - 5.0",+ "versions", List.of("aws/codebuild/amazonlinux2-x86_64-standard:5.0")))),+ Map.of("language", "NODE_JS",+ "images", List.of(+ Map.of("name", "aws/codebuild/amazonlinux2-x86_64-standard:5.0",+ "description", "AWS CodeBuild - amazonlinux2 - 5.0",+ "versions", List.of("aws/codebuild/amazonlinux2-x86_64-standard:5.0")))))),+ Map.of("platform", "UBUNTU",+ "languages", List.of(+ Map.of("language", "JAVA",+ "images", List.of(+ Map.of("name", "aws/codebuild/standard:7.0",+ "description", "AWS CodeBuild - Ubuntu - 7.0",+ "versions", List.of("aws/codebuild/standard:7.0")))),+ Map.of("language", "PYTHON",+ "images", List.of(+ Map.of("name", "aws/codebuild/standard:7.0",+ "description", "AWS CodeBuild - Ubuntu - 7.0",+ "versions", List.of("aws/codebuild/standard:7.0")))),+ Map.of("language", "NODE_JS",+ "images", List.of(+ Map.of("name", "aws/codebuild/standard:7.0",+ "description", "AWS CodeBuild - Ubuntu - 7.0",+ "versions", List.of("aws/codebuild/standard:7.0")))))));+ }++ private void validateProjectName(String name) {+ if (name == null || name.length() < 2 || name.length() > 150) {+ throw new AwsException("InvalidInputException",+ "Project name must be between 2 and 150 characters", 400);+ }+ }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/model/Project.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/Project.javanew file mode 100644index 0000000000..3bdcc81e08--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/Project.java@@ -0,0 +1,94 @@+package io.github.hectorvent.floci.services.codebuild.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++import java.util.List;+import java.util.Map;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class Project {+ public Project() {}++ private String name;+ private String arn;+ private String description;+ private ProjectSource source;+ private List<ProjectSource> secondarySources;+ private String sourceVersion;+ private ProjectArtifacts artifacts;+ private List<ProjectArtifacts> secondaryArtifacts;+ private ProjectEnvironment environment;+ private String serviceRole;+ private Integer timeoutInMinutes;+ private Integer queuedTimeoutInMinutes;+ private String encryptionKey;+ private List<Map<String, String>> tags;+ private Double created;+ private Double lastModified;+ private Map<String, Object> logsConfig;+ private Map<String, Object> vpcConfig;+ private Integer concurrentBuildLimit;+ private String projectVisibility;++ public String getName() { return name; }+ public void setName(String name) { this.name = name; }++ public String getArn() { return arn; }+ public void setArn(String arn) { this.arn = arn; }++ public String getDescription() { return description; }+ public void setDescription(String description) { this.description = description; }++ public ProjectSource getSource() { return source; }+ public void setSource(ProjectSource source) { this.source = source; }++ public List<ProjectSource> getSecondarySources() { return secondarySources; }+ public void setSecondarySources(List<ProjectSource> secondarySources) { this.secondarySources = secondarySources; }++ public String getSourceVersion() { return sourceVersion; }+ public void setSourceVersion(String sourceVersion) { this.sourceVersion = sourceVersion; }++ public ProjectArtifacts getArtifacts() { return artifacts; }+ public void setArtifacts(ProjectArtifacts artifacts) { this.artifacts = artifacts; }++ public List<ProjectArtifacts> getSecondaryArtifacts() { return secondaryArtifacts; }+ public void setSecondaryArtifacts(List<ProjectArtifacts> secondaryArtifacts) { this.secondaryArtifacts = secondaryArtifacts; }++ public ProjectEnvironment getEnvironment() { return environment; }+ public void setEnvironment(ProjectEnvironment environment) { this.environment = environment; }++ public String getServiceRole() { return serviceRole; }+ public void setServiceRole(String serviceRole) { this.serviceRole = serviceRole; }++ public Integer getTimeoutInMinutes() { return timeoutInMinutes; }+ public void setTimeoutInMinutes(Integer timeoutInMinutes) { this.timeoutInMinutes = timeoutInMinutes; }++ public Integer getQueuedTimeoutInMinutes() { return queuedTimeoutInMinutes; }+ public void setQueuedTimeoutInMinutes(Integer queuedTimeoutInMinutes) { this.queuedTimeoutInMinutes = queuedTimeoutInMinutes; }++ public String getEncryptionKey() { return encryptionKey; }+ public void setEncryptionKey(String encryptionKey) { this.encryptionKey = encryptionKey; }++ public List<Map<String, String>> getTags() { return tags; }+ public void setTags(List<Map<String, String>> tags) { this.tags = tags; }++ public Double getCreated() { return created; }+ public void setCreated(Double created) { this.created = created; }++ public Double getLastModified() { return lastModified; }+ public void setLastModified(Double lastModified) { this.lastModified = lastModified; }++ public Map<String, Object> getLogsConfig() { return logsConfig; }+ public void setLogsConfig(Map<String, Object> logsConfig) { this.logsConfig = logsConfig; }++ public Map<String, Object> getVpcConfig() { return vpcConfig; }+ public void setVpcConfig(Map<String, Object> vpcConfig) { this.vpcConfig = vpcConfig; }++ public Integer getConcurrentBuildLimit() { return concurrentBuildLimit; }+ public void setConcurrentBuildLimit(Integer concurrentBuildLimit) { this.concurrentBuildLimit = concurrentBuildLimit; }++ public String getProjectVisibility() { return projectVisibility; }+ public void setProjectVisibility(String projectVisibility) { this.projectVisibility = projectVisibility; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectArtifacts.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectArtifacts.javanew file mode 100644index 0000000000..91c26444d1--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectArtifacts.java@@ -0,0 +1,47 @@+package io.github.hectorvent.floci.services.codebuild.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class ProjectArtifacts {+ public ProjectArtifacts() {}++ private String type;+ private String location;+ private String path;+ private String namespaceType;+ private String name;+ private String packaging;+ private Boolean overrideArtifactName;+ private Boolean encryptionDisabled;+ private String artifactIdentifier;++ public String getType() { return type; }+ public void setType(String type) { this.type = type; }++ public String getLocation() { return location; }+ public void setLocation(String location) { this.location = location; }++ public String getPath() { return path; }+ public void setPath(String path) { this.path = path; }++ public String getNamespaceType() { return namespaceType; }+ public void setNamespaceType(String namespaceType) { this.namespaceType = namespaceType; }++ public String getName() { return name; }+ public void setName(String name) { this.name = name; }++ public String getPackaging() { return packaging; }+ public void setPackaging(String packaging) { this.packaging = packaging; }++ public Boolean getOverrideArtifactName() { return overrideArtifactName; }+ public void setOverrideArtifactName(Boolean overrideArtifactName) { this.overrideArtifactName = overrideArtifactName; }++ public Boolean getEncryptionDisabled() { return encryptionDisabled; }+ public void setEncryptionDisabled(Boolean encryptionDisabled) { this.encryptionDisabled = encryptionDisabled; }++ public String getArtifactIdentifier() { return artifactIdentifier; }+ public void setArtifactIdentifier(String artifactIdentifier) { this.artifactIdentifier = artifactIdentifier; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectEnvironment.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectEnvironment.javanew file mode 100644index 0000000000..6d0ab1e22b--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectEnvironment.java@@ -0,0 +1,42 @@+package io.github.hectorvent.floci.services.codebuild.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++import java.util.List;+import java.util.Map;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class ProjectEnvironment {+ public ProjectEnvironment() {}++ private String type;+ private String image;+ private String computeType;+ private List<Map<String, String>> environmentVariables;+ private Boolean privilegedMode;+ private String certificate;+ private String imagePullCredentialsType;++ public String getType() { return type; }+ public void setType(String type) { this.type = type; }++ public String getImage() { return image; }+ public void setImage(String image) { this.image = image; }++ public String getComputeType() { return computeType; }+ public void setComputeType(String computeType) { this.computeType = computeType; }++ public List<Map<String, String>> getEnvironmentVariables() { return environmentVariables; }+ public void setEnvironmentVariables(List<Map<String, String>> environmentVariables) { this.environmentVariables = environmentVariables; }++ public Boolean getPrivilegedMode() { return privilegedMode; }+ public void setPrivilegedMode(Boolean privilegedMode) { this.privilegedMode = privilegedMode; }++ public String getCertificate() { return certificate; }+ public void setCertificate(String certificate) { this.certificate = certificate; }++ public String getImagePullCredentialsType() { return imagePullCredentialsType; }+ public void setImagePullCredentialsType(String imagePullCredentialsType) { this.imagePullCredentialsType = imagePullCredentialsType; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectSource.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectSource.javanew file mode 100644index 0000000000..00cfc7ac4b--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ProjectSource.java@@ -0,0 +1,39 @@+package io.github.hectorvent.floci.services.codebuild.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class ProjectSource {+ public ProjectSource() {}++ private String type;+ private String location;+ private Integer gitCloneDepth;+ private String buildspec;+ private Boolean reportBuildStatus;+ private Boolean insecureSsl;+ private String sourceIdentifier;++ public String getType() { return type; }+ public void setType(String type) { this.type = type; }++ public String getLocation() { return location; }+ public void setLocation(String location) { this.location = location; }++ public Integer getGitCloneDepth() { return gitCloneDepth; }+ public void setGitCloneDepth(Integer gitCloneDepth) { this.gitCloneDepth = gitCloneDepth; }++ public String getBuildspec() { return buildspec; }+ public void setBuildspec(String buildspec) { this.buildspec = buildspec; }++ public Boolean getReportBuildStatus() { return reportBuildStatus; }+ public void setReportBuildStatus(Boolean reportBuildStatus) { this.reportBuildStatus = reportBuildStatus; }++ public Boolean getInsecureSsl() { return insecureSsl; }+ public void setInsecureSsl(Boolean insecureSsl) { this.insecureSsl = insecureSsl; }++ public String getSourceIdentifier() { return sourceIdentifier; }+ public void setSourceIdentifier(String sourceIdentifier) { this.sourceIdentifier = sourceIdentifier; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ReportGroup.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ReportGroup.javanew file mode 100644index 0000000000..bc46dad22f--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/ReportGroup.java@@ -0,0 +1,46 @@+package io.github.hectorvent.floci.services.codebuild.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++import java.util.List;+import java.util.Map;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class ReportGroup {+ public ReportGroup() {}++ private String arn;+ private String name;+ private String type;+ private Map<String, Object> exportConfig;+ private Double created;+ private Double lastModified;+ private List<Map<String, String>> tags;+ private String status;++ public String getArn() { return arn; }+ public void setArn(String arn) { this.arn = arn; }++ public String getName() { return name; }+ public void setName(String name) { this.name = name; }++ public String getType() { return type; }+ public void setType(String type) { this.type = type; }++ public Map<String, Object> getExportConfig() { return exportConfig; }+ public void setExportConfig(Map<String, Object> exportConfig) { this.exportConfig = exportConfig; }++ public Double getCreated() { return created; }+ public void setCreated(Double created) { this.created = created; }++ public Double getLastModified() { return lastModified; }+ public void setLastModified(Double lastModified) { this.lastModified = lastModified; }++ public List<Map<String, String>> getTags() { return tags; }+ public void setTags(List<Map<String, String>> tags) { this.tags = tags; }++ public String getStatus() { return status; }+ public void setStatus(String status) { this.status = status; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codebuild/model/SourceCredential.java b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/SourceCredential.javanew file mode 100644index 0000000000..a413a43ac0--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codebuild/model/SourceCredential.java@@ -0,0 +1,27 @@+package io.github.hectorvent.floci.services.codebuild.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class SourceCredential {+ public SourceCredential() {}++ private String arn;+ private String serverType;+ private String authType;+ private String token;++ public String getArn() { return arn; }+ public void setArn(String arn) { this.arn = arn; }++ public String getServerType() { return serverType; }+ public void setServerType(String serverType) { this.serverType = serverType; }++ public String getAuthType() { return authType; }+ public void setAuthType(String authType) { this.authType = authType; }++ public String getToken() { return token; }+ public void setToken(String token) { this.token = token; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployJsonHandler.javanew file mode 100644index 0000000000..0c7c220587--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployJsonHandler.java@@ -0,0 +1,233 @@+package io.github.hectorvent.floci.services.codedeploy;++import com.fasterxml.jackson.databind.JsonNode;+import com.fasterxml.jackson.databind.ObjectMapper;+import io.github.hectorvent.floci.core.common.AwsException;+import io.github.hectorvent.floci.services.codedeploy.model.Application;+import io.github.hectorvent.floci.services.codedeploy.model.DeploymentConfig;+import io.github.hectorvent.floci.services.codedeploy.model.DeploymentGroup;+import jakarta.enterprise.context.ApplicationScoped;+import jakarta.inject.Inject;+import jakarta.ws.rs.core.Response;++import java.util.ArrayList;+import java.util.HashMap;+import java.util.List;+import java.util.Map;++@ApplicationScoped+public class CodeDeployJsonHandler {++ private final CodeDeployService service;+ private final ObjectMapper mapper;++ @Inject+ public CodeDeployJsonHandler(CodeDeployService service, ObjectMapper mapper) {+ this.service = service;+ this.mapper = mapper;+ }++ public Response handle(String action, JsonNode request, String region) throws Exception {+ return switch (action) {+ case "CreateApplication" -> createApplication(request, region);+ case "GetApplication" -> getApplication(request, region);+ case "UpdateApplication" -> updateApplication(request, region);+ case "DeleteApplication" -> deleteApplication(request, region);+ case "ListApplications" -> listApplications(region);+ case "BatchGetApplications" -> batchGetApplications(request, region);+ case "CreateDeploymentGroup" -> createDeploymentGroup(request, region);+ case "GetDeploymentGroup" -> getDeploymentGroup(request, region);+ case "UpdateDeploymentGroup" -> updateDeploymentGroup(request, region);+ case "DeleteDeploymentGroup" -> deleteDeploymentGroup(request, region);+ case "ListDeploymentGroups" -> listDeploymentGroups(request, region);+ case "BatchGetDeploymentGroups" -> batchGetDeploymentGroups(request, region);+ case "CreateDeploymentConfig" -> createDeploymentConfig(request, region);+ case "GetDeploymentConfig" -> getDeploymentConfig(request, region);+ case "DeleteDeploymentConfig" -> deleteDeploymentConfig(request, region);+ case "ListDeploymentConfigs" -> listDeploymentConfigs(region);+ case "TagResource" -> tagResource(request);+ case "UntagResource" -> untagResource(request);+ case "ListTagsForResource" -> listTagsForResource(request);+ case "AddTagsToOnPremisesInstances", "RemoveTagsFromOnPremisesInstances" ->+ Response.ok(Map.of()).build();+ default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);+ };+ }++ private Response createApplication(JsonNode req, String region) {+ String name = req.path("applicationName").asText(null);+ String computePlatform = req.has("computePlatform") ? req.path("computePlatform").asText() : null;+ List<Map<String, String>> tags = parseTags(req, "tags");+ Application app = service.createApplication(region, name, computePlatform, tags);+ return Response.ok(Map.of("applicationId", app.getApplicationId())).build();+ }++ private Response getApplication(JsonNode req, String region) {+ String name = req.path("applicationName").asText(null);+ Application app = service.getApplication(region, name);+ return Response.ok(Map.of("application", app)).build();+ }++ private Response updateApplication(JsonNode req, String region) {+ String currentName = req.path("applicationName").asText(null);+ String newName = req.has("newApplicationName") ? req.path("newApplicationName").asText() : null;+ service.updateApplication(region, currentName, newName);+ return Response.ok(Map.of()).build();+ }++ private Response deleteApplication(JsonNode req, String region) {+ String name = req.path("applicationName").asText(null);+ service.deleteApplication(region, name);+ return Response.ok(Map.of()).build();+ }++ private Response listApplications(String region) {+ return Response.ok(Map.of("applications", service.listApplications(region))).build();+ }++ private Response batchGetApplications(JsonNode req, String region) {+ List<String> names = new ArrayList<>();+ req.path("applicationNames").forEach(n -> names.add(n.asText()));+ List<Application> apps = service.batchGetApplications(region, names);+ return Response.ok(Map.of("applicationsInfo", apps)).build();+ }++ private Response createDeploymentGroup(JsonNode req, String region) throws Exception {+ String appName = req.path("applicationName").asText(null);+ String groupName = req.path("deploymentGroupName").asText(null);+ String deploymentConfigName = req.has("deploymentConfigName") ? req.path("deploymentConfigName").asText() : null;+ String serviceRoleArn = req.has("serviceRoleArn") ? req.path("serviceRoleArn").asText() : null;+ Map<String, Object> fields = extractGroupFields(req);+ DeploymentGroup group = service.createDeploymentGroup(region, appName, groupName,+ deploymentConfigName, serviceRoleArn, fields);+ return Response.ok(Map.of("deploymentGroupId", group.getDeploymentGroupId())).build();+ }++ private Response getDeploymentGroup(JsonNode req, String region) {+ String appName = req.path("applicationName").asText(null);+ String groupName = req.path("deploymentGroupName").asText(null);+ DeploymentGroup group = service.getDeploymentGroup(region, appName, groupName);+ return Response.ok(Map.of("deploymentGroupInfo", group)).build();+ }++ private Response updateDeploymentGroup(JsonNode req, String region) throws Exception {+ String appName = req.path("applicationName").asText(null);+ String currentGroupName = req.path("currentDeploymentGroupName").asText(null);+ String newGroupName = req.has("newDeploymentGroupName") ? req.path("newDeploymentGroupName").asText() : null;+ String deploymentConfigName = req.has("deploymentConfigName") ? req.path("deploymentConfigName").asText() : null;+ String serviceRoleArn = req.has("serviceRoleArn") ? req.path("serviceRoleArn").asText() : null;+ Map<String, Object> fields = extractGroupFields(req);+ DeploymentGroup group = service.updateDeploymentGroup(region, appName, currentGroupName, newGroupName,+ deploymentConfigName, serviceRoleArn, fields);+ return Response.ok(Map.of()).build();+ }++ private Response deleteDeploymentGroup(JsonNode req, String region) {+ String appName = req.path("applicationName").asText(null);+ String groupName = req.path("deploymentGroupName").asText(null);+ service.deleteDeploymentGroup(region, appName, groupName);+ return Response.ok(Map.of("hooksNotCleanedUp", List.of())).build();+ }++ private Response listDeploymentGroups(JsonNode req, String region) {+ String appName = req.path("applicationName").asText(null);+ List<String> groups = service.listDeploymentGroups(region, appName);+ return Response.ok(Map.of("applicationName", appName, "deploymentGroups", groups)).build();+ }++ private Response batchGetDeploymentGroups(JsonNode req, String region) {+ String appName = req.path("applicationName").asText(null);+ List<String> names = new ArrayList<>();+ req.path("deploymentGroupNames").forEach(n -> names.add(n.asText()));+ List<DeploymentGroup> found = service.batchGetDeploymentGroups(region, appName, names);+ List<String> foundNames = found.stream().map(DeploymentGroup::getDeploymentGroupName).toList();+ List<String> notFound = names.stream().filter(n -> !foundNames.contains(n)).toList();+ return Response.ok(Map.of("deploymentGroupsInfo", found, "errorMessage", "")).build();+ }++ private Response createDeploymentConfig(JsonNode req, String region) throws Exception {+ String name = req.path("deploymentConfigName").asText(null);+ Map<String, Object> minimumHealthyHosts = req.has("minimumHealthyHosts")+ ? mapper.treeToValue(req.get("minimumHealthyHosts"), Map.class) : null;+ String computePlatform = req.has("computePlatform") ? req.path("computePlatform").asText() : null;+ Map<String, Object> trafficRoutingConfig = req.has("trafficRoutingConfig")+ ? mapper.treeToValue(req.get("trafficRoutingConfig"), Map.class) : null;+ Map<String, Object> zonalConfig = req.has("zonalConfig")+ ? mapper.treeToValue(req.get("zonalConfig"), Map.class) : null;+ DeploymentConfig cfg = service.createDeploymentConfig(region, name, minimumHealthyHosts,+ computePlatform, trafficRoutingConfig, zonalConfig);+ return Response.ok(Map.of("deploymentConfigId", cfg.getDeploymentConfigId())).build();+ }++ private Response getDeploymentConfig(JsonNode req, String region) {+ String name = req.path("deploymentConfigName").asText(null);+ DeploymentConfig cfg = service.getDeploymentConfig(region, name);+ return Response.ok(Map.of("deploymentConfigInfo", cfg)).build();+ }++ private Response deleteDeploymentConfig(JsonNode req, String region) {+ String name = req.path("deploymentConfigName").asText(null);+ service.deleteDeploymentConfig(region, name);+ return Response.ok(Map.of()).build();+ }++ private Response listDeploymentConfigs(String region) {+ return Response.ok(Map.of("deploymentConfigsList", service.listDeploymentConfigs(region))).build();+ }++ private Response tagResource(JsonNode req) {+ String arn = req.path("ResourceArn").asText(null);+ List<Map<String, String>> tags = parseTags(req, "Tags");+ service.tagResource(arn, tags);+ return Response.ok(Map.of()).build();+ }++ private Response untagResource(JsonNode req) {+ String arn = req.path("ResourceArn").asText(null);+ List<String> keys = new ArrayList<>();+ req.path("TagKeys").forEach(k -> keys.add(k.asText()));+ service.untagResource(arn, keys);+ return Response.ok(Map.of()).build();+ }++ private Response listTagsForResource(JsonNode req) {+ String arn = req.path("ResourceArn").asText(null);+ List<Map<String, String>> tags = service.listTagsForResource(arn);+ return Response.ok(Map.of("Tags", tags)).build();+ }++ @SuppressWarnings("unchecked")+ private Map<String, Object> extractGroupFields(JsonNode req) throws Exception {+ Map<String, Object> fields = new HashMap<>();+ for (String field : new String[]{"ec2TagFilters", "onPremisesInstanceTagFilters", "autoScalingGroups",+ "deploymentStyle", "blueGreenDeploymentConfiguration", "loadBalancerInfo",+ "ec2TagSet", "onPremisesTagSet", "alarmConfiguration", "autoRollbackConfiguration",+ "triggerConfigurations", "ecsServices", "computePlatform",+ "outdatedInstancesStrategy", "terminationHookEnabled"}) {+ if (req.has(field)) {+ fields.put(field, mapper.treeToValue(req.get(field), Object.class));+ }+ }+ return fields;+ }++ private List<Map<String, String>> parseTags(JsonNode req, String fieldName) {+ if (!req.has(fieldName) || req.get(fieldName).isNull()) {+ return List.of();+ }+ List<Map<String, String>> result = new ArrayList<>();+ for (JsonNode tag : req.get(fieldName)) {+ Map<String, String> t = new HashMap<>();+ // Support both capitalizations (Tags uses Key/Value, tags uses key/value)+ if (tag.has("Key")) {+ t.put("Key", tag.path("Key").asText());+ t.put("Value", tag.path("Value").asText());+ } else {+ t.put("Key", tag.path("key").asText());+ t.put("Value", tag.path("value").asText());+ }+ result.add(t);+ }+ return result;+ }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployService.java b/src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployService.javanew file mode 100644index 0000000000..9ae9459b2c--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployService.java@@ -0,0 +1,427 @@+package io.github.hectorvent.floci.services.codedeploy;++import io.github.hectorvent.floci.core.common.AwsException;+import io.github.hectorvent.floci.services.codedeploy.model.Application;+import io.github.hectorvent.floci.services.codedeploy.model.DeploymentConfig;+import io.github.hectorvent.floci.services.codedeploy.model.DeploymentGroup;+import jakarta.enterprise.context.ApplicationScoped;++import java.time.Instant;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.List;+import java.util.Map;+import java.util.UUID;+import java.util.concurrent.ConcurrentHashMap;+import java.util.stream.Collectors;++@ApplicationScoped+public class CodeDeployService {++ // key: region -> name -> application+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, Application>> applications = new ConcurrentHashMap<>();+ // key: region -> appName -> groupName -> group+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<String, DeploymentGroup>>> deploymentGroups = new ConcurrentHashMap<>();+ // key: region -> configName -> config (pre-seeded with built-ins)+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, DeploymentConfig>> deploymentConfigs = new ConcurrentHashMap<>();+ // key: resourceArn -> tags+ private final ConcurrentHashMap<String, Map<String, String>> tags = new ConcurrentHashMap<>();++ private static final List<String> BUILT_IN_CONFIG_NAMES = List.of(+ "CodeDeployDefault.OneAtATime",+ "CodeDeployDefault.HalfAtATime",+ "CodeDeployDefault.AllAtOnce",+ "CodeDeployDefault.LambdaAllAtOnce",+ "CodeDeployDefault.LambdaCanary10Percent5Minutes",+ "CodeDeployDefault.LambdaCanary10Percent10Minutes",+ "CodeDeployDefault.LambdaCanary10Percent15Minutes",+ "CodeDeployDefault.LambdaCanary10Percent30Minutes",+ "CodeDeployDefault.LambdaLinear10PercentEvery1Minute",+ "CodeDeployDefault.LambdaLinear10PercentEvery2Minutes",+ "CodeDeployDefault.LambdaLinear10PercentEvery3Minutes",+ "CodeDeployDefault.LambdaLinear10PercentEvery10Minutes",+ "CodeDeployDefault.ECSAllAtOnce",+ "CodeDeployDefault.ECSCanary10Percent5Minutes",+ "CodeDeployDefault.ECSCanary10Percent15Minutes",+ "CodeDeployDefault.ECSLinear10PercentEvery1Minutes",+ "CodeDeployDefault.ECSLinear10PercentEvery3Minutes"+ );++ private Map<String, Application> applicationsFor(String region) {+ return applications.computeIfAbsent(region, r -> new ConcurrentHashMap<>());+ }++ private Map<String, ConcurrentHashMap<String, DeploymentGroup>> deploymentGroupsFor(String region) {+ return deploymentGroups.computeIfAbsent(region, r -> new ConcurrentHashMap<>());+ }++ private Map<String, DeploymentConfig> deploymentConfigsFor(String region) {+ return deploymentConfigs.computeIfAbsent(region, r -> {+ ConcurrentHashMap<String, DeploymentConfig> store = new ConcurrentHashMap<>();+ double now = Instant.now().toEpochMilli() / 1000.0;+ for (String name : BUILT_IN_CONFIG_NAMES) {+ store.put(name, buildBuiltInConfig(name, now));+ }+ return store;+ });+ }++ private DeploymentConfig buildBuiltInConfig(String name, double now) {+ DeploymentConfig cfg = new DeploymentConfig();+ cfg.setDeploymentConfigId("d-" + UUID.randomUUID().toString().replace("-", "").substring(0, 10).toUpperCase());+ cfg.setDeploymentConfigName(name);+ cfg.setCreateTime(now);++ if (name.startsWith("CodeDeployDefault.Lambda")) {+ cfg.setComputePlatform("Lambda");+ if (name.equals("CodeDeployDefault.LambdaAllAtOnce")) {+ cfg.setTrafficRoutingConfig(Map.of("type", "AllAtOnce"));+ } else if (name.contains("Canary")) {+ int pct = 10;+ int minutes = extractMinutes(name);+ cfg.setTrafficRoutingConfig(Map.of("type", "TimeBasedCanary",+ "timeBasedCanary", Map.of("canaryPercentage", pct, "canaryInterval", minutes)));+ } else if (name.contains("Linear")) {+ int pct = 10;+ int minutes = extractMinutes(name);+ cfg.setTrafficRoutingConfig(Map.of("type", "TimeBasedLinear",+ "timeBasedLinear", Map.of("linearPercentage", pct, "linearInterval", minutes)));+ }+ } else if (name.startsWith("CodeDeployDefault.ECS")) {+ cfg.setComputePlatform("ECS");+ if (name.equals("CodeDeployDefault.ECSAllAtOnce")) {+ cfg.setTrafficRoutingConfig(Map.of("type", "AllAtOnce"));+ } else if (name.contains("Canary")) {+ int pct = 10;+ int minutes = extractMinutes(name);+ cfg.setTrafficRoutingConfig(Map.of("type", "TimeBasedCanary",+ "timeBasedCanary", Map.of("canaryPercentage", pct, "canaryInterval", minutes)));+ } else if (name.contains("Linear")) {+ int pct = 10;+ int minutes = extractMinutes(name);+ cfg.setTrafficRoutingConfig(Map.of("type", "TimeBasedLinear",+ "timeBasedLinear", Map.of("linearPercentage", pct, "linearInterval", minutes)));+ }+ } else {+ cfg.setComputePlatform("Server");+ if (name.equals("CodeDeployDefault.AllAtOnce")) {+ cfg.setMinimumHealthyHosts(Map.of("type", "FLEET_PERCENT", "value", 0));+ } else if (name.equals("CodeDeployDefault.HalfAtATime")) {+ cfg.setMinimumHealthyHosts(Map.of("type", "FLEET_PERCENT", "value", 50));+ } else {+ cfg.setMinimumHealthyHosts(Map.of("type", "HOST_COUNT", "value", 1));+ }+ }+ return cfg;+ }++ private int extractMinutes(String name) {+ // e.g. "…Every1Minute" -> 1, "…5Minutes" -> 5+ java.util.regex.Matcher m = java.util.regex.Pattern.compile("(\\d+)Minute").matcher(name);+ return m.find() ? Integer.parseInt(m.group(1)) : 1;+ }++ // ---- Applications ----++ public Application createApplication(String region, String name, String computePlatform,+ List<Map<String, String>> tags) {+ Map<String, Application> store = applicationsFor(region);+ if (store.containsKey(name)) {+ throw new AwsException("ApplicationAlreadyExistsException",+ "Application already exists: " + name, 400);+ }+ Application app = new Application();+ app.setApplicationId(UUID.randomUUID().toString());+ app.setApplicationName(name);+ app.setCreateTime(Instant.now().toEpochMilli() / 1000.0);+ app.setLinkedToGitHub(false);+ app.setComputePlatform(computePlatform != null ? computePlatform : "Server");+ store.put(name, app);++ if (tags != null && !tags.isEmpty()) {+ String arn = applicationArn(region, name);+ applyTags(arn, tags);+ }+ return app;+ }++ public Application getApplication(String region, String name) {+ Application app = applicationsFor(region).get(name);+ if (app == null) {+ throw new AwsException("ApplicationDoesNotExistException",+ "Application does not exist: " + name, 400);+ }+ return app;+ }++ public void updateApplication(String region, String currentName, String newName) {+ Map<String, Application> store = applicationsFor(region);+ Application app = store.get(currentName);+ if (app == null) {+ throw new AwsException("ApplicationDoesNotExistException",+ "Application does not exist: " + currentName, 400);+ }+ if (newName != null && !newName.equals(currentName)) {+ if (store.containsKey(newName)) {+ throw new AwsException("ApplicationAlreadyExistsException",+ "Application already exists: " + newName, 400);+ }+ store.remove(currentName);+ app.setApplicationName(newName);+ store.put(newName, app);+ }+ }++ public void deleteApplication(String region, String name) {+ if (applicationsFor(region).remove(name) == null) {+ throw new AwsException("ApplicationDoesNotExistException",+ "Application does not exist: " + name, 400);+ }+ }++ public List<String> listApplications(String region) {+ return new ArrayList<>(applicationsFor(region).keySet());+ }++ public List<Application> batchGetApplications(String region, List<String> names) {+ Map<String, Application> store = applicationsFor(region);+ return names.stream()+ .map(n -> {+ Application a = store.get(n);+ if (a == null) {+ throw new AwsException("ApplicationDoesNotExistException",+ "Application does not exist: " + n, 400);+ }+ return a;+ })+ .collect(Collectors.toList());+ }++ // ---- Deployment Groups ----++ public DeploymentGroup createDeploymentGroup(String region, String appName, String groupName,+ String deploymentConfigName, String serviceRoleArn,+ Map<String, Object> fields) {+ getApplication(region, appName);+ Map<String, ConcurrentHashMap<String, DeploymentGroup>> appGroups = deploymentGroupsFor(region);+ ConcurrentHashMap<String, DeploymentGroup> groupStore = appGroups.computeIfAbsent(appName, a -> new ConcurrentHashMap<>());+ if (groupStore.containsKey(groupName)) {+ throw new AwsException("DeploymentGroupAlreadyExistsException",+ "Deployment group already exists: " + groupName, 400);+ }++ DeploymentGroup group = new DeploymentGroup();+ group.setApplicationName(appName);+ group.setDeploymentGroupId(UUID.randomUUID().toString());+ group.setDeploymentGroupName(groupName);+ group.setDeploymentConfigName(deploymentConfigName != null ? deploymentConfigName : "CodeDeployDefault.OneAtATime");+ group.setServiceRoleArn(serviceRoleArn);+ applyGroupFields(group, fields);+ groupStore.put(groupName, group);+ return group;+ }++ public DeploymentGroup getDeploymentGroup(String region, String appName, String groupName) {+ getApplication(region, appName);+ Map<String, ConcurrentHashMap<String, DeploymentGroup>> appGroups = deploymentGroupsFor(region);+ ConcurrentHashMap<String, DeploymentGroup> groupStore = appGroups.get(appName);+ DeploymentGroup group = groupStore != null ? groupStore.get(groupName) : null;+ if (group == null) {+ throw new AwsException("DeploymentGroupDoesNotExistException",+ "Deployment group does not exist: " + groupName, 400);+ }+ return group;+ }++ public DeploymentGroup updateDeploymentGroup(String region, String appName,+ String currentGroupName, String newGroupName,+ String deploymentConfigName, String serviceRoleArn,+ Map<String, Object> fields) {+ DeploymentGroup group = getDeploymentGroup(region, appName, currentGroupName);+ ConcurrentHashMap<String, DeploymentGroup> groupStore = deploymentGroupsFor(region)+ .computeIfAbsent(appName, a -> new ConcurrentHashMap<>());++ if (deploymentConfigName != null) { group.setDeploymentConfigName(deploymentConfigName); }+ if (serviceRoleArn != null) { group.setServiceRoleArn(serviceRoleArn); }+ applyGroupFields(group, fields);++ if (newGroupName != null && !newGroupName.equals(currentGroupName)) {+ groupStore.remove(currentGroupName);+ group.setDeploymentGroupName(newGroupName);+ groupStore.put(newGroupName, group);+ }+ return group;+ }++ public void deleteDeploymentGroup(String region, String appName, String groupName) {+ getApplication(region, appName);+ Map<String, ConcurrentHashMap<String, DeploymentGroup>> appGroups = deploymentGroupsFor(region);+ ConcurrentHashMap<String, DeploymentGroup> groupStore = appGroups.get(appName);+ if (groupStore == null || groupStore.remove(groupName) == null) {+ throw new AwsException("DeploymentGroupDoesNotExistException",+ "Deployment group does not exist: " + groupName, 400);+ }+ }++ public List<String> listDeploymentGroups(String region, String appName) {+ getApplication(region, appName);+ Map<String, ConcurrentHashMap<String, DeploymentGroup>> appGroups = deploymentGroupsFor(region);+ ConcurrentHashMap<String, DeploymentGroup> groupStore = appGroups.get(appName);+ return groupStore != null ? new ArrayList<>(groupStore.keySet()) : List.of();+ }++ public List<DeploymentGroup> batchGetDeploymentGroups(String region, String appName, List<String> names) {+ getApplication(region, appName);+ Map<String, ConcurrentHashMap<String, DeploymentGroup>> appGroups = deploymentGroupsFor(region);+ ConcurrentHashMap<String, DeploymentGroup> groupStore = appGroups.get(appName);+ if (groupStore == null) {+ return List.of();+ }+ return names.stream()+ .map(groupStore::get)+ .filter(g -> g != null)+ .collect(Collectors.toList());+ }++ // ---- Deployment Configs ----++ public DeploymentConfig createDeploymentConfig(String region, String name,+ Map<String, Object> minimumHealthyHosts,+ String computePlatform,+ Map<String, Object> trafficRoutingConfig,+ Map<String, Object> zonalConfig) {+ Map<String, DeploymentConfig> store = deploymentConfigsFor(region);+ if (store.containsKey(name)) {+ throw new AwsException("DeploymentConfigAlreadyExistsException",+ "Deployment configuration already exists: " + name, 400);+ }+ if (name.startsWith("CodeDeployDefault.")) {+ throw new AwsException("InvalidDeploymentConfigNameException",+ "Cannot create a deployment configuration starting with 'CodeDeployDefault.'", 400);+ }+ DeploymentConfig cfg = new DeploymentConfig();+ cfg.setDeploymentConfigId(UUID.randomUUID().toString());+ cfg.setDeploymentConfigName(name);+ cfg.setMinimumHealthyHosts(minimumHealthyHosts);+ cfg.setCreateTime(Instant.now().toEpochMilli() / 1000.0);+ cfg.setComputePlatform(computePlatform != null ? computePlatform : "Server");+ cfg.setTrafficRoutingConfig(trafficRoutingConfig);+ cfg.setZonalConfig(zonalConfig);+ store.put(name, cfg);+ return cfg;+ }++ public DeploymentConfig getDeploymentConfig(String region, String name) {+ DeploymentConfig cfg = deploymentConfigsFor(region).get(name);+ if (cfg == null) {+ throw new AwsException("DeploymentConfigDoesNotExistException",+ "Deployment configuration does not exist: " + name, 400);+ }+ return cfg;+ }++ public void deleteDeploymentConfig(String region, String name) {+ if (name.startsWith("CodeDeployDefault.")) {+ throw new AwsException("InvalidDeploymentConfigNameException",+ "Cannot delete a built-in deployment configuration.", 400);+ }+ if (deploymentConfigsFor(region).remove(name) == null) {+ throw new AwsException("DeploymentConfigDoesNotExistException",+ "Deployment configuration does not exist: " + name, 400);+ }+ }++ public List<String> listDeploymentConfigs(String region) {+ return new ArrayList<>(deploymentConfigsFor(region).keySet());+ }++ // ---- Tags ----++ public void tagResource(String arn, List<Map<String, String>> tagList) {+ Map<String, String> tagMap = tags.computeIfAbsent(arn, k -> new ConcurrentHashMap<>());+ for (Map<String, String> t : tagList) {+ tagMap.put(t.get("Key"), t.get("Value"));+ }+ }++ public void untagResource(String arn, List<String> tagKeys) {+ Map<String, String> tagMap = tags.get(arn);+ if (tagMap != null) {+ tagKeys.forEach(tagMap::remove);+ }+ }++ public List<Map<String, String>> listTagsForResource(String arn) {+ Map<String, String> tagMap = tags.getOrDefault(arn, Map.of());+ return tagMap.entrySet().stream()+ .map(e -> Map.of("Key", e.getKey(), "Value", e.getValue()))+ .collect(Collectors.toList());+ }++ public String applicationArn(String region, String name) {+ return "arn:aws:codedeploy:" + region + ":000000000000:application:" + name;+ }++ public String deploymentGroupArn(String region, String appName, String groupName) {+ return "arn:aws:codedeploy:" + region + ":000000000000:deploymentgroup:" + appName + "/" + groupName;+ }++ @SuppressWarnings("unchecked")+ private void applyGroupFields(DeploymentGroup group, Map<String, Object> fields) {+ if (fields == null) { return; }+ Object ec2TagFilters = fields.get("ec2TagFilters");+ if (ec2TagFilters instanceof List<?> list) {+ group.setEc2TagFilters((List<Map<String, String>>) list);+ }+ Object onPremTagFilters = fields.get("onPremisesInstanceTagFilters");+ if (onPremTagFilters instanceof List<?> list) {+ group.setOnPremisesInstanceTagFilters((List<Map<String, String>>) list);+ }+ Object asg = fields.get("autoScalingGroups");+ if (asg instanceof List<?> list) {+ group.setAutoScalingGroups((List<Map<String, Object>>) list);+ }+ setMapField(group, fields, "deploymentStyle", DeploymentGroup::setDeploymentStyle);+ setMapField(group, fields, "blueGreenDeploymentConfiguration", DeploymentGroup::setBlueGreenDeploymentConfiguration);+ setMapField(group, fields, "loadBalancerInfo", DeploymentGroup::setLoadBalancerInfo);+ setMapField(group, fields, "ec2TagSet", DeploymentGroup::setEc2TagSet);+ setMapField(group, fields, "onPremisesTagSet", DeploymentGroup::setOnPremisesTagSet);+ setMapField(group, fields, "alarmConfiguration", DeploymentGroup::setAlarmConfiguration);+ setMapField(group, fields, "autoRollbackConfiguration", DeploymentGroup::setAutoRollbackConfiguration);+ Object triggerConfigs = fields.get("triggerConfigurations");+ if (triggerConfigs instanceof List<?> list) {+ group.setTriggerConfigurations((List<Map<String, Object>>) list);+ }+ Object ecsServices = fields.get("ecsServices");+ if (ecsServices instanceof List<?> list) {+ group.setEcsServices((List<Map<String, Object>>) list);+ }+ if (fields.containsKey("computePlatform")) {+ group.setComputePlatform((String) fields.get("computePlatform"));+ }+ if (fields.containsKey("outdatedInstancesStrategy")) {+ group.setOutdatedInstancesStrategy((String) fields.get("outdatedInstancesStrategy"));+ }+ if (fields.containsKey("terminationHookEnabled")) {+ group.setTerminationHookEnabled((Boolean) fields.get("terminationHookEnabled"));+ }+ }++ @SuppressWarnings("unchecked")+ private void setMapField(DeploymentGroup group, Map<String, Object> fields, String key,+ java.util.function.BiConsumer<DeploymentGroup, Map<String, Object>> setter) {+ Object val = fields.get(key);+ if (val instanceof Map<?, ?> m) {+ setter.accept(group, (Map<String, Object>) m);+ }+ }++ private void applyTags(String arn, List<Map<String, String>> tagList) {+ Map<String, String> tagMap = tags.computeIfAbsent(arn, k -> new ConcurrentHashMap<>());+ for (Map<String, String> t : tagList) {+ String key = t.containsKey("Key") ? t.get("Key") : t.get("key");+ String value = t.containsKey("Value") ? t.get("Value") : t.get("value");+ if (key != null) { tagMap.put(key, value != null ? value : ""); }+ }+ }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/Application.java b/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/Application.javanew file mode 100644index 0000000000..2559ca53da--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/Application.java@@ -0,0 +1,35 @@+package io.github.hectorvent.floci.services.codedeploy.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class Application {+ public Application() {}++ private String applicationId;+ private String applicationName;+ private Double createTime;+ private Boolean linkedToGitHub;+ private String gitHubAccountName;+ private String computePlatform;++ public String getApplicationId() { return applicationId; }+ public void setApplicationId(String applicationId) { this.applicationId = applicationId; }++ public String getApplicationName() { return applicationName; }+ public void setApplicationName(String applicationName) { this.applicationName = applicationName; }++ public Double getCreateTime() { return createTime; }+ public void setCreateTime(Double createTime) { this.createTime = createTime; }++ public Boolean getLinkedToGitHub() { return linkedToGitHub; }+ public void setLinkedToGitHub(Boolean linkedToGitHub) { this.linkedToGitHub = linkedToGitHub; }++ public String getGitHubAccountName() { return gitHubAccountName; }+ public void setGitHubAccountName(String gitHubAccountName) { this.gitHubAccountName = gitHubAccountName; }++ public String getComputePlatform() { return computePlatform; }+ public void setComputePlatform(String computePlatform) { this.computePlatform = computePlatform; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/DeploymentConfig.java b/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/DeploymentConfig.javanew file mode 100644index 0000000000..104eb8559f--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/DeploymentConfig.java@@ -0,0 +1,41 @@+package io.github.hectorvent.floci.services.codedeploy.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++import java.util.Map;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class DeploymentConfig {+ public DeploymentConfig() {}++ private String deploymentConfigId;+ private String deploymentConfigName;+ private Map<String, Object> minimumHealthyHosts;+ private Double createTime;+ private String computePlatform;+ private Map<String, Object> trafficRoutingConfig;+ private Map<String, Object> zonalConfig;++ public String getDeploymentConfigId() { return deploymentConfigId; }+ public void setDeploymentConfigId(String deploymentConfigId) { this.deploymentConfigId = deploymentConfigId; }++ public String getDeploymentConfigName() { return deploymentConfigName; }+ public void setDeploymentConfigName(String deploymentConfigName) { this.deploymentConfigName = deploymentConfigName; }++ public Map<String, Object> getMinimumHealthyHosts() { return minimumHealthyHosts; }+ public void setMinimumHealthyHosts(Map<String, Object> minimumHealthyHosts) { this.minimumHealthyHosts = minimumHealthyHosts; }++ public Double getCreateTime() { return createTime; }+ public void setCreateTime(Double createTime) { this.createTime = createTime; }++ public String getComputePlatform() { return computePlatform; }+ public void setComputePlatform(String computePlatform) { this.computePlatform = computePlatform; }++ public Map<String, Object> getTrafficRoutingConfig() { return trafficRoutingConfig; }+ public void setTrafficRoutingConfig(Map<String, Object> trafficRoutingConfig) { this.trafficRoutingConfig = trafficRoutingConfig; }++ public Map<String, Object> getZonalConfig() { return zonalConfig; }+ public void setZonalConfig(Map<String, Object> zonalConfig) { this.zonalConfig = zonalConfig; }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/DeploymentGroup.java b/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/DeploymentGroup.javanew file mode 100644index 0000000000..294395a27a--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/codedeploy/model/DeploymentGroup.java@@ -0,0 +1,94 @@+package io.github.hectorvent.floci.services.codedeploy.model;++import com.fasterxml.jackson.annotation.JsonInclude;+import io.quarkus.runtime.annotations.RegisterForReflection;++import java.util.List;+import java.util.Map;++@RegisterForReflection+@JsonInclude(JsonInclude.Include.NON_NULL)+public class DeploymentGroup {+ public DeploymentGroup() {}++ private String applicationName;+ private String deploymentGroupId;+ private String deploymentGroupName;+ private String deploymentConfigName;+ private String serviceRoleArn;+ private List<Map<String, String>> ec2TagFilters;+ private List<Map<String, String>> onPremisesInstanceTagFilters;+ private List<Map<String, Object>> autoScalingGroups;+ private Map<String, Object> deploymentStyle;+ private Map<String, Object> blueGreenDeploymentConfiguration;+ private Map<String, Object> loadBalancerInfo;+ private Map<String, Object> ec2TagSet;+ private Map<String, Object> onPremisesTagSet;+ private Map<String, Object> alarmConfiguration;+ private Map<String, Object> autoRollbackConfiguration;+ private List<Map<String, Object>> triggerConfigurations;+ private List<Map<String, Object>> ecsServices;+ private String computePlatform;+ private String outdatedInstancesStrategy;+ private Boolean terminationHookEnabled;++ public String getApplicationName() { return applicationName; }+ public void setApplicationName(String applicationName) { this.applicationName = applicationName; }++ public String getDeploymentGroupId() { return deploymentGroupId; }+ public void setDeploymentGroupId(String deploymentGroupId) { this.deploymentGroupId = deploymentGroupId; }++ public String getDeploymentGroupName() { return deploymentGroupName; }+ public void setDeploymentGroupName(String deploymentGroupName) { this.deploymentGroupName = deploymentGroupName; }++ public String getDeploymentConfigName() { return deploymentConfigName; }+ public void setDeploymentConfigName(String deploymentConfigName) { this.deploymentConfigName = deploymentConfigName; }++ public String getServiceRoleArn() { return serviceRoleArn; }+ public void setServiceRoleArn(String serviceRoleArn) { this.serviceRoleArn = serviceRoleArn; }++ public List<Map<String, String>> getEc2TagFilters() { return ec2TagFilters; }+ public void setEc2TagFilters(List<Map<String, String>> ec2TagFilters) { this.ec2TagFilters = ec2TagFilters; }++ public List<Map<String, String>> getOnPremisesInstanceTagFilters() { return onPremisesInstanceTagFilters; }+ public void setOnPremisesInstanceTagFilters(List<Map<String, String>> onPremisesInstanceTagFilters) { this.onPremisesInstanceTagFilters = onPremisesInstanceTagFilters; }++ public List<Map<String, Object>> getAutoScalingGroups() { return autoScalingGroups; }+ public void setAutoScalingGroups(List<Map<String, Object>> autoScalingGroups) { this.autoScalingGroups = autoScalingGroups; }++ public Map<String, Object> getDeploymentStyle() { return deploymentStyle; }+ public void setDeploymentStyle(Map<String, Object> deploymentStyle) { this.deploymentStyle = deploymentStyle; }++ public Map<String, Object> getBlueGreenDeploymentConfiguration() { return blueGreenDeploymentConfiguration; }+ public void setBlueGreenDeploymentConfiguration(Map<String, Object> blueGreenDeploymentConfiguration) { this.blueGreenDeploymentConfiguration = blueGreenDeploymentConfiguration; }++ public Map<String, Object> getLoadBalancerInfo() { return loadBalancerInfo; }+ public void setLoadBalancerInfo(Map<String, Object> loadBalancerInfo) { this.loadBalancerInfo = loadBalancerInfo; }++ public Map<String, Object> getEc2TagSet() { return ec2TagSet; }+ public void setEc2TagSet(Map<String, Object> ec2TagSet) { this.ec2TagSet = ec2TagSet; }++ public Map<String, Object> getOnPremisesTagSet() { return onPremisesTagSet; }+ public void setOnPremisesTagSet(Map<String, Object> onPremisesTagSet) { this.onPremisesTagSet = onPremisesTagSet; }++ public Map<String, Object> getAlarmConfiguration() { return alarmConfiguration; }+ public void setAlarmConfiguration(Map<String, Object> alarmConfiguration) { this.alarmConfiguration = alarmConfiguration; }++ public Map<String, Object> getAutoRollbackConfiguration() { return autoRollbackConfiguration; }+ public void setAutoRollbackConfiguration(Map<String, Object> autoRollbackConfiguration) { this.autoRollbackConfiguration = autoRollbackConfiguration; }++ public List<Map<String, Object>> getTriggerConfigurations() { return triggerConfigurations; }+ public void setTriggerConfigurations(List<Map<String, Object>> triggerConfigurations) { this.triggerConfigurations = triggerConfigurations; }++ public List<Map<String, Object>> getEcsServices() { return ecsServices; }+ public void setEcsServices(List<Map<String, Object>> ecsServices) { this.ecsServices = ecsServices; }++ public String getComputePlatform() { return computePlatform; }+ public void setComputePlatform(String computePlatform) { this.computePlatform = computePlatform; }++ public String getOutdatedInstancesStrategy() { return outdatedInstancesStrategy; }+ public void setOutdatedInstancesStrategy(String outdatedInstancesStrategy) { this.outdatedInstancesStrategy = outdatedInstancesStrategy; }++ public Boolean getTerminationHookEnabled() { return terminationHookEnabled; }+ public void setTerminationHookEnabled(Boolean terminationHookEnabled) { this.terminationHookEnabled = terminationHookEnabled; }+}diff --git a/src/main/resources/application.yml b/src/main/resources/application.ymlindex 1128a6f13b..ffaa28fa31 100644--- a/src/main/resources/application.yml+++ b/src/main/resources/application.yml@@ -219,3 +219,7 @@ floci:keep-running-on-shutdown: falseelbv2:enabled: true+ codebuild:+ enabled: true+ codedeploy:+ enabled: truediff --git a/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.javaindex 2d41833f45..6e77bb1a00 100644--- a/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java@@ -52,7 +52,9 @@ class HealthControllerIntegrationTest {"bedrock-runtime": "running","eks": "running","pipes": "running",- "elasticloadbalancing": "running"+ "elasticloadbalancing": "running",+ "codebuild": "running",+ "codedeploy": "running"},"edition": "floci-always-free","version": "dev"diff --git a/src/test/java/io/github/hectorvent/floci/services/codebuild/CodeBuildIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/codebuild/CodeBuildIntegrationTest.javanew file mode 100644index 0000000000..d762d03fad--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/codebuild/CodeBuildIntegrationTest.java@@ -0,0 +1,312 @@+package io.github.hectorvent.floci.services.codebuild;++import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;+import io.quarkus.test.junit.QuarkusTest;+import org.junit.jupiter.api.BeforeAll;+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 static io.restassured.RestAssured.given;+import static org.hamcrest.Matchers.*;++@QuarkusTest+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class CodeBuildIntegrationTest {++ private static final String CONTENT_TYPE = "application/x-amz-json-1.1";++ @BeforeAll+ static void configureRestAssured() {+ RestAssuredJsonUtils.configureAwsContentTypes();+ }++ @Test+ @Order(1)+ void createProject() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.CreateProject")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "name": "my-build-project",+ "description": "Integration test project",+ "source": {+ "type": "S3",+ "location": "my-bucket/source.zip"+ },+ "artifacts": {+ "type": "NO_ARTIFACTS"+ },+ "environment": {+ "type": "LINUX_CONTAINER",+ "image": "aws/codebuild/standard:7.0",+ "computeType": "BUILD_GENERAL1_SMALL"+ },+ "serviceRole": "arn:aws:iam::000000000000:role/codebuild-role"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("project.name", equalTo("my-build-project"))+ .body("project.description", equalTo("Integration test project"))+ .body("project.arn", containsString("arn:aws:codebuild:"))+ .body("project.arn", containsString(":project/my-build-project"))+ .body("project.serviceRole", equalTo("arn:aws:iam::000000000000:role/codebuild-role"))+ .body("project.timeoutInMinutes", equalTo(60))+ .body("project.projectVisibility", equalTo("PRIVATE"));+ }++ @Test+ @Order(2)+ void createDuplicateProjectFails() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.CreateProject")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "name": "my-build-project",+ "source": {"type": "NO_SOURCE"},+ "artifacts": {"type": "NO_ARTIFACTS"},+ "environment": {+ "type": "LINUX_CONTAINER",+ "image": "aws/codebuild/standard:7.0",+ "computeType": "BUILD_GENERAL1_SMALL"+ },+ "serviceRole": "arn:aws:iam::000000000000:role/codebuild-role"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("__type", containsString("ResourceAlreadyExistsException"));+ }++ @Test+ @Order(3)+ void batchGetProjects() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.BatchGetProjects")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "names": ["my-build-project", "nonexistent-project"]+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("projects", hasSize(1))+ .body("projects[0].name", equalTo("my-build-project"))+ .body("projectsNotFound", hasSize(1))+ .body("projectsNotFound[0]", equalTo("nonexistent-project"));+ }++ @Test+ @Order(4)+ void listProjects() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.ListProjects")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("projects", hasItem("my-build-project"));+ }++ @Test+ @Order(5)+ void updateProject() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.UpdateProject")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "name": "my-build-project",+ "description": "Updated description",+ "timeoutInMinutes": 120+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("project.name", equalTo("my-build-project"))+ .body("project.description", equalTo("Updated description"))+ .body("project.timeoutInMinutes", equalTo(120));+ }++ @Test+ @Order(6)+ void createReportGroup() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.CreateReportGroup")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "name": "my-report-group",+ "type": "TEST",+ "exportConfig": {+ "exportConfigType": "NO_EXPORT"+ }+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("reportGroup.name", equalTo("my-report-group"))+ .body("reportGroup.type", equalTo("TEST"))+ .body("reportGroup.arn", containsString(":report-group/my-report-group"))+ .body("reportGroup.status", equalTo("ACTIVE"));+ }++ @Test+ @Order(7)+ void listReportGroups() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.ListReportGroups")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("reportGroups", hasSize(greaterThanOrEqualTo(1)));+ }++ @Test+ @Order(8)+ void batchGetReportGroups() {+ // Fetch ARN first+ String arn = given()+ .header("X-Amz-Target", "CodeBuild_20161006.ListReportGroups")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .extract().path("reportGroups[0]");++ given()+ .header("X-Amz-Target", "CodeBuild_20161006.BatchGetReportGroups")+ .contentType(CONTENT_TYPE)+ .body("{\"reportGroupArns\": [\"" + arn + "\", \"arn:aws:codebuild:us-east-1:000000000000:report-group/nonexistent\"]}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("reportGroups", hasSize(1))+ .body("reportGroupsNotFound", hasSize(1));+ }++ @Test+ @Order(9)+ void importAndListSourceCredentials() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.ImportSourceCredentials")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "token": "ghp_test_token",+ "serverType": "GITHUB",+ "authType": "OAUTH"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("arn", containsString(":token/github-"));++ given()+ .header("X-Amz-Target", "CodeBuild_20161006.ListSourceCredentials")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("sourceCredentialsInfos", hasSize(greaterThanOrEqualTo(1)))+ .body("sourceCredentialsInfos[0].serverType", equalTo("GITHUB"))+ .body("sourceCredentialsInfos[0].authType", equalTo("OAUTH"));+ }++ @Test+ @Order(10)+ void listCuratedEnvironmentImages() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.ListCuratedEnvironmentImages")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("platforms", hasSize(greaterThanOrEqualTo(1)))+ .body("platforms[0].platform", notNullValue());+ }++ @Test+ @Order(11)+ void deleteSourceCredentials() {+ String arn = given()+ .header("X-Amz-Target", "CodeBuild_20161006.ListSourceCredentials")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .extract().path("sourceCredentialsInfos[0].arn");++ given()+ .header("X-Amz-Target", "CodeBuild_20161006.DeleteSourceCredentials")+ .contentType(CONTENT_TYPE)+ .body("{\"arn\": \"" + arn + "\"}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("arn", equalTo(arn));+ }++ @Test+ @Order(12)+ void deleteProject() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.DeleteProject")+ .contentType(CONTENT_TYPE)+ .body("""+ {"name": "my-build-project"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200);+ }++ @Test+ @Order(13)+ void deleteNonexistentProjectFails() {+ given()+ .header("X-Amz-Target", "CodeBuild_20161006.DeleteProject")+ .contentType(CONTENT_TYPE)+ .body("""+ {"name": "my-build-project"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("__type", containsString("ResourceNotFoundException"));+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployIntegrationTest.javanew file mode 100644index 0000000000..b1310f9a9f--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployIntegrationTest.java@@ -0,0 +1,412 @@+package io.github.hectorvent.floci.services.codedeploy;++import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;+import io.quarkus.test.junit.QuarkusTest;+import org.junit.jupiter.api.BeforeAll;+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 static io.restassured.RestAssured.given;+import static org.hamcrest.Matchers.*;++@QuarkusTest+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)+class CodeDeployIntegrationTest {++ private static final String CONTENT_TYPE = "application/x-amz-json-1.1";++ @BeforeAll+ static void configureRestAssured() {+ RestAssuredJsonUtils.configureAwsContentTypes();+ }++ @Test+ @Order(1)+ void listDeploymentConfigsIncludesBuiltIns() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.ListDeploymentConfigs")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentConfigsList", hasItem("CodeDeployDefault.AllAtOnce"))+ .body("deploymentConfigsList", hasItem("CodeDeployDefault.HalfAtATime"))+ .body("deploymentConfigsList", hasItem("CodeDeployDefault.OneAtATime"))+ .body("deploymentConfigsList", hasItem("CodeDeployDefault.LambdaAllAtOnce"))+ .body("deploymentConfigsList", hasItem("CodeDeployDefault.ECSAllAtOnce"));+ }++ @Test+ @Order(2)+ void getBuiltInDeploymentConfig() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.GetDeploymentConfig")+ .contentType(CONTENT_TYPE)+ .body("""+ {"deploymentConfigName": "CodeDeployDefault.LambdaAllAtOnce"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentConfigInfo.deploymentConfigName", equalTo("CodeDeployDefault.LambdaAllAtOnce"))+ .body("deploymentConfigInfo.computePlatform", equalTo("Lambda"))+ .body("deploymentConfigInfo.trafficRoutingConfig.type", equalTo("AllAtOnce"));+ }++ @Test+ @Order(3)+ void createApplication() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.CreateApplication")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "applicationName": "my-lambda-app",+ "computePlatform": "Lambda"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("applicationId", notNullValue());+ }++ @Test+ @Order(4)+ void createDuplicateApplicationFails() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.CreateApplication")+ .contentType(CONTENT_TYPE)+ .body("""+ {"applicationName": "my-lambda-app", "computePlatform": "Lambda"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("__type", containsString("ApplicationAlreadyExistsException"));+ }++ @Test+ @Order(5)+ void getApplication() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.GetApplication")+ .contentType(CONTENT_TYPE)+ .body("""+ {"applicationName": "my-lambda-app"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("application.applicationName", equalTo("my-lambda-app"))+ .body("application.computePlatform", equalTo("Lambda"))+ .body("application.linkedToGitHub", equalTo(false));+ }++ @Test+ @Order(6)+ void listApplications() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.ListApplications")+ .contentType(CONTENT_TYPE)+ .body("{}")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("applications", hasItem("my-lambda-app"));+ }++ @Test+ @Order(7)+ void batchGetApplications() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.BatchGetApplications")+ .contentType(CONTENT_TYPE)+ .body("""+ {"applicationNames": ["my-lambda-app"]}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("applicationsInfo", hasSize(1))+ .body("applicationsInfo[0].applicationName", equalTo("my-lambda-app"));+ }++ @Test+ @Order(8)+ void createDeploymentGroup() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.CreateDeploymentGroup")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "applicationName": "my-lambda-app",+ "deploymentGroupName": "my-lambda-dg",+ "deploymentConfigName": "CodeDeployDefault.LambdaAllAtOnce",+ "serviceRoleArn": "arn:aws:iam::000000000000:role/codedeploy-role",+ "deploymentStyle": {+ "deploymentType": "BLUE_GREEN",+ "deploymentOption": "WITH_TRAFFIC_CONTROL"+ }+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentGroupId", notNullValue());+ }++ @Test+ @Order(9)+ void getDeploymentGroup() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.GetDeploymentGroup")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "applicationName": "my-lambda-app",+ "deploymentGroupName": "my-lambda-dg"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentGroupInfo.deploymentGroupName", equalTo("my-lambda-dg"))+ .body("deploymentGroupInfo.applicationName", equalTo("my-lambda-app"))+ .body("deploymentGroupInfo.deploymentConfigName", equalTo("CodeDeployDefault.LambdaAllAtOnce"))+ .body("deploymentGroupInfo.serviceRoleArn", equalTo("arn:aws:iam::000000000000:role/codedeploy-role"));+ }++ @Test+ @Order(10)+ void listDeploymentGroups() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.ListDeploymentGroups")+ .contentType(CONTENT_TYPE)+ .body("""+ {"applicationName": "my-lambda-app"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("applicationName", equalTo("my-lambda-app"))+ .body("deploymentGroups", hasItem("my-lambda-dg"));+ }++ @Test+ @Order(11)+ void batchGetDeploymentGroups() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.BatchGetDeploymentGroups")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "applicationName": "my-lambda-app",+ "deploymentGroupNames": ["my-lambda-dg"]+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentGroupsInfo", hasSize(1))+ .body("deploymentGroupsInfo[0].deploymentGroupName", equalTo("my-lambda-dg"));+ }++ @Test+ @Order(12)+ void createCustomDeploymentConfig() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.CreateDeploymentConfig")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "deploymentConfigName": "MyCustomConfig",+ "minimumHealthyHosts": {+ "type": "FLEET_PERCENT",+ "value": 75+ },+ "computePlatform": "Server"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentConfigId", notNullValue());+ }++ @Test+ @Order(13)+ void getCustomDeploymentConfig() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.GetDeploymentConfig")+ .contentType(CONTENT_TYPE)+ .body("""+ {"deploymentConfigName": "MyCustomConfig"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("deploymentConfigInfo.deploymentConfigName", equalTo("MyCustomConfig"))+ .body("deploymentConfigInfo.computePlatform", equalTo("Server"))+ .body("deploymentConfigInfo.minimumHealthyHosts.type", equalTo("FLEET_PERCENT"))+ .body("deploymentConfigInfo.minimumHealthyHosts.value", equalTo(75));+ }++ @Test+ @Order(14)+ void cannotCreateDeploymentConfigWithBuiltInPrefix() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.CreateDeploymentConfig")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "deploymentConfigName": "CodeDeployDefault.MyCustom",+ "minimumHealthyHosts": {"type": "FLEET_PERCENT", "value": 50}+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("__type", containsString("InvalidDeploymentConfigNameException"));+ }++ @Test+ @Order(15)+ void tagAndUntagResource() {+ String appArn = "arn:aws:codedeploy:us-east-1:000000000000:application:my-lambda-app";++ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.TagResource")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "ResourceArn": "arn:aws:codedeploy:us-east-1:000000000000:application:my-lambda-app",+ "Tags": [+ {"Key": "env", "Value": "test"},+ {"Key": "team", "Value": "platform"}+ ]+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200);++ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.ListTagsForResource")+ .contentType(CONTENT_TYPE)+ .body("""+ {"ResourceArn": "arn:aws:codedeploy:us-east-1:000000000000:application:my-lambda-app"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("Tags", hasSize(2))+ .body("Tags.Key", hasItems("env", "team"));++ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.UntagResource")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "ResourceArn": "arn:aws:codedeploy:us-east-1:000000000000:application:my-lambda-app",+ "TagKeys": ["team"]+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200);++ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.ListTagsForResource")+ .contentType(CONTENT_TYPE)+ .body("""+ {"ResourceArn": "arn:aws:codedeploy:us-east-1:000000000000:application:my-lambda-app"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("Tags", hasSize(1))+ .body("Tags[0].Key", equalTo("env"));+ }++ @Test+ @Order(16)+ void deleteDeploymentGroupAndApplication() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.DeleteDeploymentGroup")+ .contentType(CONTENT_TYPE)+ .body("""+ {+ "applicationName": "my-lambda-app",+ "deploymentGroupName": "my-lambda-dg"+ }+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200);++ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.DeleteApplication")+ .contentType(CONTENT_TYPE)+ .body("""+ {"applicationName": "my-lambda-app"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200);+ }++ @Test+ @Order(17)+ void deleteCustomDeploymentConfig() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.DeleteDeploymentConfig")+ .contentType(CONTENT_TYPE)+ .body("""+ {"deploymentConfigName": "MyCustomConfig"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(200);+ }++ @Test+ @Order(18)+ void cannotDeleteBuiltInDeploymentConfig() {+ given()+ .header("X-Amz-Target", "CodeDeploy_20141006.DeleteDeploymentConfig")+ .contentType(CONTENT_TYPE)+ .body("""+ {"deploymentConfigName": "CodeDeployDefault.AllAtOnce"}+ """)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("__type", containsString("InvalidDeploymentConfigNameException"));+ }+}diff --git a/src/test/resources/application.yml b/src/test/resources/application.ymlindex 961f5f8f8f..c10f767c68 100644--- a/src/test/resources/application.yml+++ b/src/test/resources/application.yml@@ -149,3 +149,7 @@ floci:enabled: trueelbv2:enabled: true+ codebuild:+ enabled: true+ codedeploy:+ enabled: true