Closed ronaldtse closed 3 years ago
Now remove the version restriction on the module:
module "site-root" {
source = "github.com/riboseinc/terraform-aws-s3-cloudfront-website"
...
Then:
tfenv use 0.15.4
terraform init -upgrade
terraform plan
When upgrading to 0.15.4, you need to update the ACM config from:
Original:
resource "aws_route53_record" "cert_validation-main" {
provider = aws.cloudfront
name = aws_acm_certificate.cert-main.domain_validation_options[0].resource_record_name
type = aws_acm_certificate.cert-main.domain_validation_options[0].resource_record_type
zone_id = data.aws_route53_zone.main.id
records = [aws_acm_certificate.cert-main.domain_validation_options[0].resource_record_value]
ttl = 60
}
resource "aws_acm_certificate_validation" "cert-main" {
provider = aws.cloudfront
certificate_arn = aws_acm_certificate.cert-main.arn
validation_record_fqdns = [aws_route53_record.cert_validation-main.fqdn]
}
Now:
resource "aws_route53_record" "cert_validation-main" {
provider = aws.cloudfront
for_each = {
for dvo in aws_acm_certificate.cert-main.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.main.zone_id
}
resource "aws_acm_certificate_validation" "cert-main" {
provider = aws.cloudfront
certificate_arn = aws_acm_certificate.cert-main.arn
validation_record_fqdns = [for record in aws_route53_record.cert_validation-main : record.fqdn]
}
Added to README.
Use the first 0.13 version for the module.
Assume you are using terraform 0.12:
Then use terraform 0.13:
If it fails you will have to replace the providers (remember to answer
yes
):Then this will succeed:
Run this to apply: