fix(acm): report SUCCESS domain validation once a certificate is issued (#3112)

DescribeCertificate returned Status ISSUED together with
DomainValidationOptions[].ValidationStatus PENDING_VALIDATION for every
public certificate, forever. Clients that wait on the validation status
rather than the certificate status never finished: the AWS SDK
CertificateValidated waiter polls only ValidationStatus, and the CDK
DnsValidatedCertificate custom resource uses that waiter, so its stack
waited for the Lambda's timeout and rolled back.

The validation status now follows issuance: SUCCESS on an ISSUED
certificate, PENDING_VALIDATION while the configured validation wait is
running. A pending certificate is issued, with its validations marked
SUCCESS and the change stored, on the first read after
validation-wait-seconds has passed; before this the documented transition
never happened.
This commit is contained in:
Mario Toffia authored and GitHub committed 2026-09-06 10:48:30 -04:00
1 parent c67e598594
commit 9b28388d89
5 files changed
+283 -11

No files matched your search

@@ -9,6 +9,8 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.retry.backoff.FixedDelayBackoffStrategy;
import software.amazon.awssdk.core.waiters.WaiterResponse;
import software.amazon.awssdk.services.acm.AcmClient;
import software.amazon.awssdk.services.acm.model.*;
@@ -18,6 +20,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -120,6 +123,26 @@ class AcmTest {
assertThat(detail.statusAsString()).isNotNull();
}
@Test
@Order(2)
@DisplayName("CertificateValidated waiter completes for an issued certificate")
void testCertificateValidatedWaiterCompletes() {
Assumptions.assumeTrue(requestedCertArn != null, "RequestCertificate must succeed first");
Assumptions.assumeFalse(TestFixtures.isRealAws(), "real ACM waits for DNS validation");
// The waiter polls DomainValidationOptions[].ValidationStatus, as the CDK
// DnsValidatedCertificate handler does, and never returns while any domain is pending.
WaiterResponse<DescribeCertificateResponse> waited = acm.waiter().waitUntilCertificateValidated(
b -> b.certificateArn(requestedCertArn),
o -> o.maxAttempts(3).backoffStrategy(FixedDelayBackoffStrategy.create(Duration.ofSeconds(1))));
CertificateDetail detail = waited.matched().response().orElseThrow().certificate();
assertThat(detail.status()).isEqualTo(CertificateStatus.ISSUED);
assertThat(detail.domainValidationOptions()).isNotEmpty();
assertThat(detail.domainValidationOptions())
.allSatisfy(v -> assertThat(v.validationStatus()).isEqualTo(DomainStatus.SUCCESS));
}
@Test
@Order(3)
@DisplayName("Get a certificate whose chain validates it")