Skip to content

Commit

Permalink
dns but not reliable enough with bad hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
atrull committed Nov 19, 2023
1 parent a504e4e commit b0b58ff
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,26 @@ provider "curl2" {
}
}

# dns checks
data "dns_a_record_set" "myip" {
for_each = toset(local.service_urls)
host = regex("^(?:(?P<scheme>[^:/?#]+):)?(?://(?P<host>[^/?#]*))?", each.key).host
# one day, this will be more reliable when a PR for the DNS provider gets merged in..
# https://github.com/hashicorp/terraform-provider-dns/pull/76
}

# curl2 is the default method
data "curl2" "myip" {
for_each = var.data_provider == "curl2" ? toset(local.service_urls) : []
uri = each.key
http_method = "GET"

lifecycle {
# check dns first
precondition {
condition = data.dns_a_record_set.myip[each.key].addrs != null
error_message = "dns for a myip service didn't resolve please remove it from the list"
}
}
}

# but we can use http if you prefer
Expand Down

0 comments on commit b0b58ff

Please sign in to comment.