in common/src/main/java/software/amazon/kms/common/KeyHandlerHelper.java [308:334]
public ProgressEvent<M, C> deleteKey(
final AmazonWebServicesClientProxy proxy,
final ProxyClient<KmsClient> proxyClient,
final M model,
final C callbackContext
) {
return ProgressEvent.progress(model, callbackContext)
.then(p -> {
try {
return proxy.initiate("kms::delete-key", proxyClient, model, callbackContext)
.translateToServiceRequest(keyTranslator::scheduleKeyDeletionRequest)
.makeServiceCall(keyApiHelper::scheduleKeyDeletion)
.stabilize(this::isDeleted)
.done(scheduleKeyDeletionResponse -> ProgressEvent.progress(model, callbackContext));
} catch (final CfnInvalidRequestException e) {
if (e.getCause() instanceof KmsInvalidStateException) {
// Invalid state can only happen if the key is pending deletion,
// treat it as not found.
return ProgressEvent.defaultFailureHandler(e, HandlerErrorCode.NotFound);
}
throw e;
}
})
.then(eventualConsistencyHandlerHelper::waitForChangesToPropagate)
.then(p -> ProgressEvent.defaultSuccessHandler(null));
}