Closed packet-blaster closed 1 year ago
I was intending to get around this my using a data feed data source. But datafeed is also unavailable as a data source and cannot be looked up.
Resolved after speaking with NS1. The proper way to handle this is to create the monitoring data source/feed along with the monitoring job.
example provided by NS1
resource "ns1_datasource" "tf_ds" {
sourcetype = "nsone_monitoring"
name = "terraform_datasource"
}
resource "ns1_notifylist" "tf_nl" {
name = "terraform_notify_list"
notifications {
config = {
sourceid = ns1_datasource.tf_ds.id
}
type = "datafeed"
}
}
resource "ns1_monitoringjob" "tf_job" {
name = "terraform monitor"
active = true
regions = ["sjc", "dal", "lga", "gru", "lhr", "syd", "ams", "nrt", "sin"]
job_type = "http"
frequency = 30
rapid_recheck = true
policy = "quorum"
config = {
url = "https://50.116.48.14/"
virtual_host = "bigblack.dog"
tls_add_verify = true
# tls_skip_verify = false
}
notify_list = ns1_notifylist.tf_nl.id
notify_failback = true
}
resource "ns1_datafeed" "tf_feed" {
name = "tf monitor feed"
source_id = ns1_datasource.tf_ds.id
config = {
jobid = ns1_monitoringjob.tf_job.id
}
}
resource "ns1_record" "bbd_meta" {
zone = ns1_zone.bbd.zone
domain = "up-filter-feed.${ns1_zone.bbd.zone}"
type = "A"
answers {
answer = "2.2.2.2"
meta = {
us_state = "NH"
up = "{\"feed\":\"${ns1_datafeed.tf_feed.id}\"}"
}
}
answers {
answer = "1.1.1.1"
meta = {
up = true
us_state = "CA"
}
}
filters {
filter = "up"
}
filters {
filter = "geotarget_country"
}
filters {
filter = "select_first_n"
config = {
N = 1
}
}
}
When you create a Monitor (ns1_monitoringjob), an auto-generated feed is created in the background. When you create DNS records that use Filter Chains, they need to reference these auto-generated IDs to dynamically use the resources you've created through terraform. This output is currently unavailable from the ns1_monitoringjob resource.
example ns1_record:
What the meta field should be able to do: