diff --git a/docs/services/codegurureviewer.md b/docs/services/codegurureviewer.md
new file mode 100644
index 0000000000..d7a452cb90
--- /dev/null
+++ b/docs/services/codegurureviewer.md
@@ -0,0 +1,42 @@
+# CodeGuru Reviewer
+
+**Protocol:** REST JSON
+
+**Endpoint:** `http://localhost:4566`
+
+Floci implements the CodeGuru Reviewer repository-association lifecycle for local SDK,
+CLI, and Terraform workflows. Associations are isolated by region and use the configured
+Floci storage mode.
+
+## Supported Actions
+
+
+| Action | Description |
+| --- | --- |
+| `AssociateRepository` | Associates a CodeCommit, Bitbucket, GitHub Enterprise Server, or S3 repository (`POST /associations`) |
+| `DescribeRepositoryAssociation` | Returns the association, its state, and its tags (`GET /associations/{associationArn}`) |
+| `DisassociateRepository` | Removes the association (`DELETE /associations/{associationArn}`) |
+| `ListRepositoryAssociations` | Lists association summaries with filters and pagination (`GET /associations`) |
+| `ListTagsForResource` | Lists association tags (`GET /tags/{resourceArn}`) |
+| `TagResource` | Adds tags to an association (`POST /tags/{resourceArn}`) |
+| `UntagResource` | Removes tag keys from an association (`DELETE /tags/{resourceArn}`) |
+
+
+`ListRepositoryAssociations` accepts the documented filters (`ProviderType`,
+`State`, `Name`, `Owner`) plus `MaxResults` and `NextToken` pagination.
+
+An association reaches the terminal `Associated` state as soon as `AssociateRepository`
+returns, so a provider waiter polling `DescribeRepositoryAssociation` completes on its
+first read instead of spinning through an `Associating` state the emulator would never
+leave. The `Repository` union is validated the way AWS validates it: exactly one of
+`CodeCommit`, `Bitbucket`, `GitHubEnterpriseServer`, or `S3Bucket` must be set, third-party
+providers require `Owner` and `ConnectionArn`, and `CUSTOMER_MANAGED_CMK` encryption
+requires a `KMSKeyId`. Associating the same repository twice reports `ConflictException`.
+
+Code reviews and recommendations are not implemented.
+
+## Configuration
+
+| Variable | Default | Description |
+|---|---|---|
+| `FLOCI_SERVICES_CODEGURUREVIEWER_ENABLED` | `true` | Enable or disable CodeGuru Reviewer |
diff --git a/docs/services/index.md b/docs/services/index.md
index 9ae88ab7b8..8d30e1b8c4 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -95,6 +95,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [Managed Prometheus (AMP)](managed-prometheus.md) | `/workspaces/*`, `/tags/*` | REST JSON | 8 |
| [AWS Backup](backup.md) | `/backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 20 |
| [AWS FIS](fis.md) | `/experimentTemplates/*`, `/experiments/*`, `/actions/*`, `/targetResourceTypes/*`, `/safetyLevers/*`, `/tags/*` | REST JSON | 26 |
+| [CodeGuru Reviewer](codegurureviewer.md) | `/associations`, `/associations/{associationArn}`, `/tags/*` | REST JSON | 7 |
| [CloudFront](cloudfront.md) | `/2020-05-31/distribution/*`, `/2020-05-31/cache-policy/*`, `/2020-05-31/function/*` | REST XML | 50 |
| [Route53](route53.md) | `/2013-04-01/hostedzone/*`, `/2013-04-01/healthcheck/*`, `/2013-04-01/change/*` | REST XML | 17 |
| [Route 53 Resolver](route53resolver.md) | `POST /` + `X-Amz-Target: Route53Resolver.*` | JSON 1.1 | 18 |
diff --git a/mkdocs.yml b/mkdocs.yml
index a7e0f6617f..9de06047e0 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -137,6 +137,7 @@ nav:
- CodeBuild: services/codebuild.md
- AWS Batch: services/batch.md
- CodeDeploy: services/codedeploy.md
+ - CodeGuru Reviewer: services/codegurureviewer.md
- CodePipeline: services/codepipeline.md
- Service Quotas: services/servicequotas.md
- AWS RAM: services/ram.md
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 475cd414bf..fe11bc4e34 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -702,6 +702,7 @@ public interface EmulatorConfig {
LakeFormationServiceConfig lakeformation();
EfsServiceConfig efs();
+ CodeGuruReviewerServiceConfig codegurureviewer();
}
interface ConnectServiceConfig {
@@ -719,6 +720,11 @@ public interface EmulatorConfig {
boolean enabled();
}
+ interface CodeGuruReviewerServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
interface IotServiceConfig {
@WithDefault("true")
boolean enabled();
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
index 811fe02512..5b96a52572 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
@@ -571,7 +571,13 @@ public class ResolvedServiceCatalog {
storageMode(config.storage().services().efs().mode(), config.storage().mode()),
config.storage().services().efs().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
- Set.of(), Set.of("elasticfilesystem"), Set.of(), Set.of(EfsController.class))
+ Set.of(), Set.of("elasticfilesystem"), Set.of(), Set.of(EfsController.class)),
+ descriptor("codeguru-reviewer", "codegurureviewer",
+ config.services().codegurureviewer().enabled(), true,
+ "codegurureviewer", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
+ protocols(ServiceProtocol.REST_JSON),
+ Set.of(), Set.of("codeguru-reviewer"), Set.of(),
+ Set.of(io.github.hectorvent.floci.services.codegurureviewer.CodeGuruReviewerController.class))
));
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerController.java b/src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerController.java
new file mode 100644
index 0000000000..6ab4c50d7c
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerController.java
@@ -0,0 +1,203 @@
+package io.github.hectorvent.floci.services.codegurureviewer;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.JsonErrorResponseUtils;
+import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.services.codegurureviewer.model.RepositoryAssociation;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.WebApplicationException;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+
+import java.time.Instant;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Amazon CodeGuru Reviewer REST-JSON controller.
+ *
+ *
Tagging goes through the shared {@code /tags/{resourceArn}} path, which
+ * {@link CodeGuruReviewerService} serves as a {@code TagHandler}.
+ *
+ *
Only the operations declared below are served; anything else falls through to the
+ * emulator's not-found handling rather than a stub success.
+ */
+@Path("/")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class CodeGuruReviewerController {
+
+ private final CodeGuruReviewerService codeGuruReviewerService;
+ private final RegionResolver regionResolver;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public CodeGuruReviewerController(CodeGuruReviewerService codeGuruReviewerService,
+ RegionResolver regionResolver, ObjectMapper objectMapper) {
+ this.codeGuruReviewerService = codeGuruReviewerService;
+ this.regionResolver = regionResolver;
+ this.objectMapper = objectMapper;
+ }
+
+ @POST
+ @Path("/associations")
+ public Response associateRepository(@Context HttpHeaders headers, String body) {
+ String region = regionResolver.resolveRegion(headers);
+ JsonNode request = readTree(body);
+ RepositoryAssociation association = codeGuruReviewerService.associateRepository(
+ request.get("Repository"), request.get("KMSKeyDetails"),
+ parseTags(request.get("Tags")), region);
+ return Response.ok(associationResponse(association)).build();
+ }
+
+ @GET
+ @Path("/associations/{associationArn}")
+ public Response describeRepositoryAssociation(@PathParam("associationArn") String associationArn,
+ @Context HttpHeaders headers) {
+ String region = regionResolver.resolveRegion(headers);
+ return Response.ok(associationResponse(
+ codeGuruReviewerService.describeRepositoryAssociation(associationArn, region))).build();
+ }
+
+ @DELETE
+ @Path("/associations/{associationArn}")
+ public Response disassociateRepository(@PathParam("associationArn") String associationArn,
+ @Context HttpHeaders headers) {
+ String region = regionResolver.resolveRegion(headers);
+ return Response.ok(associationResponse(
+ codeGuruReviewerService.disassociateRepository(associationArn, region))).build();
+ }
+
+ /**
+ * The filter query keys are singular ({@code ProviderType=...&State=...}) because that is
+ * the wire mapping the API reference documents for the plural request fields
+ * ({@code ProviderTypes}, {@code States}, ...): the SDK serializes each list member as a
+ * repeated singular query parameter.
+ */
+ @GET
+ @Path("/associations")
+ public Response listRepositoryAssociations(@QueryParam("ProviderType") List providerTypes,
+ @QueryParam("State") List states,
+ @QueryParam("Name") List names,
+ @QueryParam("Owner") List owners,
+ @QueryParam("MaxResults") String maxResults,
+ @QueryParam("NextToken") String nextToken,
+ @Context HttpHeaders headers) {
+ String region = regionResolver.resolveRegion(headers);
+ PaginatedResult page = codeGuruReviewerService.listRepositoryAssociations(
+ providerTypes, states, names, owners, parseMaxResults(maxResults), nextToken, region);
+ ObjectNode response = objectMapper.createObjectNode();
+ ArrayNode summaries = response.putArray("RepositoryAssociationSummaries");
+ for (RepositoryAssociation association : page.items()) {
+ ObjectNode summary = summaries.addObject();
+ summary.put("AssociationArn", association.getAssociationArn());
+ if (association.getConnectionArn() != null) {
+ summary.put("ConnectionArn", association.getConnectionArn());
+ }
+ summary.put("LastUpdatedTimeStamp", epochSeconds(association.getLastUpdatedTimeStamp()));
+ summary.put("AssociationId", association.getAssociationId());
+ summary.put("Name", association.getName());
+ summary.put("Owner", association.getOwner());
+ summary.put("ProviderType", association.getProviderType());
+ summary.put("State", association.getState());
+ }
+ if (page.nextToken() != null) {
+ response.put("NextToken", page.nextToken());
+ }
+ return Response.ok(response).build();
+ }
+
+ private ObjectNode associationResponse(RepositoryAssociation association) {
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("RepositoryAssociation", associationNode(association));
+ response.set("Tags", objectMapper.valueToTree(
+ association.getTags() != null ? association.getTags() : Map.of()));
+ return response;
+ }
+
+ private ObjectNode associationNode(RepositoryAssociation association) {
+ ObjectNode node = objectMapper.createObjectNode();
+ node.put("AssociationId", association.getAssociationId());
+ node.put("AssociationArn", association.getAssociationArn());
+ if (association.getConnectionArn() != null) {
+ node.put("ConnectionArn", association.getConnectionArn());
+ }
+ node.put("Name", association.getName());
+ node.put("Owner", association.getOwner());
+ node.put("ProviderType", association.getProviderType());
+ node.put("State", association.getState());
+ node.put("StateReason", association.getStateReason());
+ node.put("CreatedTimeStamp", epochSeconds(association.getCreatedTimeStamp()));
+ node.put("LastUpdatedTimeStamp", epochSeconds(association.getLastUpdatedTimeStamp()));
+
+ ObjectNode kmsKeyDetails = node.putObject("KMSKeyDetails");
+ kmsKeyDetails.put("EncryptionOption", association.getEncryptionOption());
+ if (association.getKmsKeyId() != null) {
+ kmsKeyDetails.put("KMSKeyId", association.getKmsKeyId());
+ }
+
+ if (association.getS3BucketName() != null) {
+ ObjectNode s3Details = node.putObject("S3RepositoryDetails");
+ s3Details.put("BucketName", association.getS3BucketName());
+ if (association.getSourceCodeArtifactsObjectKey() != null) {
+ ObjectNode codeArtifacts = s3Details.putObject("CodeArtifacts");
+ codeArtifacts.put("SourceCodeArtifactsObjectKey", association.getSourceCodeArtifactsObjectKey());
+ if (association.getBuildArtifactsObjectKey() != null) {
+ codeArtifacts.put("BuildArtifactsObjectKey", association.getBuildArtifactsObjectKey());
+ }
+ }
+ }
+ return node;
+ }
+
+ private long epochSeconds(Instant instant) {
+ return instant != null ? instant.getEpochSecond() : 0L;
+ }
+
+ // Bound as String so a malformed value reaches this method: a JAX-RS Integer binding
+ // fails during parameter conversion and surfaces as 404, where AWS models 400.
+ private Integer parseMaxResults(String maxResults) {
+ if (maxResults == null || maxResults.isBlank()) {
+ return null;
+ }
+ try {
+ return Integer.valueOf(maxResults);
+ } catch (NumberFormatException e) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Value '" + maxResults
+ + "' at 'maxResults' failed to satisfy constraint: Member must be an integer.", 400);
+ }
+ }
+
+ private JsonNode readTree(String body) {
+ try {
+ return objectMapper.readTree(body == null || body.isBlank() ? "{}" : body);
+ } catch (Exception e) {
+ throw new WebApplicationException(JsonErrorResponseUtils.createSerializationErrorResponse());
+ }
+ }
+
+ private Map parseTags(JsonNode tagsNode) {
+ Map tags = new LinkedHashMap<>();
+ if (tagsNode != null && tagsNode.isObject()) {
+ tagsNode.fields().forEachRemaining(entry -> tags.put(entry.getKey(), entry.getValue().asText()));
+ }
+ return tags;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerService.java b/src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerService.java
new file mode 100644
index 0000000000..fa10d1d1b9
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerService.java
@@ -0,0 +1,312 @@
+package io.github.hectorvent.floci.services.codegurureviewer;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.core.common.Pagination;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.core.common.TagHandler;
+import io.github.hectorvent.floci.core.storage.StorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.codegurureviewer.model.RepositoryAssociation;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.time.Instant;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+/**
+ * Amazon CodeGuru Reviewer repository associations.
+ *
+ * An association reaches the terminal {@code Associated} state as soon as
+ * {@code AssociateRepository} returns, so the provider waiter that polls
+ * {@code DescribeRepositoryAssociation} completes on its first attempt instead of spinning
+ * through an {@code Associating} state the emulator would never leave.
+ */
+@ApplicationScoped
+public class CodeGuruReviewerService implements TagHandler {
+
+ private static final Logger LOG = Logger.getLogger(CodeGuruReviewerService.class);
+
+ private static final Pattern NAME = Pattern.compile("\\S[\\w.-]*");
+ private static final Pattern OWNER = Pattern.compile("\\S(.*\\S)?");
+ private static final Set ENCRYPTION_OPTIONS = Set.of("AWS_OWNED_CMK", "CUSTOMER_MANAGED_CMK");
+ private static final String ASSOCIATED = "Associated";
+ private static final String DISASSOCIATED = "Disassociated";
+ private static final String ARN_RESOURCE_PREFIX = "association:";
+
+ private final StorageBackend associations;
+ private final RegionResolver regionResolver;
+
+ @Inject
+ public CodeGuruReviewerService(StorageFactory storageFactory, RegionResolver regionResolver) {
+ this.associations = storageFactory.create("codegurureviewer", "codegurureviewer-associations.json",
+ new TypeReference