package com.aws.ec2.transitgatewayattachment; import com.aws.ec2.transitgatewayattachment.workflow.create.Create; import com.aws.ec2.transitgatewayattachment.workflow.create.CreatePreCheck; import com.aws.ec2.transitgatewayattachment.workflow.read.Read; import software.amazon.awssdk.services.ec2.Ec2Client; import software.amazon.cloudformation.exceptions.CfnInvalidRequestException; import software.amazon.cloudformation.proxy.*; public class CreateHandler extends BaseHandlerStd { protected ProgressEvent handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest request, final CallbackContext callbackContext, final ProxyClient proxyClient, final Logger logger) { if(callbackContext.getAttempts() == 1 && (request.getDesiredResourceState().getId() != null)) throw new CfnInvalidRequestException("Attempting to set a ReadOnly Property."); return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext) .then(new CreatePreCheck(proxy, request, callbackContext, proxyClient, logger):: run) .then(new Create(proxy, request, callbackContext, proxyClient, logger)::run) .then(new Read(proxy, request, callbackContext, proxyClient, logger)::run); } }