Created
May 1, 2019 05:45
-
-
Save mkuehle/50906ee1dcaf0b6cb6f0d94048f1d3b9 to your computer and use it in GitHub Desktop.
Aktuellsten RDS Snapshot Identifier herausbekommen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AmazonRDS client = createAmazonRdsClient(); | |
DescribeDBSnapshotsRequest describeDBSnapshotsRequest = new DescribeDBSnapshotsRequest(); | |
describeDBSnapshotsRequest.withSnapshotType("automated"); | |
describeDBSnapshotsRequest.setDBInstanceIdentifier(RDS_INSTANCE_IDENTIFIER); | |
List<DBSnapshot> snapshots = client.describeDBSnapshots(describeDBSnapshotsRequest).getDBSnapshots(); | |
logger.info("{} RDS Snapshots gefunden für RDS Instance ID '{}'", snapshots.size(), RDS_INSTANCE_IDENTIFIER); | |
client.shutdown(); | |
// Den letzten Eintrag verwenden, denn das ist der aktuellste Snaphshot. Liste ist aufsteigend sortiert (letzter Snapshot ganz unten). | |
String snapshotIdentifier = snapshots.get(snapshots.size() - 1).getDBSnapshotIdentifier(); | |
if (snapshotIdentifier == null) { | |
throw new RuntimeException("Kann keinen Snapshot finden; DB Instanz Id: " + RDS_INSTANCE_IDENTIFIER); | |
} | |
logger.info("RDS Snapshot Identifier: {}", snapshotIdentifier); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment