From 54838d400c309b72d5fd061da5b0d05de4008f78 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Thu, 25 May 2023 14:43:17 +0200 Subject: [PATCH] feat: parametrize namecheap config --- main.tf | 14 +++++++++++++- modules/dns/namecheap.tf | 14 ++++---------- modules/dns/variables.tf | 5 +++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/main.tf b/main.tf index 1f37abf..387c935 100644 --- a/main.tf +++ b/main.tf @@ -13,6 +13,10 @@ terraform { source = "vultr/vultr" version = "2.11.4" } + hetznerdns = { + source = "timohirt/hetznerdns" + version = ">=2.2.0" + } } } @@ -28,13 +32,21 @@ provider "vultr" { module "dns" { source = "./modules/dns" + + nameservers = [ + "ns1.linode.com", + "ns2.linode.com", + "ns3.linode.com", + "ns4.linode.com", + "ns5.linode.com" + ] + domain = "monotremata.xyz" caladan = { ipv4 = "139.162.137.29" ipv6 = "2a01:7e01::f03c:92ff:fea2:5d7c" domains = toset([ - "monotremata.xyz", "git", "gts", "kb", diff --git a/modules/dns/namecheap.tf b/modules/dns/namecheap.tf index 61548aa..6f91080 100644 --- a/modules/dns/namecheap.tf +++ b/modules/dns/namecheap.tf @@ -1,18 +1,12 @@ provider "namecheap" { user_name = "gthar" api_user = "gthar" - client_ip = "139.162.137.29" // caladan's public IP + client_ip = var.caladan.ipv4 // caladan's public IP use_sandbox = false } resource "namecheap_domain_records" "namecheap-monotremata-xyz" { - domain = "monotremata.xyz" - mode = "OVERWRITE" - nameservers = [ - "ns1.linode.com", - "ns2.linode.com", - "ns3.linode.com", - "ns4.linode.com", - "ns5.linode.com" - ] + domain = var.domain + mode = "OVERWRITE" + nameservers = var.nameservers } diff --git a/modules/dns/variables.tf b/modules/dns/variables.tf index a7c995a..ca80905 100644 --- a/modules/dns/variables.tf +++ b/modules/dns/variables.tf @@ -24,3 +24,8 @@ variable "dkim_pub_key" { type = string description = "dkim public key" } + +variable "nameservers" { + type = list(string) + description = "dns nameservers to use" +}