Skip to content

Update resource_rule tests when switcing from question_id to query is fixed #190

Description

@asaba-hashi

As noted in #174 (comment), there is an open bug in API when switching a rule from a referenced question to an inline one. The tests should be updated after it is fixed to prevent regressions.

Terraform Version

n/a

Affected Resource(s)

Please list the resources as a list, for example:

  • rule

Terraform Configuration Files

resource "jupiterone_question" "test" {
  title = "test-asaba"
  description = "test-referenced-rule"
  
  query {
      name    = "query0"
      query   = "Find DataStore with classification=('critical' or 'sensitive' or 'confidential' or 'restricted') and encrypted!=true"
      version = "v1"
  }

}

resource "jupiterone_rule" "test" {
  name             = "test-asaba"
  description      = "test"
  polling_interval = "ONE_DAY"

  #question_id = jupiterone_question.test.id
  question {
    queries {
      name    = "query0"
      query   = "Find DataStore with classification=('critical' or 'sensitive' or 'confidential' or 'restricted') and encrypted!=true"
      version = "v1"
    }
  }

  tags = ["exampletag"]

  outputs = [
    "queries.query0.total",
    "alertLevel"
  ]

  operations = [
    {
      when = jsonencode({
        "type" : "FILTER",
        "specVersion" : 1,
        "condition" : [
          "AND",
          [
            "queries.query0.total",
            "<",
            1000
          ]
        ]
      }),
      actions = [
        jsonencode({
          "targetValue" : "INFO",
          "type" : "SET_PROPERTY",
          "targetProperty" : "alertLevel"
        }),
        jsonencode({
          "type" : "CREATE_ALERT"
        }),
      ]
    }
  ]
}

Expected Behavior

The rule is updated without error.

Actual Behavior

What actually happened?

"input: Error updating rule instance"

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply as above.
  2. Uncomment question_id and remove or comment the query block.
  3. Attempt a terraform apply.

Important Factoids

This issue is mostly to keep track that the tests will need to be updated when the API bug is fixed.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions