diff --git a/go.mod b/go.mod index 41dbc5a..647b028 100644 --- a/go.mod +++ b/go.mod @@ -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.7 + github.com/signalsciences/go-sigsci v0.1.8 ) require ( diff --git a/go.sum b/go.sum index 4ebcdd0..7a24b58 100644 --- a/go.sum +++ b/go.sum @@ -168,10 +168,8 @@ github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DK github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 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/signalsciences/go-sigsci v0.1.8 h1:vTWe3beT9lsaWnvoPsItPspk/9tKriDjeAJTruC4oo4= +github.com/signalsciences/go-sigsci v0.1.8/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= diff --git a/main.tf b/main.tf index 440f25e..453b1b3 100644 --- a/main.tf +++ b/main.tf @@ -168,6 +168,7 @@ resource "sigsci_site_rule" "test" { reason = "Example site rule update" signal = "SQLI" expiration = "" + requestlogging = "sampled" conditions { type = "single" diff --git a/provider/resource_site_rule.go b/provider/resource_site_rule.go index a1526d1..744a9c3 100644 --- a/provider/resource_site_rule.go +++ b/provider/resource_site_rule.go @@ -47,6 +47,11 @@ func resourceSiteRule() *schema.Resource { Description: "Date the rule will automatically be disabled. If rule is always enabled, will return empty string", Required: true, }, + "requestlogging": { + Type: schema.TypeString, + Description: "Indicates whether to store the logs for requests that match the rule's conditions (sampled) or not store them (none). This field is only available for request rules that have a block or allow action.", + Required: false, + }, "actions": { Type: schema.TypeSet, Description: "Actions", @@ -224,12 +229,13 @@ func resourceSiteRuleCreate(d *schema.ResourceData, m interface{}) error { site := d.Get("site_short_name").(string) siteRulesBody := sigsci.CreateSiteRuleBody{ - Type: d.Get("type").(string), - GroupOperator: d.Get("group_operator").(string), - Enabled: d.Get("enabled").(bool), - Reason: d.Get("reason").(string), - Signal: d.Get("signal").(string), - Expiration: d.Get("expiration").(string), + Type: d.Get("type").(string), + GroupOperator: d.Get("group_operator").(string), + Enabled: d.Get("enabled").(bool), + Reason: d.Get("reason").(string), + Signal: d.Get("signal").(string), + Expiration: d.Get("expiration").(string), + RequestLogging: d.Get("requestlogging").(string), } siteRulesBody.Conditions = expandRuleConditions(d.Get("conditions").(*schema.Set)) @@ -290,6 +296,10 @@ func resourceSiteRuleRead(d *schema.ResourceData, m interface{}) error { if err != nil { return err } + err = d.Set("requestlogging", rule.RequestLogging) + if err != nil { + return err + } err = d.Set("actions", flattenRuleActions(rule.Actions, true)) if err != nil { return err @@ -313,12 +323,13 @@ func resourceSiteRuleUpdate(d *schema.ResourceData, m interface{}) error { site := d.Get("site_short_name").(string) updateSiteRuleBody := sigsci.CreateSiteRuleBody{ - Type: d.Get("type").(string), - GroupOperator: d.Get("group_operator").(string), - Enabled: d.Get("enabled").(bool), - Reason: d.Get("reason").(string), - Signal: d.Get("signal").(string), - Expiration: d.Get("expiration").(string), + Type: d.Get("type").(string), + GroupOperator: d.Get("group_operator").(string), + Enabled: d.Get("enabled").(bool), + Reason: d.Get("reason").(string), + Signal: d.Get("signal").(string), + Expiration: d.Get("expiration").(string), + RequestLogging: d.Get("requestlogging").(string), } updateSiteRuleBody.Conditions = expandRuleConditions(d.Get("conditions").(*schema.Set))