signalsciences / terraform-provider-sigsci

Signal sciences terraform provider
MIT License
26 stars 30 forks source link

Unable to change rule action #19

Closed willnewby closed 3 years ago

willnewby commented 3 years ago

Hello! I'm attempting to change a Rule action via the Terraform provider. I understand that SigSci doesn't allow you to update existing rules, so I'm curious why the terraform provider doesn't force a re-creation on the rule, rather than attempting to update it in-place and failing? It seems to force a replace for site-level changes (like name/etc).

Here's the command and output I'm seeing.

└─[12:50]-(%)-[$] docker run --rm -it -v $PWD:/terraform -w /terraform/targets/staging/waf/ fb3d2fee2d5f terraform apply
module.sigsci-site.sigsci_site.web: Refreshing state... [id=staging]
module.sigsci-site.sigsci_site_rule.test: Refreshing state... [id=5fad8368f6a39001db936119]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.sigsci-site.sigsci_site_rule.test will be updated in-place
  ~ resource "sigsci_site_rule" "test" {
        enabled         = true
        group_operator  = "any"
        id              = "5fad8368f6a39001db936119"
        rate_limit      = {}
        reason          = "TF-Managed: IP-blocks"
        signal          = "SQLI"
        site_short_name = "staging"
        type            = "signal"

      + actions {
          + type = "allow"
        }
      - actions {
          - type = "excludeSignal" -> null
        }

        conditions {
            field    = "path"
            operator = "contains"
            type     = "single"
            value    = "/login"
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.sigsci-site.sigsci_site_rule.test: Modifying... [id=5fad8368f6a39001db936119]

Error: Update failed for rule ID 5fad8368f6a39001db936119 in corp spothero in site staging
got:
sigsci.CreateSiteRuleBody{Type:"signal", GroupOperator:"any", Enabled:true, Reason:"TF-Managed: IP-blocks", Signal:"SQLI", Expiration:"", Conditions:[]sigsci.Condition{sigsci.Condition{Type:"single", GroupOperator:"", Field:"path", Operator:"contains", Value:"/login", Conditions:[]sigsci.Condition(nil)}}, Actions:[]sigsci.Action{sigsci.Action{Type:"excludeSignal", Signal:""}}, RateLimit:(*sigsci.RateLimit)(nil)}
expected:
sigsci.CreateSiteRuleBody{Type:"signal", GroupOperator:"any", Enabled:true, Reason:"TF-Managed: IP-blocks", Signal:"SQLI", Expiration:"", Conditions:[]sigsci.Condition{sigsci.Condition{Type:"single", GroupOperator:"", Field:"path", Operator:"contains", Value:"/login", Conditions:[]sigsci.Condition(nil)}}, Actions:[]sigsci.Action{sigsci.Action{Type:"allow", Signal:""}}, RateLimit:(*sigsci.RateLimit)(nil)}
Please re-run

  on ../../../modules/sigsci-site/site.tf line 10, in resource "sigsci_site_rule" "test":
  10: resource "sigsci_site_rule" "test" {
powtor commented 2 years ago

I have a similar issue when trying to update the rate limit rule. How to deal with it? Is there any fix for this issue?

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.site_rule.sigsci_site_rule.rule will be updated in-place
  ~ resource "sigsci_site_rule" "rule" {
        id              = "69c2000000001d2c45c95"
      ~ rate_limit      = {
          ~ "threshold" = "7" -> "8"
            # (2 unchanged elements hidden)
        }
        # (6 unchanged attributes hidden)
        # (3 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
module.site_rule.sigsci_site_rule.rule: Modifying...
╷
│ Error: Validation failed - rate limit data required for rate limit rule
│ 
│   with module.site_rule.sigsci_site_rule.rule,
│   on ../../modules/site_rule/main.tf line 5, in resource "sigsci_site_rule" "rule":
│    5: resource "sigsci_site_rule" "rule" {
│ 
╵