Skip to main content

Triage and Remediation

Remediation

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”

  1. 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.
  2. In ACM, find the certificate used by your API Gateway custom domain.
  3. Check the Status and Not after (Expiration):
    • Pending validation → DNS/Email validation incomplete.
    • Expired or In use but not valid → needs replacement/renewal.
    • Domain name mismatch (e.g., you use api.example.com but cert is for example.com) → need a new certificate with the correct SAN.

2. Request or renew a valid certificate in ACM

  1. In ACM (correct region) click Request a certificate.
  2. Choose Request a public certificateNext.
  3. Under Fully qualified domain name, enter:
    • Exact domain used by API Gateway custom domain (e.g., api.example.com).
  4. Choose DNS validation (preferred) → Request.

Complete DNS validation

  1. After request creation, open the certificate, go to the Domains section.
  2. For each domain name listed, note the required CNAME record.
  3. Go to Route 53Hosted zones → select your domain’s hosted zone.
  4. Click Create record:
    • Type: CNAME
    • Name & Value: exactly as shown in ACM.
    • Save record.
  5. Wait until ACM certificate status becomes Issued.

B. Fix a pending-validation certificate (if one already exists)

  1. Open the existing certificate in ACM.
  2. Under Domains, verify DNS CNAMEs exist in Route 53 exactly as shown.
  3. If missing or incorrect:
    • Edit/create the correct CNAME records in Route 53.
  4. Wait until status becomes Issued.

3. Attach the valid certificate to your API Gateway custom domain

  1. Open API Gateway console.
  2. In the left pane, choose Custom domain names.
  3. Click your custom domain (e.g., api.example.com).

If using API Gateway REST APIs

  1. Click Edit.
  2. Under ACM certificate, click the dropdown and select the new/valid Issued certificate.
  3. Save changes.

If using API Gateway HTTP APIs

  1. Select the custom domain → Edit.
  2. Under Custom domain configuration, choose the new ACM certificate.
  3. Save changes.

4. Ensure API mappings are still correct

  1. On the same custom domain page, check API mappings:
    • API, Stage, and Path (if any) are correctly set.
  2. If needed, edit or re-add API mappings.

5. Confirm DNS points to the API Gateway domain

  1. 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).
  2. Go to Route 53Hosted zones → your domain.
  3. 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.
  4. Save (or correct) the record.

6. Test

  1. Wait a few minutes for DNS and certificate changes to propagate.
  2. Browse to https://api.example.com.
  3. Check:
    • Browser shows a valid HTTPS connection.
    • Certificate common name/SAN matches your domain.
    • No TLS/SSL warnings.
If you share your current API Gateway custom domain type (Regional vs Edge) and current ACM cert status, I can tailor the exact steps to that configuration.
Below is a concise, CLI‑only workflow to fix “ACM certificate not valid” for an API Gateway custom domain.Assumptions:
  • 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.
Grab the CertificateArn you care about, then:
Check:
  • Status must be ISSUED (not PENDING_VALIDATION / EXPIRED / REVOKED).
  • InUseBy should list your API Gateway domain (optional, after attachment).
  • DomainName / SubjectAlternativeNames must include the exact custom domain (e.g., api.example.com).
If these are wrong, continue with the appropriate path below.

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.
For a regional custom domain:
  • Use the same region as the API (e.g., us-west-2).
The output will contain a new CertificateArn.

2.2 Complete DNS validation

Get the validation CNAME records:
For each DomainName, create the CNAME in your DNS provider exactly as shown:
  • ResourceRecord.Name -> CNAME name
  • ResourceRecord.Value -> CNAME value
If DNS is in Route 53, you can create it via CLI (example):
Wait until the certificate is 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:
Look for:
  • regionalDomainName → regional.
  • distributionDomainName → edge‑optimized.
Or for API Gateway v2 (HTTP/WebSocket APIs):
Look for 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.
Create the domain (if not existing):
Or update the existing domain to use the new cert:

Regional custom domain

  • Cert must be in the API region.
  • Use --regional-certificate-arn.
Create:
Or update:

3.3 For HTTP / WebSocket APIs (apigatewayv2)

apigatewayv2 always uses regional endpoints.Create new:
Or update existing:

4. Ensure base path mapping is still correct

For REST APIs:
If missing, create mapping:
For HTTP/WebSocket (v2):

5. Update DNS to point to the API Gateway domain

Get the target domain:
  • For REST edge‑optimized: distributionDomainName (CloudFront).
  • For REST regional / v2: regionalDomainName or DomainNameConfigurations[].ApiGatewayDomainName.
Example:
Then, in Route 53 (example):

6. Re-validate certificate status and connectivity

Confirm ACM status:
Then test:
If the certificate is:
  • 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,
the “AWS ACM Certificates Not Valid” issue for API Gateway will be remediated.
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.

1. Understand the key constraints

For API Gateway custom domains:
  • Edge-optimized custom domain
    • ACM certificate must be in us-east-1.
  • 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

Configure credentials:

3. Request / find a valid ACM certificate (Python)

3.1. Request a new certificate (if you don’t have a valid one)

Example for api.example.com with DNS validation:

3.2. Create DNS validation records (Route 53 example)

If DNS is managed outside Route 53, create equivalent CNAMEs manually using the values from 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)

For regional custom domain, use 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)

Then make or confirm 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:
  • CNAME to the CloudFront distribution name returned by get_domain_name or get_domain_name (v2) response (distributionDomainName or DomainNameConfigurations[0]['ApiGatewayDomainName']).
Example (Route 53):
For API Gateway v2 / regional endpoints, use the ApiGatewayDomainName / RegionalDomainName in DomainNameConfigurations.

6. Common failure reasons checklist

  1. ACM cert not ISSUED → ensure DNS validation is correct and wait.
  2. 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.
  3. Custom domain doesn’t match cert’s CN/SAN → recreate cert for correct domain.
  4. 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,
I can give you a minimal, ready-to-run Python script tailored to your case.
Substitute:
  • API_CUSTOM_DOMAIN_NAME with 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_ID with the Route53 hosted zone ID for the parent domain.
This change does not force replacement of the API Gateway domain name resource; Terraform will update it in place to use the new, validated ACM certificate. After applying, 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.