From ff434ab5f8e368c1e695bd619c9ed7f9ccff133a Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Mon, 30 Oct 2023 20:26:34 +0100 Subject: [PATCH] Added terraform configuration for domains --- terraform/README.md | 0 terraform/imports.tf | 9 ++++ terraform/inwx.tf | 101 +++++++++++++++++++++++++++++++++++++++++ terraform/main.tf | 0 terraform/variables.tf | 33 ++++++++++++++ 5 files changed, 143 insertions(+) create mode 100644 terraform/README.md create mode 100644 terraform/imports.tf create mode 100644 terraform/inwx.tf create mode 100644 terraform/main.tf create mode 100644 terraform/variables.tf diff --git a/terraform/README.md b/terraform/README.md new file mode 100644 index 0000000..e69de29 diff --git a/terraform/imports.tf b/terraform/imports.tf new file mode 100644 index 0000000..aad2c0c --- /dev/null +++ b/terraform/imports.tf @@ -0,0 +1,9 @@ +import { + to = inwx_domain.twomartens_de + id = "2martens.de" +} + +import { + to = inwx_domain.twomartens_eu + id = "2martens.eu" +} \ No newline at end of file diff --git a/terraform/inwx.tf b/terraform/inwx.tf new file mode 100644 index 0000000..fb94ae2 --- /dev/null +++ b/terraform/inwx.tf @@ -0,0 +1,101 @@ +terraform { + required_providers { + inwx = { + source = "inwx/inwx" + version = "1.3.2" + } + } +} + +provider "inwx" { + api_url = "https://api.domrobot.com/jsonrpc/" + username = var.inwx_user + password = var.inwx_password + # Configuration options +} + +locals { + domain_period = "1Y" + domain_renewal = "AUTORENEW" +} + +resource "inwx_domain_contact" "admin" { + // contact configuration + type = "PERSON" + name = var.admin_name + street_address = var.admin_street + city = var.admin_city + postal_code = var.admin_postal_code + country_code = var.admin_country_code + phone_number = var.admin_phone_number + email = var.admin_email +} + +resource "inwx_domain_contact" "inwx" { + // contact configuration + type = "ORG" + name = "Hostmaster Of The Day" + organization = "INWX GmbH" + street_address = "Prinzessinnenstr. 30" + city = "Berlin" + postal_code = "10969" + country_code = 'DE' + phone_number = "+49.309832120" + email = "hostmaster@inwx.de" +} + +resource "inwx_domain" "twomartens_de" { + name = "2martens.de" + nameservers = [ + "ns.inwx.de", + "ns2.inwx.de", + "ns3.inwx.eu" + ] + period = local.domain_period + renewal_mode = local.domain_renewal + transfer_lock = true + contacts { + // references to terraform managed contact "example_person" + registrant = inwx_domain_contact.admin.id + admin = inwx_domain_contact.admin.id + tech = inwx_domain_contact.inwx.id + billing = inwx_domain_contact.inwx.id + } + extra_data = { + // Enable e.g. whois protection + "WHOIS-PROTECTION": "1" // 1 == bool true + } + lifecycle { + ignore_changes = [ + extra_data["WHOIS-CURRENCY"], // ignore WHOIS-CURRENCY + ] + } +} + +resource "inwx_domain" "twomartens_eu" { + name = "2martens.eu" + nameservers = [ + "ns.inwx.de", + "ns2.inwx.de", + "ns3.inwx.eu" + ] + period = local.domain_period + renewal_mode = local.domain_renewal + transfer_lock = true + contacts { + // references to terraform managed contact "example_person" + registrant = inwx_domain_contact.admin.id + admin = inwx_domain_contact.admin.id + tech = inwx_domain_contact.inwx.id + billing = inwx_domain_contact.inwx.id + } + extra_data = { + // Enable e.g. whois protection + "WHOIS-PROTECTION": "1" // 1 == bool true + } + lifecycle { + ignore_changes = [ + extra_data["WHOIS-CURRENCY"], // ignore WHOIS-CURRENCY + ] + } +} \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..e69de29 diff --git a/terraform/variables.tf b/terraform/variables.tf new file mode 100644 index 0000000..370590d --- /dev/null +++ b/terraform/variables.tf @@ -0,0 +1,33 @@ +variable "inwx_user" { + type = string + sensitive = true +} +variable "inwx_password" { + type = string + sensitive = true +} +variable "admin_name" { + type = string + sensitive = true +} +variable "admin_street" { + type = string + sensitive = true +} +variable "admin_city" { + type = string +} +variable "admin_postal_code" { + type = string +} +variable "admin_country_code" { + type = string +} +variable "admin_phone_number" { + type = string + sensitive = true +} +variable "admin_email" { + type = string + sensitive = true +}