diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml
index 4351a52fc8..7d7bffb074 100644
--- a/compatibility-tests/sdk-test-java/pom.xml
+++ b/compatibility-tests/sdk-test-java/pom.xml
@@ -96,6 +96,10 @@
software.amazon.awssdk
ssm
+
+ software.amazon.awssdk
+ redshift
+
software.amazon.awssdk
sns
diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
index ba77b9d7ec..abbb3d05b3 100644
--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
@@ -26,6 +26,7 @@ import software.amazon.awssdk.services.lambda.LambdaClient;
import software.amazon.awssdk.services.opensearch.OpenSearchClient;
import software.amazon.awssdk.services.neptune.NeptuneClient;
import software.amazon.awssdk.services.rds.RdsClient;
+import software.amazon.awssdk.services.redshift.RedshiftClient;
import software.amazon.awssdk.services.guardduty.GuardDutyClient;
import software.amazon.awssdk.services.fis.FisClient;
import software.amazon.awssdk.services.organizations.OrganizationsClient;
@@ -1030,4 +1031,12 @@ public final class TestFixtures {
.credentialsProvider(CREDENTIALS)
.build();
}
+
+ public static RedshiftClient redshiftClient() {
+ return RedshiftClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/RedshiftOperationsTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/RedshiftOperationsTest.java
new file mode 100644
index 0000000000..baa2454c9b
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/RedshiftOperationsTest.java
@@ -0,0 +1,336 @@
+package com.floci.test;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import software.amazon.awssdk.services.redshift.RedshiftClient;
+import software.amazon.awssdk.services.redshift.model.Cluster;
+import software.amazon.awssdk.services.redshift.model.ClusterParameterGroup;
+import software.amazon.awssdk.services.redshift.model.CreateClusterParameterGroupRequest;
+import software.amazon.awssdk.services.redshift.model.CreateClusterParameterGroupResponse;
+import software.amazon.awssdk.services.redshift.model.CreateClusterRequest;
+import software.amazon.awssdk.services.redshift.model.CreateClusterResponse;
+import software.amazon.awssdk.services.redshift.model.CreateClusterSnapshotRequest;
+import software.amazon.awssdk.services.redshift.model.CreateClusterSnapshotResponse;
+import software.amazon.awssdk.services.redshift.model.CreateClusterSubnetGroupRequest;
+import software.amazon.awssdk.services.redshift.model.CreateTagsRequest;
+import software.amazon.awssdk.services.redshift.model.DeleteClusterParameterGroupRequest;
+import software.amazon.awssdk.services.redshift.model.DeleteClusterRequest;
+import software.amazon.awssdk.services.redshift.model.DeleteClusterSnapshotRequest;
+import software.amazon.awssdk.services.redshift.model.DeleteClusterSubnetGroupRequest;
+import software.amazon.awssdk.services.redshift.model.DeleteTagsRequest;
+import software.amazon.awssdk.services.redshift.model.DescribeClusterParameterGroupsRequest;
+import software.amazon.awssdk.services.redshift.model.DescribeClusterParameterGroupsResponse;
+import software.amazon.awssdk.services.redshift.model.DescribeClusterSnapshotsRequest;
+import software.amazon.awssdk.services.redshift.model.DescribeClusterSnapshotsResponse;
+import software.amazon.awssdk.services.redshift.model.DescribeClusterSubnetGroupsRequest;
+import software.amazon.awssdk.services.redshift.model.DescribeClustersRequest;
+import software.amazon.awssdk.services.redshift.model.DescribeClustersResponse;
+import software.amazon.awssdk.services.redshift.model.DescribeTagsRequest;
+import software.amazon.awssdk.services.redshift.model.ModifyClusterRequest;
+import software.amazon.awssdk.services.redshift.model.RebootClusterRequest;
+import software.amazon.awssdk.services.redshift.model.RestoreFromClusterSnapshotRequest;
+import software.amazon.awssdk.services.redshift.model.RestoreFromClusterSnapshotResponse;
+import software.amazon.awssdk.services.redshift.model.Snapshot;
+import software.amazon.awssdk.services.redshift.model.Tag;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("Redshift Operations")
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class RedshiftOperationsTest {
+
+ private static final Logger LOG = Logger.getLogger(RedshiftOperationsTest.class.getName());
+
+ private static final String USERNAME = "admin";
+ private static final String PASSWORD = "password123";
+ private static final String DATABASE = "dev";
+
+ private static RedshiftClient client;
+ private static final List clustersToCleanup = new ArrayList<>();
+ private static final List snapshotsToCleanup = new ArrayList<>();
+ private static final List parameterGroupsToCleanup = new ArrayList<>();
+ private static final List subnetGroupsToCleanup = new ArrayList<>();
+
+ @BeforeAll
+ static void setup() {
+ client = TestFixtures.redshiftClient();
+ }
+
+ @AfterAll
+ static void cleanup() {
+ if (client != null) {
+ for (String clusterId : clustersToCleanup) {
+ try {
+ client.deleteCluster(DeleteClusterRequest.builder()
+ .clusterIdentifier(clusterId)
+ .build());
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to clean up Redshift cluster " + clusterId, e);
+ }
+ }
+ for (String snapId : snapshotsToCleanup) {
+ try {
+ client.deleteClusterSnapshot(DeleteClusterSnapshotRequest.builder()
+ .snapshotIdentifier(snapId)
+ .build());
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to clean up Redshift snapshot " + snapId, e);
+ }
+ }
+ for (String pgName : parameterGroupsToCleanup) {
+ try {
+ client.deleteClusterParameterGroup(DeleteClusterParameterGroupRequest.builder()
+ .parameterGroupName(pgName)
+ .build());
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to clean up Redshift parameter group " + pgName, e);
+ }
+ }
+ for (String subnetGroupName : subnetGroupsToCleanup) {
+ try {
+ client.deleteClusterSubnetGroup(DeleteClusterSubnetGroupRequest.builder()
+ .clusterSubnetGroupName(subnetGroupName)
+ .build());
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to clean up Redshift cluster subnet group " + subnetGroupName, e);
+ }
+ }
+ client.close();
+ }
+ }
+
+ @Test
+ @Order(1)
+ @DisplayName("Create cluster, insert data, snapshot, restore to new cluster, verify data")
+ void testSnapshotAndRestoreLifecycle() throws Exception {
+ String sourceClusterId = TestFixtures.uniqueName("rs-source");
+ String restoredClusterId = TestFixtures.uniqueName("rs-restored");
+ String snapshotId = TestFixtures.uniqueName("rs-snap");
+
+ clustersToCleanup.add(sourceClusterId);
+ clustersToCleanup.add(restoredClusterId);
+ snapshotsToCleanup.add(snapshotId);
+
+ // 1. Create source cluster
+ CreateClusterResponse createRes = client.createCluster(CreateClusterRequest.builder()
+ .clusterIdentifier(sourceClusterId)
+ .nodeType("dc2.large")
+ .masterUsername(USERNAME)
+ .masterUserPassword(PASSWORD)
+ .build());
+
+ assertThat(createRes.cluster()).isNotNull();
+ assertThat(createRes.cluster().clusterIdentifier()).isEqualTo(sourceClusterId);
+
+ DescribeClustersResponse descRes = client.describeClusters(DescribeClustersRequest.builder()
+ .clusterIdentifier(sourceClusterId)
+ .build());
+ Cluster sourceCluster = descRes.clusters().get(0);
+ assertThat(sourceCluster.endpoint()).isNotNull();
+ String sourceHost = sourceCluster.endpoint().address();
+ int sourcePort = sourceCluster.endpoint().port();
+
+ // 2. Use JDBC to create a table and insert a row
+ try (Connection conn = awaitPostgresConnection(sourceHost, sourcePort, USERNAME, PASSWORD);
+ Statement stmt = conn.createStatement()) {
+ stmt.execute("CREATE TABLE test_data (id INT PRIMARY KEY, name VARCHAR(100));");
+ stmt.execute("INSERT INTO test_data (id, name) VALUES (1, 'floci-redshift-snapshot-val');");
+ }
+
+ // 3. Call createClusterSnapshot via AWS SDK
+ CreateClusterSnapshotResponse snapRes = client.createClusterSnapshot(CreateClusterSnapshotRequest.builder()
+ .snapshotIdentifier(snapshotId)
+ .clusterIdentifier(sourceClusterId)
+ .build());
+
+ Snapshot snapshot = snapRes.snapshot();
+ assertThat(snapshot).isNotNull();
+ assertThat(snapshot.snapshotIdentifier()).isEqualTo(snapshotId);
+ assertThat(snapshot.clusterIdentifier()).isEqualTo(sourceClusterId);
+ assertThat(snapshot.status()).isEqualTo("available");
+
+ DescribeClusterSnapshotsResponse descSnapRes = client.describeClusterSnapshots(DescribeClusterSnapshotsRequest.builder()
+ .snapshotIdentifier(snapshotId)
+ .build());
+ assertThat(descSnapRes.snapshots()).isNotEmpty();
+ assertThat(descSnapRes.snapshots().get(0).snapshotIdentifier()).isEqualTo(snapshotId);
+
+ // 4. Delete source cluster
+ client.deleteCluster(DeleteClusterRequest.builder()
+ .clusterIdentifier(sourceClusterId)
+ .build());
+ clustersToCleanup.remove(sourceClusterId);
+
+ // 5. Restore from snapshot to a new cluster identifier
+ RestoreFromClusterSnapshotResponse restoreRes = client.restoreFromClusterSnapshot(
+ RestoreFromClusterSnapshotRequest.builder()
+ .clusterIdentifier(restoredClusterId)
+ .snapshotIdentifier(snapshotId)
+ .nodeType("dc2.large")
+ .build());
+
+ Cluster restoredCluster = restoreRes.cluster();
+ assertThat(restoredCluster).isNotNull();
+ assertThat(restoredCluster.clusterIdentifier()).isEqualTo(restoredClusterId);
+ assertThat(restoredCluster.endpoint()).isNotNull();
+
+ String restoredHost = restoredCluster.endpoint().address();
+ int restoredPort = restoredCluster.endpoint().port();
+
+ // 6. Use JDBC to query restored cluster and verify row exists
+ try (Connection conn = awaitPostgresConnection(restoredHost, restoredPort, USERNAME, PASSWORD);
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT name FROM test_data WHERE id = 1;")) {
+ assertThat(rs.next()).isTrue();
+ assertThat(rs.getString("name")).isEqualTo("floci-redshift-snapshot-val");
+ }
+
+ // Cleanup restored cluster and snapshot
+ client.deleteCluster(DeleteClusterRequest.builder()
+ .clusterIdentifier(restoredClusterId)
+ .build());
+ clustersToCleanup.remove(restoredClusterId);
+
+ client.deleteClusterSnapshot(DeleteClusterSnapshotRequest.builder()
+ .snapshotIdentifier(snapshotId)
+ .build());
+ snapshotsToCleanup.remove(snapshotId);
+ }
+
+ @Test
+ @Order(2)
+ @DisplayName("Create, describe, and delete cluster parameter group")
+ void testClusterParameterGroupLifecycle() {
+ String pgName = TestFixtures.uniqueName("rs-pg");
+ parameterGroupsToCleanup.add(pgName);
+
+ // 1. Create cluster parameter group
+ CreateClusterParameterGroupResponse createPgRes = client.createClusterParameterGroup(
+ CreateClusterParameterGroupRequest.builder()
+ .parameterGroupName(pgName)
+ .parameterGroupFamily("redshift-1.0")
+ .description("Test parameter group for Redshift")
+ .build());
+
+ ClusterParameterGroup pg = createPgRes.clusterParameterGroup();
+ assertThat(pg).isNotNull();
+ assertThat(pg.parameterGroupName()).isEqualTo(pgName);
+ assertThat(pg.parameterGroupFamily()).isEqualTo("redshift-1.0");
+ assertThat(pg.description()).isEqualTo("Test parameter group for Redshift");
+
+ // 2. Describe cluster parameter groups
+ DescribeClusterParameterGroupsResponse descPgRes = client.describeClusterParameterGroups(
+ DescribeClusterParameterGroupsRequest.builder()
+ .parameterGroupName(pgName)
+ .build());
+
+ assertThat(descPgRes.parameterGroups()).isNotEmpty();
+ ClusterParameterGroup foundPg = descPgRes.parameterGroups().stream()
+ .filter(g -> pgName.equals(g.parameterGroupName()))
+ .findFirst()
+ .orElse(null);
+ assertThat(foundPg).isNotNull();
+ assertThat(foundPg.parameterGroupFamily()).isEqualTo("redshift-1.0");
+ assertThat(foundPg.description()).isEqualTo("Test parameter group for Redshift");
+
+ // 3. Delete cluster parameter group
+ client.deleteClusterParameterGroup(DeleteClusterParameterGroupRequest.builder()
+ .parameterGroupName(pgName)
+ .build());
+ parameterGroupsToCleanup.remove(pgName);
+ }
+
+ @Test
+ @Order(3)
+ void testTaggingAndSubnetGroupAndModify() {
+ // Cluster subnet group
+ String subnetGroupName = TestFixtures.uniqueName("rs-subnet-group");
+ client.createClusterSubnetGroup(CreateClusterSubnetGroupRequest.builder()
+ .clusterSubnetGroupName(subnetGroupName)
+ .description("SDK test subnet group")
+ .subnetIds("subnet-aaa", "subnet-bbb")
+ .build());
+ subnetGroupsToCleanup.add(subnetGroupName);
+
+ var describedGroups = client.describeClusterSubnetGroups(
+ DescribeClusterSubnetGroupsRequest.builder()
+ .clusterSubnetGroupName(subnetGroupName)
+ .build());
+ assertThat(describedGroups.clusterSubnetGroups()).hasSize(1);
+ assertThat(describedGroups.clusterSubnetGroups().get(0).subnets()).hasSize(2);
+
+ // Cluster + tagging + modify + reboot
+ String clusterId = TestFixtures.uniqueName("rs-tag-cluster");
+ CreateClusterResponse created = client.createCluster(CreateClusterRequest.builder()
+ .clusterIdentifier(clusterId)
+ .nodeType("dc2.large")
+ .masterUsername(USERNAME)
+ .masterUserPassword(PASSWORD)
+ .build());
+ clustersToCleanup.add(clusterId);
+ String arn = "arn:aws:redshift:us-east-1:000000000000:cluster:" + clusterId;
+
+ client.createTags(CreateTagsRequest.builder()
+ .resourceName(arn)
+ .tags(Tag.builder().key("env").value("test").build())
+ .build());
+
+ var described = client.describeTags(DescribeTagsRequest.builder()
+ .resourceName(arn)
+ .build());
+ assertThat(described.taggedResources()).anyMatch(t -> "env".equals(t.tag().key()) && "test".equals(t.tag().value()));
+
+ client.deleteTags(DeleteTagsRequest.builder()
+ .resourceName(arn)
+ .tagKeys("env")
+ .build());
+
+ var modified = client.modifyCluster(ModifyClusterRequest.builder()
+ .clusterIdentifier(clusterId)
+ .nodeType("ra3.xlplus")
+ .build());
+ assertThat(modified.cluster().nodeType()).isEqualTo("ra3.xlplus");
+
+ var rebooted = client.rebootCluster(RebootClusterRequest.builder()
+ .clusterIdentifier(clusterId)
+ .build());
+ assertThat(rebooted.cluster().clusterStatus()).isEqualTo("available");
+ }
+
+ private static Connection awaitPostgresConnection(String host, int port, String username, String password) throws Exception {
+ Instant deadline = Instant.now().plus(Duration.ofSeconds(60));
+ SQLException last = null;
+ while (Instant.now().isBefore(deadline)) {
+ try {
+ Properties properties = new Properties();
+ properties.setProperty("user", username);
+ properties.setProperty("password", password);
+ properties.setProperty("sslmode", "disable");
+ properties.setProperty("connectTimeout", "5");
+ return DriverManager.getConnection("jdbc:postgresql://" + host + ":" + port + "/" + DATABASE, properties);
+ } catch (SQLException e) {
+ last = e;
+ Thread.sleep(1000);
+ }
+ }
+ throw last != null ? last : new SQLException("Timed out waiting for PostgreSQL connection at " + host + ":" + port);
+ }
+}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/io/github/hectorvent/floci/compat/RedshiftTest.java b/compatibility-tests/sdk-test-java/src/test/java/io/github/hectorvent/floci/compat/RedshiftTest.java
new file mode 100644
index 0000000000..80bbaa270a
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/io/github/hectorvent/floci/compat/RedshiftTest.java
@@ -0,0 +1,75 @@
+package io.github.hectorvent.floci.compat;
+
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import software.amazon.awssdk.services.redshift.RedshiftClient;
+import software.amazon.awssdk.services.redshift.model.Cluster;
+import software.amazon.awssdk.services.redshift.model.CreateClusterRequest;
+import software.amazon.awssdk.services.redshift.model.CreateClusterResponse;
+import software.amazon.awssdk.services.redshift.model.DescribeClustersRequest;
+import software.amazon.awssdk.services.redshift.model.DescribeClustersResponse;
+import software.amazon.awssdk.services.redshift.model.DeleteClusterRequest;
+import software.amazon.awssdk.services.redshift.model.DeleteClusterResponse;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class RedshiftTest {
+
+ private RedshiftClient getClient() {
+ return RedshiftClient.builder()
+ .region(software.amazon.awssdk.regions.Region.US_EAST_1)
+ .credentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider.create(
+ software.amazon.awssdk.auth.credentials.AwsBasicCredentials.create("test", "test")))
+ .endpointOverride(java.net.URI.create("http://localhost:4566"))
+ .build();
+ }
+
+ @Test
+ @Order(1)
+ public void testCreateCluster() throws Exception {
+ RedshiftClient client = getClient();
+ CreateClusterResponse res = client.createCluster(CreateClusterRequest.builder()
+ .clusterIdentifier("test-cluster")
+ .nodeType("dc2.large")
+ .masterUsername("admin")
+ .masterUserPassword("Password123")
+ .build());
+
+ assertEquals("test-cluster", res.cluster().clusterIdentifier());
+
+ DescribeClustersResponse describeRes = client.describeClusters(DescribeClustersRequest.builder()
+ .clusterIdentifier("test-cluster")
+ .build());
+
+ Cluster cluster = describeRes.clusters().get(0);
+ assertEquals("test-cluster", cluster.clusterIdentifier());
+ assertNotNull(cluster.endpoint());
+
+ String address = cluster.endpoint().address();
+ int port = cluster.endpoint().port();
+
+ String jdbcUrl = "jdbc:postgresql://" + address + ":" + port + "/dev";
+ try (Connection conn = DriverManager.getConnection(jdbcUrl, "admin", "Password123")) {
+ assertTrue(conn.isValid(5));
+ }
+ }
+
+ @Test
+ @Order(2)
+ public void testDeleteCluster() {
+ RedshiftClient client = getClient();
+ DeleteClusterResponse res = client.deleteCluster(DeleteClusterRequest.builder()
+ .clusterIdentifier("test-cluster")
+ .build());
+ assertEquals("test-cluster", res.cluster().clusterIdentifier());
+ assertEquals("deleting", res.cluster().clusterStatus());
+ }
+}
diff --git a/docs/services/index.md b/docs/services/index.md
index 07619f1a48..e78807c20e 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -55,6 +55,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [Lake Formation](lakeformation.md) | `POST /` | REST JSON | 16 |
| [Neptune](neptune.md) | `POST /` with `Action=` param + Gremlin TCP proxy | Query + WebSocket | 8 |
| [DocumentDB](docdb.md) | `POST /` with `Action=` param + MongoDB container | Query + MongoDB wire | 8 |
+| [Redshift](redshift.md) | `POST /` with `Action=` param + PostgreSQL container | Query + PostgreSQL wire | 21 |
| [EMR](emr.md) | `POST /` + `X-Amz-Target: ElasticMapReduce.*` | JSON 1.1 | 24 |
| [EMR Serverless](emr-serverless.md) | `/applications/*` | REST JSON | 7 |
| [Data Firehose](firehose.md) | `POST /` + `X-Amz-Target: Firehose_20150804.*` | JSON 1.1 | 6 |
diff --git a/docs/services/redshift.md b/docs/services/redshift.md
new file mode 100644
index 0000000000..0d632298b0
--- /dev/null
+++ b/docs/services/redshift.md
@@ -0,0 +1,141 @@
+# Redshift
+
+**Protocol:** Query (XML) for the management API
+**Management Endpoint:** `POST http://localhost:4566/` with `Action=` param
+**Data Endpoint:** the `Endpoint` and `Port` returned by `DescribeClusters` (PostgreSQL wire protocol)
+
+Floci emulates Amazon Redshift by managing a real [PostgreSQL](https://www.postgresql.org/) Docker container per cluster behind a Redshift-shaped control plane. Redshift speaks the PostgreSQL wire protocol, so the cluster endpoint returned by `DescribeClusters` works with any standard PostgreSQL driver (`psql`, JDBC, `psycopg`, …).
+
+> **Always read the host and port from `DescribeClusters`** rather than assuming a fixed port. PostgreSQL listens on `5432` *inside* the container; the port you connect to is dynamically assigned on the host and returned as `Clusters[0].Endpoint.Port`. Redshift's conventional port is `5439`, but the emulator does not bind it — use whatever `DescribeClusters` reports.
+
+The container has **no persistent volume**: if the physical container survives a Floci restart it is adopted and its data is kept, but if the container itself is gone (host reboot, `docker rm`, a pruned dev box) the cluster comes back empty. Use `CreateClusterSnapshot` / `RestoreFromClusterSnapshot` to preserve data explicitly.
+
+## Supported Actions
+
+
+| Action | Description |
+| --- | --- |
+| `CreateCluster` | Create a cluster and start a PostgreSQL container for it |
+| `DescribeClusters` | List clusters and their connection details |
+| `DeleteCluster` | Stop and remove a cluster and its container |
+| `CreateClusterSnapshot` | Back up a cluster to a SQL dump via `pg_dump` |
+| `DescribeClusterSnapshots` | List snapshots, optionally filtered by snapshot or cluster identifier |
+| `DeleteClusterSnapshot` | Remove a snapshot and its stored dump |
+| `RestoreFromClusterSnapshot` | Create a new cluster and load a snapshot's dump into it via `psql` |
+| `CreateClusterParameterGroup` | Register a parameter group (metadata only) |
+| `DescribeClusterParameterGroups` | List parameter groups, optionally filtered by name |
+| `DescribeClusterParameters` | Return the parameters of a group, with any values set by `ModifyClusterParameterGroup` |
+| `ModifyClusterParameterGroup` | Update parameter values on a group |
+| `DeleteClusterParameterGroup` | Remove a parameter group |
+| `CreateTags` | Add or overwrite tags on a cluster, snapshot, subnet group or parameter group |
+| `DeleteTags` | Remove tags by key from a resource |
+| `DescribeTags` | List tagged resources and their tags |
+| `CreateClusterSubnetGroup` | Register a cluster subnet group (metadata only) |
+| `DescribeClusterSubnetGroups` | List subnet groups, optionally filtered by name |
+| `ModifyClusterSubnetGroup` | Update a subnet group's description or subnet list |
+| `DeleteClusterSubnetGroup` | Remove a subnet group |
+| `ModifyCluster` | Update node type, parameter group, security groups, or the master password |
+| `RebootCluster` | Restart a cluster's container |
+
+
+## Configuration
+
+| Variable | Default | Description |
+|----------|---------|-------------|
+| `FLOCI_SERVICES_REDSHIFT_ENABLED` | `true` | Enable or disable Redshift |
+| `FLOCI_SERVICES_REDSHIFT_IMAGE_VERSION` | `postgres:15-alpine` | PostgreSQL Docker image backing each cluster |
+| `FLOCI_SERVICES_REDSHIFT_DEFAULT_PORT` | `5439` | Reported Redshift port hint (the real host port is dynamic and comes from `DescribeClusters`) |
+
+Redshift needs the Docker socket so it can launch PostgreSQL containers. Each cluster's container is published on a dynamically assigned host port, returned by `DescribeClusters`.
+
+### Docker Compose
+
+```yaml
+services:
+ floci:
+ image: floci/floci:latest
+ ports:
+ - "4566:4566"
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+```
+
+For private registry authentication and other Docker settings see [Docker Configuration](../configuration/docker.md).
+
+## Examples
+
+### Management API (AWS CLI)
+
+```bash
+export AWS_ENDPOINT_URL=http://localhost:4566
+export AWS_DEFAULT_REGION=us-east-1
+export AWS_ACCESS_KEY_ID=test
+export AWS_SECRET_ACCESS_KEY=test
+
+# Create a cluster (starts a PostgreSQL container)
+aws redshift create-cluster \
+ --cluster-identifier my-warehouse \
+ --node-type dc2.large \
+ --master-username admin \
+ --master-user-password Secret123
+
+# Read the cluster endpoint and port
+aws redshift describe-clusters \
+ --cluster-identifier my-warehouse \
+ --query 'Clusters[0].Endpoint'
+
+# Snapshot and restore
+aws redshift create-cluster-snapshot \
+ --snapshot-identifier snap-1 \
+ --cluster-identifier my-warehouse
+aws redshift restore-from-cluster-snapshot \
+ --cluster-identifier my-warehouse-restored \
+ --snapshot-identifier snap-1
+
+# Delete
+aws redshift delete-cluster \
+ --cluster-identifier my-warehouse \
+ --skip-final-cluster-snapshot
+```
+
+### Data plane (Python + psycopg)
+
+```python
+import psycopg
+
+# Read host and port from DescribeClusters — the host port is dynamic.
+host, port = "localhost", 32768 # e.g. Clusters[0].Endpoint.Address / .Port
+with psycopg.connect(f"host={host} port={port} dbname=dev user=admin password=Secret123") as conn:
+ conn.execute("CREATE TABLE people (name text)")
+ conn.execute("INSERT INTO people VALUES ('Alice')")
+ for row in conn.execute("SELECT * FROM people"):
+ print(row)
+```
+
+### Management API (Python / boto3)
+
+```python
+import boto3
+
+redshift = boto3.client(
+ "redshift",
+ endpoint_url="http://localhost:4566",
+ region_name="us-east-1",
+)
+
+cluster = redshift.create_cluster(
+ ClusterIdentifier="my-warehouse",
+ NodeType="dc2.large",
+ MasterUsername="admin",
+ MasterUserPassword="Secret123",
+)
+print(cluster["Cluster"]["Endpoint"])
+```
+
+## Out of Scope
+
+- Real Redshift SQL semantics — the data plane is stock PostgreSQL, so Redshift-only SQL (distribution/sort keys, `COPY`/`UNLOAD` from S3, `SUPER`/`SPECTRUM`) is not emulated.
+- Multi-node clusters — `NodeType` and `NumberOfNodes` are stored as metadata; every cluster is a single PostgreSQL container.
+- Parameter groups apply no real engine settings; values are stored and echoed back only.
+- Subnet groups, VPC routing, and security groups are metadata only.
+- Resize, pause/resume, IAM authentication, snapshot schedules, and cross-region snapshot copy.
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 84faf36782..2e8cc5a99e 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -263,6 +263,7 @@ public interface EmulatorConfig {
ElastiCacheStorageConfig elasticache();
MemoryDbStorageConfig memorydb();
RdsStorageConfig rds();
+ RedshiftStorageConfig redshift();
Ec2StorageConfig ec2();
NeptuneStorageConfig neptune();
BackupStorageConfig backup();
@@ -401,6 +402,10 @@ public interface EmulatorConfig {
long flushIntervalMs();
}
+ interface RedshiftStorageConfig {
+ Optional mode();
+ }
+
interface RdsStorageConfig {
Optional mode();
}
@@ -609,6 +614,7 @@ public interface EmulatorConfig {
ElastiCacheServiceConfig elasticache();
MemoryDbServiceConfig memorydb();
RdsServiceConfig rds();
+ RedshiftServiceConfig redshift();
RdsDataServiceConfig rdsData();
EventBridgeServiceConfig eventbridge();
CloudMapServiceConfig cloudmap();
@@ -1095,6 +1101,16 @@ public interface EmulatorConfig {
Optional dockerNetwork();
}
+ interface RedshiftServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ @WithDefault("5439")
+ int defaultPort();
+ @WithDefault("postgres:15-alpine")
+ String imageVersion();
+ Optional dockerNetwork();
+ }
+
interface RdsServiceConfig {
String DEFAULT_POSTGRES_IMAGE = "postgres:16-alpine";
String DEFAULT_MYSQL_IMAGE = "mysql:8.0";
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java
index c4fc69ab1a..0936f33df0 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java
@@ -22,6 +22,7 @@ public final class AwsNamespaces {
public static final String ELASTIC_BEANSTALK = "https://elasticbeanstalk.amazonaws.com/docs/2010-12-01/";
public static final String ROUTE53 = "https://route53.amazonaws.com/doc/2013-04-01/";
public static final String CLOUDFRONT = "http://cloudfront.amazonaws.com/doc/2020-05-31/";
+ public static final String REDSHIFT = "http://redshift.amazonaws.com/doc/2012-12-01/";
private AwsNamespaces() {}
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java
index 22b8bca5e9..f2689e54d0 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java
@@ -16,6 +16,7 @@ import io.github.hectorvent.floci.services.iam.IamQueryHandler;
import io.github.hectorvent.floci.services.iam.StsQueryHandler;
import io.github.hectorvent.floci.services.rds.RdsQueryHandler;
import io.github.hectorvent.floci.services.rds.RdsService;
+import io.github.hectorvent.floci.services.redshift.RedshiftQueryHandler;
import io.github.hectorvent.floci.services.sns.SnsQueryHandler;
import io.github.hectorvent.floci.services.ses.SesQueryHandler;
import io.github.hectorvent.floci.services.sqs.SqsQueryHandler;
@@ -196,6 +197,7 @@ public class AwsQueryController {
private final ElbV2QueryHandler elbV2QueryHandler;
private final AutoScalingQueryHandler autoScalingQueryHandler;
private final ElasticBeanstalkQueryHandler elasticBeanstalkQueryHandler;
+ private final RedshiftQueryHandler redshiftQueryHandler;
private final ResolvedServiceCatalog catalog;
private final RegionResolver regionResolver;
@@ -217,6 +219,7 @@ public class AwsQueryController {
ElbV2QueryHandler elbV2QueryHandler,
AutoScalingQueryHandler autoScalingQueryHandler,
ElasticBeanstalkQueryHandler elasticBeanstalkQueryHandler,
+ RedshiftQueryHandler redshiftQueryHandler,
ResolvedServiceCatalog catalog,
RegionResolver regionResolver) {
this.cloudFormationQueryHandler = cloudFormationQueryHandler;
@@ -238,6 +241,7 @@ public class AwsQueryController {
this.elbV2QueryHandler = elbV2QueryHandler;
this.autoScalingQueryHandler = autoScalingQueryHandler;
this.elasticBeanstalkQueryHandler = elasticBeanstalkQueryHandler;
+ this.redshiftQueryHandler = redshiftQueryHandler;
this.catalog = catalog;
this.regionResolver = regionResolver;
}
@@ -342,6 +346,7 @@ public class AwsQueryController {
case "elasticloadbalancing" -> elbV2QueryHandler.handle(action, formParams, region);
case "autoscaling" -> autoScalingQueryHandler.handle(action, formParams, region);
case "elasticbeanstalk" -> elasticBeanstalkQueryHandler.handle(action, formParams, region);
+ case "redshift" -> redshiftQueryHandler.handle(action, formParams);
default -> xmlErrorResponse("UnknownService",
"Unknown or unsupported service: " + service, 400);
};
@@ -533,6 +538,16 @@ public class AwsQueryController {
"AdminAddUserToGroup", "AdminRemoveUserFromGroup", "AdminListGroupsForUser"
);
+ private static final Set REDSHIFT_ACTIONS = Set.of(
+ "CreateCluster", "DescribeClusters", "DeleteCluster",
+ "CreateClusterSnapshot", "DescribeClusterSnapshots", "DeleteClusterSnapshot", "RestoreFromClusterSnapshot",
+ "ModifyCluster", "RebootCluster",
+ "CreateClusterParameterGroup", "DescribeClusterParameterGroups", "DescribeClusterParameters", "DeleteClusterParameterGroup",
+ "ModifyClusterParameterGroup",
+ "CreateClusterSubnetGroup", "DescribeClusterSubnetGroups", "ModifyClusterSubnetGroup", "DeleteClusterSubnetGroup",
+ "CreateTags", "DeleteTags", "DescribeTags"
+ );
+
private String resolveService(String authorization, String action) {
ServiceDescriptor descriptor = SigV4CredentialScope.serviceName(authorization)
.flatMap(catalog::byCredentialScope)
@@ -583,6 +598,9 @@ public class AwsQueryController {
if (ELASTIC_BEANSTALK_ACTIONS.contains(action)) {
return "elasticbeanstalk";
}
+ if (REDSHIFT_ACTIONS.contains(action)) {
+ return "redshift";
+ }
// SQS actions are numerous and not enumerated — fall back to sqs only for
// requests that arrived without an Authorization header (raw/test clients)
return "sqs";
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
index 46087b4805..707d6cb6c3 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
@@ -156,6 +156,11 @@ public class ResolvedServiceCatalog {
5000L, AwsNamespaces.RDS, ServiceProtocol.QUERY,
protocols(ServiceProtocol.QUERY),
Set.of(), Set.of("docdb"), Set.of(), Set.of()),
+ descriptor("redshift", "redshift", config.services().redshift().enabled(), true,
+ "redshift", storageMode(config.storage().services().redshift().mode(), config.storage().mode()),
+ 5000L, AwsNamespaces.REDSHIFT, ServiceProtocol.QUERY,
+ protocols(ServiceProtocol.QUERY),
+ Set.of(), Set.of("redshift"), Set.of(), Set.of()),
descriptor("events", "eventbridge", config.services().eventbridge().enabled(), true,
"eventbridge", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
diff --git a/src/main/java/io/github/hectorvent/floci/core/storage/AccountAwareStorageBackend.java b/src/main/java/io/github/hectorvent/floci/core/storage/AccountAwareStorageBackend.java
index 4063bbc7ab..2473a8fb86 100644
--- a/src/main/java/io/github/hectorvent/floci/core/storage/AccountAwareStorageBackend.java
+++ b/src/main/java/io/github/hectorvent/floci/core/storage/AccountAwareStorageBackend.java
@@ -380,6 +380,11 @@ public class AccountAwareStorageBackend implements StorageBackend
// ---
+ /** Returns the account ID that keys are currently being prefixed with. */
+ public String accountId() {
+ return prefix();
+ }
+
private String prefix() {
if (requestContextInstance != null) {
try {
diff --git a/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java
new file mode 100644
index 0000000000..c57252fa6a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java
@@ -0,0 +1,598 @@
+package io.github.hectorvent.floci.services.redshift;
+
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.XmlBuilder;
+import io.github.hectorvent.floci.services.redshift.model.Cluster;
+import io.github.hectorvent.floci.services.redshift.model.ClusterParameterGroup;
+import io.github.hectorvent.floci.services.redshift.model.ClusterSubnetGroup;
+import io.github.hectorvent.floci.services.redshift.model.Parameter;
+import io.github.hectorvent.floci.services.redshift.model.Snapshot;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.Response;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+@ApplicationScoped
+public class RedshiftQueryHandler {
+ private final RedshiftService service;
+
+ @Inject
+ public RedshiftQueryHandler(RedshiftService service) {
+ this.service = service;
+ }
+
+ public Response handle(String action, MultivaluedMap params) {
+ switch (action) {
+ case "CreateCluster" -> {
+ String identifier = params.getFirst("ClusterIdentifier");
+ String nodeType = params.getFirst("NodeType");
+ String masterUsername = params.getFirst("MasterUsername");
+ String masterUserPassword = params.getFirst("MasterUserPassword");
+ String clusterSubnetGroupName = params.getFirst("ClusterSubnetGroupName");
+ List vpcSecurityGroupIds = memberList(params, "VpcSecurityGroupIds");
+
+ Cluster cluster = service.createCluster(identifier, nodeType, masterUsername, masterUserPassword,
+ clusterSubnetGroupName, vpcSecurityGroupIds);
+ String xml = new XmlBuilder()
+ .start("CreateClusterResponse")
+ .start("CreateClusterResult")
+ .raw(buildClusterXml(cluster))
+ .end("CreateClusterResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("CreateClusterResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DescribeClusters" -> {
+ String identifier = params.getFirst("ClusterIdentifier");
+ List clusters = service.describeClusters(identifier);
+ XmlBuilder xmlBuilder = new XmlBuilder()
+ .start("DescribeClustersResponse")
+ .start("DescribeClustersResult")
+ .start("Clusters");
+ for (Cluster cluster : clusters) {
+ xmlBuilder.raw(buildClusterXml(cluster));
+ }
+ String xml = xmlBuilder
+ .end("Clusters")
+ .end("DescribeClustersResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DescribeClustersResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DeleteCluster" -> {
+ String identifier = params.getFirst("ClusterIdentifier");
+ Cluster cluster = service.deleteCluster(identifier);
+ String xml = new XmlBuilder()
+ .start("DeleteClusterResponse")
+ .start("DeleteClusterResult")
+ .raw(buildClusterXml(cluster))
+ .end("DeleteClusterResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DeleteClusterResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "CreateClusterSnapshot" -> {
+ String snapshotIdentifier = params.getFirst("SnapshotIdentifier");
+ String clusterIdentifier = params.getFirst("ClusterIdentifier");
+ Snapshot snapshot = service.createSnapshot(snapshotIdentifier, clusterIdentifier);
+ String xml = new XmlBuilder()
+ .start("CreateClusterSnapshotResponse")
+ .start("CreateClusterSnapshotResult")
+ .raw(buildSnapshotXml(snapshot))
+ .end("CreateClusterSnapshotResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("CreateClusterSnapshotResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DescribeClusterSnapshots" -> {
+ String snapshotIdentifier = params.getFirst("SnapshotIdentifier");
+ String clusterIdentifier = params.getFirst("ClusterIdentifier");
+ List snapshots = service.describeSnapshots(snapshotIdentifier, clusterIdentifier);
+ XmlBuilder xmlBuilder = new XmlBuilder()
+ .start("DescribeClusterSnapshotsResponse")
+ .start("DescribeClusterSnapshotsResult")
+ .start("Snapshots");
+ for (Snapshot snapshot : snapshots) {
+ xmlBuilder.raw(buildSnapshotXml(snapshot));
+ }
+ String xml = xmlBuilder
+ .end("Snapshots")
+ .end("DescribeClusterSnapshotsResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DescribeClusterSnapshotsResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DeleteClusterSnapshot" -> {
+ String snapshotIdentifier = params.getFirst("SnapshotIdentifier");
+ Snapshot snapshot = service.deleteSnapshot(snapshotIdentifier);
+ String xml = new XmlBuilder()
+ .start("DeleteClusterSnapshotResponse")
+ .start("DeleteClusterSnapshotResult")
+ .raw(buildSnapshotXml(snapshot))
+ .end("DeleteClusterSnapshotResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DeleteClusterSnapshotResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "RestoreFromClusterSnapshot" -> {
+ String clusterIdentifier = params.getFirst("ClusterIdentifier");
+ String snapshotIdentifier = params.getFirst("SnapshotIdentifier");
+ String nodeType = params.getFirst("NodeType");
+ Cluster cluster = service.restoreFromClusterSnapshot(clusterIdentifier, snapshotIdentifier, nodeType);
+ String xml = new XmlBuilder()
+ .start("RestoreFromClusterSnapshotResponse")
+ .start("RestoreFromClusterSnapshotResult")
+ .raw(buildClusterXml(cluster))
+ .end("RestoreFromClusterSnapshotResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("RestoreFromClusterSnapshotResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "CreateClusterParameterGroup" -> {
+ String parameterGroupName = params.getFirst("ParameterGroupName");
+ String parameterGroupFamily = params.getFirst("ParameterGroupFamily");
+ String description = params.getFirst("Description");
+ ClusterParameterGroup group = service.createClusterParameterGroup(parameterGroupName, parameterGroupFamily, description);
+ String xml = new XmlBuilder()
+ .start("CreateClusterParameterGroupResponse")
+ .start("CreateClusterParameterGroupResult")
+ .raw(buildClusterParameterGroupXml(group))
+ .end("CreateClusterParameterGroupResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("CreateClusterParameterGroupResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DescribeClusterParameterGroups" -> {
+ String parameterGroupName = params.getFirst("ParameterGroupName");
+ List groups = service.describeClusterParameterGroups(parameterGroupName);
+ XmlBuilder xmlBuilder = new XmlBuilder()
+ .start("DescribeClusterParameterGroupsResponse")
+ .start("DescribeClusterParameterGroupsResult")
+ .start("ParameterGroups");
+ for (ClusterParameterGroup group : groups) {
+ xmlBuilder.raw(buildClusterParameterGroupXml(group));
+ }
+ String xml = xmlBuilder
+ .end("ParameterGroups")
+ .end("DescribeClusterParameterGroupsResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DescribeClusterParameterGroupsResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DescribeClusterParameters" -> {
+ String parameterGroupName = params.getFirst("ParameterGroupName");
+ if (parameterGroupName == null || parameterGroupName.isBlank()) {
+ throw new AwsException("InvalidParameterValue", "ParameterGroupName is required", 400);
+ }
+ List parameters = service.describeClusterParameters(parameterGroupName);
+
+ XmlBuilder xmlBuilder = new XmlBuilder()
+ .start("DescribeClusterParametersResponse")
+ .start("DescribeClusterParametersResult")
+ .start("Parameters");
+ for (Parameter param : parameters) {
+ xmlBuilder.raw(buildParameterXml(param));
+ }
+ String xml = xmlBuilder.end("Parameters")
+ .end("DescribeClusterParametersResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DescribeClusterParametersResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "ModifyClusterParameterGroup" -> {
+ String parameterGroupName = params.getFirst("ParameterGroupName");
+ if (parameterGroupName == null || parameterGroupName.isBlank()) {
+ throw new AwsException("InvalidParameterValue", "ParameterGroupName is required", 400);
+ }
+ List updates = parseParameters(params);
+ service.modifyClusterParameterGroup(parameterGroupName, updates);
+ String xml = new XmlBuilder()
+ .start("ModifyClusterParameterGroupResponse")
+ .start("ModifyClusterParameterGroupResult")
+ .elem("ParameterGroupName", parameterGroupName)
+ .elem("ParameterGroupStatus", "pending-reboot")
+ .end("ModifyClusterParameterGroupResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("ModifyClusterParameterGroupResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DeleteClusterParameterGroup" -> {
+ String parameterGroupName = params.getFirst("ParameterGroupName");
+ service.deleteClusterParameterGroup(parameterGroupName);
+ String xml = new XmlBuilder()
+ .start("DeleteClusterParameterGroupResponse")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DeleteClusterParameterGroupResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "CreateTags" -> {
+ String resourceName = params.getFirst("ResourceName");
+ service.createTags(resourceName, parseTags(params));
+ String xml = new XmlBuilder()
+ .start("CreateTagsResponse")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("CreateTagsResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DeleteTags" -> {
+ String resourceName = params.getFirst("ResourceName");
+ List tagKeys = memberList(params, "TagKeys");
+ service.deleteTags(resourceName, tagKeys);
+ String xml = new XmlBuilder()
+ .start("DeleteTagsResponse")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DeleteTagsResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DescribeTags" -> {
+ String resourceName = params.getFirst("ResourceName");
+ String resourceType = params.getFirst("ResourceType");
+ List tagKeys = memberList(params, "TagKeys");
+ List tagged = service.describeTags(resourceName, resourceType, tagKeys);
+ XmlBuilder xmlBuilder = new XmlBuilder()
+ .start("DescribeTagsResponse")
+ .start("DescribeTagsResult")
+ .start("TaggedResources");
+ for (RedshiftService.TaggedResource t : tagged) {
+ xmlBuilder.start("TaggedResource")
+ .elem("ResourceName", t.resourceName())
+ .elem("ResourceType", t.resourceType())
+ .start("Tag")
+ .elem("Key", t.tagKey())
+ .elem("Value", t.tagValue())
+ .end("Tag")
+ .end("TaggedResource");
+ }
+ String xml = xmlBuilder
+ .end("TaggedResources")
+ .end("DescribeTagsResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DescribeTagsResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "CreateClusterSubnetGroup" -> {
+ String name = params.getFirst("ClusterSubnetGroupName");
+ if (name == null || name.isBlank()) {
+ throw new AwsException("InvalidParameterValue", "ClusterSubnetGroupName is required", 400);
+ }
+ String description = params.getFirst("Description");
+ List subnetIds = memberList(params, "SubnetIds");
+ ClusterSubnetGroup group = service.createClusterSubnetGroup(name, description, null, subnetIds);
+ String xml = new XmlBuilder()
+ .start("CreateClusterSubnetGroupResponse")
+ .start("CreateClusterSubnetGroupResult")
+ .raw(buildClusterSubnetGroupXml(group))
+ .end("CreateClusterSubnetGroupResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("CreateClusterSubnetGroupResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DescribeClusterSubnetGroups" -> {
+ String name = params.getFirst("ClusterSubnetGroupName");
+ List groups = service.describeClusterSubnetGroups(name);
+ XmlBuilder xmlBuilder = new XmlBuilder()
+ .start("DescribeClusterSubnetGroupsResponse")
+ .start("DescribeClusterSubnetGroupsResult")
+ .start("ClusterSubnetGroups");
+ for (ClusterSubnetGroup group : groups) {
+ xmlBuilder.raw(buildClusterSubnetGroupXml(group));
+ }
+ String xml = xmlBuilder
+ .end("ClusterSubnetGroups")
+ .end("DescribeClusterSubnetGroupsResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DescribeClusterSubnetGroupsResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "ModifyClusterSubnetGroup" -> {
+ String name = params.getFirst("ClusterSubnetGroupName");
+ String description = params.getFirst("Description");
+ List subnetIds = memberList(params, "SubnetIds");
+ ClusterSubnetGroup group = service.modifyClusterSubnetGroup(name, description, subnetIds);
+ String xml = new XmlBuilder()
+ .start("ModifyClusterSubnetGroupResponse")
+ .start("ModifyClusterSubnetGroupResult")
+ .raw(buildClusterSubnetGroupXml(group))
+ .end("ModifyClusterSubnetGroupResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("ModifyClusterSubnetGroupResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "DeleteClusterSubnetGroup" -> {
+ String name = params.getFirst("ClusterSubnetGroupName");
+ service.deleteClusterSubnetGroup(name);
+ String xml = new XmlBuilder()
+ .start("DeleteClusterSubnetGroupResponse")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("DeleteClusterSubnetGroupResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "ModifyCluster" -> {
+ String clusterIdentifier = params.getFirst("ClusterIdentifier");
+ if (clusterIdentifier == null || clusterIdentifier.isBlank()) {
+ throw new AwsException("InvalidParameterValue", "ClusterIdentifier is required", 400);
+ }
+ String nodeType = params.getFirst("NodeType");
+ Integer numberOfNodes = parseOptionalInteger(params, "NumberOfNodes");
+ String masterUserPassword = params.getFirst("MasterUserPassword");
+ String clusterParameterGroupName = params.getFirst("ClusterParameterGroupName");
+ List vpcSecurityGroupIds = memberList(params, "VpcSecurityGroupIds");
+ Cluster cluster = service.modifyCluster(clusterIdentifier, nodeType, numberOfNodes,
+ masterUserPassword, clusterParameterGroupName, vpcSecurityGroupIds);
+ String xml = new XmlBuilder()
+ .start("ModifyClusterResponse")
+ .start("ModifyClusterResult")
+ .raw(buildClusterXml(cluster))
+ .end("ModifyClusterResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("ModifyClusterResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ case "RebootCluster" -> {
+ String clusterIdentifier = params.getFirst("ClusterIdentifier");
+ if (clusterIdentifier == null || clusterIdentifier.isBlank()) {
+ throw new AwsException("InvalidParameterValue", "ClusterIdentifier is required", 400);
+ }
+ Cluster cluster = service.rebootCluster(clusterIdentifier);
+ String xml = new XmlBuilder()
+ .start("RebootClusterResponse")
+ .start("RebootClusterResult")
+ .raw(buildClusterXml(cluster))
+ .end("RebootClusterResult")
+ .start("ResponseMetadata")
+ .elem("RequestId", "test-req-id")
+ .end("ResponseMetadata")
+ .end("RebootClusterResponse")
+ .build();
+ return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
+ }
+ default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
+ }
+ }
+
+ private String buildClusterXml(Cluster cluster) {
+ XmlBuilder builder = new XmlBuilder()
+ .start("Cluster")
+ .elem("ClusterIdentifier", cluster.getClusterIdentifier())
+ .elem("NodeType", cluster.getNodeType())
+ .elem("MasterUsername", cluster.getMasterUsername())
+ .elem("ClusterStatus", cluster.getClusterStatus())
+ .elem("ClusterSubnetGroupName", cluster.getClusterSubnetGroupName());
+
+ if (cluster.getVpcSecurityGroupIds() != null && !cluster.getVpcSecurityGroupIds().isEmpty()) {
+ builder.start("VpcSecurityGroups");
+ for (String sgId : cluster.getVpcSecurityGroupIds()) {
+ builder.start("VpcSecurityGroup").elem("VpcSecurityGroupId", sgId).end("VpcSecurityGroup");
+ }
+ builder.end("VpcSecurityGroups");
+ }
+
+ if (cluster.getClusterParameterGroupName() != null) {
+ builder.start("ClusterParameterGroups")
+ .start("ClusterParameterGroup")
+ .elem("ParameterGroupName", cluster.getClusterParameterGroupName())
+ .elem("ParameterApplyStatus", "in-sync")
+ .end("ClusterParameterGroup")
+ .end("ClusterParameterGroups");
+ }
+
+ if (cluster.getTags() != null && !cluster.getTags().isEmpty()) {
+ builder.start("Tags");
+ for (Map.Entry tag : cluster.getTags().entrySet()) {
+ builder.start("Tag")
+ .elem("Key", tag.getKey())
+ .elem("Value", tag.getValue())
+ .end("Tag");
+ }
+ builder.end("Tags");
+ }
+
+ if (cluster.getEndpoint() != null) {
+ builder.start("Endpoint")
+ .elem("Address", cluster.getEndpoint().getAddress())
+ .elem("Port", String.valueOf(cluster.getEndpoint().getPort()))
+ .end("Endpoint");
+ }
+
+ return builder.end("Cluster").build();
+ }
+
+ private String buildSnapshotXml(Snapshot snapshot) {
+ XmlBuilder builder = new XmlBuilder()
+ .start("Snapshot")
+ .elem("SnapshotIdentifier", snapshot.getSnapshotIdentifier())
+ .elem("ClusterIdentifier", snapshot.getClusterIdentifier())
+ .elem("Status", snapshot.getStatus())
+ .elem("Port", String.valueOf(snapshot.getPort()))
+ .elem("MasterUsername", snapshot.getMasterUsername());
+
+ return builder.end("Snapshot").build();
+ }
+
+ private String buildClusterParameterGroupXml(ClusterParameterGroup group) {
+ XmlBuilder builder = new XmlBuilder()
+ .start("ClusterParameterGroup")
+ .elem("ParameterGroupName", group.getParameterGroupName())
+ .elem("ParameterGroupFamily", group.getParameterGroupFamily())
+ .elem("Description", group.getDescription());
+
+ return builder.end("ClusterParameterGroup").build();
+ }
+
+ private String buildClusterSubnetGroupXml(ClusterSubnetGroup group) {
+ XmlBuilder builder = new XmlBuilder()
+ .start("ClusterSubnetGroup")
+ .elem("ClusterSubnetGroupName", group.getClusterSubnetGroupName())
+ .elem("Description", group.getDescription())
+ .elem("VpcId", group.getVpcId())
+ .start("Subnets");
+ for (String subnetId : group.getSubnetIds()) {
+ builder.start("Subnet").elem("SubnetIdentifier", subnetId).end("Subnet");
+ }
+ return builder.end("Subnets").end("ClusterSubnetGroup").build();
+ }
+
+ private String buildParameterXml(Parameter param) {
+ XmlBuilder builder = new XmlBuilder()
+ .start("Parameter")
+ .elem("ParameterName", param.getParameterName())
+ .elem("ParameterValue", param.getParameterValue());
+
+ if (param.getDescription() != null) {
+ builder.elem("Description", param.getDescription());
+ }
+ if (param.getDataType() != null) {
+ builder.elem("DataType", param.getDataType());
+ }
+ return builder.end("Parameter").build();
+ }
+
+ private static List memberList(MultivaluedMap params, String baseName) {
+ return params.keySet().stream()
+ .filter(key -> key.matches(memberKeyRegex(baseName)))
+ .sorted(Comparator.comparingInt(RedshiftQueryHandler::numericSuffix))
+ .map(params::getFirst)
+ .filter(value -> value != null && !value.isBlank())
+ .toList();
+ }
+
+ // The AWS Query protocol accepts both the generic ".member.N" form and each shape's own
+ // locationName (e.g. the real Redshift SDK sends "SubnetIds.SubnetIdentifier.N", not "SubnetIds.member.N").
+ private static String memberKeyRegex(String baseName) {
+ String quoted = Pattern.quote(baseName);
+ return switch (baseName) {
+ case "SubnetIds" -> quoted + "(\\.member|\\.SubnetIdentifier)?\\.\\d+";
+ case "VpcSecurityGroupIds" -> quoted + "(\\.member|\\.VpcSecurityGroupId)?\\.\\d+";
+ case "TagKeys" -> quoted + "(\\.member|\\.TagKey)?\\.\\d+";
+ default -> quoted + "(\\.member)?\\.\\d+";
+ };
+ }
+
+ private static int numericSuffix(String key) {
+ int lastDot = key.lastIndexOf('.');
+ if (lastDot < 0 || lastDot == key.length() - 1) {
+ return Integer.MAX_VALUE;
+ }
+ try {
+ return Integer.parseInt(key.substring(lastDot + 1));
+ } catch (NumberFormatException e) {
+ return Integer.MAX_VALUE;
+ }
+ }
+
+ private static List parseParameters(MultivaluedMap params) {
+ List parsed = new ArrayList<>();
+ readParameters(params, "Parameters.member", parsed);
+ readParameters(params, "Parameters.Parameter", parsed);
+ return parsed;
+ }
+
+ private static void readParameters(MultivaluedMap params, String prefix, List parsed) {
+ for (int i = 1; ; i++) {
+ String name = params.getFirst(prefix + "." + i + ".ParameterName");
+ if (name == null) {
+ break;
+ }
+ String value = params.getFirst(prefix + "." + i + ".ParameterValue");
+ parsed.add(new Parameter(name, value));
+ }
+ }
+
+ private static Map parseTags(MultivaluedMap params) {
+ Map tags = new LinkedHashMap<>();
+ readTags(params, "Tags.member", tags);
+ readTags(params, "Tags.Tag", tags);
+ return tags;
+ }
+
+ private static void readTags(MultivaluedMap params, String prefix, Map tags) {
+ for (int i = 1; ; i++) {
+ String key = params.getFirst(prefix + "." + i + ".Key");
+ if (key == null) {
+ break;
+ }
+ String value = params.getFirst(prefix + "." + i + ".Value");
+ tags.put(key, value == null ? "" : value);
+ }
+ }
+
+ private static Integer parseOptionalInteger(MultivaluedMap params, String parameterName) {
+ String value = params.getFirst(parameterName);
+ if (value == null) {
+ return null;
+ }
+ try {
+ return Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ throw new AwsException("InvalidParameterValue", parameterName + " must be an integer.", 400);
+ }
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java
new file mode 100644
index 0000000000..40cc75c875
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java
@@ -0,0 +1,728 @@
+package io.github.hectorvent.floci.services.redshift;
+
+import io.github.hectorvent.floci.config.EmulatorConfig;
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.redshift.container.RedshiftContainerHandle;
+import io.github.hectorvent.floci.services.redshift.container.RedshiftContainerManager;
+import io.github.hectorvent.floci.services.redshift.model.Cluster;
+import io.github.hectorvent.floci.services.redshift.model.ClusterParameterGroup;
+import io.github.hectorvent.floci.services.redshift.model.ClusterSubnetGroup;
+import io.github.hectorvent.floci.services.redshift.model.Endpoint;
+import io.github.hectorvent.floci.services.redshift.model.Parameter;
+import io.github.hectorvent.floci.services.redshift.model.Snapshot;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.event.Observes;
+import jakarta.inject.Inject;
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.quarkus.runtime.StartupEvent;
+import org.jboss.logging.Logger;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Consumer;
+
+@ApplicationScoped
+public class RedshiftService {
+ private static final Logger LOG = Logger.getLogger(RedshiftService.class);
+
+ private final AccountAwareStorageBackend clusters;
+ private final AccountAwareStorageBackend snapshots;
+ private final AccountAwareStorageBackend parameterGroups;
+ private final AccountAwareStorageBackend subnetGroups;
+ private final RedshiftContainerManager containerManager;
+ private final EmulatorConfig config;
+ private final RegionResolver regionResolver;
+
+ @Inject
+ public RedshiftService(StorageFactory storageFactory, RedshiftContainerManager containerManager,
+ EmulatorConfig config, RegionResolver regionResolver) {
+ this.clusters = storageFactory.create("redshift", "redshift-clusters.json", new TypeReference