in aws-lightsail-loadbalancer/src/main/java/software/amazon/lightsail/loadbalancer/helpers/handler/LoadBalancerHandler.java [64:85]
protected ProgressEvent<ResourceModel, CallbackContext> preCreate(
final ProgressEvent<ResourceModel, CallbackContext> progress) {
val loadBalancer = getLoadBalancer(resourceModelRequest, proxyClient, logger);
if (callbackContext.getIsPreCheckDone(PRE_CHECK_CREATE)) {
return progress;
}
logger.log("Executing AWS-Lightsail-LoadBalancer::Create::PreExistenceCheck...");
return proxy
.initiate("AWS-Lightsail-LoadBalancer::Create::PreExistenceCheck", proxyClient, progress.getResourceModel(),
progress.getCallbackContext())
.translateToServiceRequest(Translator::translateToReadRequest).makeServiceCall((awsRequest, client) -> {
loadBalancer.read(awsRequest);
logger.log(String.format("%s has successfully been read.", ResourceModel.TYPE_NAME));
throw new CfnAlreadyExistsException(ResourceType.LOAD_BALANCER.toString(),
((GetLoadBalancerRequest) awsRequest).loadBalancerName());
}).handleError((awsRequest, exception, client, model, context) -> {
callbackContext.getIsPreCheckDone().put(PRE_CHECK_CREATE, true);
return handleError(exception, model, callbackContext,
ImmutableList.of(InvalidInputException, NotFoundException), logger,
this.getClass().getSimpleName());
}).progress();
}