in aws-codeartifact-repository/src/main/java/software/amazon/codeartifact/repository/UpdateHandler.java [226:262]
protected ProgressEvent<ResourceModel, CallbackContext> disassociateExternalConnections(
ProgressEvent<ResourceModel, CallbackContext> progress,
final CallbackContext callbackContext,
final ResourceHandlerRequest<ResourceModel> request,
ProxyClient<CodeartifactClient> proxyClient,
Set<String> externalConnectionsToRemove,
Logger logger
) {
ResourceModel model = request.getDesiredResourceState();
logger.log(String.format("Removing external connections: %s", externalConnectionsToRemove.toString()));
if (CollectionUtils.isNullOrEmpty(externalConnectionsToRemove)) {
logger.log("No external connections to remove.");
// Nothing to remove, continue
return ProgressEvent.progress(model, callbackContext);
}
// Loop is currently not necessary because only 1 external connection is allowed, leaving this in for
// when multiple are supported
externalConnectionsToRemove.forEach(ec -> {
try {
DisassociateExternalConnectionRequest disassociateExternalConnectionRequest = Translator.translateDisassociateExternalConnectionsRequest(model, ec);
proxyClient.injectCredentialsAndInvokeV2(disassociateExternalConnectionRequest, proxyClient.client()::disassociateExternalConnection);
} catch (final ResourceNotFoundException e) {
// External Connection has already been removed or doesn't exist
} catch (final AwsServiceException e) {
String repositoryName = progress.getResourceModel().getRepositoryName();
Translator.throwCfnException(e, Constants.DISASSOCIATE_EXTERNAL_CONNECTION, repositoryName);
}
logger.log(String.format("Successfully disassociated external connection: %s", ec));
});
return ProgressEvent.<ResourceModel, CallbackContext>builder()
.resourceModel(model)
.status(OperationStatus.IN_PROGRESS)
.build();
}