fix(redshift): keep tags on new cluster parameter groups and snapshots (#8068)

CreateClusterParameterGroup and CreateClusterSnapshot both take Tags,
but the handler never parsed them, so the new parameter group or
snapshot came back untagged: in the create response, in
DescribeClusterParameterGroups and DescribeClusterSnapshots, and in
DescribeTags on its ARN.

Tags are now parsed (Tags.Tag.N and Tags.member.N) and stored on the
resource, as CreateClusterSubnetGroup already does, and the
ClusterParameterGroup and Snapshot elements carry a Tags list, as AWS
returns them. DeleteCluster's final snapshot and automated snapshots
are still created without tags.
This commit is contained in:
soreavis authored and GitHub committed 2026-11-11 22:56:25 -04:00
1 parent 35bdfdcb3f
commit 07d6674f79
4 files changed
+74 -15

No files matched your search

@@ -1037,6 +1037,39 @@ public class RedshiftOperationsTest {
.statusCode(200);
}
@Test
@Order(3)
void parameterGroupAndSnapshotKeepTheirCreateTags() {
when(containerManager.start(any(), eq("cluster-create-tags"), any(), any(), any(), any()))
.thenReturn(new RedshiftContainerHandle("c4", "cluster-create-tags", "localhost", 5442));
assertEquals(200, redshift("CreateCluster", "ClusterIdentifier", "cluster-create-tags", "NodeType", "dc2.large",
"MasterUsername", "admin", "MasterUserPassword", "password123").statusCode());
String tag = "<Tag><Key>team</Key><Value>red</Value></Tag>";
redshift("CreateClusterParameterGroup", "ParameterGroupName", "pg-create-tags",
"ParameterGroupFamily", "redshift-1.0", "Description", "d",
"Tags.Tag.1.Key", "team", "Tags.Tag.1.Value", "red")
.then().statusCode(200).body(containsString("<Tags>" + tag + "</Tags>"));
redshift("DescribeClusterParameterGroups", "ParameterGroupName", "pg-create-tags")
.then().statusCode(200).body(containsString(tag));
redshift("DescribeTags", "ResourceName", "arn:aws:redshift:us-east-1:000000000000:parametergroup:pg-create-tags")
.then().statusCode(200).body(containsString(tag));
redshift("CreateClusterSnapshot", "SnapshotIdentifier", "snap-create-tags",
"ClusterIdentifier", "cluster-create-tags", "Tags.Tag.1.Key", "team", "Tags.Tag.1.Value", "red")
.then().statusCode(200).body(containsString("<Tags>" + tag + "</Tags>"));
redshift("DescribeClusterSnapshots", "SnapshotIdentifier", "snap-create-tags")
.then().statusCode(200).body(containsString(tag));
redshift("DescribeTags", "ResourceName",
"arn:aws:redshift:us-east-1:000000000000:snapshot:cluster-create-tags/snap-create-tags")
.then().statusCode(200).body(containsString(tag));
assertEquals(200, redshift("DeleteClusterSnapshot", "SnapshotIdentifier", "snap-create-tags").statusCode());
assertEquals(200, redshift("DeleteClusterParameterGroup", "ParameterGroupName", "pg-create-tags").statusCode());
assertEquals(200, redshift("DeleteCluster", "ClusterIdentifier", "cluster-create-tags",
"SkipFinalClusterSnapshot", "true").statusCode());
}
/**
* CreateSnapshotCopyGrant checks the name is free and then writes. Both steps run under the
* service lock, so of two concurrent creates of one name exactly one wins and the other sees
@@ -535,7 +535,7 @@ class RedshiftQueryHandlerTest {
params.putSingle("ClusterIdentifier", "test-cluster");
Snapshot snapshot = new Snapshot("test-snapshot", "test-cluster", "available", 5439, "admin");
when(service.createSnapshot("test-snapshot", "test-cluster")).thenReturn(snapshot);
when(service.createSnapshot("test-snapshot", "test-cluster", Map.of())).thenReturn(snapshot);
Response response = handler.handle("CreateClusterSnapshot", params);
assertEquals(200, response.getStatus());
@@ -762,7 +762,8 @@ class RedshiftQueryHandlerTest {
params.putSingle("Description", "custom redshift param group");
ClusterParameterGroup group = new ClusterParameterGroup("test-pg", "redshift-1.0", "custom redshift param group");
when(service.createClusterParameterGroup("test-pg", "redshift-1.0", "custom redshift param group")).thenReturn(group);
when(service.createClusterParameterGroup("test-pg", "redshift-1.0", "custom redshift param group", Map.of()))
.thenReturn(group);
Response response = handler.handle("CreateClusterParameterGroup", params);
assertEquals(200, response.getStatus());