in aws-logs-destination/src/main/java/software/amazon/logs/destination/CreateHandler.java [19:44]
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final ProxyClient<CloudWatchLogsClient> proxyClient,
final Logger logger) {
final ResourceModel model = request.getDesiredResourceState();
// Verify if a destination is already present with same identifier
// Create destination policy command checks to see if optional destination/access policy is passed in before attempting create
return ProgressEvent.progress(model, callbackContext)
.then(progress -> preCreateCheck(proxy, callbackContext, proxyClient, model).done((response) -> {
if (isDestinationListNullOrEmpty(response)) {
return ProgressEvent.progress(model, callbackContext);
}
return ProgressEvent.defaultFailureHandler(new CfnAlreadyExistsException(ResourceModel.TYPE_NAME,
model.getPrimaryIdentifier()
.toString()), HandlerErrorCode.AlreadyExists);
}))
.then(progress -> putDestination(proxy, callbackContext, proxyClient, model, DESTINATION_CREATE_GRAPH,
logger, Action.CREATE))
.then(progress -> model.getDestinationPolicy() != null ? putDestinationPolicy(proxy, callbackContext, proxyClient, model,
DESTINATION_POLICY_CREATE_GRAPH, logger, Action.CREATE) : progress)
.then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient,
logger));
}