in aws-core-server/src/main/java/jetbrains/buildServer/clouds/amazon/ami/cleanup/EC2AmiCleanupExtension.java [133:161]
private Ec2Client getEC2Client(@NotNull SFinishedBuild build,
@NotNull SProject project,
@NotNull String connectionId,
@NotNull List<AmiArtifact> artifacts,
@NotNull BuildCleanupContext cleanupContext,
@NotNull HashMap<String, Ec2Client> clientsCache) {
final Map<String, String> connectionAttributes = artifacts.isEmpty() ? Collections.emptyMap() : artifacts.get(0).getAttributes();
return clientsCache.computeIfAbsent(connectionId, cid -> {
final AwsConnectionBean awsConnection = myConnectionsManager.getAwsConnection(project, cid, connectionAttributes);
if (awsConnection != null) {
try {
return myClientCreator.createClient(awsConnection);
} catch (ConnectionCredentialsException e) {
final String message = String.format(EC2_CLIENT_ERROR, e.getMessage());
CLEANUP.warn(message);
cleanupContext.onBuildCleanupError(this, build, message);
return null;
}
} else {
final String message = String.format(CONNECTION_ERROR, cid);
CLEANUP.warn(message);
cleanupContext.onBuildCleanupError(this, build, message);
return null;
}
});
}