Skip to content

armgit / floci

Public Imported from GitHub
0

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

fix(msk): persist CreateCluster broker node groups, encryption, client auth, logging, configuration and tags (#2366)

MAN$I VERMA0205e4ed7efe
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MskTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MskTest.java
index e0c6fd90f9..b9736ce86d 100644
--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MskTest.java
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MskTest.java
@@ -5,6 +5,7 @@ import software.amazon.awssdk.services.kafka.KafkaClient;
import software.amazon.awssdk.services.kafka.model.*;
import java.util.List;
+import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
@@ -84,8 +85,64 @@ class MskTest {
assertThat(response.bootstrapBrokerString()).isNotNull();
}
+ // Exercised through the real AWS SDK, which is the point: the v2 Cluster shape nests
+ // everything provisioned-specific under Provisioned. If the emulator returns those members
+ // flat under clusterInfo, the SDK simply does not see them and provisioned() comes back
+ // null - the same way terraform-provider-aws would fail to read them.
@Test
@Order(5)
+ void createAndDescribeClusterV2() {
+ String v2ClusterName = TestFixtures.uniqueName("msk-cluster-v2");
+ String v2ClusterArn = null;
+ try {
+ CreateClusterV2Response created = kafka.createClusterV2(CreateClusterV2Request.builder()
+ .clusterName(v2ClusterName)
+ .tags(Map.of("Environment", "compat"))
+ .provisioned(ProvisionedRequest.builder()
+ .kafkaVersion("3.6.1")
+ .numberOfBrokerNodes(2)
+ .brokerNodeGroupInfo(BrokerNodeGroupInfo.builder()
+ .instanceType("kafka.m5.large")
+ .clientSubnets("subnet-12345")
+ .build())
+ .build())
+ .build());
+
+ assertThat(created.clusterArn()).isNotNull();
+ assertThat(created.clusterType()).isEqualTo(ClusterType.PROVISIONED);
+ v2ClusterArn = created.clusterArn();
+
+ DescribeClusterV2Response described = kafka.describeClusterV2(DescribeClusterV2Request.builder()
+ .clusterArn(v2ClusterArn)
+ .build());
+
+ Cluster info = described.clusterInfo();
+ assertThat(info).isNotNull();
+ assertThat(info.clusterArn()).isEqualTo(v2ClusterArn);
+ assertThat(info.clusterName()).isEqualTo(v2ClusterName);
+ assertThat(info.clusterType()).isEqualTo(ClusterType.PROVISIONED);
+ assertThat(info.tags()).containsEntry("Environment", "compat");
+
+ assertThat(info.provisioned()).isNotNull();
+ assertThat(info.provisioned().numberOfBrokerNodes()).isEqualTo(2);
+ assertThat(info.provisioned().currentBrokerSoftwareInfo().kafkaVersion()).isEqualTo("3.6.1");
+ assertThat(info.provisioned().brokerNodeGroupInfo().instanceType()).isEqualTo("kafka.m5.large");
+ assertThat(info.provisioned().brokerNodeGroupInfo().clientSubnets()).contains("subnet-12345");
+
+ assertThat(kafka.listClustersV2(ListClustersV2Request.builder().build()).clusterInfoList())
+ .anyMatch(c -> c.provisioned() != null
+ && c.clusterName().equals(v2ClusterName));
+ } finally {
+ if (v2ClusterArn != null) {
+ try {
+ kafka.deleteCluster(DeleteClusterRequest.builder().clusterArn(v2ClusterArn).build());
+ } catch (Exception ignored) {}
+ }
+ }
+ }
+
+ @Test
+ @Order(6)
void deleteCluster() {
DeleteClusterResponse response = kafka.deleteCluster(DeleteClusterRequest.builder()
.clusterArn(clusterArn)
diff --git a/docs/services/msk.md b/docs/services/msk.md
index 47ca8e4948..2892fb5177 100644
--- a/docs/services/msk.md
+++ b/docs/services/msk.md
@@ -10,7 +10,7 @@ Floci emulates Amazon MSK by orchestrating **Redpanda** containers. This provide
| Action | Description |
|---|---|
| `CreateCluster` | Spawns a new Redpanda container for the cluster |
-| `CreateClusterV2` | Modern serverless/provisioned creation (mapped to provisioned) |
+| `CreateClusterV2` | Create a provisioned or serverless cluster |
| `ListClusters` | List all emulated clusters |
| `ListClustersV2` | List all emulated clusters using V2 API |
| `DescribeCluster` | Get cluster metadata and state |
@@ -24,6 +24,9 @@ Floci emulates Amazon MSK by orchestrating **Redpanda** containers. This provide
| `UpdateConfiguration` | Create a new revision of a configuration |
| `ListConfigurationRevisions` | List all revisions of a configuration |
| `DescribeConfigurationRevision` | Get a specific revision, including its `server.properties` |
+| `ListTagsForResource` | List the tags on a cluster or configuration |
+| `TagResource` | Add tags to a cluster or configuration |
+| `UntagResource` | Remove tags from a cluster or configuration |
## Configuration
@@ -41,6 +44,69 @@ When `mock` is set to `false` (default), Floci uses the Docker API to start a Re
- **Persistence**: Each cluster gets a named Docker volume (`floci-msk-{volumeId}`). In memory mode the volume is removed on cluster delete; in persistent modes it is retained unless `FLOCI_STORAGE_PRUNE_VOLUMES_ON_DELETE=true`.
- **Readiness**: The cluster state transitions to `ACTIVE` once the Redpanda `/ready` endpoint is reachable.
+## Cluster metadata
+
+`CreateCluster` and `CreateClusterV2` persist the metadata you pass — broker node group
+(instance type, subnets, security groups, storage, connectivity), number of broker nodes,
+encryption, client authentication, enhanced monitoring, open monitoring, logging,
+configuration, storage mode, rebalancing and tags —
+and echo it back from `DescribeCluster`/`DescribeClusterV2` and the matching `List` calls.
+
+The two API versions return different shapes, matching AWS:
+
+- **v1** (`DescribeCluster`) returns a flat `ClusterInfo`: `brokerNodeGroupInfo`,
+ `encryptionInfo`, `clientAuthentication`, `enhancedMonitoring`, `loggingInfo`,
+ `openMonitoring`, `storageMode`, `rebalancing`, `numberOfBrokerNodes` and
+ `zookeeperConnectString` all sit directly on the cluster.
+- **v2** (`DescribeClusterV2`) nests all of those under `ClusterInfo.Provisioned`, alongside a
+ top-level `ClusterType` of `PROVISIONED`. `ClusterArn`, `ClusterName`, `State`,
+ `CreationTime`, `CurrentVersion` and `Tags` stay top-level.
+
+Two details worth knowing:
+
+- `configurationInfo` is a *request-only* member. The configuration a cluster was created
+ with is reported back on `currentBrokerSoftwareInfo` as `configurationArn` and
+ `configurationRevision`, which is where the Terraform AWS provider reads it from.
+- Members AWS defaults server-side are defaulted here too, so a `terraform plan` converges:
+ `enhancedMonitoring` becomes `DEFAULT`, and `encryptionInfo.encryptionInTransit` becomes
+ `clientBroker: TLS_PLAINTEXT` / `inCluster: true` when the request omits them.
+
+### Serverless clusters
+
+`CreateClusterV2` accepts a `serverless` member as well as `provisioned` — exactly one of the
+two, as on AWS. A serverless cluster stores its `vpcConfigs` and `clientAuthentication`, reports
+`clusterType: SERVERLESS`, and comes back from `DescribeClusterV2` under a `serverless` envelope
+rather than a `provisioned` one. It is backed by the same emulated Kafka endpoint, so
+`GetBootstrapBrokers` works normally.
+
+The v1 API predates serverless and its `ClusterInfo` cannot represent one, so — as on AWS —
+`DescribeCluster` on a serverless cluster returns `BadRequestException` pointing you at
+`DescribeClusterV2`, and `ListClusters` omits serverless clusters entirely.
+
+### Validation
+
+`CreateCluster`/`CreateClusterV2` reject the values AWS rejects: a missing or over-64-character
+`clusterName`, a `numberOfBrokerNodes` below 1, an EBS `volumeSize` outside 1–16384, a
+`configurationInfo.revision` below 1, and any unrecognised `enhancedMonitoring`, `storageMode`,
+`rebalancing.status` or `encryptionInTransit.clientBroker` value. Each 400 names the offending
+member in `invalidParameter`, as MSK's `Error` schema does.
+
+There is deliberately **no** upper bound on `numberOfBrokerNodes`. The SDK model caps it at 15,
+but the REST API reference documents no maximum for it — on a page that gives ranges for its
+neighbours — and the quota page allows 30 brokers per ZooKeeper cluster and 60 per KRaft
+cluster, both adjustable. A 30-broker cluster is an ordinary thing to have.
+
+Unlike AWS, the *presence* of `kafkaVersion`, `numberOfBrokerNodes` and `brokerNodeGroupInfo` is
+not required — the emulator defaults them so that a minimal create request still works.
+
+### Tags
+
+Cluster and configuration tags are managed through `/v1/tags/{resourceArn}`
+(`ListTagsForResource`, `TagResource`, `UntagResource`). Cluster tags also round-trip through
+`DescribeCluster`/`DescribeClusterV2`, so a tag change is visible to a refresh either way.
+Configuration tags are reachable only through the tag endpoints, because AWS's
+`DescribeConfiguration` response has no tags member.
+
## Examples
```bash
@@ -50,7 +116,7 @@ export AWS_ENDPOINT_URL=http://localhost:4566
aws kafka create-cluster \
--cluster-name my-cluster \
--kafka-version "3.6.1" \
- --numberOfBrokerNodes 1 \
+ --number-of-broker-nodes 1 \
--broker-node-group-info '{"InstanceType":"kafka.m5.large","ClientSubnets":["subnet-1"]}' \
--endpoint-url $AWS_ENDPOINT_URL
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java b/src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java
index e3525b238d..41b359bd89 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java
@@ -1,9 +1,6 @@
package io.github.hectorvent.floci.core.common;
-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 jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
@@ -21,10 +18,6 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Dispatcher for AWS services that share the REST {@code /tags/{resourceArn}} path
* (API Gateway, EventBridge Scheduler, EKS, ...).
@@ -34,60 +27,43 @@ import java.util.Map;
* service from the {@code service} segment of the request ARN
* ({@code arn:aws:<service>:<region>:<account>:<resource>}) and dispatches to the
* matching {@link TagHandler}.
+ *
+ * <p>The resolution and wire-shape logic lives in {@link TagDispatcher}, shared with
+ * {@link V1TagsController}, which does the same job for the services AWS puts on
+ * {@code /v1/tags/{resourceArn}} instead.
*/
@Path("/tags")
@Produces(MediaType.APPLICATION_JSON)
public class SharedTagsController {
- private final Map<String, TagHandler> handlersByServiceKey;
- private final RegionResolver regionResolver;
- private final ObjectMapper objectMapper;
+ private final TagDispatcher dispatcher;
@Inject
public SharedTagsController(Instance<TagHandler> handlers,
RegionResolver regionResolver,
ObjectMapper objectMapper) {
- Map<String, TagHandler> map = new HashMap<>();
- for (TagHandler h : handlers) {
- String serviceKey = h.serviceKey();
- TagHandler existing = map.putIfAbsent(serviceKey, h);
- if (existing != null) {
- throw new IllegalStateException(
- "Duplicate TagHandler registration for service key '" + serviceKey
- + "': " + existing.getClass().getName()
- + " and " + h.getClass().getName());
- }
- }
- this.handlersByServiceKey = Map.copyOf(map);
- this.regionResolver = regionResolver;
- this.objectMapper = objectMapper;
+ this.dispatcher = new TagDispatcher(handlers, regionResolver, objectMapper);
}
@GET
public Response listTagsByQuery(@Context HttpHeaders headers,
@QueryParam("resourceArn") String arn) {
- return listTagsForArn(headers, arn);
+ return dispatcher.listTagsForArn(headers, arn);
}
@GET
@Path("/{arn: .+}")
public Response listTags(@Context HttpHeaders headers, @PathParam("arn") String arn) {
- return listTagsForArn(headers, arn);
- }
-
- private Response listTagsForArn(HttpHeaders headers, String arn) {
- TagHandler handler = resolveHandler(arn);
- String region = regionResolver.resolveRegion(headers);
- Map<String, String> tags = handler.listTags(region, arn);
- return Response.ok(buildListResponse(handler, tags)).build();
+ return dispatcher.listTagsForArn(headers, arn);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response tagResourceByBody(@Context HttpHeaders headers, String body) {
- String arn = readResourceArn(body);
- TagHandler handler = resolveHandler(arn);
- return doTagResource(headers, handler, arn, body, Response.ok(objectMapper.createObjectNode()).build());
+ String arn = dispatcher.readResourceArn(body);
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.doTagResource(headers, handler, arn, body,
+ Response.ok(dispatcher.emptyObject()).build());
}
@POST
@@ -96,12 +72,8 @@ public class SharedTagsController {
public Response tagResourcePost(@Context HttpHeaders headers,
@PathParam("arn") String arn,
String body) {
- TagHandler handler = resolveHandler(arn);
- if (handler.tagResourceUsesPut()) {
- throw new AwsException("MethodNotAllowedException",
- "POST is not supported for " + handler.serviceKey() + " tag resources; use PUT.", 405);
- }
- return doTagResource(headers, handler, arn, body,
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.tagResourcePost(headers, arn, body,
Response.status(handler.tagResourceSuccessStatus()).build());
}
@@ -111,36 +83,17 @@ public class SharedTagsController {
public Response tagResourcePut(@Context HttpHeaders headers,
@PathParam("arn") String arn,
String body) {
- TagHandler handler = resolveHandler(arn);
- if (!handler.tagResourceUsesPut()) {
- throw new AwsException("MethodNotAllowedException",
- "PUT is not supported for " + handler.serviceKey() + " tag resources; use POST.", 405);
- }
- return doTagResource(headers, handler, arn, body,
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.tagResourcePut(headers, arn, body,
Response.status(handler.tagResourceSuccessStatus()).build());
}
- private Response doTagResource(HttpHeaders headers, TagHandler handler, String arn, String body, Response successResponse) {
- String region = regionResolver.resolveRegion(headers);
- String effectiveBody = (body == null || body.isBlank()) ? "{}" : body;
- try {
- JsonNode node = objectMapper.readTree(effectiveBody);
- Map<String, String> tags = parseTags(handler, node);
- handler.tagResource(region, arn, tags);
- return successResponse;
- } catch (AwsException e) {
- throw e;
- } catch (Exception e) {
- String code = handler.strictTagValidation() ? "ValidationException" : "BadRequestException";
- throw new AwsException(code, e.getMessage(), 400);
- }
- }
-
@DELETE
public Response untagResourceByQuery(@Context HttpHeaders headers,
@Context UriInfo uriInfo,
@QueryParam("resourceArn") String arn) {
- return untagResourceForArn(headers, uriInfo, arn, Response.ok(objectMapper.createObjectNode()).build());
+ return dispatcher.untagResourceForArn(headers, uriInfo, arn,
+ Response.ok(dispatcher.emptyObject()).build());
}
@DELETE
@@ -148,134 +101,8 @@ public class SharedTagsController {
public Response untagResource(@Context HttpHeaders headers,
@Context UriInfo uriInfo,
@PathParam("arn") String arn) {
- TagHandler handler = resolveHandler(arn);
- return untagResourceForArn(headers, uriInfo, arn,
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.untagResourceForArn(headers, uriInfo, arn,
Response.status(handler.untagResourceSuccessStatus()).build(), handler);
}
-
- private Response untagResourceForArn(HttpHeaders headers, UriInfo uriInfo, String arn, Response successResponse) {
- return untagResourceForArn(headers, uriInfo, arn, successResponse, resolveHandler(arn));
- }
-
- private Response untagResourceForArn(HttpHeaders headers, UriInfo uriInfo, String arn,
- Response successResponse, TagHandler handler) {
- String region = regionResolver.resolveRegion(headers);
- List<String> tagKeys = readTagKeys(handler, uriInfo);
- handler.untagResource(region, arn, tagKeys);
- return successResponse;
- }
-
- private ObjectNode buildListResponse(TagHandler handler, Map<String, String> tags) {
- ObjectNode root = objectMapper.createObjectNode();
- String key = handler.tagsBodyKey();
- if (handler.tagsBodyIsList()) {
- ArrayNode arr = root.putArray(key);
- tags.forEach((k, v) -> {
- ObjectNode entry = arr.addObject();
- entry.put("Key", k);
- entry.put("Value", v);
- });
- } else {
- ObjectNode tagsNode = root.putObject(key);
- tags.forEach(tagsNode::put);
- }
- return root;
- }
-
- private Map<String, String> parseTags(TagHandler handler, JsonNode node) {
- Map<String, String> tags = new HashMap<>();
- String key = handler.tagsBodyKey();
- if (handler.strictTagValidation() && !node.isObject()) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Request payload must be a JSON object", 400);
- }
- JsonNode tagNode = node.get(key);
- if (tagNode == null || tagNode.isNull()) {
- if (handler.strictTagValidation()) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Value null at '" + key + "' failed to satisfy constraint: Member must not be null", 400);
- }
- return tags;
- }
- if (handler.tagsBodyIsList()) {
- if (!tagNode.isArray()) {
- if (handler.strictTagValidation()) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Value at '" + key + "' failed to satisfy constraint: Member must be a list", 400);
- }
- return tags;
- }
- for (JsonNode entry : tagNode) {
- JsonNode k = entry.get("Key");
- JsonNode v = entry.get("Value");
- if (k == null || k.isNull() || v == null || v.isNull()) {
- if (handler.strictTagValidation()) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Tag entries at '" + key + "' must have non-null Key and Value", 400);
- }
- continue;
- }
- if (handler.strictTagValidation() && (!k.isTextual() || !v.isTextual())) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Tag entries at '" + key
- + "' must contain string Key and Value members", 400);
- }
- tags.put(k.asText(), v.asText());
- }
- } else {
- if (!tagNode.isObject()) {
- if (handler.strictTagValidation()) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Value at '" + key + "' failed to satisfy constraint: Member must be a map", 400);
- }
- return tags;
- }
- tagNode.fields().forEachRemaining(e -> {
- if (handler.strictTagValidation() && !e.getValue().isTextual()) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Tag values at '" + key + "' must be strings", 400);
- }
- tags.put(e.getKey(), e.getValue().asText());
- });
- }
- return tags;
- }
-
- private List<String> readTagKeys(TagHandler handler, UriInfo uriInfo) {
- String paramName = handler.tagKeysQueryName();
- List<String> values = uriInfo.getQueryParameters().get(paramName);
- if (handler.strictTagValidation() && !handler.allowEmptyTagKeys()
- && (values == null || values.isEmpty())) {
- throw new AwsException("ValidationException",
- "1 validation error detected: Value null at '" + paramName + "' failed to satisfy constraint: Member must not be null", 400);
- }
- return (values == null) ? List.of() : List.copyOf(values);
- }
-
- private String readResourceArn(String body) {
- try {
- JsonNode node = objectMapper.readTree((body == null || body.isBlank()) ? "{}" : body);
- return node.path("resourceArn").asText(null);
- } catch (Exception e) {
- throw new AwsException("BadRequestException", e.getMessage(), 400);
- }
- }
-
- private TagHandler resolveHandler(String arn) {
- String serviceKey;
- try {
- serviceKey = AwsArnUtils.parse(arn).service();
- } catch (IllegalArgumentException e) {
- throw new AwsException("BadRequestException",
- "Invalid resource ARN: " + arn, 400);
- }
- TagHandler handler = handlersByServiceKey.get(serviceKey);
- if (handler == null) {
- // Surface an unregistered service as an invalid-ARN error so floci's
- // internal routing isn't leaked to the client.
- throw new AwsException("BadRequestException",
- "Invalid resource ARN: " + arn, 400);
- }
- return handler;
- }
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/TagDispatcher.java b/src/main/java/io/github/hectorvent/floci/core/common/TagDispatcher.java
new file mode 100644
index 0000000000..ef77592139
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/TagDispatcher.java
@@ -0,0 +1,222 @@
+package io.github.hectorvent.floci.core.common;
+
+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 jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.UriInfo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The shared machinery behind floci's REST tag paths: resolve the owning service from the
+ * request ARN, then apply the {@link TagHandler} wire-shape choices for that service.
+ *
+ * <p>AWS distinguishes these services by hostname, but floci serves every service on a single
+ * port, so a tag path alone is ambiguous. Two paths need this dispatch and each has its own
+ * thin controller: {@code SharedTagsController} on {@code /tags/{arn}} (API Gateway, EKS,
+ * Scheduler, ...) and {@code V1TagsController} on {@code /v1/tags/{arn}} (AppSync, MSK).
+ * The two sets of handlers are kept apart by the {@link V1Tags} qualifier, so a service is
+ * only reachable on the path AWS actually defines for it.
+ */
+public class TagDispatcher {
+
+ private final Map<String, TagHandler> handlersByServiceKey;
+ private final RegionResolver regionResolver;
+ private final ObjectMapper objectMapper;
+
+ public TagDispatcher(Iterable<TagHandler> handlers,
+ RegionResolver regionResolver,
+ ObjectMapper objectMapper) {
+ Map<String, TagHandler> map = new HashMap<>();
+ for (TagHandler h : handlers) {
+ String serviceKey = h.serviceKey();
+ TagHandler existing = map.putIfAbsent(serviceKey, h);
+ if (existing != null) {
+ throw new IllegalStateException(
+ "Duplicate TagHandler registration for service key '" + serviceKey
+ + "': " + existing.getClass().getName()
+ + " and " + h.getClass().getName());
+ }
+ }
+ this.handlersByServiceKey = Map.copyOf(map);
+ this.regionResolver = regionResolver;
+ this.objectMapper = objectMapper;
+ }
+
+ public ObjectNode emptyObject() {
+ return objectMapper.createObjectNode();
+ }
+
+ public Response listTagsForArn(HttpHeaders headers, String arn) {
+ TagHandler handler = resolveHandler(arn);
+ String region = regionResolver.resolveRegion(headers);
+ Map<String, String> tags = handler.listTags(region, arn);
+ return Response.ok(buildListResponse(handler, tags)).build();
+ }
+
+ public Response tagResourcePost(HttpHeaders headers, String arn, String body, Response successResponse) {
+ TagHandler handler = resolveHandler(arn);
+ if (handler.tagResourceUsesPut()) {
+ throw new AwsException("MethodNotAllowedException",
+ "POST is not supported for " + handler.serviceKey() + " tag resources; use PUT.", 405);
+ }
+ return doTagResource(headers, handler, arn, body, successResponse);
+ }
+
+ public Response tagResourcePut(HttpHeaders headers, String arn, String body, Response successResponse) {
+ TagHandler handler = resolveHandler(arn);
+ if (!handler.tagResourceUsesPut()) {
+ throw new AwsException("MethodNotAllowedException",
+ "PUT is not supported for " + handler.serviceKey() + " tag resources; use POST.", 405);
+ }
+ return doTagResource(headers, handler, arn, body, successResponse);
+ }
+
+ public Response doTagResource(HttpHeaders headers, TagHandler handler, String arn,
+ String body, Response successResponse) {
+ String region = regionResolver.resolveRegion(headers);
+ String effectiveBody = (body == null || body.isBlank()) ? "{}" : body;
+ try {
+ JsonNode node = objectMapper.readTree(effectiveBody);
+ Map<String, String> tags = parseTags(handler, node);
+ handler.tagResource(region, arn, tags);
+ return successResponse;
+ } catch (AwsException e) {
+ throw e;
+ } catch (Exception e) {
+ String code = handler.strictTagValidation() ? "ValidationException" : "BadRequestException";
+ throw new AwsException(code, e.getMessage(), 400);
+ }
+ }
+
+ public Response untagResourceForArn(HttpHeaders headers, UriInfo uriInfo, String arn, Response successResponse) {
+ return untagResourceForArn(headers, uriInfo, arn, successResponse, resolveHandler(arn));
+ }
+
+ public Response untagResourceForArn(HttpHeaders headers, UriInfo uriInfo, String arn,
+ Response successResponse, TagHandler handler) {
+ String region = regionResolver.resolveRegion(headers);
+ List<String> tagKeys = readTagKeys(handler, uriInfo);
+ handler.untagResource(region, arn, tagKeys);
+ return successResponse;
+ }
+
+ private ObjectNode buildListResponse(TagHandler handler, Map<String, String> tags) {
+ ObjectNode root = objectMapper.createObjectNode();
+ String key = handler.tagsBodyKey();
+ if (handler.tagsBodyIsList()) {
+ ArrayNode arr = root.putArray(key);
+ tags.forEach((k, v) -> {
+ ObjectNode entry = arr.addObject();
+ entry.put("Key", k);
+ entry.put("Value", v);
+ });
+ } else {
+ ObjectNode tagsNode = root.putObject(key);
+ tags.forEach(tagsNode::put);
+ }
+ return root;
+ }
+
+ private Map<String, String> parseTags(TagHandler handler, JsonNode node) {
+ Map<String, String> tags = new HashMap<>();
+ String key = handler.tagsBodyKey();
+ if (handler.strictTagValidation() && !node.isObject()) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Request payload must be a JSON object", 400);
+ }
+ JsonNode tagNode = node.get(key);
+ if (tagNode == null || tagNode.isNull()) {
+ if (handler.strictTagValidation()) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Value null at '" + key + "' failed to satisfy constraint: Member must not be null", 400);
+ }
+ return tags;
+ }
+ if (handler.tagsBodyIsList()) {
+ if (!tagNode.isArray()) {
+ if (handler.strictTagValidation()) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Value at '" + key + "' failed to satisfy constraint: Member must be a list", 400);
+ }
+ return tags;
+ }
+ for (JsonNode entry : tagNode) {
+ JsonNode k = entry.get("Key");
+ JsonNode v = entry.get("Value");
+ if (k == null || k.isNull() || v == null || v.isNull()) {
+ if (handler.strictTagValidation()) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Tag entries at '" + key + "' must have non-null Key and Value", 400);
+ }
+ continue;
+ }
+ if (handler.strictTagValidation() && (!k.isTextual() || !v.isTextual())) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Tag entries at '" + key
+ + "' must contain string Key and Value members", 400);
+ }
+ tags.put(k.asText(), v.asText());
+ }
+ } else {
+ if (!tagNode.isObject()) {
+ if (handler.strictTagValidation()) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Value at '" + key + "' failed to satisfy constraint: Member must be a map", 400);
+ }
+ return tags;
+ }
+ tagNode.fields().forEachRemaining(e -> {
+ if (handler.strictTagValidation() && !e.getValue().isTextual()) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Tag values at '" + key + "' must be strings", 400);
+ }
+ tags.put(e.getKey(), e.getValue().asText());
+ });
+ }
+ return tags;
+ }
+
+ private List<String> readTagKeys(TagHandler handler, UriInfo uriInfo) {
+ String paramName = handler.tagKeysQueryName();
+ List<String> values = uriInfo.getQueryParameters().get(paramName);
+ if (handler.strictTagValidation() && !handler.allowEmptyTagKeys()
+ && (values == null || values.isEmpty())) {
+ throw new AwsException("ValidationException",
+ "1 validation error detected: Value null at '" + paramName + "' failed to satisfy constraint: Member must not be null", 400);
+ }
+ return (values == null) ? List.of() : List.copyOf(values);
+ }
+
+ public String readResourceArn(String body) {
+ try {
+ JsonNode node = objectMapper.readTree((body == null || body.isBlank()) ? "{}" : body);
+ return node.path("resourceArn").asText(null);
+ } catch (Exception e) {
+ throw new AwsException("BadRequestException", e.getMessage(), 400);
+ }
+ }
+
+ public TagHandler resolveHandler(String arn) {
+ String serviceKey;
+ try {
+ serviceKey = AwsArnUtils.parse(arn).service();
+ } catch (IllegalArgumentException e) {
+ throw new AwsException("BadRequestException",
+ "Invalid resource ARN: " + arn, 400);
+ }
+ TagHandler handler = handlersByServiceKey.get(serviceKey);
+ if (handler == null) {
+ // Surface an unregistered service as an invalid-ARN error so floci's
+ // internal routing isn't leaked to the client.
+ throw new AwsException("BadRequestException",
+ "Invalid resource ARN: " + arn, 400);
+ }
+ return handler;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/V1Tags.java b/src/main/java/io/github/hectorvent/floci/core/common/V1Tags.java
new file mode 100644
index 0000000000..2bd5950d8b
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/V1Tags.java
@@ -0,0 +1,23 @@
+package io.github.hectorvent.floci.core.common;
+
+import jakarta.inject.Qualifier;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks a {@link TagHandler} as belonging to the {@code /v1/tags/{arn}} path rather than the
+ * default {@code /tags/{arn}} one.
+ *
+ * <p>A qualified bean is not a {@code @Default} bean, so {@code SharedTagsController}'s
+ * unqualified {@code Instance<TagHandler>} does not see these, and {@code V1TagsController}'s
+ * {@code @V1Tags Instance<TagHandler>} sees only these. That keeps each service reachable
+ * on the tag path AWS actually defines for it instead of on both.
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+public @interface V1Tags {
+}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/V1TagsController.java b/src/main/java/io/github/hectorvent/floci/core/common/V1TagsController.java
new file mode 100644
index 0000000000..b444d7a465
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/V1TagsController.java
@@ -0,0 +1,79 @@
+package io.github.hectorvent.floci.core.common;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import jakarta.enterprise.inject.Instance;
+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.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+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 jakarta.ws.rs.core.UriInfo;
+
+/**
+ * Dispatcher for the AWS services that put their tag endpoints on {@code /v1/tags/{resourceArn}}
+ * (AppSync, MSK).
+ *
+ * <p>Same problem and same resolution as {@link SharedTagsController}, one path up: AWS tells
+ * these services apart by hostname, floci serves them all on one port, so the owning service is
+ * resolved from the {@code service} segment of the request ARN and the request handed to the
+ * matching {@link TagHandler}. Handlers opt in to this path with {@link V1Tags}.
+ */
+@Path("/v1/tags")
+@Produces(MediaType.APPLICATION_JSON)
+public class V1TagsController {
+
+ private final TagDispatcher dispatcher;
+
+ @Inject
+ public V1TagsController(@V1Tags Instance<TagHandler> handlers,
+ RegionResolver regionResolver,
+ ObjectMapper objectMapper) {
+ this.dispatcher = new TagDispatcher(handlers, regionResolver, objectMapper);
+ }
+
+ @GET
+ @Path("/{arn: .+}")
+ public Response listTags(@Context HttpHeaders headers, @PathParam("arn") String arn) {
+ return dispatcher.listTagsForArn(headers, arn);
+ }
+
+ @POST
+ @Path("/{arn: .+}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response tagResourcePost(@Context HttpHeaders headers,
+ @PathParam("arn") String arn,
+ String body) {
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.tagResourcePost(headers, arn, body,
+ Response.status(handler.tagResourceSuccessStatus()).build());
+ }
+
+ @PUT
+ @Path("/{arn: .+}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response tagResourcePut(@Context HttpHeaders headers,
+ @PathParam("arn") String arn,
+ String body) {
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.tagResourcePut(headers, arn, body,
+ Response.status(handler.tagResourceSuccessStatus()).build());
+ }
+
+ @DELETE
+ @Path("/{arn: .+}")
+ public Response untagResource(@Context HttpHeaders headers,
+ @Context UriInfo uriInfo,
+ @PathParam("arn") String arn) {
+ TagHandler handler = dispatcher.resolveHandler(arn);
+ return dispatcher.untagResourceForArn(headers, uriInfo, arn,
+ Response.status(handler.untagResourceSuccessStatus()).build(), handler);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java
index b42a4046fd..420238e560 100644
--- a/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java
+++ b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java
@@ -454,36 +454,8 @@ public class AppSyncController {
return Response.noContent().build();
}
- // ──────────────────────────── Tags ────────────────────────────
-
- @POST
- @Path("/v1/tags/{resourceArn: .+}")
- public Response tagResource(@PathParam("resourceArn") String resourceArn, String body) throws IOException {
- @SuppressWarnings("unchecked")
- Map<String, Object> request = objectMapper.readValue(body, Map.class);
- @SuppressWarnings("unchecked")
- Map<String, String> tags = (Map<String, String>) request.get("tags");
- service.tagResource(resourceArn, tags);
- return Response.noContent().build();
- }
-
- @DELETE
- @Path("/v1/tags/{resourceArn: .+}")
- public Response untagResource(@PathParam("resourceArn") String resourceArn,
- @QueryParam("tagKeys") List<String> tagKeys) {
- service.untagResource(resourceArn, tagKeys);
- return Response.noContent().build();
- }
-
- @GET
- @Path("/v1/tags/{resourceArn: .+}")
- public Response listTagsForResource(@PathParam("resourceArn") String resourceArn) {
- Map<String, String> tags = service.getTags(resourceArn);
- ObjectNode root = objectMapper.createObjectNode();
- ObjectNode tagsNode = root.putObject("tags");
- tags.forEach(tagsNode::put);
- return Response.ok(root).build();
- }
+ // Tags moved to AppSyncTagHandler: MSK shares the /v1/tags/{arn} path, so it is served by
+ // the ARN-dispatching V1TagsController now.
// ──────────────────────────── Environment Variables ────────────────────────────
diff --git a/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncTagHandler.java b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncTagHandler.java
new file mode 100644
index 0000000000..20cb08c6bb
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncTagHandler.java
@@ -0,0 +1,50 @@
+package io.github.hectorvent.floci.services.appsync;
+
+import io.github.hectorvent.floci.core.common.TagHandler;
+import io.github.hectorvent.floci.core.common.V1Tags;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AppSync's tag endpoints, which AWS puts on {@code /v1/tags/{resourceArn}}.
+ *
+ * <p>These used to be three handlers on {@code AppSyncController}. MSK's tag API lives on the
+ * same path, and floci serves both services on one port, so the path had to move behind the
+ * ARN-dispatching {@code V1TagsController} - two JAX-RS resource methods cannot claim the same
+ * path and method. The wire shape is unchanged: a lowercase {@code tags} map, POST to tag,
+ * {@code tagKeys} to untag, 204 on both.
+ */
+@ApplicationScoped
+@V1Tags
+public class AppSyncTagHandler implements TagHandler {
+
+ private final AppSyncService service;
+
+ @Inject
+ public AppSyncTagHandler(AppSyncService service) {
+ this.service = service;
+ }
+
+ @Override
+ public String serviceKey() {
+ return "appsync";
+ }
+
+ @Override
+ public Map<String, String> listTags(String region, String arn) {
+ return service.getTags(arn);
+ }
+
+ @Override
+ public void tagResource(String region, String arn, Map<String, String> tags) {
+ service.tagResource(arn, tags);
+ }
+
+ @Override
+ public void untagResource(String region, String arn, List<String> tagKeys) {
+ service.untagResource(arn, tagKeys);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/MskController.java b/src/main/java/io/github/hectorvent/floci/services/msk/MskController.java
index ef14520403..936e46d9d4 100644
--- a/src/main/java/io/github/hectorvent/floci/services/msk/MskController.java
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/MskController.java
@@ -1,10 +1,12 @@
package io.github.hectorvent.floci.services.msk;
import io.github.hectorvent.floci.core.common.AwsException;
-import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.services.msk.model.ConfigurationRevision;
import io.github.hectorvent.floci.services.msk.model.ConfigurationRevisionDetail;
+import io.github.hectorvent.floci.services.msk.model.CreateClusterRequest;
+import io.github.hectorvent.floci.services.msk.model.CreateClusterV2Request;
import io.github.hectorvent.floci.services.msk.model.MskCluster;
import io.github.hectorvent.floci.services.msk.model.MskConfiguration;
import jakarta.inject.Inject;
@@ -23,6 +25,10 @@ import java.util.Map;
@Consumes(MediaType.APPLICATION_JSON)
public class MskController {
+ // Fallback for clusters persisted before clusterType was stored - everything written back
+ // then was provisioned, since serverless had no representation at all.
+ private static final String PROVISIONED_CLUSTER_TYPE = "PROVISIONED";
+
private final MskService mskService;
@Inject
@@ -32,51 +38,48 @@ public class MskController {
@POST
@Path("/v1/clusters")
- public Response createCluster(Map<String, Object> request) {
- String clusterName = (String) request.get("clusterName");
- String kafkaVersion = (String) request.get("kafkaVersion");
- MskCluster cluster = mskService.createCluster(clusterName, kafkaVersion);
+ public Response createCluster(CreateClusterRequest request) {
+ MskCluster cluster = mskService.createCluster(request);
return Response.ok(Map.of("clusterArn", cluster.getClusterArn(), "clusterName", cluster.getClusterName(), "state", cluster.getState())).build();
}
@POST
@Path("/api/v2/clusters")
- @SuppressWarnings("unchecked")
- public Response createClusterV2(Map<String, Object> request) {
- // Simple mapping to V1 for now
- String clusterName = (String) request.get("clusterName");
- Map<String, Object> provisioned = (Map<String, Object>) request.get("provisioned");
- String kafkaVersion = provisioned != null ? (String) provisioned.get("kafkaVersion") : null;
- MskCluster cluster = mskService.createCluster(clusterName, kafkaVersion);
- return Response.ok(Map.of("clusterArn", cluster.getClusterArn(), "clusterName", cluster.getClusterName(), "state", cluster.getState())).build();
+ public Response createClusterV2(CreateClusterV2Request request) {
+ MskCluster cluster = mskService.createCluster(request);
+ return Response.ok(Map.of(
+ "clusterArn", cluster.getClusterArn(),
+ "clusterName", cluster.getClusterName(),
+ "state", cluster.getState(),
+ "clusterType", clusterType(cluster))).build();
}
@GET
@Path("/v1/clusters")
public Response listClusters() {
- var clusters = mskService.listClusters();
+ var clusters = mskService.listProvisionedClusters().stream().map(this::toClusterViewV1).toList();
return Response.ok(Map.of("clusterInfoList", clusters)).build();
}
@GET
@Path("/api/v2/clusters")
public Response listClustersV2() {
- var clusters = mskService.listClusters();
+ var clusters = mskService.listClusters().stream().map(this::toClusterViewV2).toList();
return Response.ok(Map.of("clusterInfoList", clusters)).build();
}
@GET
@Path("/v1/clusters/{clusterArn}")
public Response describeCluster(@PathParam("clusterArn") String clusterArn) {
- MskCluster cluster = mskService.describeCluster(clusterArn);
- return Response.ok(Map.of("clusterInfo", cluster)).build();
+ MskCluster cluster = mskService.describeClusterV1(clusterArn);
+ return Response.ok(Map.of("clusterInfo", toClusterViewV1(cluster))).build();
}
@GET
@Path("/api/v2/clusters/{clusterArn}")
public Response describeClusterV2(@PathParam("clusterArn") String clusterArn) {
MskCluster cluster = mskService.describeCluster(clusterArn);
- return Response.ok(Map.of("clusterInfo", cluster)).build();
+ return Response.ok(Map.of("clusterInfo", toClusterViewV2(cluster))).build();
}
@DELETE
@@ -189,6 +192,73 @@ public class MskController {
return Response.ok(response).build();
}
+ // The v1 ClusterInfo is flat: broker node group, encryption, client auth, monitoring and
+ // logging all sit directly on the cluster object.
+ //
+ // Built explicitly rather than by serializing MskCluster, because that model is also the
+ // persisted shape and carries internal bookkeeping (bootstrapBrokers, containerId,
+ // accountId, volumeId) that must stay in the store but never reach a client.
+ private Map<String, Object> toClusterViewV1(MskCluster cluster) {
+ Map<String, Object> view = commonClusterFields(cluster);
+ view.putAll(provisionedFields(cluster));
+ return view;
+ }
+
+ // The v2 ClusterInfo is NOT the v1 shape with extra members: everything provisioned-specific
+ // nests under "provisioned", and a "clusterType" discriminator selects between that and the
+ // serverless shape. An AWS SDK v2 client - which is what terraform-provider-aws calls -
+ // looks for these fields only there, so returning them flat leaves them invisible to it.
+ private Map<String, Object> toClusterViewV2(MskCluster cluster) {
+ Map<String, Object> view = commonClusterFields(cluster);
+ view.put("clusterType", clusterType(cluster));
+ if (mskService.isServerless(cluster)) {
+ putIfPresent(view, "serverless", cluster.getServerless());
+ } else {
+ view.put("provisioned", provisionedFields(cluster));
+ }
+ return view;
+ }
+
+ private String clusterType(MskCluster cluster) {
+ return cluster.getClusterType() != null ? cluster.getClusterType() : PROVISIONED_CLUSTER_TYPE;
+ }
+
+ // Members that stay top-level in both versions.
+ private Map<String, Object> commonClusterFields(MskCluster cluster) {
+ Map<String, Object> view = new HashMap<>();
+ view.put("clusterArn", cluster.getClusterArn());
+ view.put("clusterName", cluster.getClusterName());
+ view.put("state", cluster.getState());
+ view.put("creationTime", cluster.getCreationTime());
+ view.put("currentVersion", cluster.getCurrentVersion());
+ view.put("tags", cluster.getTags() != null ? cluster.getTags() : Map.of());
+ return view;
+ }
+
+ // Members that are flat on v1's ClusterInfo and nested under v2's "provisioned".
+ private Map<String, Object> provisionedFields(MskCluster cluster) {
+ Map<String, Object> view = new HashMap<>();
+ view.put("numberOfBrokerNodes", cluster.getNumberOfBrokerNodes());
+ view.put("zookeeperConnectString", cluster.getZookeeperConnectString());
+ view.put("currentBrokerSoftwareInfo", cluster.getCurrentBrokerSoftwareInfo());
+ // Absent optional members are omitted rather than sent as null, matching AWS.
+ putIfPresent(view, "brokerNodeGroupInfo", cluster.getBrokerNodeGroupInfo());
+ putIfPresent(view, "encryptionInfo", cluster.getEncryptionInfo());
+ putIfPresent(view, "clientAuthentication", cluster.getClientAuthentication());
+ putIfPresent(view, "enhancedMonitoring", cluster.getEnhancedMonitoring());
+ putIfPresent(view, "loggingInfo", cluster.getLoggingInfo());
+ putIfPresent(view, "openMonitoring", cluster.getOpenMonitoring());
+ putIfPresent(view, "storageMode", cluster.getStorageMode());
+ putIfPresent(view, "rebalancing", cluster.getRebalancing());
+ return view;
+ }
+
+ private void putIfPresent(Map<String, Object> view, String key, Object value) {
+ if (value != null) {
+ view.put(key, value);
+ }
+ }
+
// AWS's Configuration/DescribeConfigurationResponse shape never includes
// serverProperties (that's only returned via DescribeConfigurationRevision), so build
// an explicit view instead of serializing the model directly.
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/MskService.java b/src/main/java/io/github/hectorvent/floci/services/msk/MskService.java
index 743ce7f634..a049c0cb79 100644
--- a/src/main/java/io/github/hectorvent/floci/services/msk/MskService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/MskService.java
@@ -12,10 +12,16 @@ import io.github.hectorvent.floci.core.resource.SupportedResourceType;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.msk.model.BrokerNodeGroupInfo;
import io.github.hectorvent.floci.services.msk.model.ClusterState;
import io.github.hectorvent.floci.services.msk.model.ConfigurationRevision;
import io.github.hectorvent.floci.services.msk.model.ConfigurationRevisionDetail;
+import io.github.hectorvent.floci.services.msk.model.ConfigurationInfo;
import io.github.hectorvent.floci.services.msk.model.ConfigurationState;
+import io.github.hectorvent.floci.services.msk.model.CreateClusterRequest;
+import io.github.hectorvent.floci.services.msk.model.CreateClusterV2Request;
+import io.github.hectorvent.floci.services.msk.model.EncryptionInTransit;
+import io.github.hectorvent.floci.services.msk.model.EncryptionInfo;
import io.github.hectorvent.floci.services.msk.model.MskCluster;
import io.github.hectorvent.floci.services.msk.model.MskConfiguration;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -28,6 +34,7 @@ import org.jboss.logging.Logger;
import java.security.SecureRandom;
import java.time.Instant;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -41,7 +48,28 @@ public class MskService implements ResourceProvider {
private static final Logger LOG = Logger.getLogger(MskService.class);
private static final String DEFAULT_KAFKA_VERSION = "3.6.0";
+ private static final String DEFAULT_ENHANCED_MONITORING = "DEFAULT";
+ private static final String DEFAULT_CLIENT_BROKER_ENCRYPTION = "TLS_PLAINTEXT";
+ private static final String PROVISIONED_CLUSTER_TYPE = "PROVISIONED";
+ private static final String SERVERLESS_CLUSTER_TYPE = "SERVERLESS";
private static final int MAX_PAGE = 100;
+ private static final int MAX_CLUSTER_NAME_LENGTH = 64;
+ // Floor only, deliberately no ceiling. The SDK/CLI reference carries an __integerMin1Max15
+ // shape for numberOfBrokerNodes, but the REST API reference documents no minimum or maximum
+ // for it - on a page that does give ranges for its neighbours (volumeSize 1-16384,
+ // revision min 1) - and the quota page allows 30 brokers per ZooKeeper cluster and 60 per
+ // KRaft cluster, both adjustable upward. Capping at 15 would reject clusters real MSK
+ // accepts and turn a converging-on-the-wrong-number bug into an outright apply failure for
+ // every count from 16 up. An emulator that accepts a little more than AWS costs nobody
+ // anything; one that rejects a valid request blocks real work.
+ private static final int MIN_BROKER_NODES = 1;
+ private static final int MIN_EBS_VOLUME_SIZE = 1;
+ private static final int MAX_EBS_VOLUME_SIZE = 16384;
+ private static final Set<String> ENHANCED_MONITORING_VALUES =
+ Set.of("DEFAULT", "PER_BROKER", "PER_TOPIC_PER_BROKER", "PER_TOPIC_PER_PARTITION");
+ private static final Set<String> STORAGE_MODE_VALUES = Set.of("LOCAL", "TIERED");
+ private static final Set<String> CLIENT_BROKER_VALUES = Set.of("TLS", "TLS_PLAINTEXT", "PLAINTEXT");
+ private static final Set<String> REBALANCING_STATUS_VALUES = Set.of("PAUSED", "ACTIVE");
private final StorageBackend<String, MskCluster> storage;
private final StorageBackend<String, MskConfiguration> configurationStorage;
private final EmulatorConfig config;
@@ -81,6 +109,15 @@ public class MskService implements ResourceProvider {
}
public MskCluster createCluster(String clusterName, String kafkaVersion) {
+ CreateClusterRequest request = new CreateClusterRequest();
+ request.setClusterName(clusterName);
+ request.setKafkaVersion(kafkaVersion);
+ return createCluster(request);
+ }
+
+ public MskCluster createCluster(CreateClusterRequest request) {
+ validateCreateRequest(request);
+ String clusterName = request.getClusterName();
if (storage.scan(k -> true).stream().anyMatch(c -> c.getClusterName().equals(clusterName))) {
throw new AwsException("ConflictException", "Cluster already exists: " + clusterName, 409);
}
@@ -88,11 +125,209 @@ public class MskService implements ResourceProvider {
String accountId = regionResolver.getAccountId();
String clusterArn = AwsArnUtils.Arn.of("kafka", config.defaultRegion(), accountId, "cluster/" + clusterName + "/" + java.util.UUID.randomUUID()).toString();
+ String kafkaVersion = request.getKafkaVersion();
String resolvedKafkaVersion = (kafkaVersion == null || kafkaVersion.isBlank()) ? DEFAULT_KAFKA_VERSION : kafkaVersion;
MskCluster cluster = new MskCluster(clusterArn, clusterName, resolvedKafkaVersion);
+ cluster.setClusterType(PROVISIONED_CLUSTER_TYPE);
+ cluster.setAccountId(accountId);
+ cluster.setVolumeId(String.format("%06x", new SecureRandom().nextInt(0xFFFFFF)));
+
+ if (request.getNumberOfBrokerNodes() != null) {
+ cluster.setNumberOfBrokerNodes(request.getNumberOfBrokerNodes());
+ }
+ cluster.setTags(request.getTags());
+ cluster.setBrokerNodeGroupInfo(request.getBrokerNodeGroupInfo());
+ cluster.setClientAuthentication(request.getClientAuthentication());
+ cluster.setLoggingInfo(request.getLoggingInfo());
+ cluster.setOpenMonitoring(request.getOpenMonitoring());
+ cluster.setStorageMode(request.getStorageMode());
+ cluster.setRebalancing(request.getRebalancing());
+
+ // AWS applies these server-side when the member is absent, and echoes the resolved
+ // value back on Describe. Leaving them unset instead is what keeps a terraform plan
+ // permanently dirty: the provider's schema defaults them, so a null in the response
+ // reads as a drift against config the user never wrote.
+ cluster.setEnhancedMonitoring(request.getEnhancedMonitoring() != null
+ ? request.getEnhancedMonitoring() : DEFAULT_ENHANCED_MONITORING);
+ cluster.setEncryptionInfo(withEncryptionDefaults(request.getEncryptionInfo()));
+
+ // configurationInfo is a request-only member: the response carries the configuration
+ // on currentBrokerSoftwareInfo instead (see BrokerSoftwareInfo).
+ ConfigurationInfo configurationInfo = request.getConfigurationInfo();
+ if (configurationInfo != null) {
+ cluster.getCurrentBrokerSoftwareInfo().setConfigurationArn(configurationInfo.getArn());
+ cluster.getCurrentBrokerSoftwareInfo().setConfigurationRevision(configurationInfo.getRevision());
+ }
+
+ if (config.services().msk().mock()) {
+ cluster.setState(ClusterState.ACTIVE);
+ cluster.setBootstrapBrokers("localhost:9092");
+ } else {
+ redpandaManager.startContainer(cluster);
+ }
+
+ storage.put(clusterArn, cluster);
+ return cluster;
+ }
+
+ public MskCluster createCluster(CreateClusterV2Request request) {
+ // A CreateClusterV2 request carries exactly one of provisioned/serverless. A serverless
+ // request used to be flattened into a provisioned cluster, which then reported itself as
+ // provisioned and echoed broker metadata the caller never asked for.
+ if (request.getServerless() != null) {
+ if (request.getProvisioned() != null) {
+ throw badRequest("serverless",
+ "Exactly one of provisioned and serverless must be specified.");
+ }
+ return createServerlessCluster(request);
+ }
+
+ CreateClusterRequest merged = new CreateClusterRequest();
+ merged.setClusterName(request.getClusterName());
+ merged.setTags(request.getTags());
+ if (request.getProvisioned() != null) {
+ merged.setKafkaVersion(request.getProvisioned().getKafkaVersion());
+ merged.setNumberOfBrokerNodes(request.getProvisioned().getNumberOfBrokerNodes());
+ merged.setBrokerNodeGroupInfo(request.getProvisioned().getBrokerNodeGroupInfo());
+ merged.setEncryptionInfo(request.getProvisioned().getEncryptionInfo());
+ merged.setClientAuthentication(request.getProvisioned().getClientAuthentication());
+ merged.setEnhancedMonitoring(request.getProvisioned().getEnhancedMonitoring());
+ merged.setLoggingInfo(request.getProvisioned().getLoggingInfo());
+ merged.setConfigurationInfo(request.getProvisioned().getConfigurationInfo());
+ merged.setOpenMonitoring(request.getProvisioned().getOpenMonitoring());
+ merged.setStorageMode(request.getProvisioned().getStorageMode());
+ merged.setRebalancing(request.getProvisioned().getRebalancing());
+ }
+ return createCluster(merged);
+ }
+
+ /**
+ * Rejects the CreateCluster input AWS rejects.
+ *
+ * <p>Scoped to the members AWS documents an actual constraint for, plus {@code clusterName},
+ * whose absence used to build an ARN containing {@code cluster/null/<uuid>} and store a
+ * cluster that could never be addressed by name.
+ *
+ * <p>Deliberately NOT enforced: the *presence* of {@code kafkaVersion},
+ * {@code numberOfBrokerNodes} and {@code brokerNodeGroupInfo}, which real MSK requires.
+ * The emulator has always defaulted those, and tightening it would reject minimal fixtures
+ * across the suite for no emulation benefit - a separate, deliberate break rather than
+ * something to slip into a metadata round-trip fix.
+ */
+ private void validateCreateRequest(CreateClusterRequest request) {
+ String clusterName = request.getClusterName();
+ if (clusterName == null || clusterName.isBlank()) {
+ throw badRequest("clusterName", "clusterName is required.");
+ }
+ if (clusterName.length() > MAX_CLUSTER_NAME_LENGTH) {
+ throw badRequest("clusterName",
+ "clusterName must be between 1 and " + MAX_CLUSTER_NAME_LENGTH + " characters.");
+ }
+
+ Integer brokerNodes = request.getNumberOfBrokerNodes();
+ if (brokerNodes != null && brokerNodes < MIN_BROKER_NODES) {
+ throw badRequest("numberOfBrokerNodes",
+ "numberOfBrokerNodes must be at least " + MIN_BROKER_NODES + ".");
+ }
+
+ BrokerNodeGroupInfo nodeGroup = request.getBrokerNodeGroupInfo();
+ if (nodeGroup != null && nodeGroup.getStorageInfo() != null
+ && nodeGroup.getStorageInfo().getEbsStorageInfo() != null) {
+ Integer volumeSize = nodeGroup.getStorageInfo().getEbsStorageInfo().getVolumeSize();
+ if (volumeSize != null && (volumeSize < MIN_EBS_VOLUME_SIZE || volumeSize > MAX_EBS_VOLUME_SIZE)) {
+ throw badRequest("volumeSize",
+ "volumeSize must be between " + MIN_EBS_VOLUME_SIZE + " and " + MAX_EBS_VOLUME_SIZE + ".");
+ }
+ }
+
+ ConfigurationInfo configurationInfo = request.getConfigurationInfo();
+ if (configurationInfo != null && configurationInfo.getRevision() != null
+ && configurationInfo.getRevision() < 1) {
+ throw badRequest("configurationInfo.revision", "configurationInfo.revision must be at least 1.");
+ }
+
+ validateEnum("enhancedMonitoring", request.getEnhancedMonitoring(), ENHANCED_MONITORING_VALUES);
+ validateEnum("storageMode", request.getStorageMode(), STORAGE_MODE_VALUES);
+ if (request.getEncryptionInfo() != null && request.getEncryptionInfo().getEncryptionInTransit() != null) {
+ validateEnum("encryptionInfo.encryptionInTransit.clientBroker",
+ request.getEncryptionInfo().getEncryptionInTransit().getClientBroker(), CLIENT_BROKER_VALUES);
+ }
+ if (request.getRebalancing() != null) {
+ validateEnum("rebalancing.status", request.getRebalancing().getStatus(), REBALANCING_STATUS_VALUES);
+ }
+ }
+
+ private void validateEnum(String field, String value, Set<String> allowed) {
+ if (value != null && !allowed.contains(value)) {
+ throw badRequest(field,
+ field + " must be one of " + String.join(", ", new java.util.TreeSet<>(allowed)) + ".");
+ }
+ }
+
+ // MSK's Error schema is two members - message and invalidParameter, "the parameter that
+ // caused the error" - so a validation failure names the member it rejected.
+ private AwsException badRequest(String invalidParameter, String message) {
+ return new AwsException("BadRequestException", message, 400,
+ Map.of("invalidParameter", invalidParameter));
+ }
+
+ /**
+ * Fills in the encryption-in-transit defaults AWS applies when CreateCluster omits them:
+ * {@code clientBroker} defaults to TLS_PLAINTEXT and {@code inCluster} to true. An
+ * explicitly supplied value is never overwritten. {@code encryptionAtRest} is left alone -
+ * real MSK creates a KMS key for you there, which the emulator has no equivalent of, so
+ * inventing an ARN would be worse than omitting the member.
+ */
+ private EncryptionInfo withEncryptionDefaults(EncryptionInfo requested) {
+ EncryptionInfo encryptionInfo = requested != null ? requested : new EncryptionInfo();
+ EncryptionInTransit inTransit = encryptionInfo.getEncryptionInTransit();
+ if (inTransit == null) {
+ inTransit = new EncryptionInTransit();
+ encryptionInfo.setEncryptionInTransit(inTransit);
+ }
+ if (inTransit.getClientBroker() == null) {
+ inTransit.setClientBroker(DEFAULT_CLIENT_BROKER_ENCRYPTION);
+ }
+ if (inTransit.getInCluster() == null) {
+ inTransit.setInCluster(true);
+ }
+ return encryptionInfo;
+ }
+
+ /**
+ * Serverless clusters have no broker node group, instance type or broker count to speak of -
+ * AWS manages that - so none of the provisioned metadata is stored or echoed for them. The
+ * emulated Kafka endpoint behind the cluster is the same either way.
+ */
+ private MskCluster createServerlessCluster(CreateClusterV2Request request) {
+ String clusterName = request.getClusterName();
+ if (clusterName == null || clusterName.isBlank()) {
+ throw badRequest("clusterName", "clusterName is required.");
+ }
+ if (clusterName.length() > MAX_CLUSTER_NAME_LENGTH) {
+ throw badRequest("clusterName",
+ "clusterName must be between 1 and " + MAX_CLUSTER_NAME_LENGTH + " characters.");
+ }
+ if (storage.scan(k -> true).stream().anyMatch(c -> c.getClusterName().equals(clusterName))) {
+ throw new AwsException("ConflictException", "Cluster already exists: " + clusterName, 409);
+ }
+
+ String accountId = regionResolver.getAccountId();
+ String clusterArn = AwsArnUtils.Arn.of("kafka", config.defaultRegion(), accountId,
+ "cluster/" + clusterName + "/" + UUID.randomUUID()).toString();
+
+ MskCluster cluster = new MskCluster(clusterArn, clusterName, DEFAULT_KAFKA_VERSION);
+ cluster.setClusterType(SERVERLESS_CLUSTER_TYPE);
+ cluster.setServerless(request.getServerless());
+ cluster.setTags(request.getTags());
cluster.setAccountId(accountId);
cluster.setVolumeId(String.format("%06x", new SecureRandom().nextInt(0xFFFFFF)));
+ // Provisioned-only members must not surface on a serverless cluster.
+ cluster.setNumberOfBrokerNodes(0);
+ cluster.setZookeeperConnectString(null);
+ cluster.setCurrentBrokerSoftwareInfo(null);
+
if (config.services().msk().mock()) {
cluster.setState(ClusterState.ACTIVE);
cluster.setBootstrapBrokers("localhost:9092");
@@ -104,6 +339,29 @@ public class MskService implements ResourceProvider {
return cluster;
}
+ public boolean isServerless(MskCluster cluster) {
+ return SERVERLESS_CLUSTER_TYPE.equals(cluster.getClusterType());
+ }
+
+ /**
+ * DescribeCluster for the v1 API, which predates serverless: its ClusterInfo has no way to
+ * represent one, and real MSK answers a v1 describe of a serverless cluster with a
+ * BadRequestException pointing the caller at DescribeClusterV2.
+ */
+ public MskCluster describeClusterV1(String clusterArn) {
+ MskCluster cluster = describeCluster(clusterArn);
+ if (isServerless(cluster)) {
+ throw new AwsException("BadRequestException",
+ "This operation cannot be performed on serverless clusters. Use DescribeClusterV2 instead.", 400);
+ }
+ return cluster;
+ }
+
+ /** ListClusters for the v1 API, which likewise cannot represent serverless clusters. */
+ public List<MskCluster> listProvisionedClusters() {
+ return storage.scan(k -> true).stream().filter(c -> !isServerless(c)).toList();
+ }
+
public MskCluster describeCluster(String clusterArn) {
return storage.get(clusterArn)
.orElseThrow(() -> new AwsException("NotFoundException", "Cluster not found: " + clusterArn, 404));
@@ -257,6 +515,80 @@ public class MskService implements ResourceProvider {
revision, serverProperties);
}
+ // ── Tags (ListTagsForResource / TagResource / UntagResource on /v1/tags/{arn}) ──────────
+ //
+ // MSK tags both clusters and configurations, and the tag path carries only an ARN, so the
+ // resource type is resolved by looking the ARN up in each store rather than by parsing it.
+ // An unknown ARN is a 404 here, which is what the tags path documents - unlike
+ // DescribeConfiguration, whose 400 is a deliberate terraform-provider contract.
+
+ public Map<String, String> listTagsForResource(String arn) {
+ MskCluster cluster = storage.get(arn).orElse(null);
+ if (cluster != null) {
+ return cluster.getTags() != null ? cluster.getTags() : Map.of();
+ }
+ MskConfiguration configuration = configurationStorage.get(arn).orElse(null);
+ if (configuration != null) {
+ return configuration.getTags() != null ? configuration.getTags() : Map.of();
+ }
+ throw taggedResourceNotFound(arn);
+ }
+
+ public void tagResource(String arn, Map<String, String> tags) {
+ MskCluster cluster = storage.get(arn).orElse(null);
+ if (cluster != null) {
+ cluster.setTags(merged(cluster.getTags(), tags));
+ storage.put(arn, cluster);
+ return;
+ }
+ MskConfiguration configuration = configurationStorage.get(arn).orElse(null);
+ if (configuration != null) {
+ configuration.setTags(merged(configuration.getTags(), tags));
+ configurationStorage.put(arn, configuration);
+ return;
+ }
+ throw taggedResourceNotFound(arn);
+ }
+
+ public void untagResource(String arn, List<String> tagKeys) {
+ MskCluster cluster = storage.get(arn).orElse(null);
+ if (cluster != null) {
+ cluster.setTags(without(cluster.getTags(), tagKeys));
+ storage.put(arn, cluster);
+ return;
+ }
+ MskConfiguration configuration = configurationStorage.get(arn).orElse(null);
+ if (configuration != null) {
+ configuration.setTags(without(configuration.getTags(), tagKeys));
+ configurationStorage.put(arn, configuration);
+ return;
+ }
+ throw taggedResourceNotFound(arn);
+ }
+
+ // Copies rather than mutating in place: a tag map that arrived through CreateCluster can be
+ // an immutable Map (Map.of, or whatever Jackson handed us), which putAll/remove would
+ // reject at runtime.
+ private Map<String, String> merged(Map<String, String> existing, Map<String, String> added) {
+ Map<String, String> result = new HashMap<>(existing != null ? existing : Map.of());
+ if (added != null) {
+ result.putAll(added);
+ }
+ return result;
+ }
+
+ private Map<String, String> without(Map<String, String> existing, List<String> tagKeys) {
+ Map<String, String> result = new HashMap<>(existing != null ? existing : Map.of());
+ if (tagKeys != null) {
+ tagKeys.forEach(result::remove);
+ }
+ return result;
+ }
+
+ private AwsException taggedResourceNotFound(String arn) {
+ return new AwsException("NotFoundException", "Resource " + arn + " does not exist.", 404);
+ }
+
private void startReadinessPoller() {
poller.scheduleAtFixedRate(() -> {
try {
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/MskTagHandler.java b/src/main/java/io/github/hectorvent/floci/services/msk/MskTagHandler.java
new file mode 100644
index 0000000000..7dacc5c097
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/MskTagHandler.java
@@ -0,0 +1,53 @@
+package io.github.hectorvent.floci.services.msk;
+
+import io.github.hectorvent.floci.core.common.TagHandler;
+import io.github.hectorvent.floci.core.common.V1Tags;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * MSK's tag endpoints, which AWS puts on {@code /v1/tags/{resourceArn}}.
+ *
+ * <p>A separate bean rather than {@code MskService} implementing {@link TagHandler} itself:
+ * a class-level {@link V1Tags} on the service would strip its {@code @Default} qualifier and
+ * break every plain {@code @Inject MskService} injection point, while adding {@code @Default}
+ * back would make MSK reachable on {@code /tags/{arn}} as well, which AWS does not define.
+ *
+ * <p>MSK's wire shape matches every {@link TagHandler} default - a lowercase {@code tags} map,
+ * POST for TagResource, {@code tagKeys} for UntagResource, 204 on both - so nothing is
+ * overridden here.
+ */
+@ApplicationScoped
+@V1Tags
+public class MskTagHandler implements TagHandler {
+
+ private final MskService mskService;
+
+ @Inject
+ public MskTagHandler(MskService mskService) {
+ this.mskService = mskService;
+ }
+
+ @Override
+ public String serviceKey() {
+ return "kafka";
+ }
+
+ @Override
+ public Map<String, String> listTags(String region, String arn) {
+ return mskService.listTagsForResource(arn);
+ }
+
+ @Override
+ public void tagResource(String region, String arn, Map<String, String> tags) {
+ mskService.tagResource(arn, tags);
+ }
+
+ @Override
+ public void untagResource(String region, String arn, List<String> tagKeys) {
+ mskService.untagResource(arn, tagKeys);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerLogs.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerLogs.java
new file mode 100644
index 0000000000..547740b142
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerLogs.java
@@ -0,0 +1,32 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BrokerLogs {
+
+ @JsonProperty("cloudWatchLogs")
+ private CloudWatchLogs cloudWatchLogs;
+
+ @JsonProperty("firehose")
+ private Firehose firehose;
+
+ @JsonProperty("s3")
+ private S3 s3;
+
+ public BrokerLogs() {}
+
+ public CloudWatchLogs getCloudWatchLogs() { return cloudWatchLogs; }
+ public void setCloudWatchLogs(CloudWatchLogs cloudWatchLogs) { this.cloudWatchLogs = cloudWatchLogs; }
+
+ public Firehose getFirehose() { return firehose; }
+ public void setFirehose(Firehose firehose) { this.firehose = firehose; }
+
+ public S3 getS3() { return s3; }
+ public void setS3(S3 s3) { this.s3 = s3; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerNodeGroupInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerNodeGroupInfo.java
new file mode 100644
index 0000000000..c36603d48e
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerNodeGroupInfo.java
@@ -0,0 +1,58 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+import java.util.List;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BrokerNodeGroupInfo {
+
+ @JsonProperty("brokerAZDistribution")
+ private String brokerAZDistribution;
+
+ @JsonProperty("clientSubnets")
+ private List<String> clientSubnets;
+
+ @JsonProperty("instanceType")
+ private String instanceType;
+
+ @JsonProperty("securityGroups")
+ private List<String> securityGroups;
+
+ @JsonProperty("storageInfo")
+ private StorageInfo storageInfo;
+
+ @JsonProperty("connectivityInfo")
+ private ConnectivityInfo connectivityInfo;
+
+ @JsonProperty("zoneIds")
+ private List<String> zoneIds;
+
+ public BrokerNodeGroupInfo() {}
+
+ public String getBrokerAZDistribution() { return brokerAZDistribution; }
+ public void setBrokerAZDistribution(String brokerAZDistribution) { this.brokerAZDistribution = brokerAZDistribution; }
+
+ public List<String> getClientSubnets() { return clientSubnets; }
+ public void setClientSubnets(List<String> clientSubnets) { this.clientSubnets = clientSubnets; }
+
+ public String getInstanceType() { return instanceType; }
+ public void setInstanceType(String instanceType) { this.instanceType = instanceType; }
+
+ public List<String> getSecurityGroups() { return securityGroups; }
+ public void setSecurityGroups(List<String> securityGroups) { this.securityGroups = securityGroups; }
+
+ public StorageInfo getStorageInfo() { return storageInfo; }
+ public void setStorageInfo(StorageInfo storageInfo) { this.storageInfo = storageInfo; }
+
+ public ConnectivityInfo getConnectivityInfo() { return connectivityInfo; }
+ public void setConnectivityInfo(ConnectivityInfo connectivityInfo) { this.connectivityInfo = connectivityInfo; }
+
+ public List<String> getZoneIds() { return zoneIds; }
+ public void setZoneIds(List<String> zoneIds) { this.zoneIds = zoneIds; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerSoftwareInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerSoftwareInfo.java
index 5779e9eb2a..9da14a461e 100644
--- a/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerSoftwareInfo.java
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/BrokerSoftwareInfo.java
@@ -1,11 +1,29 @@
package io.github.hectorvent.floci.services.msk.model;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
+/**
+ * Where a cluster reports the Apache Kafka version it runs and the MSK configuration it
+ * was created with.
+ *
+ * <p>{@code configurationInfo} is a CreateCluster *request* member only - neither
+ * DescribeCluster's {@code ClusterInfo} nor DescribeClusterV2's {@code Provisioned} has a
+ * top-level {@code configurationInfo}. AWS echoes the configuration back here instead, as
+ * {@code configurationArn}/{@code configurationRevision}, and that is where
+ * terraform-provider-aws reads it from to populate {@code configuration_info}.
+ */
@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class BrokerSoftwareInfo {
+ @JsonProperty("configurationArn")
+ private String configurationArn;
+
+ @JsonProperty("configurationRevision")
+ private Long configurationRevision;
+
@JsonProperty("kafkaVersion")
private String kafkaVersion;
@@ -15,6 +33,12 @@ public class BrokerSoftwareInfo {
this.kafkaVersion = kafkaVersion;
}
+ public String getConfigurationArn() { return configurationArn; }
+ public void setConfigurationArn(String configurationArn) { this.configurationArn = configurationArn; }
+
+ public Long getConfigurationRevision() { return configurationRevision; }
+ public void setConfigurationRevision(Long configurationRevision) { this.configurationRevision = configurationRevision; }
+
public String getKafkaVersion() { return kafkaVersion; }
public void setKafkaVersion(String kafkaVersion) { this.kafkaVersion = kafkaVersion; }
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/ClientAuthentication.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/ClientAuthentication.java
new file mode 100644
index 0000000000..91767abfbb
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/ClientAuthentication.java
@@ -0,0 +1,32 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ClientAuthentication {
+
+ @JsonProperty("sasl")
+ private Sasl sasl;
+
+ @JsonProperty("tls")
+ private Tls tls;
+
+ @JsonProperty("unauthenticated")
+ private Unauthenticated unauthenticated;
+
+ public ClientAuthentication() {}
+
+ public Sasl getSasl() { return sasl; }
+ public void setSasl(Sasl sasl) { this.sasl = sasl; }
+
+ public Tls getTls() { return tls; }
+ public void setTls(Tls tls) { this.tls = tls; }
+
+ public Unauthenticated getUnauthenticated() { return unauthenticated; }
+ public void setUnauthenticated(Unauthenticated unauthenticated) { this.unauthenticated = unauthenticated; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/CloudWatchLogs.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/CloudWatchLogs.java
new file mode 100644
index 0000000000..4f971cac3a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/CloudWatchLogs.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CloudWatchLogs {
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ @JsonProperty("logGroup")
+ private String logGroup;
+
+ public CloudWatchLogs() {}
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+
+ public String getLogGroup() { return logGroup; }
+ public void setLogGroup(String logGroup) { this.logGroup = logGroup; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/ConfigurationInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/ConfigurationInfo.java
new file mode 100644
index 0000000000..ef8fa52f95
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/ConfigurationInfo.java
@@ -0,0 +1,24 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConfigurationInfo {
+
+ @JsonProperty("arn")
+ private String arn;
+
+ @JsonProperty("revision")
+ private Long revision;
+
+ public ConfigurationInfo() {}
+
+ public String getArn() { return arn; }
+ public void setArn(String arn) { this.arn = arn; }
+
+ public Long getRevision() { return revision; }
+ public void setRevision(Long revision) { this.revision = revision; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/ConnectivityInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/ConnectivityInfo.java
new file mode 100644
index 0000000000..8cd670d0bc
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/ConnectivityInfo.java
@@ -0,0 +1,32 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConnectivityInfo {
+
+ @JsonProperty("publicAccess")
+ private PublicAccess publicAccess;
+
+ @JsonProperty("vpcConnectivity")
+ private VpcConnectivity vpcConnectivity;
+
+ @JsonProperty("networkType")
+ private String networkType;
+
+ public ConnectivityInfo() {}
+
+ public PublicAccess getPublicAccess() { return publicAccess; }
+ public void setPublicAccess(PublicAccess publicAccess) { this.publicAccess = publicAccess; }
+
+ public VpcConnectivity getVpcConnectivity() { return vpcConnectivity; }
+ public void setVpcConnectivity(VpcConnectivity vpcConnectivity) { this.vpcConnectivity = vpcConnectivity; }
+
+ public String getNetworkType() { return networkType; }
+ public void setNetworkType(String networkType) { this.networkType = networkType; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/CreateClusterRequest.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/CreateClusterRequest.java
new file mode 100644
index 0000000000..344069d9b3
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/CreateClusterRequest.java
@@ -0,0 +1,92 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+import java.util.Map;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CreateClusterRequest {
+
+ @JsonProperty("clusterName")
+ private String clusterName;
+
+ @JsonProperty("kafkaVersion")
+ private String kafkaVersion;
+
+ @JsonProperty("numberOfBrokerNodes")
+ private Integer numberOfBrokerNodes;
+
+ @JsonProperty("brokerNodeGroupInfo")
+ private BrokerNodeGroupInfo brokerNodeGroupInfo;
+
+ @JsonProperty("encryptionInfo")
+ private EncryptionInfo encryptionInfo;
+
+ @JsonProperty("clientAuthentication")
+ private ClientAuthentication clientAuthentication;
+
+ @JsonProperty("enhancedMonitoring")
+ private String enhancedMonitoring;
+
+ @JsonProperty("loggingInfo")
+ private LoggingInfo loggingInfo;
+
+ @JsonProperty("configurationInfo")
+ private ConfigurationInfo configurationInfo;
+
+ @JsonProperty("openMonitoring")
+ private OpenMonitoring openMonitoring;
+
+ @JsonProperty("storageMode")
+ private String storageMode;
+
+ @JsonProperty("rebalancing")
+ private Rebalancing rebalancing;
+
+ @JsonProperty("tags")
+ private Map<String, String> tags;
+
+ public CreateClusterRequest() {}
+
+ public String getClusterName() { return clusterName; }
+ public void setClusterName(String clusterName) { this.clusterName = clusterName; }
+
+ public String getKafkaVersion() { return kafkaVersion; }
+ public void setKafkaVersion(String kafkaVersion) { this.kafkaVersion = kafkaVersion; }
+
+ public Integer getNumberOfBrokerNodes() { return numberOfBrokerNodes; }
+ public void setNumberOfBrokerNodes(Integer numberOfBrokerNodes) { this.numberOfBrokerNodes = numberOfBrokerNodes; }
+
+ public BrokerNodeGroupInfo getBrokerNodeGroupInfo() { return brokerNodeGroupInfo; }
+ public void setBrokerNodeGroupInfo(BrokerNodeGroupInfo brokerNodeGroupInfo) { this.brokerNodeGroupInfo = brokerNodeGroupInfo; }
+
+ public EncryptionInfo getEncryptionInfo() { return encryptionInfo; }
+ public void setEncryptionInfo(EncryptionInfo encryptionInfo) { this.encryptionInfo = encryptionInfo; }
+
+ public ClientAuthentication getClientAuthentication() { return clientAuthentication; }
+ public void setClientAuthentication(ClientAuthentication clientAuthentication) { this.clientAuthentication = clientAuthentication; }
+
+ public String getEnhancedMonitoring() { return enhancedMonitoring; }
+ public void setEnhancedMonitoring(String enhancedMonitoring) { this.enhancedMonitoring = enhancedMonitoring; }
+
+ public LoggingInfo getLoggingInfo() { return loggingInfo; }
+ public void setLoggingInfo(LoggingInfo loggingInfo) { this.loggingInfo = loggingInfo; }
+
+ public ConfigurationInfo getConfigurationInfo() { return configurationInfo; }
+ public void setConfigurationInfo(ConfigurationInfo configurationInfo) { this.configurationInfo = configurationInfo; }
+
+ public OpenMonitoring getOpenMonitoring() { return openMonitoring; }
+ public void setOpenMonitoring(OpenMonitoring openMonitoring) { this.openMonitoring = openMonitoring; }
+
+ public String getStorageMode() { return storageMode; }
+ public void setStorageMode(String storageMode) { this.storageMode = storageMode; }
+
+ public Rebalancing getRebalancing() { return rebalancing; }
+ public void setRebalancing(Rebalancing rebalancing) { this.rebalancing = rebalancing; }
+
+ public Map<String, String> getTags() { return tags; }
+ public void setTags(Map<String, String> tags) { this.tags = tags; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/CreateClusterV2Request.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/CreateClusterV2Request.java
new file mode 100644
index 0000000000..2cc3920d73
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/CreateClusterV2Request.java
@@ -0,0 +1,38 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+import java.util.Map;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CreateClusterV2Request {
+
+ @JsonProperty("clusterName")
+ private String clusterName;
+
+ @JsonProperty("tags")
+ private Map<String, String> tags;
+
+ @JsonProperty("provisioned")
+ private ProvisionedRequest provisioned;
+
+ @JsonProperty("serverless")
+ private Serverless serverless;
+
+ public CreateClusterV2Request() {}
+
+ public String getClusterName() { return clusterName; }
+ public void setClusterName(String clusterName) { this.clusterName = clusterName; }
+
+ public Map<String, String> getTags() { return tags; }
+ public void setTags(Map<String, String> tags) { this.tags = tags; }
+
+ public ProvisionedRequest getProvisioned() { return provisioned; }
+ public void setProvisioned(ProvisionedRequest provisioned) { this.provisioned = provisioned; }
+
+ public Serverless getServerless() { return serverless; }
+ public void setServerless(Serverless serverless) { this.serverless = serverless; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/EbsStorageInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/EbsStorageInfo.java
new file mode 100644
index 0000000000..637565e19e
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/EbsStorageInfo.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EbsStorageInfo {
+
+ @JsonProperty("provisionedThroughput")
+ private ProvisionedThroughput provisionedThroughput;
+
+ @JsonProperty("volumeSize")
+ private Integer volumeSize;
+
+ public EbsStorageInfo() {}
+
+ public ProvisionedThroughput getProvisionedThroughput() { return provisionedThroughput; }
+ public void setProvisionedThroughput(ProvisionedThroughput provisionedThroughput) { this.provisionedThroughput = provisionedThroughput; }
+
+ public Integer getVolumeSize() { return volumeSize; }
+ public void setVolumeSize(Integer volumeSize) { this.volumeSize = volumeSize; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionAtRest.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionAtRest.java
new file mode 100644
index 0000000000..206f6405dd
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionAtRest.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EncryptionAtRest {
+
+ @JsonProperty("dataVolumeKMSKeyId")
+ private String dataVolumeKMSKeyId;
+
+ public EncryptionAtRest() {}
+
+ public String getDataVolumeKMSKeyId() { return dataVolumeKMSKeyId; }
+ public void setDataVolumeKMSKeyId(String dataVolumeKMSKeyId) { this.dataVolumeKMSKeyId = dataVolumeKMSKeyId; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionInTransit.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionInTransit.java
new file mode 100644
index 0000000000..ec8572f548
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionInTransit.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EncryptionInTransit {
+
+ @JsonProperty("clientBroker")
+ private String clientBroker;
+
+ @JsonProperty("inCluster")
+ private Boolean inCluster;
+
+ public EncryptionInTransit() {}
+
+ public String getClientBroker() { return clientBroker; }
+ public void setClientBroker(String clientBroker) { this.clientBroker = clientBroker; }
+
+ public Boolean getInCluster() { return inCluster; }
+ public void setInCluster(Boolean inCluster) { this.inCluster = inCluster; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionInfo.java
new file mode 100644
index 0000000000..c8a3266958
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/EncryptionInfo.java
@@ -0,0 +1,28 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+import java.util.List;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EncryptionInfo {
+
+ @JsonProperty("encryptionAtRest")
+ private EncryptionAtRest encryptionAtRest;
+
+ @JsonProperty("encryptionInTransit")
+ private EncryptionInTransit encryptionInTransit;
+
+ public EncryptionInfo() {}
+
+ public EncryptionAtRest getEncryptionAtRest() { return encryptionAtRest; }
+ public void setEncryptionAtRest(EncryptionAtRest encryptionAtRest) { this.encryptionAtRest = encryptionAtRest; }
+
+ public EncryptionInTransit getEncryptionInTransit() { return encryptionInTransit; }
+ public void setEncryptionInTransit(EncryptionInTransit encryptionInTransit) { this.encryptionInTransit = encryptionInTransit; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Firehose.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Firehose.java
new file mode 100644
index 0000000000..9b0ae30b2a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Firehose.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Firehose {
+
+ @JsonProperty("deliveryStream")
+ private String deliveryStream;
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ public Firehose() {}
+
+ public String getDeliveryStream() { return deliveryStream; }
+ public void setDeliveryStream(String deliveryStream) { this.deliveryStream = deliveryStream; }
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Iam.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Iam.java
new file mode 100644
index 0000000000..9109371449
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Iam.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Iam {
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ public Iam() {}
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/JmxExporter.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/JmxExporter.java
new file mode 100644
index 0000000000..51f396cba2
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/JmxExporter.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class JmxExporter {
+
+ @JsonProperty("enabledInBroker")
+ private Boolean enabledInBroker;
+
+ public JmxExporter() {}
+
+ public Boolean getEnabledInBroker() { return enabledInBroker; }
+ public void setEnabledInBroker(Boolean enabledInBroker) { this.enabledInBroker = enabledInBroker; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/LoggingInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/LoggingInfo.java
new file mode 100644
index 0000000000..2729d4704a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/LoggingInfo.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class LoggingInfo {
+
+ @JsonProperty("brokerLogs")
+ private BrokerLogs brokerLogs;
+
+ public LoggingInfo() {}
+
+ public BrokerLogs getBrokerLogs() { return brokerLogs; }
+ public void setBrokerLogs(BrokerLogs brokerLogs) { this.brokerLogs = brokerLogs; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/MskCluster.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/MskCluster.java
index b43592f507..3535601a6c 100644
--- a/src/main/java/io/github/hectorvent/floci/services/msk/model/MskCluster.java
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/MskCluster.java
@@ -1,11 +1,24 @@
package io.github.hectorvent.floci.services.msk.model;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
import java.util.Map;
+/**
+ * The persisted shape of an MSK cluster.
+ *
+ * <p>This model is what the storage backends serialize: {@code WalStorage},
+ * {@code PersistentStorage} and {@code HybridStorage} all write it with a plain
+ * {@code ObjectMapper}, so any field hidden here is hidden from the store too and does
+ * not survive a restart. Internal bookkeeping ({@code bootstrapBrokers},
+ * {@code containerId}, {@code accountId}, {@code volumeId}) therefore stays serializable.
+ *
+ * <p>Keeping those fields out of the API is the responsibility of the response views in
+ * {@code MskController} ({@code toClusterViewV1}/{@code toClusterViewV2}), which build the
+ * client-facing JSON explicitly rather than serializing this model directly - the same
+ * split {@code MskConfiguration} and {@code toConfigurationView} already use.
+ */
@RegisterForReflection
public class MskCluster {
@@ -15,6 +28,14 @@ public class MskCluster {
@JsonProperty("clusterName")
private String clusterName;
+ // PROVISIONED or SERVERLESS. Selects which envelope the v2 view emits, and whether the v1
+ // operations - which predate serverless and have no way to describe one - accept it at all.
+ @JsonProperty("clusterType")
+ private String clusterType;
+
+ @JsonProperty("serverless")
+ private Serverless serverless;
+
@JsonProperty("state")
private ClusterState state;
@@ -36,16 +57,48 @@ public class MskCluster {
@JsonProperty("currentBrokerSoftwareInfo")
private BrokerSoftwareInfo currentBrokerSoftwareInfo;
- // Internal field, not directly in AWS response but needed for GetBootstrapBrokers
+ @JsonProperty("brokerNodeGroupInfo")
+ private BrokerNodeGroupInfo brokerNodeGroupInfo;
+
+ @JsonProperty("encryptionInfo")
+ private EncryptionInfo encryptionInfo;
+
+ @JsonProperty("clientAuthentication")
+ private ClientAuthentication clientAuthentication;
+
+ @JsonProperty("enhancedMonitoring")
+ private String enhancedMonitoring;
+
+ @JsonProperty("loggingInfo")
+ private LoggingInfo loggingInfo;
+
+ @JsonProperty("openMonitoring")
+ private OpenMonitoring openMonitoring;
+
+ @JsonProperty("storageMode")
+ private String storageMode;
+
+ @JsonProperty("rebalancing")
+ private Rebalancing rebalancing;
+
+ // Internal bookkeeping: excluded from API responses by MskController's views, but
+ // persisted, since GetBootstrapBrokers, the readiness poller and container/volume
+ // teardown all need these back after a restart.
+
+ // Needed for GetBootstrapBrokers (and by Pipes, to resolve a Kafka source's brokers)
+ @JsonProperty("bootstrapBrokers")
private String bootstrapBrokers;
-
+
// Docker container ID for mock=false
+ @JsonProperty("containerId")
private String containerId;
- @JsonIgnore
+ // Owning account, used by putCluster to write back to the right account partition
+ @JsonProperty("accountId")
private String accountId;
// 6-char hex generated once at creation for stable, collision-free volume/container naming
+ @JsonProperty("volumeId")
private String volumeId;
public MskCluster() {}
@@ -67,6 +120,12 @@ public class MskCluster {
public String getClusterName() { return clusterName; }
public void setClusterName(String clusterName) { this.clusterName = clusterName; }
+ public String getClusterType() { return clusterType; }
+ public void setClusterType(String clusterType) { this.clusterType = clusterType; }
+
+ public Serverless getServerless() { return serverless; }
+ public void setServerless(Serverless serverless) { this.serverless = serverless; }
+
public ClusterState getState() { return state; }
public void setState(ClusterState state) { this.state = state; }
@@ -88,6 +147,30 @@ public class MskCluster {
public BrokerSoftwareInfo getCurrentBrokerSoftwareInfo() { return currentBrokerSoftwareInfo; }
public void setCurrentBrokerSoftwareInfo(BrokerSoftwareInfo currentBrokerSoftwareInfo) { this.currentBrokerSoftwareInfo = currentBrokerSoftwareInfo; }
+ public BrokerNodeGroupInfo getBrokerNodeGroupInfo() { return brokerNodeGroupInfo; }
+ public void setBrokerNodeGroupInfo(BrokerNodeGroupInfo brokerNodeGroupInfo) { this.brokerNodeGroupInfo = brokerNodeGroupInfo; }
+
+ public EncryptionInfo getEncryptionInfo() { return encryptionInfo; }
+ public void setEncryptionInfo(EncryptionInfo encryptionInfo) { this.encryptionInfo = encryptionInfo; }
+
+ public ClientAuthentication getClientAuthentication() { return clientAuthentication; }
+ public void setClientAuthentication(ClientAuthentication clientAuthentication) { this.clientAuthentication = clientAuthentication; }
+
+ public String getEnhancedMonitoring() { return enhancedMonitoring; }
+ public void setEnhancedMonitoring(String enhancedMonitoring) { this.enhancedMonitoring = enhancedMonitoring; }
+
+ public LoggingInfo getLoggingInfo() { return loggingInfo; }
+ public void setLoggingInfo(LoggingInfo loggingInfo) { this.loggingInfo = loggingInfo; }
+
+ public OpenMonitoring getOpenMonitoring() { return openMonitoring; }
+ public void setOpenMonitoring(OpenMonitoring openMonitoring) { this.openMonitoring = openMonitoring; }
+
+ public String getStorageMode() { return storageMode; }
+ public void setStorageMode(String storageMode) { this.storageMode = storageMode; }
+
+ public Rebalancing getRebalancing() { return rebalancing; }
+ public void setRebalancing(Rebalancing rebalancing) { this.rebalancing = rebalancing; }
+
public String getBootstrapBrokers() { return bootstrapBrokers; }
public void setBootstrapBrokers(String bootstrapBrokers) { this.bootstrapBrokers = bootstrapBrokers; }
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/MskConfiguration.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/MskConfiguration.java
index 93aa187605..dcdfcf8c58 100644
--- a/src/main/java/io/github/hectorvent/floci/services/msk/model/MskConfiguration.java
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/MskConfiguration.java
@@ -58,7 +58,13 @@ public class MskConfiguration {
@JsonProperty("serverPropertiesByRevision")
private Map<Long, String> serverPropertiesByRevision = new ConcurrentHashMap<>();
- @JsonIgnore
+ // Tags live only in the store: AWS's Configuration/DescribeConfigurationResponse shape has
+ // no tags member, so they are reachable through ListTagsForResource only.
+ @JsonProperty("tags")
+ private Map<String, String> tags;
+
+ // Persisted so an async path can write back to the right account partition after a reload.
+ @JsonProperty("accountId")
private String accountId;
public MskConfiguration() {}
@@ -163,6 +169,9 @@ public class MskConfiguration {
}
}
+ public Map<String, String> getTags() { return tags; }
+ public void setTags(Map<String, String> tags) { this.tags = tags; }
+
public String getAccountId() { return accountId; }
public void setAccountId(String accountId) { this.accountId = accountId; }
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/NodeExporter.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/NodeExporter.java
new file mode 100644
index 0000000000..4f2d7b5736
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/NodeExporter.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class NodeExporter {
+
+ @JsonProperty("enabledInBroker")
+ private Boolean enabledInBroker;
+
+ public NodeExporter() {}
+
+ public Boolean getEnabledInBroker() { return enabledInBroker; }
+ public void setEnabledInBroker(Boolean enabledInBroker) { this.enabledInBroker = enabledInBroker; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/OpenMonitoring.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/OpenMonitoring.java
new file mode 100644
index 0000000000..4defff13cc
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/OpenMonitoring.java
@@ -0,0 +1,25 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+/**
+ * The settings for open monitoring. CreateCluster names this shape OpenMonitoringInfo and the
+ * response names it OpenMonitoring, but both carry the same single {@code prometheus} member,
+ * so one model serves both directions.
+ */
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OpenMonitoring {
+
+ @JsonProperty("prometheus")
+ private Prometheus prometheus;
+
+ public OpenMonitoring() {}
+
+ public Prometheus getPrometheus() { return prometheus; }
+ public void setPrometheus(Prometheus prometheus) { this.prometheus = prometheus; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Prometheus.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Prometheus.java
new file mode 100644
index 0000000000..180d0b2d03
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Prometheus.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Prometheus {
+
+ @JsonProperty("jmxExporter")
+ private JmxExporter jmxExporter;
+
+ @JsonProperty("nodeExporter")
+ private NodeExporter nodeExporter;
+
+ public Prometheus() {}
+
+ public JmxExporter getJmxExporter() { return jmxExporter; }
+ public void setJmxExporter(JmxExporter jmxExporter) { this.jmxExporter = jmxExporter; }
+
+ public NodeExporter getNodeExporter() { return nodeExporter; }
+ public void setNodeExporter(NodeExporter nodeExporter) { this.nodeExporter = nodeExporter; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/ProvisionedRequest.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/ProvisionedRequest.java
new file mode 100644
index 0000000000..68a57db4d3
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/ProvisionedRequest.java
@@ -0,0 +1,78 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ProvisionedRequest {
+
+ @JsonProperty("kafkaVersion")
+ private String kafkaVersion;
+
+ @JsonProperty("numberOfBrokerNodes")
+ private Integer numberOfBrokerNodes;
+
+ @JsonProperty("brokerNodeGroupInfo")
+ private BrokerNodeGroupInfo brokerNodeGroupInfo;
+
+ @JsonProperty("encryptionInfo")
+ private EncryptionInfo encryptionInfo;
+
+ @JsonProperty("clientAuthentication")
+ private ClientAuthentication clientAuthentication;
+
+ @JsonProperty("enhancedMonitoring")
+ private String enhancedMonitoring;
+
+ @JsonProperty("loggingInfo")
+ private LoggingInfo loggingInfo;
+
+ @JsonProperty("configurationInfo")
+ private ConfigurationInfo configurationInfo;
+
+ @JsonProperty("openMonitoring")
+ private OpenMonitoring openMonitoring;
+
+ @JsonProperty("storageMode")
+ private String storageMode;
+
+ @JsonProperty("rebalancing")
+ private Rebalancing rebalancing;
+
+ public ProvisionedRequest() {}
+
+ public String getKafkaVersion() { return kafkaVersion; }
+ public void setKafkaVersion(String kafkaVersion) { this.kafkaVersion = kafkaVersion; }
+
+ public Integer getNumberOfBrokerNodes() { return numberOfBrokerNodes; }
+ public void setNumberOfBrokerNodes(Integer numberOfBrokerNodes) { this.numberOfBrokerNodes = numberOfBrokerNodes; }
+
+ public BrokerNodeGroupInfo getBrokerNodeGroupInfo() { return brokerNodeGroupInfo; }
+ public void setBrokerNodeGroupInfo(BrokerNodeGroupInfo brokerNodeGroupInfo) { this.brokerNodeGroupInfo = brokerNodeGroupInfo; }
+
+ public EncryptionInfo getEncryptionInfo() { return encryptionInfo; }
+ public void setEncryptionInfo(EncryptionInfo encryptionInfo) { this.encryptionInfo = encryptionInfo; }
+
+ public ClientAuthentication getClientAuthentication() { return clientAuthentication; }
+ public void setClientAuthentication(ClientAuthentication clientAuthentication) { this.clientAuthentication = clientAuthentication; }
+
+ public String getEnhancedMonitoring() { return enhancedMonitoring; }
+ public void setEnhancedMonitoring(String enhancedMonitoring) { this.enhancedMonitoring = enhancedMonitoring; }
+
+ public LoggingInfo getLoggingInfo() { return loggingInfo; }
+ public void setLoggingInfo(LoggingInfo loggingInfo) { this.loggingInfo = loggingInfo; }
+
+ public ConfigurationInfo getConfigurationInfo() { return configurationInfo; }
+ public void setConfigurationInfo(ConfigurationInfo configurationInfo) { this.configurationInfo = configurationInfo; }
+
+ public OpenMonitoring getOpenMonitoring() { return openMonitoring; }
+ public void setOpenMonitoring(OpenMonitoring openMonitoring) { this.openMonitoring = openMonitoring; }
+
+ public String getStorageMode() { return storageMode; }
+ public void setStorageMode(String storageMode) { this.storageMode = storageMode; }
+
+ public Rebalancing getRebalancing() { return rebalancing; }
+ public void setRebalancing(Rebalancing rebalancing) { this.rebalancing = rebalancing; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/ProvisionedThroughput.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/ProvisionedThroughput.java
new file mode 100644
index 0000000000..b1a9e2e937
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/ProvisionedThroughput.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ProvisionedThroughput {
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ @JsonProperty("volumeThroughput")
+ private Integer volumeThroughput;
+
+ public ProvisionedThroughput() {}
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+
+ public Integer getVolumeThroughput() { return volumeThroughput; }
+ public void setVolumeThroughput(Integer volumeThroughput) { this.volumeThroughput = volumeThroughput; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/PublicAccess.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/PublicAccess.java
new file mode 100644
index 0000000000..5b6f5c4881
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/PublicAccess.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class PublicAccess {
+
+ @JsonProperty("type")
+ private String type;
+
+ public PublicAccess() {}
+
+ public String getType() { return type; }
+ public void setType(String type) { this.type = type; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Rebalancing.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Rebalancing.java
new file mode 100644
index 0000000000..44b8cddbff
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Rebalancing.java
@@ -0,0 +1,21 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+/** Whether intelligent rebalancing is on. Status is PAUSED or ACTIVE. */
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Rebalancing {
+
+ @JsonProperty("status")
+ private String status;
+
+ public Rebalancing() {}
+
+ public String getStatus() { return status; }
+ public void setStatus(String status) { this.status = status; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/S3.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/S3.java
new file mode 100644
index 0000000000..84cb6ff8ac
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/S3.java
@@ -0,0 +1,32 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class S3 {
+
+ @JsonProperty("bucket")
+ private String bucket;
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ @JsonProperty("prefix")
+ private String prefix;
+
+ public S3() {}
+
+ public String getBucket() { return bucket; }
+ public void setBucket(String bucket) { this.bucket = bucket; }
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+
+ public String getPrefix() { return prefix; }
+ public void setPrefix(String prefix) { this.prefix = prefix; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Sasl.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Sasl.java
new file mode 100644
index 0000000000..893ed0c446
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Sasl.java
@@ -0,0 +1,26 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Sasl {
+
+ @JsonProperty("scram")
+ private Scram scram;
+
+ @JsonProperty("iam")
+ private Iam iam;
+
+ public Sasl() {}
+
+ public Scram getScram() { return scram; }
+ public void setScram(Scram scram) { this.scram = scram; }
+
+ public Iam getIam() { return iam; }
+ public void setIam(Iam iam) { this.iam = iam; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Scram.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Scram.java
new file mode 100644
index 0000000000..4528004041
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Scram.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Scram {
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ public Scram() {}
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Serverless.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Serverless.java
new file mode 100644
index 0000000000..984b8158ad
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Serverless.java
@@ -0,0 +1,41 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import java.util.List;
+
+/**
+ * A serverless cluster's configuration - the {@code serverless} member of CreateClusterV2 and
+ * the {@code Serverless} member of the v2 Cluster response, which carry the same shape.
+ *
+ * <p>Only SASL/IAM is a valid client authentication for serverless clusters; the shared
+ * {@link ClientAuthentication} model is reused because it is a superset and omits its unset
+ * members, so a serverless response never grows a {@code tls} or {@code unauthenticated} key.
+ */
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Serverless {
+
+ @JsonProperty("vpcConfigs")
+ private List<VpcConfig> vpcConfigs;
+
+ @JsonProperty("clientAuthentication")
+ private ClientAuthentication clientAuthentication;
+
+ @JsonProperty("connectivityInfo")
+ private ConnectivityInfo connectivityInfo;
+
+ public Serverless() {}
+
+ public List<VpcConfig> getVpcConfigs() { return vpcConfigs; }
+ public void setVpcConfigs(List<VpcConfig> vpcConfigs) { this.vpcConfigs = vpcConfigs; }
+
+ public ClientAuthentication getClientAuthentication() { return clientAuthentication; }
+ public void setClientAuthentication(ClientAuthentication clientAuthentication) { this.clientAuthentication = clientAuthentication; }
+
+ public ConnectivityInfo getConnectivityInfo() { return connectivityInfo; }
+ public void setConnectivityInfo(ConnectivityInfo connectivityInfo) { this.connectivityInfo = connectivityInfo; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/StorageInfo.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/StorageInfo.java
new file mode 100644
index 0000000000..59b2d4cd2f
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/StorageInfo.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class StorageInfo {
+
+ @JsonProperty("ebsStorageInfo")
+ private EbsStorageInfo ebsStorageInfo;
+
+ public StorageInfo() {}
+
+ public EbsStorageInfo getEbsStorageInfo() { return ebsStorageInfo; }
+ public void setEbsStorageInfo(EbsStorageInfo ebsStorageInfo) { this.ebsStorageInfo = ebsStorageInfo; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Tls.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Tls.java
new file mode 100644
index 0000000000..9ccaf14e9b
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Tls.java
@@ -0,0 +1,28 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+import java.util.List;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Tls {
+
+ @JsonProperty("certificateAuthorityArnList")
+ private List<String> certificateAuthorityArnList;
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ public Tls() {}
+
+ public List<String> getCertificateAuthorityArnList() { return certificateAuthorityArnList; }
+ public void setCertificateAuthorityArnList(List<String> certificateAuthorityArnList) { this.certificateAuthorityArnList = certificateAuthorityArnList; }
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/Unauthenticated.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/Unauthenticated.java
new file mode 100644
index 0000000000..a25eda1d34
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/Unauthenticated.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Unauthenticated {
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ public Unauthenticated() {}
+
+ public Boolean getEnabled() { return enabled; }
+ public void setEnabled(Boolean enabled) { this.enabled = enabled; }
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/VpcConfig.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/VpcConfig.java
new file mode 100644
index 0000000000..71e5a3658b
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/VpcConfig.java
@@ -0,0 +1,28 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import java.util.List;
+
+/** The VPC a serverless cluster's clients connect from. */
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class VpcConfig {
+
+ @JsonProperty("subnetIds")
+ private List<String> subnetIds;
+
+ @JsonProperty("securityGroupIds")
+ private List<String> securityGroupIds;
+
+ public VpcConfig() {}
+
+ public List<String> getSubnetIds() { return subnetIds; }
+ public void setSubnetIds(List<String> subnetIds) { this.subnetIds = subnetIds; }
+
+ public List<String> getSecurityGroupIds() { return securityGroupIds; }
+ public void setSecurityGroupIds(List<String> securityGroupIds) { this.securityGroupIds = securityGroupIds; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/msk/model/VpcConnectivity.java b/src/main/java/io/github/hectorvent/floci/services/msk/model/VpcConnectivity.java
new file mode 100644
index 0000000000..de7e1dec5f
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/msk/model/VpcConnectivity.java
@@ -0,0 +1,20 @@
+package io.github.hectorvent.floci.services.msk.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class VpcConnectivity {
+
+ @JsonProperty("clientAuthentication")
+ private ClientAuthentication clientAuthentication;
+
+ public VpcConnectivity() {}
+
+ public ClientAuthentication getClientAuthentication() { return clientAuthentication; }
+ public void setClientAuthentication(ClientAuthentication clientAuthentication) { this.clientAuthentication = clientAuthentication; }
+}
\ No newline at end of file
diff --git a/src/test/java/io/github/hectorvent/floci/services/msk/MskControllerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/msk/MskControllerIntegrationTest.java
index 720f03722c..08bb37757d 100644
--- a/src/test/java/io/github/hectorvent/floci/services/msk/MskControllerIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/msk/MskControllerIntegrationTest.java
@@ -59,7 +59,7 @@ class MskControllerIntegrationTest {
.get("/api/v2/clusters/{clusterArn}", clusterArn)
.then()
.statusCode(200)
- .body("clusterInfo.currentBrokerSoftwareInfo.kafkaVersion", equalTo("3.5.1"));
+ .body("clusterInfo.provisioned.currentBrokerSoftwareInfo.kafkaVersion", equalTo("3.5.1"));
}
@Test
@@ -80,7 +80,326 @@ class MskControllerIntegrationTest {
.get("/api/v2/clusters/{clusterArn}", clusterArn)
.then()
.statusCode(200)
- .body("clusterInfo.currentBrokerSoftwareInfo.kafkaVersion", equalTo("3.6.0"));
+ .body("clusterInfo.provisioned.currentBrokerSoftwareInfo.kafkaVersion", equalTo("3.6.0"));
+ }
+
+ @Test
+ void createClusterV1EchoesBrokerNodeGroupInfoNumberOfBrokerNodesAndTags() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "v1-metadata-test",
+ "kafkaVersion": "3.6.0",
+ "numberOfBrokerNodes": 3,
+ "brokerNodeGroupInfo": {
+ "instanceType": "kafka.m5.large",
+ "clientSubnets": ["subnet-aaa", "subnet-bbb"],
+ "securityGroups": ["sg-111"],
+ "storageInfo": {"ebsStorageInfo": {"volumeSize": 100}}
+ },
+ "tags": {"Environment": "example"}
+ }
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.numberOfBrokerNodes", equalTo(3))
+ .body("clusterInfo.brokerNodeGroupInfo.instanceType", equalTo("kafka.m5.large"))
+ .body("clusterInfo.brokerNodeGroupInfo.clientSubnets", hasItem("subnet-aaa"))
+ .body("clusterInfo.brokerNodeGroupInfo.securityGroups", hasItem("sg-111"))
+ .body("clusterInfo.brokerNodeGroupInfo.storageInfo.ebsStorageInfo.volumeSize", equalTo(100))
+ .body("clusterInfo.tags.Environment", equalTo("example"));
+ }
+
+ @Test
+ void createClusterV1EchoesEncryptionClientAuthenticationAndLogging() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "v1-security-test",
+ "kafkaVersion": "3.6.0",
+ "numberOfBrokerNodes": 2,
+ "brokerNodeGroupInfo": {
+ "instanceType": "kafka.m5.large",
+ "clientSubnets": ["subnet-aaa"]
+ },
+ "encryptionInfo": {
+ "encryptionInTransit": {"clientBroker": "TLS", "inCluster": true},
+ "encryptionAtRest": {"dataVolumeKMSKeyId": "arn:aws:kms:us-east-1:123456789012:key/abc"}
+ },
+ "clientAuthentication": {
+ "sasl": {"scram": {"enabled": true}, "iam": {"enabled": false}},
+ "tls": {"certificateAuthorityArnList": ["arn:aws:acm-pca:us-east-1:123456789012:certificate-authority/ca-1"], "enabled": true}
+ },
+ "enhancedMonitoring": "PER_BROKER",
+ "loggingInfo": {"brokerLogs": {"s3": {"bucket": "msk-logs", "enabled": true, "prefix": "kafka"}}}
+ }
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.encryptionInfo.encryptionInTransit.clientBroker", equalTo("TLS"))
+ .body("clusterInfo.encryptionInfo.encryptionInTransit.inCluster", equalTo(true))
+ .body("clusterInfo.encryptionInfo.encryptionAtRest.dataVolumeKMSKeyId", equalTo("arn:aws:kms:us-east-1:123456789012:key/abc"))
+ .body("clusterInfo.clientAuthentication.sasl.scram.enabled", equalTo(true))
+ .body("clusterInfo.clientAuthentication.sasl.iam.enabled", equalTo(false))
+ .body("clusterInfo.clientAuthentication.tls.enabled", equalTo(true))
+ .body("clusterInfo.enhancedMonitoring", equalTo("PER_BROKER"))
+ .body("clusterInfo.loggingInfo.brokerLogs.s3.bucket", equalTo("msk-logs"))
+ .body("clusterInfo.loggingInfo.brokerLogs.s3.prefix", equalTo("kafka"));
+ }
+
+ // configurationInfo is a CreateCluster request member with no matching response member:
+ // AWS reports the cluster's configuration on currentBrokerSoftwareInfo instead, which is
+ // where terraform-provider-aws reads it back from.
+ @Test
+ void createClusterV1ReportsConfigurationOnCurrentBrokerSoftwareInfo() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "v1-configuration-test",
+ "kafkaVersion": "3.6.0",
+ "numberOfBrokerNodes": 1,
+ "configurationInfo": {
+ "arn": "arn:aws:kafka:us-east-1:123456789012:configuration/conf/1",
+ "revision": 3
+ }
+ }
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.currentBrokerSoftwareInfo.configurationArn",
+ equalTo("arn:aws:kafka:us-east-1:123456789012:configuration/conf/1"))
+ .body("clusterInfo.currentBrokerSoftwareInfo.configurationRevision", equalTo(3))
+ .body("clusterInfo.currentBrokerSoftwareInfo.kafkaVersion", equalTo("3.6.0"))
+ .body("clusterInfo", not(hasKey("configurationInfo")));
+ }
+
+ // AWS resolves these server-side when CreateCluster omits them and echoes the resolved
+ // value back; returning null instead leaves a terraform plan permanently dirty.
+ @Test
+ void createClusterV1AppliesServerSideDefaultsForMonitoringAndEncryptionInTransit() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {"clusterName": "v1-defaults-test", "kafkaVersion": "3.6.0", "numberOfBrokerNodes": 1}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.enhancedMonitoring", equalTo("DEFAULT"))
+ .body("clusterInfo.encryptionInfo.encryptionInTransit.clientBroker", equalTo("TLS_PLAINTEXT"))
+ .body("clusterInfo.encryptionInfo.encryptionInTransit.inCluster", equalTo(true));
+ }
+
+ // The v2 ClusterInfo is not the flat v1 shape: everything provisioned-specific nests under
+ // "provisioned", which is the only place an AWS SDK v2 client looks for it.
+ @Test
+ void describeClusterV2NestsProvisionedMetadataAndKeepsTagsTopLevel() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "v2-metadata-test",
+ "tags": {"Environment": "prod"},
+ "provisioned": {
+ "kafkaVersion": "3.5.1",
+ "numberOfBrokerNodes": 3,
+ "brokerNodeGroupInfo": {
+ "instanceType": "kafka.t3.small",
+ "clientSubnets": ["subnet-ccc"]
+ },
+ "clientAuthentication": {"unauthenticated": {"enabled": true}},
+ "loggingInfo": {"brokerLogs": {"cloudWatchLogs": {"enabled": true, "logGroup": "msk-logs"}}},
+ "configurationInfo": {
+ "arn": "arn:aws:kafka:us-east-1:123456789012:configuration/conf/2",
+ "revision": 7
+ }
+ }
+ }
+ """)
+ .when()
+ .post("/api/v2/clusters")
+ .then()
+ .statusCode(200)
+ .body("clusterType", equalTo("PROVISIONED"))
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/api/v2/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.clusterType", equalTo("PROVISIONED"))
+ .body("clusterInfo.clusterArn", equalTo(clusterArn))
+ .body("clusterInfo.tags.Environment", equalTo("prod"))
+ .body("clusterInfo.provisioned.numberOfBrokerNodes", equalTo(3))
+ .body("clusterInfo.provisioned.currentBrokerSoftwareInfo.kafkaVersion", equalTo("3.5.1"))
+ .body("clusterInfo.provisioned.currentBrokerSoftwareInfo.configurationArn",
+ equalTo("arn:aws:kafka:us-east-1:123456789012:configuration/conf/2"))
+ .body("clusterInfo.provisioned.currentBrokerSoftwareInfo.configurationRevision", equalTo(7))
+ .body("clusterInfo.provisioned.brokerNodeGroupInfo.instanceType", equalTo("kafka.t3.small"))
+ .body("clusterInfo.provisioned.brokerNodeGroupInfo.clientSubnets", hasItem("subnet-ccc"))
+ .body("clusterInfo.provisioned.clientAuthentication.unauthenticated.enabled", equalTo(true))
+ .body("clusterInfo.provisioned.loggingInfo.brokerLogs.cloudWatchLogs.logGroup", equalTo("msk-logs"))
+ .body("clusterInfo.provisioned.zookeeperConnectString", notNullValue())
+ // the same members must NOT also appear flat, where a v2 client would not read them
+ .body("clusterInfo", not(hasKey("numberOfBrokerNodes")))
+ .body("clusterInfo", not(hasKey("brokerNodeGroupInfo")))
+ .body("clusterInfo", not(hasKey("currentBrokerSoftwareInfo")))
+ .body("clusterInfo", not(hasKey("clientAuthentication")))
+ .body("clusterInfo", not(hasKey("loggingInfo")));
+ }
+
+ @Test
+ void createClusterEchoesOpenMonitoringStorageModeAndRebalancing() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "v1-open-monitoring-test",
+ "kafkaVersion": "3.6.0",
+ "numberOfBrokerNodes": 1,
+ "storageMode": "TIERED",
+ "rebalancing": {"status": "ACTIVE"},
+ "openMonitoring": {
+ "prometheus": {
+ "jmxExporter": {"enabledInBroker": true},
+ "nodeExporter": {"enabledInBroker": false}
+ }
+ }
+ }
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.storageMode", equalTo("TIERED"))
+ .body("clusterInfo.rebalancing.status", equalTo("ACTIVE"))
+ .body("clusterInfo.openMonitoring.prometheus.jmxExporter.enabledInBroker", equalTo(true))
+ .body("clusterInfo.openMonitoring.prometheus.nodeExporter.enabledInBroker", equalTo(false));
+
+ // and the v2 view nests them under provisioned, like every other provisioned member
+ given()
+ .when()
+ .get("/api/v2/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.provisioned.storageMode", equalTo("TIERED"))
+ .body("clusterInfo.provisioned.openMonitoring.prometheus.jmxExporter.enabledInBroker", equalTo(true))
+ .body("clusterInfo", not(hasKey("storageMode")))
+ .body("clusterInfo", not(hasKey("openMonitoring")));
+ }
+
+ @Test
+ void listClustersV2NestsProvisionedMetadataTheSameWayDescribeDoes() {
+ given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "v2-list-test",
+ "provisioned": {"kafkaVersion": "3.6.0", "numberOfBrokerNodes": 2}
+ }
+ """)
+ .when()
+ .post("/api/v2/clusters")
+ .then()
+ .statusCode(200);
+
+ given()
+ .when()
+ .get("/api/v2/clusters")
+ .then()
+ .statusCode(200)
+ .body("clusterInfoList.find { it.clusterName == 'v2-list-test' }.clusterType",
+ equalTo("PROVISIONED"))
+ .body("clusterInfoList.find { it.clusterName == 'v2-list-test' }.provisioned.numberOfBrokerNodes",
+ equalTo(2))
+ .body("clusterInfoList.find { it.clusterName == 'v2-list-test' }.provisioned.currentBrokerSoftwareInfo.kafkaVersion",
+ equalTo("3.6.0"));
+ }
+
+ @Test
+ void describeClusterDoesNotLeakInternalFields() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {"clusterName": "v1-no-internal-fields-test", "kafkaVersion": "3.6.0"}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo", notNullValue())
+ .body("clusterInfo.clusterArn", equalTo(clusterArn))
+ .body("clusterInfo", not(hasKey("bootstrapBrokers")))
+ .body("clusterInfo", not(hasKey("containerId")))
+ .body("clusterInfo", not(hasKey("accountId")))
+ .body("clusterInfo", not(hasKey("volumeId")));
+
+ given()
+ .when()
+ .get("/api/v2/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo", not(hasKey("bootstrapBrokers")))
+ .body("clusterInfo", not(hasKey("containerId")))
+ .body("clusterInfo", not(hasKey("accountId")))
+ .body("clusterInfo", not(hasKey("volumeId")))
+ .body("clusterInfo.provisioned", not(hasKey("bootstrapBrokers")))
+ .body("clusterInfo.provisioned", not(hasKey("containerId")))
+ .body("clusterInfo.provisioned", not(hasKey("accountId")))
+ .body("clusterInfo.provisioned", not(hasKey("volumeId")));
}
@Test
@@ -505,4 +824,304 @@ class MskControllerIntegrationTest {
.then()
.statusCode(400);
}
+
+ // ── Tags (/v1/tags/{arn}, shared with AppSync behind V1TagsController) ────────────────
+
+ @Test
+ void clusterTagsRoundTripThroughTheTagEndpoints() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {"clusterName": "tag-cluster", "kafkaVersion": "3.6.0", "tags": {"Environment": "example"}}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ // tags set at create time are visible to ListTagsForResource
+ given()
+ .urlEncodingEnabled(false)
+ .when()
+ .get("/v1/tags/" + clusterArn)
+ .then()
+ .statusCode(200)
+ .body("tags.Environment", equalTo("example"));
+
+ given()
+ .contentType("application/json")
+ .body("""
+ {"tags": {"Team": "data", "Environment": "prod"}}
+ """)
+ .urlEncodingEnabled(false)
+ .when()
+ .post("/v1/tags/" + clusterArn)
+ .then()
+ .statusCode(204);
+
+ given()
+ .urlEncodingEnabled(false)
+ .when()
+ .get("/v1/tags/" + clusterArn)
+ .then()
+ .statusCode(200)
+ .body("tags.Team", equalTo("data"))
+ .body("tags.Environment", equalTo("prod"));
+
+ // and DescribeCluster echoes the same set, so a tag update is not invisible to a refresh
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.tags.Team", equalTo("data"))
+ .body("clusterInfo.tags.Environment", equalTo("prod"));
+
+ given()
+ .queryParam("tagKeys", "Team")
+ .urlEncodingEnabled(false)
+ .when()
+ .delete("/v1/tags/" + clusterArn)
+ .then()
+ .statusCode(204);
+
+ given()
+ .urlEncodingEnabled(false)
+ .when()
+ .get("/v1/tags/" + clusterArn)
+ .then()
+ .statusCode(200)
+ .body("tags", not(hasKey("Team")))
+ .body("tags.Environment", equalTo("prod"));
+ }
+
+ @Test
+ void configurationTagsRoundTripThroughTheTagEndpoints() {
+ String properties = Base64.getEncoder()
+ .encodeToString("auto.create.topics.enable=true".getBytes(StandardCharsets.UTF_8));
+ String arn = given()
+ .contentType("application/json")
+ .body("""
+ {"name": "tagged-config", "description": "d", "kafkaVersions": ["3.6.0"], "serverProperties": "%s"}
+ """.formatted(properties))
+ .when()
+ .post("/v1/configurations")
+ .then()
+ .statusCode(200)
+ .extract().path("arn");
+
+ given()
+ .contentType("application/json")
+ .body("""
+ {"tags": {"Owner": "platform"}}
+ """)
+ .urlEncodingEnabled(false)
+ .when()
+ .post("/v1/tags/" + arn)
+ .then()
+ .statusCode(204);
+
+ given()
+ .urlEncodingEnabled(false)
+ .when()
+ .get("/v1/tags/" + arn)
+ .then()
+ .statusCode(200)
+ .body("tags.Owner", equalTo("platform"));
+
+ // AWS's DescribeConfiguration shape has no tags member, so they stay out of that view
+ given()
+ .when()
+ .get("/v1/configurations/{arn}", arn)
+ .then()
+ .statusCode(200)
+ .body("$", not(hasKey("tags")));
+ }
+
+ @Test
+ void tagEndpointsReturnNotFoundForAnUnknownKafkaArn() {
+ String missing = "arn:aws:kafka:us-east-1:000000000000:cluster/nope/00000000-0000-0000-0000-000000000000";
+
+ given()
+ .urlEncodingEnabled(false)
+ .when()
+ .get("/v1/tags/" + missing)
+ .then()
+ .statusCode(404);
+ }
+
+ // ── CreateCluster validation ─────────────────────────────────────────────────────────
+
+ @Test
+ void createClusterRejectsAMissingClusterName() {
+ given()
+ .contentType("application/json")
+ .body("""
+ {"kafkaVersion": "3.6.0"}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(400)
+ .body("message", containsString("clusterName"));
+ }
+
+ @Test
+ void createClusterRejectsOutOfRangeAndUnknownEnumValues() {
+ given()
+ .contentType("application/json")
+ .body("""
+ {"clusterName": "zero-brokers", "kafkaVersion": "3.6.0", "numberOfBrokerNodes": 0}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(400)
+ .body("message", containsString("numberOfBrokerNodes"))
+ // MSK's Error schema names the offending member alongside the message
+ .body("invalidParameter", equalTo("numberOfBrokerNodes"));
+
+ given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "bad-volume-size",
+ "kafkaVersion": "3.6.0",
+ "brokerNodeGroupInfo": {"storageInfo": {"ebsStorageInfo": {"volumeSize": 0}}}
+ }
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(400)
+ .body("message", containsString("volumeSize"));
+
+ given()
+ .contentType("application/json")
+ .body("""
+ {"clusterName": "bad-monitoring", "kafkaVersion": "3.6.0", "enhancedMonitoring": "SOMETIMES"}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(400)
+ .body("message", containsString("enhancedMonitoring"));
+
+ given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "bad-client-broker",
+ "kafkaVersion": "3.6.0",
+ "encryptionInfo": {"encryptionInTransit": {"clientBroker": "MAYBE"}}
+ }
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(400)
+ .body("message", containsString("clientBroker"));
+ }
+
+ // The SDK model caps numberOfBrokerNodes at 15, but the REST API reference documents no
+ // maximum and the quota page allows 30 per ZooKeeper cluster and 60 per KRaft cluster, both
+ // adjustable. Rejecting these would break clusters real MSK creates happily.
+ @Test
+ void createClusterAcceptsBrokerCountsAboveTheSdkModelCap() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {"clusterName": "thirty-brokers", "kafkaVersion": "3.6.0", "numberOfBrokerNodes": 30}
+ """)
+ .when()
+ .post("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.numberOfBrokerNodes", equalTo(30));
+ }
+
+ // ── Serverless clusters ──────────────────────────────────────────────────────────────
+
+ @Test
+ void createClusterV2SupportsServerlessAndKeepsItOutOfTheV1Api() {
+ String clusterArn = given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "serverless-cluster",
+ "tags": {"Environment": "prod"},
+ "serverless": {
+ "vpcConfigs": [{"subnetIds": ["subnet-aaa", "subnet-bbb"], "securityGroupIds": ["sg-111"]}],
+ "clientAuthentication": {"sasl": {"iam": {"enabled": true}}}
+ }
+ }
+ """)
+ .when()
+ .post("/api/v2/clusters")
+ .then()
+ .statusCode(200)
+ .body("clusterType", equalTo("SERVERLESS"))
+ .extract().path("clusterArn");
+
+ given()
+ .when()
+ .get("/api/v2/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(200)
+ .body("clusterInfo.clusterType", equalTo("SERVERLESS"))
+ .body("clusterInfo.tags.Environment", equalTo("prod"))
+ .body("clusterInfo.serverless.vpcConfigs[0].subnetIds", hasItem("subnet-aaa"))
+ .body("clusterInfo.serverless.vpcConfigs[0].securityGroupIds", hasItem("sg-111"))
+ .body("clusterInfo.serverless.clientAuthentication.sasl.iam.enabled", equalTo(true))
+ // a serverless cluster has no provisioned envelope at all
+ .body("clusterInfo", not(hasKey("provisioned")));
+
+ // the v1 API predates serverless and cannot describe one
+ given()
+ .when()
+ .get("/v1/clusters/{clusterArn}", clusterArn)
+ .then()
+ .statusCode(400)
+ .body("message", containsString("DescribeClusterV2"));
+
+ given()
+ .when()
+ .get("/v1/clusters")
+ .then()
+ .statusCode(200)
+ .body("clusterInfoList.findAll { it.clusterName == 'serverless-cluster' }", hasSize(0));
+
+ given()
+ .when()
+ .get("/api/v2/clusters")
+ .then()
+ .statusCode(200)
+ .body("clusterInfoList.findAll { it.clusterName == 'serverless-cluster' }", hasSize(1));
+ }
+
+ @Test
+ void createClusterV2RejectsBothProvisionedAndServerless() {
+ given()
+ .contentType("application/json")
+ .body("""
+ {
+ "clusterName": "both-shapes",
+ "provisioned": {"kafkaVersion": "3.6.0"},
+ "serverless": {"vpcConfigs": [{"subnetIds": ["subnet-aaa"]}]}
+ }
+ """)
+ .when()
+ .post("/api/v2/clusters")
+ .then()
+ .statusCode(400)
+ .body("message", containsString("Exactly one"));
+ }
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/msk/MskServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/msk/MskServiceTest.java
index a495657019..6138fe37af 100644
--- a/src/test/java/io/github/hectorvent/floci/services/msk/MskServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/msk/MskServiceTest.java
@@ -9,19 +9,40 @@ import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.PaginatedResult;
import io.github.hectorvent.floci.services.msk.model.ClusterState;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import io.github.hectorvent.floci.services.msk.model.BrokerNodeGroupInfo;
+import io.github.hectorvent.floci.services.msk.model.ClientAuthentication;
+import io.github.hectorvent.floci.services.msk.model.ConfigurationInfo;
import io.github.hectorvent.floci.services.msk.model.ConfigurationRevision;
import io.github.hectorvent.floci.services.msk.model.ConfigurationRevisionDetail;
import io.github.hectorvent.floci.services.msk.model.ConfigurationState;
+import io.github.hectorvent.floci.services.msk.model.CreateClusterRequest;
+import io.github.hectorvent.floci.services.msk.model.CreateClusterV2Request;
+import io.github.hectorvent.floci.services.msk.model.EncryptionInTransit;
+import io.github.hectorvent.floci.services.msk.model.EbsStorageInfo;
+import io.github.hectorvent.floci.services.msk.model.EncryptionInfo;
+import io.github.hectorvent.floci.services.msk.model.JmxExporter;
+import io.github.hectorvent.floci.services.msk.model.LoggingInfo;
+import io.github.hectorvent.floci.services.msk.model.OpenMonitoring;
+import io.github.hectorvent.floci.services.msk.model.Prometheus;
+import io.github.hectorvent.floci.services.msk.model.Rebalancing;
import io.github.hectorvent.floci.services.msk.model.MskCluster;
import io.github.hectorvent.floci.services.msk.model.MskConfiguration;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import io.github.hectorvent.floci.services.msk.model.ProvisionedRequest;
+import io.github.hectorvent.floci.services.msk.model.Sasl;
+import io.github.hectorvent.floci.services.msk.model.Scram;
+import io.github.hectorvent.floci.services.msk.model.Serverless;
+import io.github.hectorvent.floci.services.msk.model.StorageInfo;
+import io.github.hectorvent.floci.services.msk.model.VpcConfig;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -115,6 +136,204 @@ class MskServiceTest {
assertTrue(mskService.listClusters().isEmpty());
}
+ @Test
+ void createClusterPersistsRequestMetadata() {
+ CreateClusterRequest request = new CreateClusterRequest();
+ request.setClusterName("meta-cluster");
+ request.setKafkaVersion("3.5.1");
+ request.setNumberOfBrokerNodes(3);
+
+ BrokerNodeGroupInfo nodeGroup = new BrokerNodeGroupInfo();
+ nodeGroup.setInstanceType("kafka.m5.large");
+ nodeGroup.setClientSubnets(List.of("subnet-aaa", "subnet-bbb"));
+ nodeGroup.setSecurityGroups(List.of("sg-111"));
+ request.setBrokerNodeGroupInfo(nodeGroup);
+
+ EncryptionInTransit encryptionInTransit = new EncryptionInTransit();
+ encryptionInTransit.setClientBroker("TLS");
+ encryptionInTransit.setInCluster(true);
+ EncryptionInfo encryptionInfo = new EncryptionInfo();
+ encryptionInfo.setEncryptionInTransit(encryptionInTransit);
+ request.setEncryptionInfo(encryptionInfo);
+
+ Sasl sasl = new Sasl();
+ Scram scram = new Scram();
+ scram.setEnabled(true);
+ sasl.setScram(scram);
+ ClientAuthentication clientAuthentication = new ClientAuthentication();
+ clientAuthentication.setSasl(sasl);
+ request.setClientAuthentication(clientAuthentication);
+
+ request.setEnhancedMonitoring("PER_BROKER");
+ request.setLoggingInfo(new LoggingInfo());
+ ConfigurationInfo configurationInfo = new ConfigurationInfo();
+ configurationInfo.setArn("arn:aws:kafka:us-east-1:123456789012:configuration/conf/1");
+ configurationInfo.setRevision(2L);
+ request.setConfigurationInfo(configurationInfo);
+ request.setTags(Map.of("Environment", "example"));
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertEquals(3, cluster.getNumberOfBrokerNodes());
+ assertEquals("kafka.m5.large", cluster.getBrokerNodeGroupInfo().getInstanceType());
+ assertEquals(List.of("subnet-aaa", "subnet-bbb"), cluster.getBrokerNodeGroupInfo().getClientSubnets());
+ assertEquals(List.of("sg-111"), cluster.getBrokerNodeGroupInfo().getSecurityGroups());
+ assertEquals("TLS", cluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
+ assertTrue(cluster.getEncryptionInfo().getEncryptionInTransit().getInCluster());
+ assertTrue(cluster.getClientAuthentication().getSasl().getScram().getEnabled());
+ assertEquals("PER_BROKER", cluster.getEnhancedMonitoring());
+ assertNotNull(cluster.getLoggingInfo());
+ assertEquals("arn:aws:kafka:us-east-1:123456789012:configuration/conf/1",
+ cluster.getCurrentBrokerSoftwareInfo().getConfigurationArn());
+ assertEquals(2L, cluster.getCurrentBrokerSoftwareInfo().getConfigurationRevision());
+ assertEquals("example", cluster.getTags().get("Environment"));
+
+ MskCluster described = mskService.describeCluster(cluster.getClusterArn());
+ assertEquals(3, described.getNumberOfBrokerNodes());
+ assertEquals("kafka.m5.large", described.getBrokerNodeGroupInfo().getInstanceType());
+ assertEquals("example", described.getTags().get("Environment"));
+ }
+
+ @Test
+ void createClusterV2MergesTopLevelTagsAndProvisionedFields() {
+ CreateClusterV2Request request = new CreateClusterV2Request();
+ request.setClusterName("v2-meta-cluster");
+ request.setTags(Map.of("Team", "data"));
+
+ ProvisionedRequest provisioned = new ProvisionedRequest();
+ provisioned.setKafkaVersion("3.4.0");
+ provisioned.setNumberOfBrokerNodes(5);
+ BrokerNodeGroupInfo nodeGroup = new BrokerNodeGroupInfo();
+ nodeGroup.setInstanceType("kafka.t3.small");
+ nodeGroup.setClientSubnets(List.of("subnet-ccc"));
+ provisioned.setBrokerNodeGroupInfo(nodeGroup);
+ request.setProvisioned(provisioned);
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertEquals("v2-meta-cluster", cluster.getClusterName());
+ assertEquals("3.4.0", cluster.getCurrentBrokerSoftwareInfo().getKafkaVersion());
+ assertEquals(5, cluster.getNumberOfBrokerNodes());
+ assertEquals("kafka.t3.small", cluster.getBrokerNodeGroupInfo().getInstanceType());
+ assertEquals(List.of("subnet-ccc"), cluster.getBrokerNodeGroupInfo().getClientSubnets());
+ assertEquals("data", cluster.getTags().get("Team"));
+ }
+
+ @Test
+ void createClusterV2MapsProvisionedConfigurationOntoCurrentBrokerSoftwareInfo() {
+ CreateClusterV2Request request = new CreateClusterV2Request();
+ request.setClusterName("v2-configuration-cluster");
+
+ ProvisionedRequest provisioned = new ProvisionedRequest();
+ provisioned.setKafkaVersion("3.6.0");
+ ConfigurationInfo configurationInfo = new ConfigurationInfo();
+ configurationInfo.setArn("arn:aws:kafka:us-east-1:123456789012:configuration/conf/9");
+ configurationInfo.setRevision(4L);
+ provisioned.setConfigurationInfo(configurationInfo);
+ request.setProvisioned(provisioned);
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertEquals("arn:aws:kafka:us-east-1:123456789012:configuration/conf/9",
+ cluster.getCurrentBrokerSoftwareInfo().getConfigurationArn());
+ assertEquals(4L, cluster.getCurrentBrokerSoftwareInfo().getConfigurationRevision());
+ }
+
+ @Test
+ void createClusterV2PersistsOpenMonitoringStorageModeAndRebalancing() {
+ CreateClusterV2Request request = new CreateClusterV2Request();
+ request.setClusterName("v2-open-monitoring-cluster");
+
+ JmxExporter jmxExporter = new JmxExporter();
+ jmxExporter.setEnabledInBroker(true);
+ Prometheus prometheus = new Prometheus();
+ prometheus.setJmxExporter(jmxExporter);
+ OpenMonitoring openMonitoring = new OpenMonitoring();
+ openMonitoring.setPrometheus(prometheus);
+ Rebalancing rebalancing = new Rebalancing();
+ rebalancing.setStatus("PAUSED");
+
+ ProvisionedRequest provisioned = new ProvisionedRequest();
+ provisioned.setKafkaVersion("3.6.0");
+ provisioned.setOpenMonitoring(openMonitoring);
+ provisioned.setStorageMode("TIERED");
+ provisioned.setRebalancing(rebalancing);
+ request.setProvisioned(provisioned);
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertTrue(cluster.getOpenMonitoring().getPrometheus().getJmxExporter().getEnabledInBroker());
+ assertEquals("TIERED", cluster.getStorageMode());
+ assertEquals("PAUSED", cluster.getRebalancing().getStatus());
+ }
+
+ @Test
+ void createClusterAppliesServerSideDefaultsWhenMembersAreAbsent() {
+ CreateClusterRequest request = new CreateClusterRequest();
+ request.setClusterName("defaults-cluster");
+ request.setKafkaVersion("3.6.0");
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertEquals("DEFAULT", cluster.getEnhancedMonitoring());
+ assertEquals("TLS_PLAINTEXT", cluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
+ assertTrue(cluster.getEncryptionInfo().getEncryptionInTransit().getInCluster());
+ }
+
+ @Test
+ void createClusterDoesNotOverrideExplicitlyRequestedEncryptionInTransit() {
+ CreateClusterRequest request = new CreateClusterRequest();
+ request.setClusterName("explicit-encryption-cluster");
+ request.setKafkaVersion("3.6.0");
+ EncryptionInTransit inTransit = new EncryptionInTransit();
+ inTransit.setClientBroker("PLAINTEXT");
+ inTransit.setInCluster(false);
+ EncryptionInfo encryptionInfo = new EncryptionInfo();
+ encryptionInfo.setEncryptionInTransit(inTransit);
+ request.setEncryptionInfo(encryptionInfo);
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertEquals("PLAINTEXT", cluster.getEncryptionInfo().getEncryptionInTransit().getClientBroker());
+ assertFalse(cluster.getEncryptionInfo().getEncryptionInTransit().getInCluster());
+ }
+
+ // MskCluster is the shape WalStorage/PersistentStorage/HybridStorage write. All three build
+ // their mapper the same way this test does - JavaTimeModule and a date format, no view or
+ // mixin - so a @JsonIgnore on the model hides the field from the store, not just from the
+ // API: a restart would come back with no bootstrap brokers (breaking GetBootstrapBrokers
+ // and the Pipes Kafka source) and no container or volume ID (orphaning the Docker
+ // resources). Responses stay clean through MskController's views instead - see
+ // MskControllerIntegrationTest#describeClusterDoesNotLeakInternalFields.
+ @Test
+ void clusterSurvivesTheStorageMapperRoundTripWithItsInternalFields() throws Exception {
+ CreateClusterRequest request = new CreateClusterRequest();
+ request.setClusterName("persistence-cluster");
+ request.setKafkaVersion("3.6.0");
+ request.setNumberOfBrokerNodes(3);
+ request.setTags(Map.of("Environment", "example"));
+ MskCluster cluster = mskService.createCluster(request);
+ cluster.setContainerId("container-abc");
+
+ ObjectMapper storageMapper = new ObjectMapper();
+ storageMapper.registerModule(new JavaTimeModule());
+ storageMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ MskCluster reloaded = storageMapper.readValue(storageMapper.writeValueAsString(cluster), MskCluster.class);
+
+ assertEquals(cluster.getBootstrapBrokers(), reloaded.getBootstrapBrokers());
+ assertNotNull(reloaded.getBootstrapBrokers());
+ assertEquals("container-abc", reloaded.getContainerId());
+ assertEquals(cluster.getVolumeId(), reloaded.getVolumeId());
+ assertNotNull(reloaded.getVolumeId());
+ assertEquals(cluster.getAccountId(), reloaded.getAccountId());
+ assertNotNull(reloaded.getAccountId());
+
+ // and the client-facing metadata survives too
+ assertEquals(3, reloaded.getNumberOfBrokerNodes());
+ assertEquals("example", reloaded.getTags().get("Environment"));
+ assertEquals("3.6.0", reloaded.getCurrentBrokerSoftwareInfo().getKafkaVersion());
+ }
+
@Test
void createConfiguration() {
MskConfiguration configuration = mskService.createConfiguration(
@@ -562,4 +781,166 @@ class MskServiceTest {
"revision " + revision + " lost its serverProperties");
}
}
+
+ // ── Tags ─────────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void tagAndUntagResourceWorkOnClustersAndConfigurations() {
+ MskCluster cluster = mskService.createCluster("tagged-cluster");
+ mskService.tagResource(cluster.getClusterArn(), Map.of("Environment", "example"));
+ assertEquals("example", mskService.listTagsForResource(cluster.getClusterArn()).get("Environment"));
+
+ MskConfiguration configuration = mskService.createConfiguration(
+ "tagged-config", "d", List.of("3.6.0"), "auto.create.topics.enable=true");
+ mskService.tagResource(configuration.getArn(), Map.of("Owner", "platform"));
+ assertEquals("platform", mskService.listTagsForResource(configuration.getArn()).get("Owner"));
+
+ mskService.untagResource(cluster.getClusterArn(), List.of("Environment"));
+ assertTrue(mskService.listTagsForResource(cluster.getClusterArn()).isEmpty());
+ }
+
+ // createCluster stores whatever map the request carried, which for an immutable Map.of would
+ // reject an in-place putAll - the tag write has to copy instead.
+ @Test
+ void tagResourceCanExtendAnImmutableTagMapSetAtCreateTime() {
+ CreateClusterRequest request = new CreateClusterRequest();
+ request.setClusterName("immutable-tags-cluster");
+ request.setTags(Map.of("Environment", "example"));
+ MskCluster cluster = mskService.createCluster(request);
+
+ mskService.tagResource(cluster.getClusterArn(), Map.of("Team", "data"));
+
+ Map<String, String> tags = mskService.listTagsForResource(cluster.getClusterArn());
+ assertEquals("example", tags.get("Environment"));
+ assertEquals("data", tags.get("Team"));
+ }
+
+ @Test
+ void tagOperationsOnAnUnknownArnAreNotFound() {
+ String missing = "arn:aws:kafka:us-east-1:000000000000:cluster/nope/id";
+ assertThrows(AwsException.class, () -> mskService.listTagsForResource(missing));
+ assertThrows(AwsException.class, () -> mskService.tagResource(missing, Map.of("a", "b")));
+ assertThrows(AwsException.class, () -> mskService.untagResource(missing, List.of("a")));
+ }
+
+ @Test
+ void configurationKeepsTagsAndAccountIdAcrossTheStorageMapperRoundTrip() throws Exception {
+ MskConfiguration configuration = mskService.createConfiguration(
+ "persisted-config", "d", List.of("3.6.0"), "auto.create.topics.enable=true");
+ mskService.tagResource(configuration.getArn(), Map.of("Owner", "platform"));
+ MskConfiguration tagged = mskService.describeConfiguration(configuration.getArn());
+
+ ObjectMapper storageMapper = new ObjectMapper();
+ storageMapper.registerModule(new JavaTimeModule());
+ storageMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ MskConfiguration reloaded = storageMapper.readValue(
+ storageMapper.writeValueAsString(tagged), MskConfiguration.class);
+
+ assertEquals("platform", reloaded.getTags().get("Owner"));
+ assertEquals(tagged.getAccountId(), reloaded.getAccountId());
+ assertNotNull(reloaded.getAccountId());
+ }
+
+ // ── CreateCluster validation ─────────────────────────────────────────────────────────
+
+ @Test
+ void createClusterRejectsAMissingOrOversizedClusterName() {
+ CreateClusterRequest noName = new CreateClusterRequest();
+ noName.setKafkaVersion("3.6.0");
+ assertThrows(AwsException.class, () -> mskService.createCluster(noName));
+
+ CreateClusterRequest longName = new CreateClusterRequest();
+ longName.setClusterName("c".repeat(65));
+ assertThrows(AwsException.class, () -> mskService.createCluster(longName));
+ }
+
+ @Test
+ void createClusterRejectsOnlyNonsensicalBrokerCountsAndOutOfRangeVolumeSize() {
+ // No upper bound: the SDK model says 15, but the REST reference documents no maximum and
+ // the quota page allows 30 (ZooKeeper) / 60 (KRaft), adjustable upward.
+ CreateClusterRequest manyBrokers = new CreateClusterRequest();
+ manyBrokers.setClusterName("many-brokers");
+ manyBrokers.setNumberOfBrokerNodes(30);
+ assertEquals(30, mskService.createCluster(manyBrokers).getNumberOfBrokerNodes());
+
+ CreateClusterRequest tooFew = new CreateClusterRequest();
+ tooFew.setClusterName("too-few");
+ tooFew.setNumberOfBrokerNodes(0);
+ assertThrows(AwsException.class, () -> mskService.createCluster(tooFew));
+
+ CreateClusterRequest badVolume = new CreateClusterRequest();
+ badVolume.setClusterName("bad-volume");
+ EbsStorageInfo ebs = new EbsStorageInfo();
+ ebs.setVolumeSize(16385);
+ StorageInfo storageInfo = new StorageInfo();
+ storageInfo.setEbsStorageInfo(ebs);
+ BrokerNodeGroupInfo nodeGroup = new BrokerNodeGroupInfo();
+ nodeGroup.setStorageInfo(storageInfo);
+ badVolume.setBrokerNodeGroupInfo(nodeGroup);
+ assertThrows(AwsException.class, () -> mskService.createCluster(badVolume));
+ }
+
+ @Test
+ void createClusterRejectsUnknownEnumValuesButAcceptsTheDocumentedOnes() {
+ CreateClusterRequest bad = new CreateClusterRequest();
+ bad.setClusterName("bad-monitoring");
+ bad.setEnhancedMonitoring("SOMETIMES");
+ assertThrows(AwsException.class, () -> mskService.createCluster(bad));
+
+ CreateClusterRequest good = new CreateClusterRequest();
+ good.setClusterName("good-monitoring");
+ good.setEnhancedMonitoring("PER_TOPIC_PER_PARTITION");
+ good.setStorageMode("TIERED");
+ assertEquals("PER_TOPIC_PER_PARTITION", mskService.createCluster(good).getEnhancedMonitoring());
+ }
+
+ // ── Serverless ───────────────────────────────────────────────────────────────────────
+
+ @Test
+ void createClusterV2CreatesAServerlessClusterWithoutProvisionedMetadata() {
+ VpcConfig vpcConfig = new VpcConfig();
+ vpcConfig.setSubnetIds(List.of("subnet-aaa"));
+ Serverless serverless = new Serverless();
+ serverless.setVpcConfigs(List.of(vpcConfig));
+
+ CreateClusterV2Request request = new CreateClusterV2Request();
+ request.setClusterName("serverless-cluster");
+ request.setServerless(serverless);
+
+ MskCluster cluster = mskService.createCluster(request);
+
+ assertTrue(mskService.isServerless(cluster));
+ assertEquals("SERVERLESS", cluster.getClusterType());
+ assertEquals(List.of("subnet-aaa"), cluster.getServerless().getVpcConfigs().get(0).getSubnetIds());
+ assertNull(cluster.getBrokerNodeGroupInfo());
+ assertNull(cluster.getCurrentBrokerSoftwareInfo());
+ assertEquals(0, cluster.getNumberOfBrokerNodes());
+ }
+
+ @Test
+ void v1ReadsExcludeServerlessClusters() {
+ Serverless serverless = new Serverless();
+ serverless.setVpcConfigs(List.of(new VpcConfig()));
+ CreateClusterV2Request request = new CreateClusterV2Request();
+ request.setClusterName("serverless-cluster");
+ request.setServerless(serverless);
+ MskCluster serverlessCluster = mskService.createCluster(request);
+
+ mskService.createCluster("provisioned-cluster");
+
+ assertThrows(AwsException.class, () -> mskService.describeClusterV1(serverlessCluster.getClusterArn()));
+ assertEquals(2, mskService.listClusters().size());
+ assertEquals(1, mskService.listProvisionedClusters().size());
+ assertEquals("provisioned-cluster", mskService.listProvisionedClusters().get(0).getClusterName());
+ }
+
+ @Test
+ void createClusterV2RejectsBothProvisionedAndServerless() {
+ CreateClusterV2Request request = new CreateClusterV2Request();
+ request.setClusterName("both-shapes");
+ request.setProvisioned(new ProvisionedRequest());
+ request.setServerless(new Serverless());
+
+ assertThrows(AwsException.class, () -> mskService.createCluster(request));
+ }
}