Skip to content

Instantly share code, notes, and snippets.

@mkuehle
Created May 1, 2019 06:47
Show Gist options
  • Save mkuehle/6b7d362db5b846103df0b0731ef0ae41 to your computer and use it in GitHub Desktop.
Save mkuehle/6b7d362db5b846103df0b0731ef0ae41 to your computer and use it in GitHub Desktop.
Auf den Status available warten während die RDS Instanz erstellt wird
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