in aws-cloudformation-stackset/src/main/java/software/amazon/cloudformation/stackset/BaseHandlerStd.java [175:216]
protected ProgressEvent<ResourceModel, CallbackContext> deleteStackInstances(
final AmazonWebServicesClientProxy proxy,
final ProxyClient<CloudFormationClient> client,
final ProgressEvent<ResourceModel, CallbackContext> progress,
final List<StackInstances> stackInstancesList,
final Logger logger) {
final ResourceModel model = progress.getResourceModel();
final CallbackContext callbackContext = progress.getCallbackContext();
for (final StackInstances stackInstances : stackInstancesList) {
final ProgressEvent<ResourceModel, CallbackContext> progressEvent = proxy
.initiate("AWS-CloudFormation-StackSet::DeleteStackInstances" + stackInstances.hashCode(), client, model, callbackContext)
.translateToServiceRequest(modelRequest -> deleteStackInstancesRequest(modelRequest.getStackSetId(), modelRequest.getOperationPreferences(), stackInstances, modelRequest.getCallAs()))
.backoffDelay(MULTIPLE_OF)
.makeServiceCall((modelRequest, proxyInvocation) -> {
logger.log(String.format("%s [%s] DeleteStackInstances request: [%s]", ResourceModel.TYPE_NAME, model.getStackSetId(), modelRequest));
final DeleteStackInstancesResponse response = proxyInvocation.injectCredentialsAndInvokeV2(modelRequest, proxyInvocation.client()::deleteStackInstances);
logger.log(String.format("%s [%s] DeleteStackInstances in [%s] of [%s] initiated", ResourceModel.TYPE_NAME, model.getStackSetId(), stackInstances.getRegions(), stackInstances.getDeploymentTargets()));
return response;
})
.stabilize((request, response, proxyInvocation, resourceModel, context) -> isOperationStabilized(proxyInvocation, resourceModel, response.operationId(), logger))
.handleError((request, e, proxyClient, model_, context) -> {
// If StackInstanceNotFoundException is thrown by the service, then we did succeed delete/stabilization call in case of out of band deletion.
if (e instanceof StackInstanceNotFoundException) {
return ProgressEvent.success(model_, context);
}
// If OperationInProgressException is thrown by the service, then we retry
if (e instanceof OperationInProgressException) {
return ProgressEvent.progress(model_, context);
}
throw e;
})
.success();
if (!progressEvent.isSuccess()) {
return progressEvent;
}
}
return ProgressEvent.progress(model, callbackContext);
}