以前のスナップショットから Amazon RDS を開始するスクリプトがあります。ここで、Java API を使用してこの機能を実装する必要があります。
私が実行するスクリプトは次のとおりです。
rds-restore-db-instance-from-db-snapshot $RDS_DEV --db-snapshot-identifier $SNAP --db-subnet-group-name $SUBNET_GROUP --region $REGION
echo sleep $TIME
そのため、その後、一定時間スリープしてから、適切なセキュリティ グループとパラメーター グループを割り当てます。
rds-modify-db-instance $RDS_DEV --db-security-groups $SEC_GROUP --db-parameter-group-name $PARAM_GROUP --apply-immediately --region $REGION
次に、インスタンスを再起動します。
私の API 実装では、スナップショットから RDS を復元するためにこのメソッドを作成しました。
public void restoreDBSnapshot(String rdsDev, String snapshotId,
String subnetGroup, String availabilityZone) {
RestoreDBInstanceFromDBSnapshotRequest restoreDBInstanceRequest = new RestoreDBInstanceFromDBSnapshotRequest();
restoreDBInstanceRequest.setDBSnapshotIdentifier(snapshotId);
restoreDBInstanceRequest.setDBName(rdsDev);
restoreDBInstanceRequest.setDBSubnetGroupName(subnetGroup);
restoreDBInstanceRequest.setAvailabilityZone(availabilityZone);
LOG.info("Restoring RDS from backup snapshot");
this.rds.restoreDBInstanceFromDBSnapshot(restoreDBInstanceRequest);
}
しかし、RDS の起動を待ってアプリケーションをスリープさせてから、securityGroup と parameterGroupName を変更したくありません。
ModifyDBInstanceRequest
作成段階でそれを行う解決策はありますか?