Skip to content

Resource timed out waiting for creation of physical resource #210

Description

@samgurtman-zz

Hello,

Thanks for releasing it. Hopefully it will prove useful to a lot of people. I'm trialling it by transferring an existing custom resource to this new system. I'm trying to utilize the chaining functionality but I've hit a bit of a wall. When I utilize the new resource Cloudformation fails with Resource timed out waiting for creation of physical resource. Interestingly, after this occurs I can see that the handler does run the stabilization part of the chain and complete (but Cloudformation has already failed by this part). I've copied the create handler below. Any obvious issues you can see?

publicclassCreateHandlerextendsBaseHandler<CallbackContext> {
@OverridepublicProgressEvent<ResourceModel, CallbackContext> handleRequest(
finalAmazonWebServicesClientProxyproxy,
finalResourceHandlerRequest<ResourceModel> request,
CallbackContextcallbackContext,
finalLoggerlogger) {
returnproxy.initiate("ecs:CreateService", proxy.newProxy(EcsClient::create), request.getDesiredResourceState(), callbackContext == null ? newCallbackContext() : callbackContext)
.request(model -> ResourceModelConverter.toCreateServiceRequest(model, request.getDesiredResourceTags()))
.retry(Constant.of().delay(Duration.ofSeconds(20)).timeout(Duration.ofMinutes(60)).build())
.call((createServiceRequest, client) ->
client.injectCredentialsAndInvokeV2(createServiceRequest, client.client()::createService))
.stabilize((createServiceRequest, createServiceResponse, client, model, context) -> {
logger.log("Running stabilization test");
StringexpectedPrimaryId = createServiceResponse.service().deployments().stream().filter(
deployment -> deployment.status().equals("PRIMARY")
).findAny()
.map(Deployment::id)
.orElseThrow(() -> newCfnGeneralServiceException("Should have one primary deployment in service"));
DescribeServicesRequestdescribeServicesRequest = DescribeServicesRequest.builder()
.services(createServiceResponse.service().serviceArn())
.cluster(createServiceResponse.service().clusterArn())
.build();
List<Service> services = client.injectCredentialsAndInvokeV2(describeServicesRequest, client.client()::describeServices).services();
if (services.size() != 1) {
thrownewCfnGeneralServiceException("Could not find service which was created");
}
List<Deployment> updatedDeployments = services.get(0).deployments();
DeploymentprimaryLatest = updatedDeployments.stream()
.filter(deployment -> deployment.status().equals("PRIMARY"))
.filter(deployment -> deployment.id().equals(expectedPrimaryId))
.findAny()
.orElseThrow(() -> newCfnGeneralServiceException("Service has been modified from expected configuration"));
booleannotInProgress = updatedDeployments.stream()
.allMatch(deployment -> deployment.status().equals("PRIMARY") || deployment.status().equals("INACTIVE"));
if (!notInProgress) {
thrownewCfnGeneralServiceException("Deployment has been modified concurrently");
}
booleandone = primaryLatest.runningCount().equals(primaryLatest.desiredCount());
if (!done) {
IntegermaximumFailures = model.getAllowableStartupFailures();
if (maximumFailures == null) {
maximumFailures = 0;
}
if (BadCreateDetection.badExits(client, expectedPrimaryId, createServiceResponse.service().clusterArn()) > maximumFailures) {
thrownewCfnGeneralServiceException("Some containers failed during startup");
}
}
returnprimaryLatest.runningCount().equals(primaryLatest.desiredCount());
}).done((createServiceRequest, createServiceResponse, ecsClient, resourceModel, context) -> ProgressEvent.success(
ResourceModelConverter.merge(createServiceResponse.service(), resourceModel),
context
));
}
}

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions