diff --git a/ns1/resource_monitoringjob.go b/ns1/resource_monitoringjob.go index 93a824f6..dd858650 100644 --- a/ns1/resource_monitoringjob.go +++ b/ns1/resource_monitoringjob.go @@ -4,7 +4,6 @@ import ( "fmt" "log" "regexp" - "sort" "strconv" "strings" @@ -28,7 +27,7 @@ func monitoringJobResource() *schema.Resource { ForceNew: true, }, "regions": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, Elem: &schema.Schema{ Type: schema.TypeString, @@ -130,10 +129,7 @@ func monitoringJobToResourceData(d *schema.ResourceData, r *monitor.Job) error { d.Set("job_type", r.Type) d.Set("active", r.Active) d.Set("mute", r.Mute) - if len(r.Regions) > 0 { - sort.Strings(r.Regions) - d.Set("regions", r.Regions) - } + d.Set("regions", r.Regions) d.Set("frequency", r.Frequency) d.Set("rapid_recheck", r.RapidRecheck) config := make(map[string]string) @@ -191,7 +187,7 @@ func resourceDataToMonitoringJob(r *monitor.Job, d *schema.ResourceData) error { r.Type = d.Get("job_type").(string) r.Active = d.Get("active").(bool) r.Mute = d.Get("mute").(bool) - rawRegions := d.Get("regions").([]interface{}) + rawRegions := d.Get("regions").(*schema.Set).List() r.Regions = make([]string, len(rawRegions)) for i, v := range rawRegions { r.Regions[i] = v.(string) diff --git a/ns1/resource_monitoringjob_test.go b/ns1/resource_monitoringjob_test.go index 3af45c37..b9e22711 100644 --- a/ns1/resource_monitoringjob_test.go +++ b/ns1/resource_monitoringjob_test.go @@ -26,7 +26,7 @@ func TestAccMonitoringJob_basic(t *testing.T) { testAccCheckMonitoringJobExists("ns1_monitoringjob.it", &mj), testAccCheckMonitoringJobName(&mj, "terraform test"), testAccCheckMonitoringJobActive(&mj, true), - testAccCheckMonitoringJobRegions(&mj, []string{"lga", "sjc", "sin"}), + testAccCheckMonitoringJobRegions(&mj, []string{"lga", "sjc", "nrt"}), testAccCheckMonitoringJobType(&mj, "tcp"), testAccCheckMonitoringJobFrequency(&mj, 60), testAccCheckMonitoringJobRapidRecheck(&mj, false), @@ -46,7 +46,7 @@ func TestAccMonitoringJob_basic(t *testing.T) { testAccCheckMonitoringJobExists("ns1_monitoringjob.it", &mj), testAccCheckMonitoringJobName(&mj, "terraform http test"), testAccCheckMonitoringJobActive(&mj, true), - testAccCheckMonitoringJobRegions(&mj, []string{"lga", "sjc", "sin"}), + testAccCheckMonitoringJobRegions(&mj, []string{"lga", "sjc", "lhr"}), testAccCheckMonitoringJobType(&mj, "http"), testAccCheckMonitoringJobFrequency(&mj, 60), testAccCheckMonitoringJobRapidRecheck(&mj, false), @@ -71,7 +71,7 @@ func TestAccMonitoringJob_updated(t *testing.T) { testAccCheckMonitoringJobExists("ns1_monitoringjob.it", &mj), testAccCheckMonitoringJobName(&mj, "terraform test"), testAccCheckMonitoringJobActive(&mj, true), - testAccCheckMonitoringJobRegions(&mj, []string{"lga", "sjc", "sin"}), + testAccCheckMonitoringJobRegions(&mj, []string{"nrt", "sjc", "sin"}), testAccCheckMonitoringJobType(&mj, "tcp"), testAccCheckMonitoringJobFrequency(&mj, 60), testAccCheckMonitoringJobRapidRecheck(&mj, false), diff --git a/website/docs/r/monitoringjob.html.markdown b/website/docs/r/monitoringjob.html.markdown index 89b8e635..33eb88f6 100644 --- a/website/docs/r/monitoringjob.html.markdown +++ b/website/docs/r/monitoringjob.html.markdown @@ -46,7 +46,7 @@ The following arguments are supported: * `job_type` - (Required) The type of monitoring job to be run. Refer to the NS1 API documentation (https://ns1.com/api#monitoring-jobs) for supported values which include ping, tcp, dns, http. * `active` - (Required) Indicates if the job is active or temporarily disabled. * `regions` - (Required) The list of region codes in which to run the monitoring - job. See NS1 API docs for supported values. NOTE: order alphabetically by region code. + job. See NS1 API docs for supported values. * `frequency` - (Required) The frequency, in seconds, at which to run the monitoring job in each region. * `rapid_recheck` - (Required) If true, on any apparent state change, the job is quickly re-run after one second to confirm the state change before notification. * `policy` - (Required) The policy for determining the monitor's global status