Skip to content

acm-route53

ACM certificate validated by DNS in Route 53. Creates the aws_acm_certificate, one validation record per distinct validation name (wildcard + apex share one) and the aws_acm_certificate_validation, so validated_certificate_arn only resolves once the certificate is issued. Optionally creates an alias A record for domain_name pointing at an ALB (alb_dns_name + alb_zone_id).

Usage

module "acm" {
  source = "github.com/rafaelcarvajal05/terraform-stacks//modules/acm-route53?ref=v0.1.0"

  domain_name               = "app.example.com"
  subject_alternative_names = ["www.example.com"]
  zone_id                   = var.zone_id

  alb_dns_name = module.alb.dns_name
  alb_zone_id  = module.alb.zone_id

  tags = { Environment = "prod" }
}

The hosted zone must already exist and contain every name in domain_name and subject_alternative_names.

Requirements

Name Version
terraform >= 1.6.0
aws >= 5.0

Providers

Name Version
aws >= 5.0

Modules

No modules.

Resources

Name Type
aws_acm_certificate.this resource
aws_acm_certificate_validation.this resource
aws_route53_record.alias resource
aws_route53_record.validation resource

Inputs

Name Description Type Default Required
domain_name Primary domain name of the certificate, e.g. app.example.com. Must live inside the hosted zone zone_id. string n/a yes
zone_id ID of the Route 53 hosted zone that holds the DNS validation records (and the alias record, if enabled). string n/a yes
alb_dns_name DNS name of the load balancer to point domain_name at. When null, no alias record is created. string null no
alb_zone_id Canonical hosted zone ID of the load balancer (zone_id attribute of the ALB). Required when alb_dns_name is set. string null no
alias_evaluate_target_health Whether Route 53 evaluates the health of the load balancer for the alias record. bool true no
subject_alternative_names Additional domain names covered by the certificate. All of them must be resolvable in the same hosted zone. list(string) [] no
tags Tags applied to every resource that supports them. A Name tag is added on top. map(string) {} no
validation_record_ttl TTL in seconds of the DNS validation records. number 60 no

Outputs

Name Description
alias_fqdn FQDN of the alias record pointing at the load balancer, or null when no alias was requested.
certificate_arn ARN of the ACM certificate. May still be pending validation; use validated_certificate_arn for listeners.
domain_name Primary domain name of the certificate.
validated_certificate_arn ARN of the ACM certificate once DNS validation has completed. Use this one for ALB HTTPS listeners.
validation_record_fqdns FQDNs of the DNS validation records created in Route 53.