From 9867a2ae3302a13c0fa214a8392c97f9a9af3078 Mon Sep 17 00:00:00 2001 From: DXTimer Date: Thu, 10 Aug 2023 15:44:49 +0700 Subject: [PATCH] wip support all record types from service meta --- main.tf | 21 +++++++++++---------- test/terraform.tfvars.example | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/main.tf b/main.tf index 37cdd59..0255fe4 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnsimple = { source = "dnsimple/dnsimple" - version = ">= 0.13" + version = ">= 1.0" } } } @@ -14,14 +14,14 @@ provider "dnsimple" { user_agent = "DNSimple-Consul-Terraform" } -# Add a record to a service specific domain -resource "dnsimple_zone_record" "records_a" { +# Add a record of any type to a service specific domain +resource "dnsimple_zone_record" "consul_service_records" { for_each = local.consul_services zone_name = each.value.zone_name name = each.value.record_name - value = each.value.address - type = "A" + value = each.value.record_content + type = each.value.record_type ttl = each.value.record_ttl } @@ -29,11 +29,12 @@ locals { consul_services = { for id, service in var.services : id => { - "name" = service.name, - "address" = service.address, - "zone_name" = service.meta["zone_name"], - "record_name" = service.meta["record_name"], - "record_ttl" = lookup(service.meta, "record_ttl", 3600), + "name" = service.name, + "zone_name" = service.meta["zone_name"], + "record_name" = service.meta["record_name"], + "record_content" = lookup(service.meta, "record_content", service.address), + "record_type" = lookup(service.meta, "record_type", "A"), + "record_ttl" = lookup(service.meta, "record_ttl", 3600), } } } diff --git a/test/terraform.tfvars.example b/test/terraform.tfvars.example index 2575e55..ed4e401 100644 --- a/test/terraform.tfvars.example +++ b/test/terraform.tfvars.example @@ -82,4 +82,27 @@ services = { } node_meta = {} } + "web_3" : { + address = "172.17.0.3" + id = "web_2" + name = "web" + kind = "" + port = 5000 + meta = { + zone_name = "amazon.works" + record_name = "web" + } + tags = ["burrito"] + namespace = null + status = "passing" + node_id = "node_b" + node = "foobarbaz" + node_address = "192.168.10.11" + node_datacenter = "dc1" + node_tagged_addresses = { + lan = "192.168.10.11" + wan = "10.0.10.10" + } + node_meta = {} + } }