in aws-cloudformation-resourceversion/src/main/java/software/amazon/cloudformation/resourceversion/CreateHandler.java [52:82]
ProgressEvent<ResourceModel, CallbackContext> stabilizeOnCreate(ProgressEvent<ResourceModel, CallbackContext> progress,
AmazonWebServicesClientProxy proxy,
ProxyClient<CloudFormationClient> proxyClient) {
this.logger.log("Stabilizing Registration: " + progress.getCallbackContext().getRegistrationToken());
String registrationToken = progress.getCallbackContext().getRegistrationToken();
return proxy.initiate("stabilize", proxyClient, progress.getResourceModel(), progress.getCallbackContext())
.translateToServiceRequest(m ->
progress.getCallbackContext().findAllRequestByContains("cloudformation:RegisterType").get(0))
.makeServiceCall((r, c) ->
progress.getCallbackContext().findAllResponseByContains("cloudformation:RegisterType").get(0))
.stabilize((awsRequest, awsResponse, proxyInvocation, model, cc) -> {
DescribeTypeRegistrationRequest describe =
DescribeTypeRegistrationRequest.builder()
.registrationToken(registrationToken)
.build();
DescribeTypeRegistrationResponse response =
proxyInvocation.injectCredentialsAndInvokeV2(describe, proxyInvocation.client()::describeTypeRegistration);
if (response.progressStatus().equals(RegistrationStatus.COMPLETE)) {
logger.log(String.format("%s registration successfully completed [%s].", ResourceModel.TYPE_NAME, response.typeVersionArn()));
return true;
} else if (response.progressStatus().equals(RegistrationStatus.FAILED)) {
logger.log(String.format("Registration request %s failed with '%s'", registrationToken, response.description()));
throw new CfnNotStabilizedException(ResourceModel.TYPE_NAME, progress.getResourceModel().getArn());
} else {
logger.log(String.format("Stabilization On Create failed with the status %s", response.progressStatusAsString()));
return false;
}
})
.progress();
}