gessnerfl / terraform-provider-instana

Terraform provider implementation for Instana REST API
Apache License 2.0
29 stars 16 forks source link

Failed to map TagFilterExpression #195

Closed gessnerfl closed 11 months ago

gessnerfl commented 11 months ago

In certain use cases, Instana is wrapping expressions in a nested AND expression with a single element. Currently this is resulting in an error in the terraform provider as the mapping logic expects at least two elements for a logical and expression.

gessnerfl commented 11 months ago

This is an example response:

{
  "id": "my-id",
  "label": "my-label",
  "matchSpecification": null,
  "tagFilterExpression": {
    "type": "EXPRESSION",
    "logicalOperator": "AND",
    "elements": [
      {
        "type": "EXPRESSION",
        "logicalOperator": "AND",
        "elements": [
          {
            "type": "EXPRESSION",
            "logicalOperator": "OR",
            "elements": [
              {
                "type": "TAG_FILTER",
                "name": "agent.tag",
                "stringValue": "key1=value1",
                "numberValue": null,
                "booleanValue": null,
                "key": "tis:Project",
                "value": "tech-insights",
                "operator": "EQUALS",
                "entity": "DESTINATION"
              },
              {
                "type": "TAG_FILTER",
                "name": "aws.ec2.tag",
                "stringValue": "key1=value1",
                "numberValue": null,
                "booleanValue": null,
                "key": "tis:Project",
                "value": "tech-insights",
                "operator": "EQUALS",
                "entity": "DESTINATION"
              }
            ]
          }
        ]
      },
      {
        "type": "EXPRESSION",
        "logicalOperator": "AND",
        "elements": [
          {
            "type": "EXPRESSION",
            "logicalOperator": "OR",
            "elements": [
              {
                "type": "TAG_FILTER",
                "name": "agent.tag",
                "stringValue": "key2=value2",
                "numberValue": null,
                "booleanValue": null,
                "key": "tis:Environment",
                "value": "arch-aws-eu",
                "operator": "EQUALS",
                "entity": "DESTINATION"
              },
              {
                "type": "TAG_FILTER",
                "name": "aws.ec2.tag",
                "stringValue": "key2=value2",
                "numberValue": null,
                "booleanValue": null,
                "key": "tis:Environment",
                "value": "arch-aws-eu",
                "operator": "EQUALS",
                "entity": "DESTINATION"
              }
            ]
          }
        ]
      }
    ]
  },
  "scope": "INCLUDE_ALL_DOWNSTREAM",
  "boundaryScope": "INBOUND",
  "accessRules": [
    {
      "accessType": "READ_WRITE",
      "relationType": "GLOBAL",
      "relatedId": null
    }
  ]
}