@Test public void handlerRequest_CfnInvalidRequestException_NestedStack() { request = ResourceHandlerRequest.<ResourceModel>builder() .desiredResourceState(SELF_MANAGED_DUPLICATE_INSTANCES_MODEL) .logicalResourceIdentifier(LOGICAL_ID) .clientRequestToken(REQUEST_TOKEN) .build(); when(proxyClient.client().getTemplateSummary(any(GetTemplateSummaryRequest.class))) .thenReturn(TEMPLATE_SUMMARY_RESPONSE_WITH_NESTED_STACK); assertThrows(CfnInvalidRequestException.class, () -> handler.handleRequest(proxy, request, new CallbackContext(), proxyClient, logger)); verify(proxyClient.client()).getTemplateSummary(any(GetTemplateSummaryRequest.class)); }
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { this.logger = logger; final ResourceModel model = request.getDesiredResourceState(); final StackInstancesPlaceHolder placeHolder = new StackInstancesPlaceHolder(); analyzeTemplate(proxyClient, request, placeHolder, Action.CREATE); return proxy.initiate("AWS-CloudFormation-StackSet::Create", proxyClient, model, callbackContext) .translateToServiceRequest(resourceModel -> createStackSetRequest(resourceModel, request.getClientRequestToken())) .makeServiceCall((modelRequest, proxyInvocation) -> { final CreateStackSetResponse response = proxyClient.injectCredentialsAndInvokeV2(modelRequest, proxyClient.client()::createStackSet); model.setStackSetId(response.stackSetId()); logger.log(String.format("%s [%s] StackSet creation succeeded", ResourceModel.TYPE_NAME, model.getStackSetId())); return response; }) .progress() .then(progress -> createStackInstances(proxy, proxyClient, progress, placeHolder.getCreateStackInstances(), logger)) .then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger)); }
CreateHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { this.logger = logger; final ResourceModel model = request.getDesiredResourceState(); final StackInstancesPlaceHolder placeHolder = new StackInstancesPlaceHolder(); analyzeTemplate(proxyClient, request, placeHolder, Action.CREATE); return proxy.initiate("AWS-CloudFormation-StackSet::Create", proxyClient, model, callbackContext) .translateToServiceRequest(resourceModel -> createStackSetRequest(resourceModel, request.getClientRequestToken())) .makeServiceCall((modelRequest, proxyInvocation) -> { final CreateStackSetResponse response = proxyClient.injectCredentialsAndInvokeV2(modelRequest, proxyClient.client()::createStackSet); model.setStackSetId(response.stackSetId()); logger.log(String.format("%s [%s] StackSet creation succeeded", ResourceModel.TYPE_NAME, model.getStackSetId())); return response; }) .progress() .then(progress -> createStackInstances(proxy, proxyClient, progress, placeHolder.getCreateStackInstances(), logger)) .then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger)); } }
CreateHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { this.logger = logger; final ResourceModel model = request.getDesiredResourceState(); final StackInstancesPlaceHolder placeHolder = new StackInstancesPlaceHolder(); analyzeTemplate(proxyClient, request, placeHolder, Action.CREATE); return proxy.initiate("AWS-CloudFormation-StackSet::Create", proxyClient, model, callbackContext) .translateToServiceRequest(resourceModel -> createStackSetRequest(resourceModel, request.getClientRequestToken())) .makeServiceCall((modelRequest, proxyInvocation) -> { final CreateStackSetResponse response = proxyClient.injectCredentialsAndInvokeV2(modelRequest, proxyClient.client()::createStackSet); model.setStackSetId(response.stackSetId()); logger.log(String.format("%s [%s] StackSet creation succeeded", ResourceModel.TYPE_NAME, model.getStackSetId())); return response; }) .progress() .then(progress -> createStackInstances(proxy, proxyClient, progress, placeHolder.getCreateStackInstances(), logger)) .then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger)); }  }
CreateHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { this.logger = logger; final ResourceModel model = request.getDesiredResourceState(); final StackInstancesPlaceHolder placeHolder = new StackInstancesPlaceHolder(); analyzeTemplate(proxyClient, request, placeHolder, Action.CREATE); return proxy.initiate("AWS-CloudFormation-StackSet::Create", proxyClient, model, callbackContext) .translateToServiceRequest(resourceModel -> createStackSetRequest(resourceModel, request.getClientRequestToken())) .makeServiceCall((modelRequest, proxyInvocation) -> { final CreateStackSetResponse response = proxyClient.injectCredentialsAndInvokeV2(modelRequest, proxyClient.client()::createStackSet); model.setStackSetId(response.stackSetId()); logger.log(String.format("%s [%s] StackSet creation succeeded", ResourceModel.TYPE_NAME, model.getStackSetId())); return response; }) .progress() .then(progress -> createStackInstances(proxy, proxyClient, progress, placeHolder.getCreateStackInstances(), logger)) .then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger)); }   }
CreateHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { this.logger = logger; final ResourceModel model = request.getDesiredResourceState(); final StackInstancesPlaceHolder placeHolder = new StackInstancesPlaceHolder(); analyzeTemplate(proxyClient, request, placeHolder, Action.CREATE); return proxy.initiate("AWS-CloudFormation-StackSet::Create", proxyClient, model, callbackContext) .translateToServiceRequest(resourceModel -> createStackSetRequest(resourceModel, request.getClientRequestToken())) .makeServiceCall((modelRequest, proxyInvocation) -> { final CreateStackSetResponse response = proxyClient.injectCredentialsAndInvokeV2(modelRequest, proxyClient.client()::createStackSet); model.setStackSetId(response.stackSetId()); logger.log(String.format("%s [%s] StackSet creation succeeded", ResourceModel.TYPE_NAME, model.getStackSetId())); return response; }) .progress() .then(progress -> createStackInstances(proxy, proxyClient, progress, placeHolder.getCreateStackInstances(), logger)) .then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger)); }    }