/* The commented out code relates to fixing a problem I had where one day
TF decided to recreate my ACM cert and validations, see:
I found this github issue about an order problem, especially relating to SANs:
After I saw people reporting the issue was fixed in us-east-1, TF plan was still
saying it wanted to recreate the records, so I decided to let it and ran apply.
The apply failed, complaining about being unable to create the kopi.cloud and
Looking in the ACM console, I noticed the records that it tells you must exist
for validation are actually identical (same record name and value).
So I decided to delete the wildcard validation records and re-run apply.
It worked for one record, but the other record failed again.
I removed the create_before_destroy attribute and re-ran apply and now
everything seems to work.
Don't know if the create_before_destroy is relevant, or if it would've fixed
the problem to just run apply again.
*/
resource "aws_acm_certificate" "website-prd-cloudfront-acm-certificate-v2" {
tags {
Name = "website-prd-cloudfront-acm-certificate-v2"
}
lifecycle {
// I remember adding this out of paranoia back in the day, not sure if it
// was contributing to the problem, but removed it anyway.
// create_before_destroy = true
}
domain_name = "*.${local.kopi_cloud_dns_name}"
subject_alternative_names = [
"*.${local.kopimail_net_name}",
"${local.kopi_cloud_dns_name}",
"${local.kopimail_net_name}"
]
validation_method = "DNS"
}
//resource "aws_route53_record" "kopi-cloud-wildcard-acm-validation-record-v2" {
// name = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.0.resource_record_name}"
// type = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.0.resource_record_type}"
// records = ["${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.0.resource_record_value}"]
// ttl = 60
//}
//
//resource "aws_route53_record" "kopi-mail-wildcard-acm-validation_record-v2" {
// name = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.1.resource_record_name}"
// type = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.1.resource_record_type}"
// records = ["${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.1.resource_record_value}"]
// ttl = 60
//}
resource "aws_route53_record" "kopi-cloud-root-acm-validation-record-v2" {
name = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.2.resource_record_name}"
type = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.2.resource_record_type}"
records = ["${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.2.resource_record_value}"]
ttl = 60
}
resource "aws_route53_record" "kopi-mail-root-acm-validation_record-v2" {
name = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.3.resource_record_name}"
type = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.3.resource_record_type}"
records = ["${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.domain_validation_options.3.resource_record_value}"]
ttl = 60
}
resource "aws_acm_certificate_validation" "website-prd-cloudfront-acm-certificate-validation-v2" {
certificate_arn = "${aws_acm_certificate.website-prd-cloudfront-acm-certificate-v2.arn}"
validation_record_fqdns = [
// "${aws_route53_record.kopi-cloud-wildcard-acm-validation-record-v2.fqdn}",
// "${aws_route53_record.kopi-mail-wildcard-acm-validation_record-v2.fqdn}"
// ,
"${aws_route53_record.kopi-cloud-root-acm-validation-record-v2.fqdn}",
"${aws_route53_record.kopi-mail-root-acm-validation_record-v2.fqdn}"
]
}