fix(ecs): resolve a service only in the request's cluster and Region (#8546)

This commit is contained in:
Hector Ventura authored and GitHub committed 2026-11-16 10:47:37 -04:00
1 parent 2d6d122419
commit 66c5c98406
2 files changed
+53 -5

No files matched your search

@@ -297,6 +297,46 @@ class EcsDescribeServicesIntegrationTest {
.body("failures[0].reason", equalTo("MISSING"));
}
@Test
void sameNamedServicesInTwoClustersEachResolveOnlyInTheirOwnCluster() {
// ECS services are cluster and Region specific (botocore ServiceNotFoundException docs):
// a name or an ARN must never resolve to a service in another cluster.
seedClusterAndTaskDef("dep-cluster-30a", "dep-td-30");
call("CreateCluster", "{\"clusterName\":\"dep-cluster-30b\"}");
String arnA = call("CreateService", "{\"cluster\":\"dep-cluster-30a\",\"serviceName\":\"dep-svc-30\","
+ "\"taskDefinition\":\"dep-td-30\",\"desiredCount\":0}").path("service.serviceArn");
String arnB = call("CreateService", "{\"cluster\":\"dep-cluster-30b\",\"serviceName\":\"dep-svc-30\","
+ "\"taskDefinition\":\"dep-td-30\",\"desiredCount\":0}").path("service.serviceArn");
try {
describe("dep-cluster-30a", "dep-svc-30").then()
.body("services", hasSize(1))
.body("services[0].serviceArn", equalTo(arnA));
describe("dep-cluster-30b", "dep-svc-30").then()
.body("services", hasSize(1))
.body("services[0].serviceArn", equalTo(arnB));
describe("dep-cluster-30a", arnA).then()
.body("services", hasSize(1))
.body("services[0].serviceArn", equalTo(arnA));
describe("dep-cluster-30a", arnB).then()
.body("services", hasSize(0))
.body("failures", hasSize(1))
.body("failures[0].arn", equalTo(arnB))
.body("failures[0].reason", equalTo("MISSING"));
given().contentType(CT).header("X-Amz-Target", TARGET + "DescribeTaskSets")
.body("{\"cluster\":\"dep-cluster-30a\",\"service\":\"" + arnB + "\"}")
.when().post("/")
.then().body("__type", containsString("ServiceNotFoundException"));
} finally {
call("DeleteService", "{\"cluster\":\"dep-cluster-30a\",\"service\":\"dep-svc-30\",\"force\":true}");
call("DeleteService", "{\"cluster\":\"dep-cluster-30b\",\"service\":\"dep-svc-30\",\"force\":true}");
call("DeleteCluster", "{\"cluster\":\"dep-cluster-30a\"}");
call("DeleteCluster", "{\"cluster\":\"dep-cluster-30b\"}");
call("DeregisterTaskDefinition", "{\"taskDefinition\":\"dep-td-30:1\"}");
}
}
@Test
void deletedServiceReportsAnEmptyDeploymentListRatherThanOmittingIt() {
// AWS's ServicesStable waiter fails an INACTIVE service on status, so an empty list is