|
41 | 41 | import gyro.core.validation.ConflictsWith;
|
42 | 42 | import gyro.core.validation.Required;
|
43 | 43 | import gyro.core.validation.ValidStrings;
|
| 44 | +import gyro.core.validation.ValidationError; |
44 | 45 | import software.amazon.awssdk.services.rds.RdsClient;
|
45 | 46 | import software.amazon.awssdk.services.rds.model.CreateDbClusterRequest;
|
46 | 47 | import software.amazon.awssdk.services.rds.model.CreateDbClusterResponse;
|
@@ -1094,7 +1095,8 @@ public void delete(GyroUI ui, State state) {
|
1094 | 1095 |
|
1095 | 1096 | client.deleteDBCluster(
|
1096 | 1097 | r -> r.dbClusterIdentifier(getIdentifier())
|
1097 |
| - .finalDBSnapshotIdentifier(!getSkipFinalSnapshot() ? getFinalDbSnapshotIdentifier() : null) |
| 1098 | + .finalDBSnapshotIdentifier( |
| 1099 | + Boolean.TRUE.equals(getSkipFinalSnapshot()) ? null : getFinalDbSnapshotIdentifier()) |
1098 | 1100 | .skipFinalSnapshot(getSkipFinalSnapshot())
|
1099 | 1101 | );
|
1100 | 1102 |
|
@@ -1129,4 +1131,20 @@ private void waitForActiveStatus(RdsClient client, TimeoutSettings.Action action
|
1129 | 1131 | throw new GyroException("Unable to reach 'available' state for rds db cluster - " + getIdentifier());
|
1130 | 1132 | }
|
1131 | 1133 | }
|
| 1134 | + |
| 1135 | + @Override |
| 1136 | + public List<ValidationError> validate(Set<String> configuredFields) { |
| 1137 | + ArrayList<ValidationError> errors = new ArrayList<>(); |
| 1138 | + |
| 1139 | + if ((getSkipFinalSnapshot() == null || Boolean.FALSE.equals(getSkipFinalSnapshot())) && |
| 1140 | + getFinalDbSnapshotIdentifier() == null) { |
| 1141 | + errors.add(new ValidationError( |
| 1142 | + this, |
| 1143 | + "final-db-snapshot-identifier", |
| 1144 | + "'final-db-snapshot-identifier' is required when 'skip-final-snapshot' is unspecified or set to 'false'." |
| 1145 | + )); |
| 1146 | + } |
| 1147 | + |
| 1148 | + return errors; |
| 1149 | + } |
1132 | 1150 | }
|
0 commit comments