Cloud/Terraform/AwsAcmCertificateAndValidation
resource "aws_acm_certificate" "cert" { domain_name = "mycert.dev.m.com" validation_method = "DNS" tags = { Environment = "test" } lifecycle { create_before_destroy = true } } data "aws_route53_zone" "dns" { name = "dev.m.com" #base domain private_zone = false } resource "aws_route53_record" "dns" { 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 = 300 type = each.value.type zone_id = data.aws_route53_zone.dns.zone_id } resource "aws_acm_certificate_validation" "example" { certificate_arn = aws_acm_certificate.cert.arn validation_record_fqdns = [for record in aws_route53_record.dns : record.fqdn] }
tf_backend.tf
/***** Common: AWS Provider *****/ provider "aws" { region = var.aws_region assume_role { role_arn = var.aws_assume_role_arn session_name = var.aws_assume_role_session_name #external_id = var.aws_assume_role_external_id } } /***** Common: Remote state backend *****/ terraform { backend "s3" { } }