我有一个脚本可以从之前的快照启动亚马逊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和parameterGroupNameModifyDBInstanceRequest
在创作阶段是否有解决方案?