in aws-rds-dbinstance/src/main/java/software/amazon/rds/dbinstance/CreateHandler.java [122:157]
private ProgressEvent<ResourceModel, CallbackContext> restoreDbInstanceFromSnapshot(
final AmazonWebServicesClientProxy proxy,
final ProxyClient<RdsClient> rdsProxyClient,
final ProgressEvent<ResourceModel, CallbackContext> progress
) {
final ResourceModel resourceModel = progress.getResourceModel();
if (resourceModel.getMultiAZ() == null) {
try {
final DBSnapshot snapshot = fetchDBSnapshot(rdsProxyClient, resourceModel);
final String engine = snapshot.engine();
resourceModel.setMultiAZ(getDefaultMultiAzForEngine(engine));
} catch (Exception e) {
return Commons.handleException(progress, e, RESTORE_DB_INSTANCE_ERROR_RULE_SET);
}
}
return proxy.initiate(
"rds::restore-db-instance-from-snapshot",
rdsProxyClient,
resourceModel,
progress.getCallbackContext()
).translateToServiceRequest(Translator::restoreDbInstanceFromSnapshotRequest)
.backoffDelay(config.getBackoff())
.makeServiceCall((restoreRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(
restoreRequest,
proxyInvocation.client()::restoreDBInstanceFromDBSnapshot
))
.stabilize((request, response, proxyInvocation, model, context) ->
isDbInstanceStabilized(proxyInvocation, model))
.handleError((request, exception, client, model, context) -> Commons.handleException(
ProgressEvent.progress(model, context),
exception,
RESTORE_DB_INSTANCE_ERROR_RULE_SET
))
.progress();
}