fix(cloudmap): keep an empty HealthCheckCustomConfig and report FailureThreshold 1 (#6792)

CreateService dropped a HealthCheckCustomConfig sent as {}. The handler
passed it through rawJson, which returns null for an empty object, so
the CreateService, GetService and ListServices responses left the field
out. Terraform sends {} when failure_threshold is unset and then sees a
change to the block on every plan.

FailureThreshold is no longer supported, and the Cloud Map API
reference says AWS always sets it to 1. The handler now keeps an empty
object for this field, and CloudMapService stores
{"FailureThreshold":1} for any HealthCheckCustomConfig, so a service
created through CloudFormation reads back the same way.

Fixes #6751
This commit is contained in:
kenny-ish authored and GitHub committed 2026-10-28 07:24:01 -04:00
1 parent 0ee1d10659
commit db86fc7d72
3 files changed
+37 -2

No files matched your search

@@ -193,4 +193,32 @@ class CloudMapIntegrationTest {
.then().statusCode(404)
.body("__type", equalTo("NamespaceNotFound"));
}
@Test
@Order(13)
void healthCheckCustomConfigAlwaysReadsBackFailureThresholdOne() {
String operationId = call("CreateHttpNamespace", "{\"Name\":\"floci-cm-custom-health\"}")
.then().statusCode(200)
.extract().jsonPath().getString("OperationId");
String customNamespaceId = call("GetOperation", "{\"OperationId\":\"" + operationId + "\"}")
.then().statusCode(200)
.extract().jsonPath().getString("Operation.Targets.NAMESPACE");
String emptyId = createCustomHealthService("empty", customNamespaceId, "{}");
String thresholdId = createCustomHealthService("threshold", customNamespaceId, "{\"FailureThreshold\":3}");
for (String id : List.of(emptyId, thresholdId)) {
call("GetService", "{\"Id\":\"" + id + "\"}")
.then().statusCode(200)
.body("Service.HealthCheckCustomConfig.FailureThreshold", equalTo(1));
call("DeleteService", "{\"Id\":\"" + id + "\"}").then().statusCode(200);
}
call("DeleteNamespace", "{\"Id\":\"" + customNamespaceId + "\"}").then().statusCode(200);
}
private static String createCustomHealthService(String name, String nsId, String healthCheckCustomConfig) {
return call("CreateService", "{\"Name\":\"" + name + "\",\"NamespaceId\":\"" + nsId
+ "\",\"HealthCheckCustomConfig\":" + healthCheckCustomConfig + "}")
.then().statusCode(200)
.extract().jsonPath().getString("Service.Id");
}
}