-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate resource for dst works locally
- Loading branch information
1 parent
985ac0f
commit 793fc25
Showing
7 changed files
with
257 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "observe_monitor_v2_destination Resource - terraform-provider-observe" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
# observe_monitor_v2_destination | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `action` (String) | ||
- `name` (String) | ||
- `type` (String) | ||
- `workspace` (String) | ||
|
||
### Optional | ||
|
||
- `description` (String) | ||
- `email` (Block List) (see [below for nested schema](#nestedblock--email)) | ||
- `icon_url` (String) | ||
- `webhook` (Block List) (see [below for nested schema](#nestedblock--webhook)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `oid` (String) | ||
|
||
<a id="nestedblock--email"></a> | ||
### Nested Schema for `email` | ||
|
||
Optional: | ||
|
||
- `addresses` (List of String) | ||
- `users` (List of String) | ||
|
||
|
||
<a id="nestedblock--webhook"></a> | ||
### Nested Schema for `webhook` | ||
|
||
Required: | ||
|
||
- `method` (String) | ||
- `url` (String) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
package observe | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccObserveMonitorV2DestinationEmail(t *testing.T) { | ||
randomPrefix := acctest.RandomWithPrefix("tf") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: fmt.Sprintf(monitorV2ConfigPreamble+` | ||
resource "observe_monitor_v2" "first" { | ||
workspace = data.observe_workspace.default.oid | ||
rule_kind = "count" | ||
name = "%[1]s" | ||
lookback_time = "30m" | ||
comment = "a descriptive comment" | ||
inputs = { | ||
"test" = observe_datastream.test.dataset | ||
} | ||
stage { | ||
pipeline = <<-EOF | ||
colmake kind:"test", description:"test" | ||
EOF | ||
output_stage = true | ||
} | ||
stage { | ||
pipeline = <<-EOF | ||
filter kind ~ "test" | ||
EOF | ||
} | ||
rules { | ||
level = "informational" | ||
count { | ||
compare_values { | ||
compare_fn = "greater" | ||
value_int64 = [0] | ||
} | ||
} | ||
} | ||
scheduling { | ||
interval { | ||
interval = "15m" | ||
randomize = "0" | ||
} | ||
} | ||
} | ||
resource "observe_monitor_v2_action" "act" { | ||
workspace = data.observe_workspace.default.oid | ||
type = "email" | ||
email { | ||
subject = "somebody once told me" | ||
body = "the world is gonna roll me" | ||
fragments = jsonencode({ | ||
foo = "bar" | ||
}) | ||
} | ||
name = "%[1]s" | ||
description = "an interesting description" | ||
} | ||
`, randomPrefix), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("observe_monitor_v2_action.act", "workspace"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "name", randomPrefix), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "type", "email"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "description", "an interesting description"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "email.0.fragments", "{\"foo\":\"bar\"}"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "email.0.subject", "somebody once told me"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "email.0.body", "the world is gonna roll me"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccObserveMonitorV2DestinationWebhook(t *testing.T) { | ||
randomPrefix := acctest.RandomWithPrefix("tf") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: fmt.Sprintf(monitorV2ConfigPreamble+` | ||
resource "observe_monitor_v2" "first" { | ||
workspace = data.observe_workspace.default.oid | ||
rule_kind = "count" | ||
name = "%[1]s" | ||
lookback_time = "30m" | ||
comment = "a descriptive comment" | ||
inputs = { | ||
"test" = observe_datastream.test.dataset | ||
} | ||
stage { | ||
pipeline = <<-EOF | ||
colmake kind:"test", description:"test" | ||
EOF | ||
output_stage = true | ||
} | ||
stage { | ||
pipeline = <<-EOF | ||
filter kind ~ "test" | ||
EOF | ||
} | ||
rules { | ||
level = "informational" | ||
count { | ||
compare_values { | ||
compare_fn = "greater" | ||
value_int64 = [0] | ||
} | ||
} | ||
} | ||
scheduling { | ||
interval { | ||
interval = "15m" | ||
randomize = "0" | ||
} | ||
} | ||
} | ||
resource "observe_monitor_v2_action" "act" { | ||
workspace = data.observe_workspace.default.oid | ||
type = "webhook" | ||
webhook { | ||
headers { | ||
header = "never gonna give you up" | ||
value = "never gonna let you down" | ||
} | ||
body = "never gonna run around and desert you" | ||
fragments = jsonencode({ | ||
foo = "bar" | ||
}) | ||
} | ||
name = "%[1]s" | ||
description = "an interesting description" | ||
} | ||
`, randomPrefix), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("observe_monitor_v2_action.act", "workspace"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "name", randomPrefix), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "type", "webhook"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "description", "an interesting description"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "webhook.0.fragments", "{\"foo\":\"bar\"}"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "webhook.0.headers.0.header", "never gonna give you up"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "webhook.0.headers.0.value", "never gonna let you down"), | ||
resource.TestCheckResourceAttr("observe_monitor_v2_action.act", "webhook.0.body", "never gonna run around and desert you"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |