Two certificates per environment, and up to four DNS records. Start this first on arrival: certificates wait on KIMS's DNS team, which can take a while (main's runbook, AWS set-up A).
| Certificate | ACM region | Used by | Covers |
|---|---|---|---|
| Website | us-east-1 (N. Virginia), always |
The CloudFront distribution (CloudFront) | The website host (for example www.kimshospitals.com), and the bare domain if the site should also answer on it |
| CMS | The cluster's region (ap-south-2 or ap-south-1) |
The CMS load balancer (EKS ingress), when TLS ends there | The CMS host (for example cms.kimshospitals.com) |
CloudFront only reads certificates from us-east-1; a load balancer only reads certificates from its own region. A certificate in the wrong region simply does not appear in the list. If KIMS already has a wildcard certificate (for example *.kimshospitals.com) in the right region, use its ARN and skip the request.
#Who does what
| Task | Usually done by | What our engineer needs |
|---|---|---|
| Request the certificates | KIMS's cloud team, or our engineer | The two ARNs |
| Add the validation CNAMEs | KIMS's DNS team | The records shown by ACM, handed over as a table |
| Point the CMS host at the load balancer | KIMS's DNS team | The ALB address, after the first deploy |
| Point the website host at CloudFront | KIMS's DNS team, when KIMS decides (production: this is go-live) | The d....cloudfront.net domain |
#The values to collect
| Value | Production | UAT |
|---|---|---|
| Website host | <SITE_HOST> |
<SITE_UAT_HOST> |
| Bare domain too? | Yes or no (KIMS decides) | Usually no |
| CMS host | <CMS_HOST> |
<CMS_UAT_HOST> |
| Where KIMS's DNS is | Route 53 in this account, Route 53 in another account, or another provider |
#Request the website certificate (us-east-1)
#Console steps
- AWS Certificate Manager console. In the region menu (top right), choose US East (N. Virginia) us-east-1.
- Request a certificate (or left menu Request) > Request a public certificate > Next.
- Fully qualified domain name:
<SITE_HOST>. If the bare domain is wanted too: Add another name to this certificate ><BARE_DOMAIN>. - Allow export (if shown): Disable export.
- Validation method: DNS validation - recommended.
- Key algorithm: RSA 2048.
- Request.
- Open the certificate from the list. Status is Pending validation. Under Domains, each name shows a CNAME name and CNAME value. Use Export to CSV to hand them to KIMS's DNS team, or, if the zone is in Route 53 in this account, Create records in Route 53 > Create records.
- Wait for Status: Issued (usually within 30 minutes of the records existing). Copy the ARN.
#CLI steps
SITE_HOST=<SITE_HOST>
SITE_CERT_ARN=$(aws acm request-certificate --region us-east-1 \
--domain-name "$SITE_HOST" --validation-method DNS --key-algorithm RSA_2048 \
--idempotency-token kimssite \
--query CertificateArn --output text)
echo "$SITE_CERT_ARN"
sleep 10
aws acm describe-certificate --region us-east-1 --certificate-arn "$SITE_CERT_ARN" \
--query "Certificate.DomainValidationOptions[].ResourceRecord" --output tableSITE_HOST=<SITE_HOST>
SITE_CERT_ARN=$(aws acm request-certificate --region us-east-1 \
--domain-name "$SITE_HOST" --validation-method DNS --key-algorithm RSA_2048 \
--idempotency-token kimssite \
--query CertificateArn --output text)
echo "$SITE_CERT_ARN"
sleep 10
aws acm describe-certificate --region us-east-1 --certificate-arn "$SITE_CERT_ARN" \
--query "Certificate.DomainValidationOptions[].ResourceRecord" --output table$SiteHost = "<SITE_HOST>"
$SiteCertArn = aws acm request-certificate --region us-east-1 `
--domain-name $SiteHost --validation-method DNS --key-algorithm RSA_2048 `
--idempotency-token kimssite `
--query CertificateArn --output text
$SiteCertArn
Start-Sleep -Seconds 10
aws acm describe-certificate --region us-east-1 --certificate-arn $SiteCertArn `
--query "Certificate.DomainValidationOptions[].ResourceRecord" --output tableFor the bare domain as well, add --subject-alternative-names <BARE_DOMAIN> to the request. The table shows, per name, a Name like _3f2a...<SITE_HOST>., Type CNAME, and a Value like _9b1c....acm-validations.aws.. If it is empty, wait a few seconds and run describe-certificate again.
#Request the CMS certificate (cluster's region)
Same steps, in the cluster's region (ap-south-2 or ap-south-1), with the CMS host.
CMS_HOST=<CMS_HOST>
CMS_CERT_ARN=$(aws acm request-certificate --region ap-south-2 \
--domain-name "$CMS_HOST" --validation-method DNS --key-algorithm RSA_2048 \
--idempotency-token kimscms \
--query CertificateArn --output text)
echo "$CMS_CERT_ARN"
sleep 10
aws acm describe-certificate --region ap-south-2 --certificate-arn "$CMS_CERT_ARN" \
--query "Certificate.DomainValidationOptions[].ResourceRecord" --output tableCMS_HOST=<CMS_HOST>
CMS_CERT_ARN=$(aws acm request-certificate --region ap-south-2 \
--domain-name "$CMS_HOST" --validation-method DNS --key-algorithm RSA_2048 \
--idempotency-token kimscms \
--query CertificateArn --output text)
echo "$CMS_CERT_ARN"
sleep 10
aws acm describe-certificate --region ap-south-2 --certificate-arn "$CMS_CERT_ARN" \
--query "Certificate.DomainValidationOptions[].ResourceRecord" --output table$CmsHost = "<CMS_HOST>"
$CmsCertArn = aws acm request-certificate --region ap-south-2 `
--domain-name $CmsHost --validation-method DNS --key-algorithm RSA_2048 `
--idempotency-token kimscms `
--query CertificateArn --output text
$CmsCertArn
Start-Sleep -Seconds 10
aws acm describe-certificate --region ap-south-2 --certificate-arn $CmsCertArn `
--query "Certificate.DomainValidationOptions[].ResourceRecord" --output tableNot needed if KIMS's ingress already terminates TLS with its own certificate (an nginx ingress with a TLS Secret, for example): then the TLS Secret's name goes in cms.ingress.tlsSecretName.
#The CMS certificate in the cluster's region
Its ARN goes in the Helm values as the annotation alb.ingress.kubernetes.io/certificate-arn (EKS, Helm values for an ALB). It looks like arn:aws:acm:ap-south-2:<AWS_ACCOUNT_ID>:certificate/<ID>: the region in the ARN must be the cluster's.
#The validation records
Hand KIMS's DNS team a table like this, one row per name, copied exactly (the trailing dot is fine to keep or drop):
| Type | Name | Value | For |
|---|---|---|---|
| CNAME | _<HASH1>.<SITE_HOST>. |
_<HASH2>.<RANDOM>.acm-validations.aws. |
Website certificate |
| CNAME | _<HASH3>.<CMS_HOST>. |
_<HASH4>.<RANDOM>.acm-validations.aws. |
CMS certificate |
Leave these records in place for good: ACM uses them to renew the certificates automatically every year. Deleting them makes the renewal fail about 13 months later.
If the zone is in Route 53 in this account, the console button Create records in Route 53 does it. By CLI, save the record as validation.json and run aws route53 change-resource-record-sets --hosted-zone-id <ZONE_ID> --change-batch file://validation.json with:
{
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "_<HASH1>.<SITE_HOST>.",
"Type": "CNAME",
"TTL": 300,
"ResourceRecords": [{ "Value": "_<HASH2>.<RANDOM>.acm-validations.aws." }]
}
}
]
}#Wait for Issued
aws acm wait certificate-validated --region us-east-1 --certificate-arn "$SITE_CERT_ARN"
aws acm wait certificate-validated --region ap-south-2 --certificate-arn "$CMS_CERT_ARN"
aws acm describe-certificate --region us-east-1 --certificate-arn "$SITE_CERT_ARN" --query Certificate.Status --output textaws acm wait certificate-validated --region us-east-1 --certificate-arn "$SITE_CERT_ARN"
aws acm wait certificate-validated --region ap-south-2 --certificate-arn "$CMS_CERT_ARN"
aws acm describe-certificate --region us-east-1 --certificate-arn "$SITE_CERT_ARN" --query Certificate.Status --output textaws acm wait certificate-validated --region us-east-1 --certificate-arn $SiteCertArn
aws acm wait certificate-validated --region ap-south-2 --certificate-arn $CmsCertArn
aws acm describe-certificate --region us-east-1 --certificate-arn $SiteCertArn --query Certificate.Status --output textYou should see ISSUED. The wait gives up after about 40 minutes; run it again if the DNS team is still working.
#Check the validation record is visible
dig +short CNAME _<HASH1>.<SITE_HOST>dig +short CNAME _<HASH1>.<SITE_HOST>Resolve-DnsName -Type CNAME _<HASH1>.<SITE_HOST> | Select-Object Name, NameHostYou should see the ...acm-validations.aws. value. Nothing means the record is not published yet (or was added in an internal-only DNS view that ACM cannot see).
#The service DNS records
| Host | Points at | Record | When |
|---|---|---|---|
<CMS_HOST> |
The ALB address from kubectl -n kims get ingress (k8s-....elb.amazonaws.com) |
CNAME (or Route 53 alias A) | Right after the first deploy. Keycloak's redirect URIs use it, so sign-in needs it |
<SITE_HOST> (UAT) |
The UAT distribution's d....cloudfront.net |
CNAME | After UAT's first site build is checked on the d....cloudfront.net address |
<SITE_HOST> (production) |
Production's d....cloudfront.net |
CNAME | Go-live, when KIMS decides (Production cutover) |
| Bare domain (if used) | Production's d....cloudfront.net |
Route 53 alias A and AAAA (a bare domain cannot be a CNAME) | Go-live |
The website's DNS record comes last. Point it at CloudFront only after the first site build succeeded and was checked on the d....cloudfront.net address, so nobody sees an empty site. While the old platform still serves the production host, CloudFront may refuse the alternate domain with CNAMEAlreadyExists; see CloudFront.
#Check the records
dig +short <CMS_HOST>
dig +short <SITE_HOST>
curl -sSI https://<CMS_HOST>/api/health | head -n 1
curl -sSI https://<SITE_HOST>/ | grep -iE '^(HTTP|x-cache|via)'dig +short <CMS_HOST>
dig +short <SITE_HOST>
curl -sSI https://<CMS_HOST>/api/health | head -n 1
curl -sSI https://<SITE_HOST>/ | grep -iE '^(HTTP|x-cache|via)'Resolve-DnsName <CMS_HOST> | Select-Object Name, Type, NameHost, IPAddress
Resolve-DnsName <SITE_HOST> | Select-Object Name, Type, NameHost, IPAddress
curl.exe -sSI https://<CMS_HOST>/api/health | Select-Object -First 1
curl.exe -sSI https://<SITE_HOST>/ | Select-String -Pattern '^(HTTP|x-cache|via)'You should see the CMS host resolve to the ALB name and then IP addresses, and the website host to d....cloudfront.net. Then HTTP/2 200 for the CMS health check, and for the site HTTP/2 200 with x-cache: Hit from cloudfront or Miss from cloudfront and a via: ... (CloudFront) header.
To check a certificate's names and expiry from the outside:
openssl s_client -connect <SITE_HOST>:443 -servername <SITE_HOST> </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName -enddateopenssl s_client -connect <SITE_HOST>:443 -servername <SITE_HOST> </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName -enddate$tcp = New-Object Net.Sockets.TcpClient("<SITE_HOST>", 443)
$ssl = New-Object Net.Security.SslStream($tcp.GetStream())
$ssl.AuthenticateAsClient("<SITE_HOST>")
$ssl.RemoteCertificate.Subject; $ssl.RemoteCertificate.GetExpirationDateString()
$tcp.Close()#If it goes wrong
| What you see | Likely cause | What to do |
|---|---|---|
| The certificate is not in CloudFront's list | It is not in us-east-1, or not Issued yet |
Request it in us-east-1; wait for Issued |
The certificate is not accepted by the ALB (CertificateNotFound) |
It is in us-east-1 or another region, not the cluster's |
Request one in the cluster's region |
| Pending validation for hours | The CNAME is missing, mistyped, or only in an internal DNS view | dig / Resolve-DnsName check above; compare the record character by character |
| Status Failed or Validation timed out (after 72 hours) | The records never appeared | Delete the certificate and request again; send the new records |
| CAA error in the certificate's details | KIMS's domain has a CAA record that does not allow Amazon | KIMS adds a CAA record for amazon.com (or amazontrust.com) |
Browser: NET::ERR_CERT_COMMON_NAME_INVALID on the CMS |
ALB certificate does not cover the CMS host | Check the certificate-arn annotation |
Browser: the site shows the *.cloudfront.net certificate |
The website host is not an alternate domain on the distribution | CloudFront, alternate domain |
CMS host resolves, but curl times out |
ALB is internal and you are outside the VPN |
Expected for a VPN-only CMS: test from inside |
#Sources
kims-v2/docs/ON-SITE-DEPLOYMENT.mdonmain(AWS set-up A, C and H)kims-v2/deploy/helm/kims/values-production.example.yaml,templates/cms-ingress.yaml- https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html
- https://docs.aws.amazon.com/acm/latest/userguide/dns-validation.html
- https://docs.aws.amazon.com/acm/latest/userguide/acm-regions.html
- https://docs.aws.amazon.com/acm/latest/userguide/troubleshooting-DNS-validation.html
- https://docs.aws.amazon.com/acm/latest/userguide/setup-caa.html
- https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cnames-and-https-requirements.html
- https://docs.aws.amazon.com/elasticloadbalancing/latest/application/https-listener-certificates.html
- https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html
- https://docs.aws.amazon.com/cli/latest/reference/acm/request-certificate.html