Created
May 1, 2019 06:47
-
-
Save mkuehle/6b7d362db5b846103df0b0731ef0ae41 to your computer and use it in GitHub Desktop.
Auf den Status available warten während die RDS Instanz erstellt wird
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
public DBInstance getRdsInstance(String dbInstanceIdentifier) { | |
AmazonRDS client = createAmazonRdsClient(); | |
DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest() | |
.withDBInstanceIdentifier(dbInstanceIdentifier); | |
DescribeDBInstancesResult describeDBInstances = client.describeDBInstances(describeDBInstancesRequest); | |
client.shutdown(); | |
return describeDBInstances.getDBInstances().get(0); | |
} | |
private void waitUntilRdsInstanceIsAvailable(DBInstance instance) { | |
DBInstance newRdsInstance = getRdsInstance(instance.getDBInstanceIdentifier()); | |
while (!newRdsInstance.getDBInstanceStatus().equals("available")) { | |
logger.info("RDS Stage Instanz ist im Status {} - prüfe in 30 Sekunden erneut.", newRdsInstance.getDBInstanceStatus()); | |
try { | |
Thread.sleep(TimeUnit.SECONDS.toMillis(30)); | |
} catch (InterruptedException e) { | |
// Do nothing but sleep! | |
} | |
newRdsInstance = getRdsInstance(instance.getDBInstanceIdentifier()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment