Closed AppleMaster closed 5 years ago
We've now managed to create the feeds and datasources ourselves , using terraform but not specifically tied to the monitoring jobs, with the below configuration:
resource "ns1_datasource" "ftevif2" {
name = "ftevif2"
sourcetype = "nsone_monitoring"
}
resource "ns1_datafeed" "ftevif2" {
name = "ftevif2"
source_id = "${ns1_datasource.ftevif2.id}"
config = {
jobid = "${ns1_monitoringjob.ftevif2.id}"
}
}
This works and creates the two, and in the UI we can then associate a record's "up" metadata with the feed that has been created - but we cannot do this with terraform or the NS1 API itself.
Is this supposed to be supported or can support be added?
Being able to do the majority of the configuration via terraform and then having to do the final step manually is kind of not ideal
So to paraphase the situation;
Problem is; we can't associated the datafeed to the record using Terraform.
When viewing configuration via the API for systems setup through the UI we can see;
{
"meta" : {
"up" : {
"feed" : "5b646848bbccf900016f3a10"
},
"georegion" : [
"US-WEST"
]
},
"answer" : [
"REDACTED"
],
"id" : "5be9ba81c9c79d0001109647",
"feeds" : [
{
"source" : "91bb55a0a53b38761794e0c6f0d14ef8",
"feed" : "5b646848bbccf900016f3a10"
}
]
}
So tried to setup the feed using this Terraform configuration;
answers = {
answer = "REDACTED"
meta = {
up = {
feed = "${ns1_datafeed.ftevif1.id}"
}
}
}
but the provider expects up
to be a String.
Can you tell us how we'd link a datafeed to a record with an example syntax please.
Paraphrased response from NS1 support team;
Due to a limitation in the terraform framework, it is only possible to define the up
meta property as a boolean and not a more complex structure that'd support that field being either a boolean or another map.
As such, we can't automatically associate a data-feed with a record via Terraform at this time.
Related pull request on upstream NS1 go library which was closed as remarks on the same need for 0.12 of Terraform.
ns1/ns1-go#63 merges a similar fix to the one proposed in ns1/ns1-go#54 and is available in the latest release of this provider. This allows the value of a metadata key to be set to a raw JSON string that points at a feed (i.e. weight = "{\"feed\":\"${ns1_datafeed.foobar.id}\"}"
).
I'm going to close this issue as this should enable a workaround while we wait for the improvements in v0.12 to make it into the SDK.
Terraform Version
Terraform 0.11.11
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
There should be a data feed created that is linked to this new monitoring job, which then allows us to link the job to answer records - this can be observed when creating a monitoring job through the UI on NS1.
Actual Behavior
When a new monitoring job is created via terraform, it exists in the web UI and system , but no corresponding data feed is created, meaning the monitor job cannot then be linked to records.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform plan
terraform apply