From 20a652c857995211827fcef4d6de6eefe28e3772 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:17:08 -0500 Subject: [PATCH] Update DbSubnetGroupResource.java --- .../gyro/aws/rds/DbSubnetGroupResource.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java index 5e5e7fbf3..f0d6e0521 100644 --- a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java +++ b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java @@ -36,6 +36,9 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; /** * Create a db subnet group. @@ -63,7 +66,7 @@ public class DbSubnetGroupResource extends RdsTaggableResource implements Copyab private String description; private String name; - private Set subnets; + private List subnets; /** * The description for the DB subnet group. @@ -96,23 +99,25 @@ public void setName(String name) { */ @Required @Updatable - public Set getSubnets() { + public List getSubnets() { if (subnets == null) { - return new HashSet<>(); + return new ArrayList<>(); } - return subnets; + return subnets.stream() + .sorted(Comparator.comparing(SubnetResource::getId)) + .collect(Collectors.toList()); } - public void setSubnets(Set subnets) { - this.subnets = subnets; + public void setSubnets(List subnets) { + this.subnets = new ArrayList<>(subnets); } @Override public void copyFrom(DBSubnetGroup group) { setDescription(group.dbSubnetGroupDescription()); setName(group.dbSubnetGroupName()); - setSubnets(group.subnets().stream().map(s -> findById(SubnetResource.class, s.subnetIdentifier())).collect(Collectors.toSet())); + setSubnets(group.subnets().stream().map(s -> findById(SubnetResource.class, s.subnetIdentifier())).collect(Collectors.toList())); setArn(group.dbSubnetGroupArn()); } @@ -143,8 +148,8 @@ public void doCreate(GyroUI ui, State state) { RdsClient client = createClient(RdsClient.class); CreateDbSubnetGroupResponse response = client.createDBSubnetGroup( r -> r.dbSubnetGroupDescription(getDescription()) - .dbSubnetGroupName(getName()) - .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toSet())) + .dbSubnetGroupName(getName()) + .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toList())) ); setArn(response.dbSubnetGroup().dbSubnetGroupArn()); @@ -155,8 +160,8 @@ public void doUpdate(Resource current, Set changedProperties) { RdsClient client = createClient(RdsClient.class); client.modifyDBSubnetGroup( r -> r.dbSubnetGroupName(getName()) - .dbSubnetGroupDescription(getDescription()) - .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toSet())) + .dbSubnetGroupDescription(getDescription()) + .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toList())) ); } @@ -167,4 +172,4 @@ public void delete(GyroUI ui, State state) { r -> r.dbSubnetGroupName(getName()) ); } -} +} \ No newline at end of file