Skip to content

Instantly share code, notes, and snippets.

@mkuehle
Created May 1, 2019 06:40
Show Gist options
  • Save mkuehle/fb80bf8c92e2ae905df4c2a028b0eb04 to your computer and use it in GitHub Desktop.
Save mkuehle/fb80bf8c92e2ae905df4c2a028b0eb04 to your computer and use it in GitHub Desktop.
Amazon RDS Instanz mit Snapshot ID erstellen
private DBInstance createRdsInstance(String snapshotIdentifier) {
String newRdsInstanceId = "mk-dev-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMdd-HHmm"));
logger.info("Erstelle neue RDS Stage Instance mit ID: {}", newRdsInstanceId);
AmazonRDS client = createAmazonRdsClient();
RestoreDBInstanceFromDBSnapshotRequest request = new RestoreDBInstanceFromDBSnapshotRequest()
.withPubliclyAccessible(true)
.withDBInstanceIdentifier(newRdsInstanceId)
.withDBSnapshotIdentifier(snapshotIdentifier)
.withMultiAZ(false)
.withDBInstanceClass("db.t3.small")
.withAvailabilityZone("eu-central-1b")
.withDBSubnetGroupName("default");
DBInstance instance = client.restoreDBInstanceFromDBSnapshot(request);
client.shutdown();
return instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment