Skip to content

Instantly share code, notes, and snippets.

@estenssoros
Created September 20, 2023 07:40
Show Gist options
  • Save estenssoros/7fdb9fe809e4361e982ae28926bc6839 to your computer and use it in GitHub Desktop.
Save estenssoros/7fdb9fe809e4361e982ae28926bc6839 to your computer and use it in GitHub Desktop.
Docker, ECR, Elastic Beanstalk, & Terraform certificates.tf
resource "aws_acm_certificate" "cert" {
domain_name = var.domain_name
validation_method = "DNS"
subject_alternative_names = ["www.${var.domain_name}"]
}
data "aws_route53_zone" "zone" {
name = var.route53_zone_name
private_zone = false
}
resource "aws_route53_record" "record" {
for_each = {
for dvo in aws_acm_certificate.cert.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = data.aws_route53_zone.zone.zone_id
}
resource "aws_acm_certificate_validation" "validation" {
certificate_arn = aws_acm_certificate.cert.arn
validation_record_fqdns = [for record in aws_route53_record.record : record.fqdn]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment