Skip to content

Commit cf54dd7

Browse files
committed
update dns record after static ip is added
1 parent a6d6a33 commit cf54dd7

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

certmanager.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module "cert_manager" {
4343
},
4444
selector = {
4545
dnsZones = [
46-
var.ingress_hosts.ftp_svc
46+
var.ingress_hosts.ftp_svc.domain
4747
]
4848
}
4949
},
@@ -57,9 +57,8 @@ module "cert_manager" {
5757
]
5858

5959
certificates = {
60-
# "${replace(var.ingress_hosts.ftp_svc, ".", "_")}" = {
61-
"${var.ingress_hosts.ftp_svc}" = {
62-
dns_names = [var.ingress_hosts.ftp_svc]
60+
"${var.ingress_hosts.ftp_svc.domain}" = {
61+
dns_names = [var.ingress_hosts.ftp_svc.domain]
6362
}
6463
}
6564

ingress.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ resource "kubernetes_ingress_v1" "example" {
1717
spec {
1818
ingress_class_name = "gce"
1919
tls {
20-
# hosts = [var.ingress_hosts.ftp_svc]
21-
hosts = values(var.ingress_hosts)
20+
hosts = [var.ingress_hosts.ftp_svc.domain]
21+
# hosts = values(var.ingress_hosts)
2222
secret_name = var.cluster_issuer_private_key_secret_name
2323
}
2424

@@ -32,7 +32,7 @@ resource "kubernetes_ingress_v1" "example" {
3232
}
3333

3434
rule {
35-
host = var.ingress_hosts.ftp_svc
35+
host = var.ingress_hosts.ftp_svc.domain
3636
http {
3737
path {
3838
path = "/*"

main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ terraform {
1919
source = "hashicorp/google"
2020
version = "5.41.0"
2121
}
22+
cloudflare = {
23+
source = "cloudflare/cloudflare"
24+
version = "4.39.0"
25+
}
2226
kubernetes = {
2327
source = "hashicorp/kubernetes"
2428
version = "2.32.0"
@@ -33,7 +37,7 @@ terraform {
3337
}
3438
newrelic = {
3539
source = "newrelic/newrelic"
36-
version = "3.42.1"
40+
version = "3.42.3"
3741
}
3842
}
3943
}
@@ -66,7 +70,11 @@ provider "helm" {
6670
}
6771
}
6872

69-
# TODO: implement newrelic
73+
provider "cloudflare" {
74+
email = var.cloudflare_email
75+
api_key = var.cloudflare_api_key
76+
}
77+
7078
# provider "newrelic" {
7179
# account_id = var.nr_account_id
7280
# api_key = ""

networks.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,14 @@ resource "kubectl_manifest" "app_frontend_config" {
9191
})
9292

9393
depends_on = [google_container_node_pool.primary_nodes]
94+
}
95+
96+
resource "cloudflare_record" "example" {
97+
name = "${var.ingress_hosts.ftp_svc.domain}-dns-a-record"
98+
99+
zone_id = var.ingress_hosts.ftp_svc.zone_id
100+
content = google_compute_global_address.ingress.address
101+
type = "A"
102+
ttl = 60
103+
allow_overwrite = true
94104
}

variables.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ variable "cloudflare_api_key" {
3939
}
4040

4141
variable "ingress_hosts" {
42-
type = map(string)
42+
type = map(map(string))
4343
description = "hostnames (domains) that will be used in certs and/or routing"
4444
}
4545

@@ -64,8 +64,12 @@ variable "firewall_allow_https" {
6464
default = "https-enabled"
6565
}
6666

67-
# TODO: implement
68-
# variable "nr_account_id" {
69-
# type = number
70-
# description = "new relic account ID"
71-
# }
67+
variable "nr_account_id" {
68+
type = number
69+
description = "new relic account ID"
70+
}
71+
72+
variable "nr_api_key" {
73+
type = string
74+
description = "new relic api key"
75+
}

0 commit comments

Comments
 (0)