From c8e0547687b6d1c7827a92800aa146aa94fe594d Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Tue, 14 Nov 2023 12:46:02 +0100 Subject: [PATCH] Upgrade global dns to 0.12 --- global/dns/input.tf | 21 +++----- global/dns/main.tf | 106 ++++++++++++++++++---------------------- global/dns/terraform.tf | 2 +- global/dns/tld.tf | 24 ++++----- 4 files changed, 69 insertions(+), 84 deletions(-) diff --git a/global/dns/input.tf b/global/dns/input.tf index 0f1ab6d8f..8dbeb1d17 100644 --- a/global/dns/input.tf +++ b/global/dns/input.tf @@ -1,24 +1,19 @@ provider "aws" { - access_key = "${var.access_key}" - secret_key = "${var.secret_key}" - region = "${var.region}" - version = "~> 1.6" + access_key = var.access_key + secret_key = var.secret_key + region = var.region + version = "~> 2.70" } provider "aws" { # us-east-1 instance - access_key = "${var.access_key}" - secret_key = "${var.secret_key}" + access_key = var.access_key + secret_key = var.secret_key region = "us-east-1" alias = "use1" - version = "~> 1.6" + version = "~> 2.70" } data "aws_vpc" "datacite" { - id = "${var.vpc_id}" + id = var.vpc_id } - -// data "aws_vpc" "us" { -// provider = "aws.use1" -// id = "${var.vpc_id_us}" -// } diff --git a/global/dns/main.tf b/global/dns/main.tf index a689dd401..1ba864aa2 100644 --- a/global/dns/main.tf +++ b/global/dns/main.tf @@ -1,104 +1,94 @@ resource "aws_route53_zone" "production" { name = "datacite.org" - tags { + tags = { Environment = "production" } } resource "aws_route53_record" "production-ns" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "datacite.org" type = "NS" ttl = "300" records = [ - "${aws_route53_zone.production.name_servers.0}", - "${aws_route53_zone.production.name_servers.1}", - "${aws_route53_zone.production.name_servers.2}", - "${aws_route53_zone.production.name_servers.3}" + aws_route53_zone.production.name_servers.0, + aws_route53_zone.production.name_servers.1, + aws_route53_zone.production.name_servers.2, + aws_route53_zone.production.name_servers.3, ] } resource "aws_route53_zone" "internal" { name = "datacite.org" - vpc_id = "${var.vpc_id}" - tags { + vpc { + vpc_id = var.vpc_id + } + + tags = { Environment = "internal" } } -// resource "aws_route53_zone_association" "us-east-1" { -// zone_id = "${aws_route53_zone.internal.zone_id}" -// vpc_id = "${data.aws_vpc.us.id}" -// vpc_region = "us-east-1" -// } - resource "aws_route53_record" "internal-ns" { - zone_id = "${aws_route53_zone.internal.zone_id}" + zone_id = aws_route53_zone.internal.zone_id name = "datacite.org" type = "NS" ttl = "30" records = [ - "${aws_route53_zone.internal.name_servers.0}", - "${aws_route53_zone.internal.name_servers.1}", - "${aws_route53_zone.internal.name_servers.2}", - "${aws_route53_zone.internal.name_servers.3}" + aws_route53_zone.internal.name_servers.0, + aws_route53_zone.internal.name_servers.1, + aws_route53_zone.internal.name_servers.2, + aws_route53_zone.internal.name_servers.3, ] } resource "aws_route53_record" "dkim-cm" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "cm._domainkey.datacite.org" type = "TXT" ttl = "300" records = [ - "k=rsa; p=${var.dkim_cm}" + "k=rsa; p=var.dkim_cm" ] } resource "aws_route53_record" "status" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "status.datacite.org" type = "CNAME" ttl = "3600" - records = ["${var.status_dns_name}"] + records = [var.status_dns_name] } resource "aws_route53_record" "changelog" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "changelog.datacite.org" type = "CNAME" ttl = "3600" - records = ["${var.changelog_dns_name}"] + records = [var.changelog_dns_name] } resource "aws_route53_record" "support" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "support.datacite.org" type = "CNAME" ttl = "300" - records = ["${var.support_dns_name}"] + records = [var.support_dns_name] } resource "aws_route53_record" "design" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "design.datacite.org" type = "CNAME" ttl = "300" - records = ["${var.design_dns_name}"] + records = [var.design_dns_name] } -// resource "aws_route53_record" "stage" { -// zone_id = "${aws_route53_zone.production.zone_id}" -// name = "stage.datacite.org" -// type = "A" -// ttl = "300" -// } - resource "aws_route53_record" "mx-datacite" { - zone_id = "${aws_route53_zone.production.zone_id}" - name = "${aws_route53_zone.production.name}" + zone_id = aws_route53_zone.production.zone_id + name = aws_route53_zone.production.name type = "MX" ttl = "300" records = [ @@ -111,52 +101,52 @@ resource "aws_route53_record" "mx-datacite" { } resource "aws_route53_record" "txt-datacite" { - zone_id = "${aws_route53_zone.production.zone_id}" - name = "${aws_route53_zone.production.name}" + zone_id = aws_route53_zone.production.zone_id + name = aws_route53_zone.production.name type = "TXT" ttl = "300" records = [ - "${var.google_site_verification_record}", + var.google_site_verification_record, "v=spf1 include:_spf.google.com include:_spf.salesforce.com ~all", - "${var.ms_record}", - "${var.verification_record}" + var.ms_record, + var.verification_record ] } resource "aws_route53_record" "dkim-datacite" { - zone_id = "${aws_route53_zone.production.zone_id}" - name = "google._domainkey.${aws_route53_zone.production.name}" + zone_id = aws_route53_zone.production.zone_id + name = "google._domainkey.aws_route53_zone.production.name" type = "TXT" ttl = "300" - records = ["${var.dkim_record}"] + records = [var.dkim_record] } resource "aws_route53_record" "dkim-salesforce" { - zone_id = "${aws_route53_zone.production.zone_id}" - name = "datacite._domainkey.${aws_route53_zone.production.name}" + zone_id = aws_route53_zone.production.zone_id + name = "datacite._domainkey.aws_route53_zone.production.name" type = "TXT" ttl = "300" - records = ["${var.dkim_salesforce}"] + records = [var.dkim_salesforce] } resource "aws_route53_record" "dkim-alt-salesforce" { - zone_id = "${aws_route53_zone.production.zone_id}" - name = "DataCite.org._domainkey.${aws_route53_zone.production.name}" + zone_id = aws_route53_zone.production.zone_id + name = "DataCite.org._domainkey.aws_route53_zone.production.name" type = "TXT" ttl = "300" - records = ["${var.dkim_alt_salesforce}"] + records = [var.dkim_alt_salesforce] } resource "aws_route53_record" "dmarc-datacite" { - zone_id = "${aws_route53_zone.production.zone_id}" - name = "_dmarc.${aws_route53_zone.production.name}" + zone_id = aws_route53_zone.production.zone_id + name = "_dmarc.aws_route53_zone.production.name" type = "TXT" ttl = "300" - records = ["${var.dmarc_record}"] + records = [var.dmarc_record] } resource "aws_route53_record" "github_datacite" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "_github-challenge-datacite.datacite.org" type = "TXT" ttl = "300" @@ -164,7 +154,7 @@ resource "aws_route53_record" "github_datacite" { } resource "aws_route53_record" "lists" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "lists.datacite.org" type = "CNAME" ttl = "300" @@ -172,7 +162,7 @@ resource "aws_route53_record" "lists" { } resource "aws_route53_record" "corpus-prototype" { - zone_id = "${aws_route53_zone.production.zone_id}" + zone_id = aws_route53_zone.production.zone_id name = "corpus.stage.datacite.org" type = "A" ttl = "300" diff --git a/global/dns/terraform.tf b/global/dns/terraform.tf index 0ef4c3ee0..39c085429 100644 --- a/global/dns/terraform.tf +++ b/global/dns/terraform.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.11" + required_version = ">= 0.12" backend "atlas" { name = "datacite-ng/global-dns" diff --git a/global/dns/tld.tf b/global/dns/tld.tf index 6ccd16cc8..1d13b0cfb 100644 --- a/global/dns/tld.tf +++ b/global/dns/tld.tf @@ -1,41 +1,41 @@ resource "aws_route53_zone" "com" { name = "datacite.com" - tags { + tags = { Environment = "production" } } resource "aws_route53_record" "com-ns" { - zone_id = "${aws_route53_zone.com.zone_id}" + zone_id = aws_route53_zone.com.zone_id name = "datacite.com" type = "NS" ttl = "300" records = [ - "${aws_route53_zone.com.name_servers.0}", - "${aws_route53_zone.com.name_servers.1}", - "${aws_route53_zone.com.name_servers.2}", - "${aws_route53_zone.com.name_servers.3}" + aws_route53_zone.com.name_servers.0, + aws_route53_zone.com.name_servers.1, + aws_route53_zone.com.name_servers.2, + aws_route53_zone.com.name_servers.3 ] } resource "aws_route53_zone" "eu" { name = "datacite.eu" - tags { + tags = { Environment = "production" } } resource "aws_route53_record" "eu-ns" { - zone_id = "${aws_route53_zone.eu.zone_id}" + zone_id = aws_route53_zone.eu.zone_id name = "datacite.eu" type = "NS" ttl = "300" records = [ - "${aws_route53_zone.eu.name_servers.0}", - "${aws_route53_zone.eu.name_servers.1}", - "${aws_route53_zone.eu.name_servers.2}", - "${aws_route53_zone.eu.name_servers.3}" + aws_route53_zone.eu.name_servers.0, + aws_route53_zone.eu.name_servers.1, + aws_route53_zone.eu.name_servers.2, + aws_route53_zone.eu.name_servers.3 ] }