Skip to content

Commit

Permalink
feat(terraform): add edgedns for prd oldeworld (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
raisedadead authored Sep 1, 2023
1 parent 94593e8 commit 9929e6b
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 1 deletion.
22 changes: 22 additions & 0 deletions terraform/prd-cluster-oldeworld/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion terraform/prd-cluster-oldeworld/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
zone = "freecodecamp.net"
}

# This data source depends on the stackscript resource
# which is created in terraform/ops-stackscripts/main.tf
data "linode_stackscripts" "cloudinit_scripts" {
Expand All @@ -14,7 +18,7 @@ data "linode_stackscripts" "cloudinit_scripts" {
# This data source depends on the domain resource
# which is created in terraform/ops-dns/main.tf
data "linode_domain" "ops_dns_domain" {
domain = "freecodecamp.net"
domain = local.zone
}

data "hcp_packer_image" "linode_ubuntu" {
Expand Down
33 changes: 33 additions & 0 deletions terraform/prd-cluster-oldeworld/next-01-pxy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,36 @@ resource "linode_domain_record" "prd_oldeworld_pxy_dnsrecord__private" {
target = linode_instance.prd_oldeworld_pxy[count.index].private_ip_address
ttl_sec = 120
}

resource "akamai_dns_record" "prd_oldeworld_pxy_dnsrecord__vlan" {
count = local.pxy_node_count

zone = local.zone
recordtype = "A"
ttl = 120

name = "pxy-${count.index + 1}.oldeworld.prd.${local.zone}"
target = [trimsuffix(linode_instance_config.prd_oldeworld_pxy_config[count.index].interface[1].ipam_address, "/24")]
}

resource "akamai_dns_record" "prd_oldeworld_pxy_dnsrecord__public" {
count = local.pxy_node_count

zone = local.zone
recordtype = "A"
ttl = 120

name = "pub.pxy-${count.index + 1}.oldeworld.prd.${var.network_subdomain}.${local.zone}"
target = [linode_instance.prd_oldeworld_pxy[count.index].ip_address]
}

resource "akamai_dns_record" "prd_oldeworld_pxy_dnsrecord__private" {
count = local.pxy_node_count

zone = local.zone
recordtype = "A"
ttl = 120

name = "prv.pxy-${count.index + 1}.oldeworld.prd.${local.zone}"
target = [linode_instance.prd_oldeworld_pxy[count.index].private_ip_address]
}
9 changes: 9 additions & 0 deletions terraform/prd-cluster-oldeworld/next-02-pxy-origins.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ resource "linode_domain_record" "prd_oldeworld_nb_pxy_dnsrecord__public" {
target = data.linode_nodebalancer.prd_oldeworld_nb_pxy.ipv4
ttl_sec = 120
}

resource "akamai_dns_record" "prd_oldeworld_nb_pxy_dnsrecord__public" {
zone = local.zone
recordtype = "A"
ttl = 120

name = "oldeworld.prd.${var.network_subdomain}.${local.zone}"
target = [data.linode_nodebalancer.prd_oldeworld_nb_pxy.ipv4]
}
33 changes: 33 additions & 0 deletions terraform/prd-cluster-oldeworld/next-03-clt.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,36 @@ resource "linode_domain_record" "prd_oldeworld_clt_dnsrecord__private" {
target = linode_instance.prd_oldeworld_clt[each.key].private_ip_address
ttl_sec = 120
}

resource "akamai_dns_record" "prd_oldeworld_clt_dnsrecord__vlan" {
for_each = { for i in local.clt_instances : i.instance => i }

zone = local.zone
recordtype = "A"
ttl = 120

name = "clt-${each.value.instance}.oldeworld.prd.${local.zone}"
target = [trimsuffix(linode_instance_config.prd_oldeworld_clt_config[each.key].interface[1].ipam_address, "/24")]
}

resource "akamai_dns_record" "prd_oldeworld_clt_dnsrecord__public" {
for_each = { for i in local.clt_instances : i.instance => i }

zone = local.zone
recordtype = "A"
ttl = 120

name = "pub.clt-${each.value.instance}.oldeworld.prd.${var.network_subdomain}.${local.zone}"
target = [linode_instance.prd_oldeworld_clt[each.key].ip_address]
}

resource "akamai_dns_record" "prd_oldeworld_clt_dnsrecord__private" {
for_each = { for i in local.clt_instances : i.instance => i }

zone = local.zone
recordtype = "A"
ttl = 120

name = "prv.clt-${each.value.instance}.oldeworld.prd.${local.zone}"
target = [linode_instance.prd_oldeworld_clt[each.key].private_ip_address]
}
33 changes: 33 additions & 0 deletions terraform/prd-cluster-oldeworld/next-04-api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,36 @@ resource "linode_domain_record" "prd_oldeworld_api_dnsrecord__private" {
target = linode_instance.prd_oldeworld_api[count.index].private_ip_address
ttl_sec = 120
}

resource "akamai_dns_record" "prd_oldeworld_api_dnsrecord__vlan" {
count = local.api_node_count

zone = local.zone
recordtype = "A"
ttl = 120

name = "api-${count.index + 1}.oldeworld.prd.${local.zone}"
target = [trimsuffix(linode_instance_config.prd_oldeworld_api_config[count.index].interface[1].ipam_address, "/24")]
}

resource "akamai_dns_record" "prd_oldeworld_api_dnsrecord__public" {
count = local.api_node_count

zone = local.zone
recordtype = "A"
ttl = 120

name = "pub.api-${count.index + 1}.oldeworld.prd.${var.network_subdomain}.${local.zone}"
target = [linode_instance.prd_oldeworld_api[count.index].ip_address]
}

resource "akamai_dns_record" "prd_oldeworld_api_dnsrecord__private" {
count = local.api_node_count

zone = local.zone
recordtype = "A"
ttl = 120

name = "prv.api-${count.index + 1}.oldeworld.prd.${local.zone}"
target = [linode_instance.prd_oldeworld_api[count.index].private_ip_address]
}
33 changes: 33 additions & 0 deletions terraform/prd-cluster-oldeworld/next-05-nws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,36 @@ resource "linode_domain_record" "prd_oldeworld_nws_dnsrecord__private" {
target = linode_instance.prd_oldeworld_nws[each.key].private_ip_address
ttl_sec = 120
}

resource "akamai_dns_record" "prd_oldeworld_nws_dnsrecord__vlan" {
for_each = local.nws_instances

zone = local.zone
recordtype = "A"
ttl = 120

name = "nws-${each.value.name}.oldeworld.prd.${local.zone}"
target = [trimsuffix(linode_instance_config.prd_oldeworld_nws_config[each.key].interface[1].ipam_address, "/24")]
}

resource "akamai_dns_record" "prd_oldeworld_nws_dnsrecord__public" {
for_each = local.nws_instances

zone = local.zone
recordtype = "A"
ttl = 120

name = "pub.nws-${each.value.name}.oldeworld.prd.${var.network_subdomain}.${local.zone}"
target = [linode_instance.prd_oldeworld_nws[each.key].ip_address]
}

resource "akamai_dns_record" "prd_oldeworld_nws_dnsrecord__private" {
for_each = local.nws_instances

zone = local.zone
recordtype = "A"
ttl = 120

name = "prv.nws-${each.value.name}.oldeworld.prd.${local.zone}"
target = [linode_instance.prd_oldeworld_nws[each.key].private_ip_address]
}
5 changes: 5 additions & 0 deletions terraform/prd-cluster-oldeworld/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ provider "hcp" {
client_id = var.hcp_client_id
client_secret = var.hcp_client_secret
}

provider "akamai" {
edgerc = ".edgerc"
config_section = "default"
}
5 changes: 5 additions & 0 deletions terraform/prd-cluster-oldeworld/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ terraform {
source = "hashicorp/hcp"
version = "0.69.0"
}

akamai = {
source = "akamai/akamai"
version = "5.2.0"
}
}
required_version = ">= 1"
}

0 comments on commit 9929e6b

Please sign in to comment.