Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are the console steps to fix invalid ACM certificates for an AWS API Gateway custom domain.
1. Identify why the certificate is “not valid”
- Open AWS Certificate Manager (ACM) in the same region as your API Gateway custom domain:
- For Edge-Optimized custom domains → ACM must be in us-east-1.
- For Regional custom domains → ACM must be in the same region as the API.
- In ACM, find the certificate used by your API Gateway custom domain.
- Check the Status and Not after (Expiration):
Pending validation→ DNS/Email validation incomplete.ExpiredorIn use but not valid→ needs replacement/renewal.Domain name mismatch(e.g., you useapi.example.combut cert is forexample.com) → need a new certificate with the correct SAN.
2. Request or renew a valid certificate in ACM
A. Request a new certificate (recommended if expired or mismatched)
- In ACM (correct region) click Request a certificate.
- Choose Request a public certificate → Next.
- Under Fully qualified domain name, enter:
- Exact domain used by API Gateway custom domain (e.g.,
api.example.com).
- Exact domain used by API Gateway custom domain (e.g.,
- Choose DNS validation (preferred) → Request.
Complete DNS validation
- After request creation, open the certificate, go to the Domains section.
- For each domain name listed, note the required CNAME record.
- Go to Route 53 → Hosted zones → select your domain’s hosted zone.
- Click Create record:
- Type:
CNAME - Name & Value: exactly as shown in ACM.
- Save record.
- Type:
- Wait until ACM certificate status becomes Issued.
B. Fix a pending-validation certificate (if one already exists)
- Open the existing certificate in ACM.
- Under Domains, verify DNS CNAMEs exist in Route 53 exactly as shown.
- If missing or incorrect:
- Edit/create the correct CNAME records in Route 53.
- Wait until status becomes Issued.
3. Attach the valid certificate to your API Gateway custom domain
- Open API Gateway console.
- In the left pane, choose Custom domain names.
- Click your custom domain (e.g.,
api.example.com).
If using API Gateway REST APIs
- Click Edit.
- Under ACM certificate, click the dropdown and select the new/valid Issued certificate.
- Save changes.
If using API Gateway HTTP APIs
- Select the custom domain → Edit.
- Under Custom domain configuration, choose the new ACM certificate.
- Save changes.
4. Ensure API mappings are still correct
- On the same custom domain page, check API mappings:
- API, Stage, and Path (if any) are correctly set.
- If needed, edit or re-add API mappings.
5. Confirm DNS points to the API Gateway domain
- On the custom domain detail page in API Gateway, note the Target domain name (e.g.,
d-xxxxxx.execute-api.us-east-1.amazonaws.com). - Go to Route 53 → Hosted zones → your domain.
- Ensure your custom domain (
api.example.com) has:- Type:
A - Routing policy: Alias to API Gateway (recommended)
- Alias target: the Target domain name from API Gateway.
- Type:
- Save (or correct) the record.
6. Test
- Wait a few minutes for DNS and certificate changes to propagate.
- Browse to
https://api.example.com. - Check:
- Browser shows a valid HTTPS connection.
- Certificate common name/SAN matches your domain.
- No TLS/SSL warnings.
Using CLI
Using CLI
Below is a concise, CLI‑only workflow to fix “ACM certificate not valid” for an API Gateway custom domain.Assumptions:
Grab the Check:
For a regional custom domain:The output will contain a new For each Wait until the certificate is
Look for:Look for
Or update the existing domain to use the new cert:Or update:
Or update existing:
If missing, create mapping:For HTTP/WebSocket (v2):
Then, in Route 53 (example):
Then test:If the certificate is:
- You already have an API Gateway custom domain or plan to create one.
- You want to use AWS CLI only.
- Replace all UPPER_CASE placeholders with your values.
1. Identify why the ACM certificate is “not valid”
First, find the certificate you’re using (or plan to use) for the custom domain.CertificateArn you care about, then:Statusmust beISSUED(notPENDING_VALIDATION/EXPIRED/REVOKED).InUseByshould list your API Gateway domain (optional, after attachment).DomainName/SubjectAlternativeNamesmust include the exact custom domain (e.g.,api.example.com).
2. (If needed) Request a new valid ACM certificate
2.1 Request the cert from ACM
For an edge‑optimized custom domain (CloudFront-backed):- Region must be
us-east-1.
- Use the same region as the API (e.g.,
us-west-2).
CertificateArn.2.2 Complete DNS validation
Get the validation CNAME records:DomainName, create the CNAME in your DNS provider exactly as shown:ResourceRecord.Name-> CNAME nameResourceRecord.Value-> CNAME value
ISSUED:3. Attach the valid certificate to the API Gateway custom domain
3.1 Determine if your API domain is edge‑optimized or regional
Describe the domain:regionalDomainName→ regional.distributionDomainName→ edge‑optimized.
DomainNameConfigurations[].EndpointType (REGIONAL or EDGE).3.2 For REST APIs (apigateway, v1)
Edge‑optimized custom domain
- Cert must be in
us-east-1. - Use
--certificate-arn.
Regional custom domain
- Cert must be in the API region.
- Use
--regional-certificate-arn.
3.3 For HTTP / WebSocket APIs (apigatewayv2)
apigatewayv2 always uses regional endpoints.Create new:4. Ensure base path mapping is still correct
For REST APIs:5. Update DNS to point to the API Gateway domain
Get the target domain:- For REST edge‑optimized:
distributionDomainName(CloudFront). - For REST regional / v2:
regionalDomainNameorDomainNameConfigurations[].ApiGatewayDomainName.
6. Re-validate certificate status and connectivity
Confirm ACM status:ISSUED,- In correct region for the endpoint type,
- Contains the exact domain name,
- Attached to the API Gateway custom domain,
- And DNS points to API Gateway,
Using Python
Using Python
Here’s how to fix invalid ACM certificates for an API Gateway custom domain using Python (boto3). This assumes the issue is something like: expired cert, not validated, wrong region, or not matching the domain.
Configure credentials:
If DNS is managed outside Route 53, create equivalent CNAMEs manually using the values from
For regional custom domain, use
Then make or confirm
For API Gateway v2 / regional endpoints, use the
If you tell me:
1. Understand the key constraints
For API Gateway custom domains:- Edge-optimized custom domain
- ACM certificate must be in
us-east-1.
- ACM certificate must be in
- Regional custom domain
- ACM certificate must be in the same region as the API Gateway endpoint.
- Certificate must:
- Be ISSUED (not PENDING_VALIDATION, EXPIRED, etc.).
- Have a domain name or SAN that matches your custom domain (e.g.,
api.example.com).
2. Install and configure boto3
3. Request / find a valid ACM certificate (Python)
3.1. Request a new certificate (if you don’t have a valid one)
Example forapi.example.com with DNS validation:3.2. Create DNS validation records (Route 53 example)
ResourceRecord.If you already have a valid cert, skip to step 4 and just set certificate_arn to that ARN.4. Update the API Gateway custom domain to use the valid cert
4.1. For REST API custom domain (API Gateway v1)
endpoint_type="REGIONAL" and ensure both API Gateway and ACM cert are in that region.If you already have base path mappings, they’re preserved by update_domain_name. If not, you may need:4.2. For HTTP/REST APIs (API Gateway v2)
ApiMapping:5. Update DNS to point the custom domain to API Gateway
After the custom domain is configured to use the new certificate, make sure DNS is correct.For REST API / EDGE:CNAMEto the CloudFront distribution name returned byget_domain_nameorget_domain_name(v2) response (distributionDomainNameorDomainNameConfigurations[0]['ApiGatewayDomainName']).
ApiGatewayDomainName / RegionalDomainName in DomainNameConfigurations.6. Common failure reasons checklist
- ACM cert not ISSUED → ensure DNS validation is correct and wait.
- ACM cert in wrong region:
- Edge-optimized REST: certificate must be in
us-east-1. - Regional REST or v2: cert region must match API region.
- Edge-optimized REST: certificate must be in
- Custom domain doesn’t match cert’s CN/SAN → recreate cert for correct domain.
- DNS still pointing to old endpoint → update CNAME/alias.
If you tell me:
- region,
- API type (REST v1, HTTP API, WebSocket),
- and the current ACM cert status / ARN,
Using Terraform
Using Terraform
API_CUSTOM_DOMAIN_NAMEwith your API Gateway custom domain (e.g.api.example.com).OPTIONAL_ADDITIONAL_DOMAIN_*with any SANs you need, or remove the line if none.ROUTE53_HOSTED_ZONE_IDwith the Route53 hosted zone ID for the parent domain.
terraform plan should show creation of aws_acm_certificate, aws_route53_record, aws_acm_certificate_validation, and an in-place update to aws_apigatewayv2_domain_name.api_custom_domain changing certificate_arn to the new valid certificate.
