Skip to content

Commit

Permalink
Merge pull request #83 from signalsciences/alert-blockduration
Browse files Browse the repository at this point in the history
Alert blockduration
  • Loading branch information
shawnps authored Oct 20, 2022
2 parents 4fd5192 + b82638a commit 2040d86
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/davecgh/go-spew v1.1.1
github.com/hashicorp/terraform-plugin-sdk v1.14.0
github.com/signalsciences/go-sigsci v0.1.6
github.com/signalsciences/go-sigsci v0.1.7
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/signalsciences/go-sigsci v0.1.6 h1:O3v1kQOA00d+HO4pD8ykymouojBe02bYy0gj15ow8jA=
github.com/signalsciences/go-sigsci v0.1.6/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A=
github.com/signalsciences/go-sigsci v0.1.7 h1:86Avjmn5Kg5QZIqR9LBqvSHr7sUpR07c59GSTG4AocQ=
github.com/signalsciences/go-sigsci v0.1.7/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A=
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down
21 changes: 11 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ resource "sigsci_site_signal_tag" "test" {
}

resource "sigsci_site_alert" "test_site_alert" {
site_short_name = sigsci_site.my-site.short_name
tag_name = sigsci_site_signal_tag.test_tag.id
long_name = "test_alert"
interval = 10
threshold = 12
enabled = true
action = "info"
site_short_name = sigsci_site.my-site.short_name
tag_name = sigsci_site_signal_tag.test_tag.id
long_name = "test_alert"
interval = 10
threshold = 12
enabled = true
action = "info"
block_duration_seconds = 86400
}

resource "sigsci_site_templated_rule" "test_template_rule" {
Expand Down Expand Up @@ -336,8 +337,8 @@ resource "sigsci_site_integration" "test_integration" {
events = ["listCreated"]
}

resource "sigsci_corp_cloudwaf_certificate" "test_cloudwaf_certificate"{
name = "Certificate Name"
resource "sigsci_corp_cloudwaf_certificate" "test_cloudwaf_certificate" {
name = "Certificate Name"
certificate_body = <<CERT
-----BEGIN CERTIFICATE-----
MIIDzjCCArYCCQD6uBPuCbaDuDANBgkqhkiG9w0BAQsFADCBqDELMAkGA1UEBhMC
Expand All @@ -363,7 +364,7 @@ UVhVTn9w3UPLMkEl7nAVzydpdMb/M/GLCV787BrQL35EtiCr9MSL9Gc8vR/9PzPP
QodC+xWXbig7xKLqZgQ/PbPt
-----END CERTIFICATE-----
CERT
private_key = <<PRIVATEKEY
private_key = <<PRIVATEKEY
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCxy8NvaPaz1t2I
AgdupGgzapkHF0zhq1LAAlCtdV7elud7YotnDneQelW2Nq6B8woGde55HWKKVi7l
Expand Down
39 changes: 25 additions & 14 deletions provider/resource_site_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func resourceSiteAlert() *schema.Resource {
Description: "A flag to skip notifications",
Optional: true,
},
"block_duration_seconds": {
Type: schema.TypeInt,
Description: "The number of seconds this alert is active.",
Optional: true,
},
},
}
}
Expand All @@ -63,13 +68,14 @@ func resourceSiteAlertCreate(d *schema.ResourceData, m interface{}) error {
sc := pm.Client

alert, err := sc.CreateCustomAlert(pm.Corp, d.Get("site_short_name").(string), sigsci.CustomAlertBody{
TagName: d.Get("tag_name").(string),
LongName: d.Get("long_name").(string),
Interval: d.Get("interval").(int),
Threshold: d.Get("threshold").(int),
Enabled: d.Get("enabled").(bool),
Action: d.Get("action").(string),
SkipNotifications: d.Get("skip_notifications").(bool),
TagName: d.Get("tag_name").(string),
LongName: d.Get("long_name").(string),
Interval: d.Get("interval").(int),
Threshold: d.Get("threshold").(int),
Enabled: d.Get("enabled").(bool),
Action: d.Get("action").(string),
SkipNotifications: d.Get("skip_notifications").(bool),
BlockDurationSeconds: d.Get("block_duration_seconds").(int),
})
if err != nil {
return err
Expand Down Expand Up @@ -121,6 +127,10 @@ func resourceSiteAlertRead(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}
err = d.Set("block_duration_seconds", alert.BlockDurationSeconds)
if err != nil {
return err
}

return nil
}
Expand All @@ -130,13 +140,14 @@ func resourceSiteAlertUpdate(d *schema.ResourceData, m interface{}) error {
sc := pm.Client

alert, err := sc.UpdateCustomAlert(pm.Corp, d.Get("site_short_name").(string), d.Id(), sigsci.CustomAlertBody{
TagName: d.Get("tag_name").(string),
LongName: d.Get("long_name").(string),
Interval: d.Get("interval").(int),
Threshold: d.Get("threshold").(int),
Enabled: d.Get("enabled").(bool),
Action: d.Get("action").(string),
SkipNotifications: d.Get("skip_notifications").(bool),
TagName: d.Get("tag_name").(string),
LongName: d.Get("long_name").(string),
Interval: d.Get("interval").(int),
Threshold: d.Get("threshold").(int),
Enabled: d.Get("enabled").(bool),
Action: d.Get("action").(string),
SkipNotifications: d.Get("skip_notifications").(bool),
BlockDurationSeconds: d.Get("block_duration_seconds").(int),
})
if err != nil {
d.SetId("")
Expand Down

0 comments on commit 2040d86

Please sign in to comment.