fix(elbv2): hold an ACM certificate in use while a listener serves it (#6056)

This commit is contained in:
Younes Beriane authored and GitHub committed 2026-10-24 00:04:54 -04:00
1 parent 348874766f
commit 020015fd4e
5 files changed
+6 -5

No files matched your search

@@ -354,7 +354,7 @@ public class AcmService implements ResourceProvider {
List<String> consumers = certificateInUseBy(certificateArn, region);
if (!consumers.isEmpty()) {
throw new AwsException("ResourceInUseException",
"Certificate " + certificateArn + " is in use by: " + String.join(", ", consumers), 409);
"Certificate " + certificateArn + " is in use by: " + String.join(", ", consumers), 400);
}
String storageKey = regionKey(region, cert.extractCertificateId());
@@ -78,6 +78,7 @@ class AcmInUseByTest {
AwsException failure = assertThrows(AwsException.class, () -> service.deleteCertificate(arn, REGION));
assertEquals("ResourceInUseException", failure.getErrorCode());
assertEquals(400, failure.getHttpStatus());
assertEquals(List.of(CONSUMER), service.describeCertificate(arn, REGION).getInUseBy());
}
@@ -422,7 +422,7 @@ class AcmCfnProvisionerTest {
stored.setKeyAlgorithm(KeyAlgorithm.RSA_2048);
when(acm.describeCertificate(ARN, REGION)).thenReturn(stored);
stubRequestCertificate("new.example.com", certificate(NEW_ARN, "new.example.com"));
doThrow(new AwsException("ResourceInUseException", "in use", 409))
doThrow(new AwsException("ResourceInUseException", "in use", 400))
.when(acm).deleteCertificate(ARN, REGION);
StackResource r = resource();
@@ -491,7 +491,7 @@ class AcmCfnProvisionerTest {
@Test
void deletePropagatesACertificateStillInUse() {
doThrow(new AwsException("ResourceInUseException", "in use", 409))
doThrow(new AwsException("ResourceInUseException", "in use", 400))
.when(acm).deleteCertificate(ARN, REGION);
assertThrows(AwsException.class,
@@ -224,7 +224,7 @@ class CognitoUserPoolDomainIntegrationTest {
acm("DeleteCertificate", CERTIFICATE_ARN)
.then()
.statusCode(409)
.statusCode(400)
.body("__type", equalTo("ResourceInUseException"));
}
@@ -263,7 +263,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
acmRequest()
.header("Authorization", accountAuthorization("test", "acm"))
.header("X-Amz-Target", "CertificateManager.DeleteCertificate")
.body(Map.of("CertificateArn", arn)).when().post("/").then().statusCode(409)
.body(Map.of("CertificateArn", arn)).when().post("/").then().statusCode(400)
.body("__type", equalTo("ResourceInUseException"));
}