feat: Add domain-test for testing INWX changes

This commit is contained in:
2024-09-04 08:38:51 +02:00
parent 056e709c8d
commit 82def8fc67
18 changed files with 538 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/inwx/inwx" {
version = "1.4.2"
constraints = "1.4.2"
hashes = [
"h1:P0eXBoEM310xtKnkXHa4vzPxDW+G0C5TJm6PAtaepJE=",
"zh:04f9bde7215ac87d8a3f4b7b8fd3c4760141e985bec817199351d6e5208a8a46",
"zh:32955d9c5e089a4b7679ff27ac92ee77f35ce0869eae52c1df31ff860095577a",
"zh:3cdc572911665a2441cb43c6e0abdcf5ddb5866d7d051cde05ce9077e32bdaea",
"zh:40c8d3698bcfd6b08b1828d0f326c2c90edb94ac24f2d5b47fd411a61bb72686",
"zh:43a4d11cbc60b8a612260d4cab535878bd7c0668c9988528d7fa5e42f50849da",
"zh:448f40504e4c2a94f530e250a2b7a7131101038dfe4dbd19dd3fcfcb11a65f8c",
"zh:4686ed779f5156dc4169b876fc055badfcb08a9e46aeb1f224aa45a8717cedab",
"zh:82f4c210d7427512313794d846c8aaf5e2983cbff248709841716ad1d1ebec46",
"zh:9cf669d0caba5b44a90b97c7e0cd57d2eb219ed3d969c5d1e972af755d7c553f",
"zh:d685589ae68db4ee9c4d9c22eeb145bb51c3966f128c85c0a722a9d961317ddd",
]
}
+1
View File
@@ -0,0 +1 @@
domain-test
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 INWX GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,23 @@
<p align="center">
<a href="https://www.inwx.com/en/" target="_blank">
<img src="https://www.inwx.com/images/logos/inwx.png">
</a>
</p>
INWX Terraform Provider
=========
INWX Terraform Provider is a plugin for Terraform that allows registration and management of domains and their domain contacts. This plugin is on Terraform Registry: https://registry.terraform.io/providers/inwx/inwx
Documentation
------
You can find a detailed description of the provider and all resources under [docs/](docs/) or at https://registry.terraform.io/providers/inwx/inwx/.
If you still experience any kind of problems don't hesitate to contact our [support via email](mailto:support@inwx.de).
-------
License
----
MIT
+18
View File
@@ -0,0 +1,18 @@
{
"version": 3,
"terraform_version": "1.9.5",
"backend": {
"type": "cloud",
"config": {
"hostname": null,
"organization": "2martens",
"token": null,
"workspaces": {
"name": "domain-test",
"project": null,
"tags": null
}
},
"hash": 3293156678
}
}
+162
View File
@@ -0,0 +1,162 @@
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_nameserver" "twomartens_de_nameserver" {
domain = local.domain
type = "MASTER"
nameservers = [
"ns.inwx.de",
"ns2.inwx.de",
"ns3.inwx.eu"
]
}
resource "inwx_domain" "twomartens_de" {
name = local.domain
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 = 1
billing = 1
}
}
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 = 1
billing = 1
}
extra_data = {
"EU-COUNTRY-OF-CITIZENSHIP" : "DE"
}
}
// NS records
# resource "inwx_nameserver_record" "twomartens_de_ns1" {
# domain = local.domain
# name = local.domain
# content = "ns.inwx.de"
# type = "NS"
# ttl = 86400
# }
#
# resource "inwx_nameserver_record" "twomartens_de_ns2" {
# domain = local.domain
# name = local.domain
# content = "ns2.inwx.de"
# type = "NS"
# ttl = 86400
# }
#
# resource "inwx_nameserver_record" "twomartens_de_ns3" {
# domain = local.domain
# name = local.domain
# content = "ns3.inwx.eu"
# type = "NS"
# ttl = 86400
# }
resource "inwx_nameserver_record" "twomartens_eu_ns1" {
domain = "2martens.eu"
name = "2martens.eu"
content = "ns.inwx.de"
type = "NS"
ttl = 86400
}
resource "inwx_nameserver_record" "twomartens_eu_ns2" {
domain = "2martens.eu"
name = "2martens.eu"
content = "ns2.inwx.de"
type = "NS"
ttl = 86400
}
resource "inwx_nameserver_record" "twomartens_eu_ns3" {
domain = "2martens.eu"
name = "2martens.eu"
content = "ns3.inwx.eu"
type = "NS"
ttl = 86400
}
// SOAs
# resource "inwx_nameserver_record" "twomartens_de_soa" {
# domain = local.domain
# name = local.domain
# content = "ns.inwx.de hostmaster.inwx.de 2023103008 10800 3600 604800 3600"
# type = "SOA"
# ttl = 86400
#
# lifecycle {
# ignore_changes = [content]
# }
# }
resource "inwx_nameserver_record" "twomartens_eu_soa" {
domain = "2martens.eu"
name = "2martens.eu"
content = "ns.inwx.de hostmaster.inwx.de 2023103001 10800 3600 604800 3600"
type = "SOA"
ttl = 86400
lifecycle {
ignore_changes = [content]
}
}
// redirect 2martens.eu to 2martens.de
resource "inwx_nameserver_record" "twomartens_eu_root_redirect" {
domain = "2martens.eu"
name = "2martens.eu"
content = "https://2martens.de"
type = "URL"
url_redirect_type = "HEADER301"
prio = 301
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_eu_www_redirect" {
domain = "2martens.eu"
name = "www.2martens.eu"
content = "https://2martens.de"
type = "URL"
url_redirect_type = "HEADER301"
prio = 301
ttl = 3600
}
View File
+3
View File
@@ -0,0 +1,3 @@
locals {
domain = "2martens.de"
}
+31
View File
@@ -0,0 +1,31 @@
resource "inwx_nameserver_record" "a" {
domain = var.domain
name = var.subdomain != "" ? format("%s.%s", var.subdomain, var.domain) : var.domain
content = var.ipv4
type = "A"
ttl = 3600
}
resource "inwx_nameserver_record" "aaaa" {
domain = var.domain
name = var.subdomain != "" ? format("%s.%s", var.subdomain, var.domain) : var.domain
content = var.ipv6
type = "AAAA"
ttl = 3600
}
resource "inwx_nameserver_record" "mx" {
domain = var.domain
name = var.subdomain != "" ? format("%s.%s", var.subdomain, var.domain) : var.domain
content = var.hostName
type = "MX"
prio = var.mxPrio
ttl = 3600
count = var.hasMXRecord ? 1 : 0
}
resource "inwx_nameserver_record" "mx-spf" {
domain = var.domain
name = var.subdomain != "" ? format("%s.%s", var.subdomain, var.domain) : var.domain
content = var.mxSpf
type = "TXT"
ttl = 3600
count = var.hasMXRecord ? 1 : 0
}
+35
View File
@@ -0,0 +1,35 @@
variable "ipv4" {
type = string
}
variable "ipv6" {
type = string
}
variable "domain" {
type = string
}
variable "subdomain" {
type = string
}
variable "hasMXRecord" {
type = bool
default = false
}
variable "hostName" {
type = string
default = ""
}
variable "mxPrio" {
type = number
default = 0
}
variable "mxSpf" {
type = string
default = ""
}
+8
View File
@@ -0,0 +1,8 @@
terraform {
required_providers {
inwx = {
source = "inwx/inwx"
version = "1.4.2"
}
}
}
+116
View File
@@ -0,0 +1,116 @@
// A records
resource "inwx_nameserver_record" "twomartens_de_allris_a" {
domain = local.domain
name = "allris.2martens.de"
content = "185.26.156.105"
type = "A"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_autoconfig_a" {
domain = local.domain
name = "autoconfig.2martens.de"
content = "185.26.156.22"
type = "A"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_autodiscover_a" {
domain = local.domain
name = "autodiscover.2martens.de"
content = "185.26.156.22"
type = "A"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_jim_a" {
domain = local.domain
name = "jim.2martens.de"
content = "185.26.156.65"
type = "A"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_pad_a" {
domain = local.domain
name = "pad.2martens.de"
content = "185.26.156.132"
type = "A"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_short_a" {
domain = local.domain
name = "short.2martens.de"
content = "95.143.172.56"
type = "A"
ttl = 3600
}
// AAAA records
resource "inwx_nameserver_record" "twomartens_de_allris_aaaa" {
domain = local.domain
name = "allris.2martens.de"
content = "2a00:d0c0:200:0:b9:1a:9c:61"
type = "AAAA"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_autoconfig_aaaa" {
domain = local.domain
name = "autoconfig.2martens.de"
content = "2a00:d0c0:200:0:b9:1a:9c16:5d"
type = "AAAA"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_autodiscover_aaaa" {
domain = local.domain
name = "autodiscover.2martens.de"
content = "2a00:d0c0:200:0:b9:1a:9c16:5d"
type = "AAAA"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_jim_aaaa" {
domain = local.domain
name = "jim.2martens.de"
content = "2a00:d0c0:200:0:b9:1a:9c:40"
type = "AAAA"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_pad_aaaa" {
domain = local.domain
name = "pad.2martens.de"
content = "2a00:d0c0:200:0:c0bf:e0ff:fec1:af72"
type = "AAAA"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_short_aaaa" {
domain = local.domain
name = "short.2martens.de"
content = "2001:1a50:11:0:3854:d4ff:fe62:e0d8"
type = "AAAA"
ttl = 3600
}
// CNAME records
resource "inwx_nameserver_record" "twomartens_de_cdn_cname" {
domain = local.domain
name = "cdn.2martens.de"
content = "d1fvxyvcoii67h.cloudfront.net"
type = "CNAME"
ttl = 3600
}
resource "inwx_nameserver_record" "twomartens_de_aws-validations-cdn_cname" {
domain = local.domain
name = "_4741e2d9c8a605950eebfa048029e4ef.cdn.2martens.de"
content = "_cf71e85bb40cc12717f2718e4590ad23.acm-validations.aws"
type = "CNAME"
ttl = 3600
}
+8
View File
@@ -0,0 +1,8 @@
output "ansible_inventory" {
value = templatefile("${path.module}/templates/inventory.tftpl", {
devops = hcloud_server.server_devops.ipv4_address,
k8s_servers = concat(
module.test_cluster.node_ipv6_addresses
)
})
}
+5
View File
@@ -0,0 +1,5 @@
provider "inwx" {
api_url = "https://api.ote.domrobot.com/jsonrpc/"
username = var.inwx_user
password = var.inwx_password
}
+72
View File
@@ -0,0 +1,72 @@
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
}
variable "hcloud_token" {
type = string
sensitive = true
}
variable "terraform_private_ssh_key" {
description = "Private SSH key to be used by Terraform to connect with remote machines"
type = string
sensitive = true
}
variable "terraform_public_ssh_key" {
description = "Public SSH key for the private key used by Terraform to connect with remote machines"
type = string
}
variable "vault_client_id" {
description = "Client ID of the service principal used to access Hashicorp Cloud"
type = string
sensitive = true
}
variable "vault_client_secret" {
description = "Client Secret of the service principal used to access Hashicorp Cloud"
type = string
sensitive = true
}
variable "aws_access_key" {
description = "Access key for AWS"
type = string
sensitive = true
}
variable "aws_secret_key" {
description = "Secret key for AWS"
type = string
sensitive = true
}
+15
View File
@@ -0,0 +1,15 @@
terraform {
cloud {
organization = "2martens"
workspaces {
name = "domain-test"
}
}
required_providers {
inwx = {
source = "inwx/inwx"
version = "1.4.2"
}
}
}