in aws-lightsail-loadbalancer/src/main/java/software/amazon/lightsail/loadbalancer/helpers/handler/LoadBalancerHandler.java [163:193]
protected ProgressEvent<ResourceModel, CallbackContext> preAttachInstances(
final ProgressEvent<ResourceModel, CallbackContext> progress) {
val loadBalancer = getLoadBalancer(resourceModelRequest, proxyClient, logger);
val instance = getInstance(resourceModelRequest, proxyClient, logger);
logger.log("Executing AWS-Lightsail-LoadBalancer::Update::PreAttachInstances...");
return proxy
.initiate("AWS-Lightsail-LoadBalancer::Update::PreAttachInstances", proxyClient, progress.getResourceModel(),
progress.getCallbackContext())
.translateToServiceRequest(Translator::translateToReadRequest).backoffDelay(BACKOFF_DELAY)
.makeServiceCall((awsRequest, client) -> {
// Just return empty Get Response. We are not making any service call here.
// We are making sure in the stabilize step that all instances that need to be attached are running.
return GetLoadBalancerResponse.builder().build();
})
.stabilize((awsRequest, awsResponse, client, model, context) -> {
Set<String> desiredInstances = resourceModelRequest.getDesiredResourceState().getAttachedInstances();
Set<String> currentInstances = loadBalancer.getCurrentResourceModelFromLightsail().getAttachedInstances();
Set<String> resourcesToAttach = loadBalancer.setDifference(desiredInstances, currentInstances);
for (val resource: resourcesToAttach) {
if (!instance.isStabilized(resource)) {
return this.isStabilized(callbackContext, PRE_CHECK_ATTACH);
}
}
return true;
})
.handleError((awsRequest, exception, client, model, context) -> handleError(exception, model,
callbackContext, ImmutableList.of(), logger, this.getClass().getSimpleName()))
.progress();
}