This allows for multiple contacts per test.
Required: true,
},
- "contact_id": {
- Type: schema.TypeInt,
+ "contact_group": {
+ Type: schema.TypeSet,
+ Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
+ Set: schema.HashString,
},
"check_rate": {
TestType: d.Get("test_type").(string),
Paused: d.Get("paused").(bool),
Timeout: d.Get("timeout").(int),
- ContactID: d.Get("contact_id").(int),
+ ContactGroup: castSetToSliceStrings(d.Get("contact_group").(*schema.Set).List()),
Confirmation: d.Get("confirmations").(int),
Port: d.Get("port").(int),
TriggerRate: d.Get("trigger_rate").(int),
d.Set("test_type", testResp.TestType)
d.Set("paused", testResp.Paused)
d.Set("timeout", testResp.Timeout)
- d.Set("contact_id", testResp.ContactID)
+ d.Set("contact_group", testResp.ContactGroup)
d.Set("confirmations", testResp.Confirmation)
d.Set("port", testResp.Port)
d.Set("trigger_rate", testResp.TriggerRate)
if v, ok := d.GetOk("check_rate"); ok {
test.CheckRate = v.(int)
}
- if v, ok := d.GetOk("contact_id"); ok {
- test.ContactID = v.(int)
+ if v, ok := d.GetOk("contact_group"); ok {
+ test.ContactGroup = castSetToSliceStrings(v.(*schema.Set).List())
}
if v, ok := d.GetOk("test_type"); ok {
test.TestType = v.(string)
resource.TestCheckResourceAttr("statuscake_test.google", "check_rate", "500"),
resource.TestCheckResourceAttr("statuscake_test.google", "paused", "true"),
resource.TestCheckResourceAttr("statuscake_test.google", "timeout", "40"),
- resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"),
resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"),
resource.TestCheckResourceAttr("statuscake_test.google", "trigger_rate", "20"),
resource.TestCheckResourceAttr("statuscake_test.google", "custom_header", "{ \"Content-Type\": \"application/x-www-form-urlencoded\" }"),
err = check(key, value, strconv.FormatBool(test.Paused))
case "timeout":
err = check(key, value, strconv.Itoa(test.Timeout))
- case "contact_id":
- err = check(key, value, strconv.Itoa(test.ContactID))
+ case "contact_group":
+ for _, tv := range test.ContactGroup {
+ err = check(key, value, tv)
+ if err != nil {
+ return err
+ }
+ }
case "confirmations":
err = check(key, value, strconv.Itoa(test.Confirmation))
case "trigger_rate":
}
func interpolateTerraformTemplate(template string) string {
- testContactGroupId := 43402
+ testContactGroupId := "43402"
if v := os.Getenv("STATUSCAKE_TEST_CONTACT_GROUP_ID"); v != "" {
- id, err := strconv.Atoi(v)
- if err == nil {
- testContactGroupId = id
- }
+ testContactGroupId = v
}
return fmt.Sprintf(template, testContactGroupId)
test_type = "HTTP"
check_rate = 300
timeout = 10
- contact_id = %d
+ contact_group = ["%s"]
confirmations = 1
trigger_rate = 10
}
test_type = "TCP"
check_rate = 300
timeout = 10
- contact_id = %d
+ contact_group = ["%s"]
confirmations = 1
port = 80
}
```hcl
resource "statuscake_test" "google" {
- website_name = "google.com"
- website_url = "www.google.com"
- test_type = "HTTP"
- check_rate = 300
- contact_id = 12345
+ website_name = "google.com"
+ website_url = "www.google.com"
+ test_type = "HTTP"
+ check_rate = 300
+ contact_group = ["12345"]
}
```
* `website_name` - (Required) This is the name of the test and the website to be monitored.
* `website_url` - (Required) The URL of the website to be monitored
* `check_rate` - (Optional) Test check rate in seconds. Defaults to 300
-* `contact_id` - (Optional) The id of the contact group to be add to the test. Each test can have only one.
+* `contact_group` - (Optional) Set test contact groups, must be array of strings.
* `test_type` - (Required) The type of Test. Either HTTP, TCP, PING, or DNS
* `paused` - (Optional) Whether or not the test is paused. Defaults to false.
* `timeout` - (Optional) The timeout of the test in seconds.