diff --git a/gradle.properties b/gradle.properties index 8e426bde..26661297 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ group=com.nike artifactId=cerberus-lifecycle-cli -version=4.12.0 +version=4.12.1 diff --git a/src/main/java/com/nike/cerberus/operation/rds/XRegionDatabaseReplicationOperation.java b/src/main/java/com/nike/cerberus/operation/rds/XRegionDatabaseReplicationOperation.java index 410339ab..b59d50ce 100644 --- a/src/main/java/com/nike/cerberus/operation/rds/XRegionDatabaseReplicationOperation.java +++ b/src/main/java/com/nike/cerberus/operation/rds/XRegionDatabaseReplicationOperation.java @@ -84,10 +84,13 @@ public void run(XRegionDatabaseReplicationCommand command) { log.info("Preparing to initiate copy of RDS DB snapshot: {} located in region: {} to region: {}", sourceSnapshot.getDBClusterSnapshotIdentifier(), sourceRegion.getName(), targetRegion.getName()); - DBClusterSnapshot copiedSnapshot = rdsService.copySnapshot(sourceSnapshot, sourceRegion, targetRegion); - rdsService.waitForSnapshotsToBecomeAvailable(copiedSnapshot, targetRegion); - - rdsService.deleteSnapshot(sourceSnapshot, sourceRegion); + DBClusterSnapshot copiedSnapshot; + try { + copiedSnapshot = rdsService.copySnapshot(sourceSnapshot, sourceRegion, targetRegion); + rdsService.waitForSnapshotsToBecomeAvailable(copiedSnapshot, targetRegion); + } finally { + rdsService.deleteSnapshot(sourceSnapshot, sourceRegion); + } String databasePassword = configStore.getCmsDatabasePassword() .orElseThrow(() -> new RuntimeException("Expected the database password to exist")); @@ -117,9 +120,9 @@ public void run(XRegionDatabaseReplicationCommand command) { } else { throw ase; } + } finally { + rdsService.deleteSnapshot(copiedSnapshot, targetRegion); } - - rdsService.deleteSnapshot(copiedSnapshot, targetRegion); }