Skip to content

Commit

Permalink
wip support all record types from service meta
Browse files Browse the repository at this point in the history
  • Loading branch information
DXTimer committed Aug 10, 2023
1 parent a935786 commit 9867a2a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
21 changes: 11 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
dnsimple = {
source = "dnsimple/dnsimple"
version = ">= 0.13"
version = ">= 1.0"
}
}
}
Expand All @@ -14,26 +14,27 @@ 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
}

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),
}
}
}
23 changes: 23 additions & 0 deletions test/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
}
}

0 comments on commit 9867a2a

Please sign in to comment.