fix(elasticache): preserve member security group metadata (#5937)

Keep CreateReplicationGroup SecurityGroupIds in persistent group metadata and report active memberships on every DescribeCacheClusters member. Cover both topologies and Query list spellings with SDK regressions, plus legacy JSON defaults.
This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-10-18 11:13:30 -04:00
1 parent 301ac79c6e
commit 3a44e19e36
7 files changed
+256 -22

No files matched your search

@@ -143,7 +143,8 @@ public class ElastiCacheQueryHandler {
intParam(params, "Port"),
replicationGroupSettings(params),
parseTags(params),
extractMemberList(params, "UserGroupIds.member.")));
extractMemberList(params, "UserGroupIds.member."),
parseSecurityGroupIds(params)));
String result = replicationGroupXml(group);
return Response.ok(AwsQueryResponse.envelope("CreateReplicationGroup", AwsNamespaces.EC, result)).build();
} catch (AwsException e) {
@@ -525,6 +526,7 @@ public class ElastiCacheQueryHandler {
if (g.getCacheSubnetGroupName() != null) {
xml.elem("CacheSubnetGroupName", g.getCacheSubnetGroupName());
}
appendSecurityGroups(xml, g.getSecurityGroupIds());
if (showNodeInfo && g.getConfigurationEndpoint() != null) {
xml.start("CacheNodes")
.start("CacheNode")
@@ -959,16 +961,7 @@ private Response handleCreateCacheParameterGroup(MultivaluedMap<String, String>
if (c.getIpDiscovery() != null) {
xml.elem("IpDiscovery", c.getIpDiscovery());
}
if (!c.getSecurityGroupIds().isEmpty()) {
xml.start("SecurityGroups");
for (String securityGroupId : c.getSecurityGroupIds()) {
xml.start("member")
.elem("SecurityGroupId", securityGroupId)
.elem("Status", "active")
.end("member");
}
xml.end("SecurityGroups");
}
appendSecurityGroups(xml, c.getSecurityGroupIds());
if (c.getCacheNodeType() != null) {
xml.elem("CacheNodeType", c.getCacheNodeType());
}
@@ -1016,6 +1009,19 @@ private Response handleCreateCacheParameterGroup(MultivaluedMap<String, String>
return xml.end("CacheCluster").build();
}
private static void appendSecurityGroups(XmlBuilder xml, List<String> securityGroupIds) {
if (!securityGroupIds.isEmpty()) {
xml.start("SecurityGroups");
for (String securityGroupId : securityGroupIds) {
xml.start("member")
.elem("SecurityGroupId", securityGroupId)
.elem("Status", "active")
.end("member");
}
xml.end("SecurityGroups");
}
}
/**
* TransitEncryptionEnabled is not AuthTokenEnabled. An auth token forces encryption in transit,
* so a PASSWORD group is always encrypted — but the reverse does not hold: a group created with
@@ -198,7 +198,8 @@ public class ElastiCacheService implements ResourceProvider {
Integer port,
ReplicationGroupSettings settings,
Map<String, String> tags,
List<String> userGroupIds) {
List<String> userGroupIds,
List<String> securityGroupIds) {
}
public ReplicationGroup createReplicationGroup(String groupId, String description,
@@ -213,7 +214,7 @@ public class ElastiCacheService implements ResourceProvider {
Map<String, String> tags) {
return createReplicationGroup(new CreateReplicationGroupRequest(groupId, description,
authMode, authToken, region, null, null, null, null, null, null,
null, null, null, null, null, null, settings, tags, null));
null, null, null, null, null, null, settings, tags, null, null));
}
public ReplicationGroup createReplicationGroup(CreateReplicationGroupRequest request) {
@@ -500,6 +501,7 @@ public class ElastiCacheService implements ResourceProvider {
: "cache.t4g.micro");
group.setCacheParameterGroupName(request.cacheParameterGroupName());
group.setCacheSubnetGroupName(request.cacheSubnetGroupName());
group.setSecurityGroupIds(request.securityGroupIds());
group.setAutomaticFailoverEnabled(Boolean.TRUE.equals(request.automaticFailoverEnabled()));
group.setMultiAzEnabled(Boolean.TRUE.equals(request.multiAzEnabled()));
group.setSnapshotWindow(ReplicationGroupSettings.DEFAULT_SNAPSHOT_WINDOW);
@@ -47,6 +47,7 @@ public class ReplicationGroup {
private String cacheNodeType;
private String cacheParameterGroupName;
private String cacheSubnetGroupName;
private List<String> securityGroupIds = new ArrayList<>();
private boolean automaticFailoverEnabled;
private boolean multiAzEnabled;
private List<ClusterNode> clusterNodes = new ArrayList<>();
@@ -182,4 +183,9 @@ public class ReplicationGroup {
public void setClusterNodes(List<ClusterNode> clusterNodes) {
this.clusterNodes = clusterNodes != null ? clusterNodes : new ArrayList<>();
}
public List<String> getSecurityGroupIds() { return securityGroupIds; }
public void setSecurityGroupIds(List<String> securityGroupIds) {
this.securityGroupIds = securityGroupIds == null ? new ArrayList<>() : new ArrayList<>(securityGroupIds);
}
}