From 85e47c50d3bcb7d6debcfe03bded3b5c54f82873 Mon Sep 17 00:00:00 2001 From: Harshil Sanjay Jain Date: Fri, 13 Sep 2024 13:42:35 -0400 Subject: [PATCH 1/5] Add writer endpoint type --- src/main/java/gyro/aws/rds/DbClusterEndpointResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java index c9740e2f5..b226759b7 100644 --- a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java @@ -96,7 +96,7 @@ public void setDbCluster(DbClusterResource dbCluster) { */ @Required @Updatable - @ValidStrings({"READER", "ANY"}) + @ValidStrings({"READER", "WRITER", "ANY"}) public String getEndpointType() { return endpointType; } From d347dbedbf1265e577391a5cae45c9951d0d467e Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Wed, 18 Sep 2024 08:35:39 -0500 Subject: [PATCH 2/5] Add validation for endpoint type WRITER if engine is aurora. --- .../aws/rds/DbClusterEndpointResource.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java index b226759b7..295587a6d 100644 --- a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java @@ -29,6 +29,7 @@ import gyro.core.scope.State; import gyro.core.validation.Required; import gyro.core.validation.ValidStrings; +import gyro.core.validation.ValidationError; import software.amazon.awssdk.services.rds.RdsClient; import software.amazon.awssdk.services.rds.model.CreateDbClusterEndpointResponse; import software.amazon.awssdk.services.rds.model.DBClusterEndpoint; @@ -226,4 +227,21 @@ public void delete(GyroUI ui, State state) { r -> r.dbClusterEndpointIdentifier(getIdentifier()) ); } + + @Override + public List validate(Set configuredFields) { + List errors = new ArrayList<>(); + + // Add validation for Aurora DB and endpointType 'WRITER' + String engine = getDbCluster().getEngine(); + if ((engine.equalsIgnoreCase("aurora-mysql") || engine.equalsIgnoreCase("aurora-postgresql")) + && getEndpointType().equalsIgnoreCase("WRITER")) { + errors.add(new ValidationError( + this, + "dbCluster", + "Database engine " + engine + " with endpointType 'WRITER' is not supported")); + } + + return errors; + } } From 954eae5115f95820ce8df7bfb7563165cc2e49f5 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:07:03 -0500 Subject: [PATCH 3/5] Add a note for WRITER endpoint --- src/main/java/gyro/aws/rds/DbClusterEndpointResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java index 295587a6d..1e179432b 100644 --- a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java @@ -93,7 +93,7 @@ public void setDbCluster(DbClusterResource dbCluster) { } /** - * The type of the endpoint. + * The type of the endpoint. Note: For Aurora, WRITER is not used. */ @Required @Updatable From d4f443722d2756a3ceae07ad3ddfd6bbd8dd3a56 Mon Sep 17 00:00:00 2001 From: Rustem <134000942+Russsnizza@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:38:40 -0600 Subject: [PATCH 4/5] Update comment for Aurora WRITER endpoint Co-authored-by: Deepanjan Bhattacharyya --- src/main/java/gyro/aws/rds/DbClusterEndpointResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java index 1e179432b..981507bd3 100644 --- a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java @@ -93,7 +93,7 @@ public void setDbCluster(DbClusterResource dbCluster) { } /** - * The type of the endpoint. Note: For Aurora, WRITER is not used. + * The type of the endpoint. Cannot be set to ``WRITER`` if 'db-cluster' is set to ``Aurora``. */ @Required @Updatable From 6e1a9666198dcee8eb0cdd3ca5e7fde2b6e81992 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:09:06 -0600 Subject: [PATCH 5/5] Update ValidationError for DbClusterEndpointResource --- .../aws/rds/DbClusterEndpointResource.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java index 981507bd3..34a0866ae 100644 --- a/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterEndpointResource.java @@ -231,17 +231,21 @@ public void delete(GyroUI ui, State state) { @Override public List validate(Set configuredFields) { List errors = new ArrayList<>(); - + // Add validation for Aurora DB and endpointType 'WRITER' - String engine = getDbCluster().getEngine(); - if ((engine.equalsIgnoreCase("aurora-mysql") || engine.equalsIgnoreCase("aurora-postgresql")) - && getEndpointType().equalsIgnoreCase("WRITER")) { - errors.add(new ValidationError( - this, - "dbCluster", - "Database engine " + engine + " with endpointType 'WRITER' is not supported")); + if (getDbCluster() != null) { + String engine = getDbCluster().getEngine(); + if (engine != null && getEndpointType() != null) { + if ((engine.equalsIgnoreCase("aurora-mysql") || engine.equalsIgnoreCase("aurora-postgresql")) + && getEndpointType().equalsIgnoreCase("WRITER")) { + errors.add(new ValidationError( + this, + "dbCluster", + "Database engine " + engine + " with endpointType 'WRITER' is not supported")); + } + } } - + return errors; } }