CiscoISE / terraform-provider-ciscoise

Terraform Provider for Cisco ISE
https://registry.terraform.io/providers/CiscoISE/ciscoise/latest/docs
MIT License
10 stars 4 forks source link

Getting all network access policy sets throwing error #90

Closed KubaMazurkiewicz closed 1 year ago

KubaMazurkiewicz commented 1 year ago

Prerequisites

Describe the bug When I try to get all network access policy sets using following terraform code:

data "ciscoise_network_access_policy_set" "example" {
  provider = ciscoise
}

I'm getting following error:

terraform plan    
data.ciscoise_network_access_policy_set.example: Reading...

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Failure when setting GetNetworkAccessPolicySets response
│ 
│   with data.ciscoise_network_access_policy_set.example,
│   on main.tf line 1, in data "ciscoise_network_access_policy_set" "example":
│    1: data "ciscoise_network_access_policy_set" "example" {
│ 
│ Invalid address to set: []string{"items", "0", "condition", "0", "children", "0", "id"}
╵

Logs

2023-06-05T17:47:59.069+0200 [DEBUG] Starting graph walk: walkPlan
2023-06-05T17:47:59.069+0200 [DEBUG] created provider logger: level=debug
2023-06-05T17:47:59.069+0200 [INFO]  provider: configuring client automatic mTLS
2023-06-05T17:47:59.073+0200 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.18-beta/darwin_arm64/terraform-provider-ciscoise_v0.6.18-beta args=[.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.18-beta/darwin_arm64/terraform-provider-ciscoise_v0.6.18-beta]
2023-06-05T17:47:59.075+0200 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.18-beta/darwin_arm64/terraform-provider-ciscoise_v0.6.18-beta pid=64124
2023-06-05T17:47:59.075+0200 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.18-beta/darwin_arm64/terraform-provider-ciscoise_v0.6.18-beta
2023-06-05T17:47:59.083+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: configuring server automatic mTLS: timestamp=2023-06-05T17:47:59.083+0200
2023-06-05T17:47:59.091+0200 [DEBUG] provider: using plugin: version=5
2023-06-05T17:47:59.091+0200 [DEBUG] provider.terraform-provider-ciscoise_v0.6.18-beta: plugin address: address=/var/folders/54/bchpg7k13p71_m0pwn00qxwr0000gn/T/plugin2938220287 network=unix timestamp=2023-06-05T17:47:59.091+0200
2023-06-05T17:47:59.139+0200 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/ciscoise/ciscoise\"]" changed the config value, but that value is unused
2023-06-05T17:47:59.140+0200 [DEBUG] Resource instance state not found for node "data.ciscoise_network_access_policy_set.example", instance data.ciscoise_network_access_policy_set.example
2023-06-05T17:47:59.140+0200 [DEBUG] ReferenceTransformer: "data.ciscoise_network_access_policy_set.example" references: []
2023-06-05T17:47:59.141+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: 2023/06/05 17:47:59 [DEBUG] Selecting method. Method 1 []: timestamp=2023-06-05T17:47:59.141+0200
2023-06-05T17:47:59.141+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: 2023/06/05 17:47:59 [DEBUG] Selecting method. Method 2 [false]: timestamp=2023-06-05T17:47:59.141+0200
2023-06-05T17:47:59.141+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: 2023/06/05 17:47:59 [DEBUG] Selected method: GetNetworkAccessPolicySets: timestamp=2023-06-05T17:47:59.141+0200
2023-06-05T17:47:59.627+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: 2023/06/05 17:47:59 [DEBUG] [RESTY] 
==============================================================================
~~~ REQUEST ~~~
GET  /api/v1/policy/network-access/policy-set  HTTP/1.1
HOST   : 10.48.35.230:443
HEADERS:
    Accept: application/json
    Authorization: Basic YWRtaW46RGV2bmV0LjEyMzQ=
    Content-Type: application/json
    User-Agent: go-resty/2.7.0 (https://github.com/go-resty/resty)
BODY   :
***** NO CONTENT *****
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS       : 200 
PROTO        : HTTP/1.1
RECEIVED AT  : 2023-06-05T17:47:59.627012+02:00
TIME DURATION: 485.100375ms
HEADERS      :
    Cache-Control: no-cache, no-store, must-revalidate
    Connection: keep-alive
    Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;
    Content-Type: application/json
    Date: Mon, 05 Jun 2023 15:43:38 GMT
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Pragma: no-cache
    Server:
    Set-Cookie: JSESSIONIDSSO=224FF5EF9F68CF67AFFC46D204DBC923; Path=/; Secure; HttpOnly, APPSESSIONID=622310DBE913EE7203C50BD7AA710EAE; Path=/api; Secure; HttpOnly
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    Vary: accept-encoding
    X-Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-Request-Id: bdb15cc0-03b7-11ee-9782-52440e95fa07
    X-Webkit-Csp: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;
    X-Xss-Protection: 1; mode=block
BODY         :
{
   "version": "1.0.0",
   "response": [
      {
         "default": false,
         "id": "a3ed2780-6458-455f-8835-34a01218aeba",
         "name": "New Policy Set 4",
         "description": "My policy set 4",
         "hitCounts": 0,
         "rank": 0,
         "state": "enabled",
         "condition": {
            "link": null,
            "conditionType": "ConditionAndBlock",
            "isNegate": false,
            "children": [
               {
                  "link": null,
                  "conditionType": "ConditionReference",
                  "isNegate": false,
                  "name": "Condition_4",
                  "id": "715c80c0-19e7-45e7-9f10-678674e06f77",
                  "description": "Condition_4"
               },
               {
                  "link": null,
                  "conditionType": "ConditionReference",
                  "isNegate": false,
                  "name": "Condition_5",
                  "id": "cdcaef32-b9a5-4575-9da9-fef776acf278",
                  "description": "Condition_5"
               },
               {
                  "link": null,
                  "conditionType": "ConditionReference",
                  "isNegate": false,
                  "name": "Switch_Local_Web_Authentication",
                  "id": "4c162a13-6f18-43f5-81af-aa973a2b7b6e",
                  "description": "A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches"
               }
            ]
         },
         "serviceName": "Default Network Access",
         "isProxy": false,
         "link": {
            "rel": "self",
            "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/a3ed2780-6458-455f-8835-34a01218aeba",
            "type": "application/json"
         }
      },
      {
         "default": false,
         "id": "d5376d79-5e76-476f-8bbe-eed7bfa3204d",
         "name": "New Policy Set 3",
         "description": "My policy set 3",
         "hitCounts": 0,
         "rank": 1,
         "state": "enabled",
         "condition": {
            "link": null,
            "conditionType": "ConditionReference",
            "isNegate": false,
            "name": "Switch_Local_Web_Authentication",
            "id": "4c162a13-6f18-43f5-81af-aa973a2b7b6e",
            "description": "A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches"
         },
         "serviceName": "Default Network Access",
         "isProxy": false,
         "link": {
            "rel": "self",
            "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/d5376d79-5e76-476f-8bbe-eed7bfa3204d",
            "type": "application/json"
         }
      },
      {
         "default": false,
         "id": "bd6ce264-c34c-4c53-a12a-2460a7a3e005",
         "name": "New Policy Set 1",
         "description": null,
         "hitCounts": 0,
         "rank": 2,
         "state": "enabled",
         "condition": {
            "link": null,
            "conditionType": "ConditionReference",
            "isNegate": false,
            "name": "Switch_Local_Web_Authentication",
            "id": "4c162a13-6f18-43f5-81af-aa973a2b7b6e",
            "description": "A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches"
         },
         "serviceName": "Default Network Access",
         "isProxy": false,
         "link": {
            "rel": "self",
            "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/bd6ce264-c34c-4c53-a12a-2460a7a3e005",
            "type": "application/json"
         }
      },
      {
         "default": true,
         "id": "b4278d98-8750-4d00-bacb-b2cc63bfe569",
         "name": "Default",
         "description": "Default policy set",
         "hitCounts": 0,
         "rank": 3,
         "state": "enabled",
         "condition": null,
         "serviceName": "Default Network Access",
         "isProxy": false,
         "link": {
            "rel": "self",
            "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/b4278d98-8750-4d00-bacb-b2cc63bfe569",
            "type": "application/json"
         }
      }
   ]
}
==============================================================================: timestamp=2023-06-05T17:47:59.627+0200
2023-06-05T17:47:59.628+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: 2023/06/05 17:47:59 [DEBUG] Retrieved response {"response":[{"condition":{"conditionType":"ConditionAndBlock","isNegate":false,"children":[{"conditionType":"ConditionReference","isNegate":false,"id":"715c80c0-19e7-45e7-9f10-678674e06f77"},{"conditionType":"ConditionReference","isNegate":false,"id":"cdcaef32-b9a5-4575-9da9-fef776acf278"},{"conditionType":"ConditionReference","isNegate":false,"id":"4c162a13-6f18-43f5-81af-aa973a2b7b6e"}]},"default":false,"description":"My policy set 4","hitCounts":0,"id":"a3ed2780-6458-455f-8835-34a01218aeba","isProxy":false,"link":{"href":"https://10.48.35.230/api/v1/policy/network-access/policy-set/a3ed2780-6458-455f-8835-34a01218aeba","rel":"self","type":"application/json"},"name":"New Policy Set 4","rank":0,"serviceName":"Default Network Access","state":"enabled"},{"condition":{"conditionType":"ConditionReference","isNegate":false,"description":"A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches","id":"4c162a13-6f18-43f5-81af-aa973a2b7b6e","name":"Switch_Local_Web_Authentication"},"default":false,"description":"My policy set 3","hitCounts":0,"id":"d5376d79-5e76-476f-8bbe-eed7bfa3204d","isProxy":false,"link":{"href":"https://10.48.35.230/api/v1/policy/network-access/policy-set/d5376d79-5e76-476f-8bbe-eed7bfa3204d","rel":"self","type":"application/json"},"name":"New Policy Set 3","rank":1,"serviceName":"Default Network Access","state":"enabled"},{"condition":{"conditionType":"ConditionReference","isNegate":false,"description":"A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches","id":"4c162a13-6f18-43f5-81af-aa973a2b7b6e","name":"Switch_Local_Web_Authentication"},"default":false,"hitCounts":0,"id":"bd6ce264-c34c-4c53-a12a-2460a7a3e005","isProxy":false,"link":{"href":"https://10.48.35.230/api/v1/policy/network-access/policy-set/bd6ce264-c34c-4c53-a12a-2460a7a3e005","rel":"self","type":"application/json"},"name":"New Policy Set 1","rank":2,"serviceName":"Default Network Access","state":"enabled"},{"default":true,"description":"Default policy set","hitCounts":0,"id":"b4278d98-8750-4d00-bacb-b2cc63bfe569","isProxy":false,"link":{"href":"https://10.48.35.230/api/v1/policy/network-access/policy-set/b4278d98-8750-4d00-bacb-b2cc63bfe569","rel":"self","type":"application/json"},"name":"Default","rank":3,"serviceName":"Default Network Access","state":"enabled"}],"version":"1.0.0"}: timestamp=2023-06-05T17:47:59.627+0200
2023-06-05T17:47:59.628+0200 [INFO]  provider.terraform-provider-ciscoise_v0.6.18-beta: 2023/06/05 17:47:59 [ERROR] setting state: Invalid address to set: []string{"items", "0", "condition", "0", "children", "0", "id"}: timestamp=2023-06-05T17:47:59.627+0200
2023-06-05T17:47:59.628+0200 [ERROR] provider.terraform-provider-ciscoise_v0.6.18-beta: Response contains error diagnostic: diagnostic_severity=ERROR tf_proto_version=5.3 @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto diagnostic_detail="Invalid address to set: []string{"items", "0", "condition", "0", "children", "0", "id"}" diagnostic_summary="Failure when setting GetNetworkAccessPolicySets response" tf_data_source_type=ciscoise_network_access_policy_set tf_provider_addr=provider tf_req_id=a960ed2e-467b-40aa-97b8-10c7673915b4 tf_rpc=ReadDataSource timestamp=2023-06-05T17:47:59.628+0200
2023-06-05T17:47:59.628+0200 [ERROR] vertex "data.ciscoise_network_access_policy_set.example" error: Failure when setting GetNetworkAccessPolicySets response
2023-06-05T17:47:59.628+0200 [ERROR] vertex "data.ciscoise_network_access_policy_set.example (expand)" error: Failure when setting GetNetworkAccessPolicySets response
2023-06-05T17:47:59.628+0200 [INFO]  backend/local: plan operation completed
2023-06-05T17:47:59.640+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-06-05T17:47:59.641+0200 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.18-beta/darwin_arm64/terraform-provider-ciscoise_v0.6.18-beta pid=64124
2023-06-05T17:47:59.641+0200 [DEBUG] provider: plugin exited

CURL

curl -X GET "https://10.48.35.230:443/api/v1/policy/network-access/policy-set" -H "accept: application/json"

Response BODY

{
  "version": "1.0.0",
  "response": [
    {
      "default": false,
      "id": "a3ed2780-6458-455f-8835-34a01218aeba",
      "name": "New Policy Set 4",
      "description": "My policy set 4",
      "hitCounts": 0,
      "rank": 0,
      "state": "enabled",
      "condition": {
        "link": null,
        "conditionType": "ConditionAndBlock",
        "isNegate": false,
        "children": [
          {
            "link": null,
            "conditionType": "ConditionReference",
            "isNegate": false,
            "name": "Condition_4",
            "id": "715c80c0-19e7-45e7-9f10-678674e06f77",
            "description": "Condition_4"
          },
          {
            "link": null,
            "conditionType": "ConditionReference",
            "isNegate": false,
            "name": "Condition_5",
            "id": "cdcaef32-b9a5-4575-9da9-fef776acf278",
            "description": "Condition_5"
          },
          {
            "link": null,
            "conditionType": "ConditionReference",
            "isNegate": false,
            "name": "Switch_Local_Web_Authentication",
            "id": "4c162a13-6f18-43f5-81af-aa973a2b7b6e",
            "description": "A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches"
          }
        ]
      },
      "serviceName": "Default Network Access",
      "isProxy": false,
      "link": {
        "rel": "self",
        "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/a3ed2780-6458-455f-8835-34a01218aeba",
        "type": "application/json"
      }
    },
    {
      "default": false,
      "id": "d5376d79-5e76-476f-8bbe-eed7bfa3204d",
      "name": "New Policy Set 3",
      "description": "My policy set 3",
      "hitCounts": 0,
      "rank": 1,
      "state": "enabled",
      "condition": {
        "link": null,
        "conditionType": "ConditionReference",
        "isNegate": false,
        "name": "Switch_Local_Web_Authentication",
        "id": "4c162a13-6f18-43f5-81af-aa973a2b7b6e",
        "description": "A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches"
      },
      "serviceName": "Default Network Access",
      "isProxy": false,
      "link": {
        "rel": "self",
        "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/d5376d79-5e76-476f-8bbe-eed7bfa3204d",
        "type": "application/json"
      }
    },
    {
      "default": false,
      "id": "bd6ce264-c34c-4c53-a12a-2460a7a3e005",
      "name": "New Policy Set 1",
      "description": null,
      "hitCounts": 0,
      "rank": 2,
      "state": "enabled",
      "condition": {
        "link": null,
        "conditionType": "ConditionReference",
        "isNegate": false,
        "name": "Switch_Local_Web_Authentication",
        "id": "4c162a13-6f18-43f5-81af-aa973a2b7b6e",
        "description": "A condition to match authentication requests for Local Web Authentication from Cisco Catalyst Switches"
      },
      "serviceName": "Default Network Access",
      "isProxy": false,
      "link": {
        "rel": "self",
        "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/bd6ce264-c34c-4c53-a12a-2460a7a3e005",
        "type": "application/json"
      }
    },
    {
      "default": true,
      "id": "b4278d98-8750-4d00-bacb-b2cc63bfe569",
      "name": "Default",
      "description": "Default policy set",
      "hitCounts": 0,
      "rank": 3,
      "state": "enabled",
      "condition": null,
      "serviceName": "Default Network Access",
      "isProxy": false,
      "link": {
        "rel": "self",
        "href": "https://10.48.35.230/api/v1/policy/network-access/policy-set/b4278d98-8750-4d00-bacb-b2cc63bfe569",
        "type": "application/json"
      }
    }
  ]
}

Environment (please complete the following information):

fmunozmiranda commented 1 year ago

Hey @KubaMazurkiewicz , plese try it again with new provider version and let us know if it works for you now.

KubaMazurkiewicz commented 1 year ago

Hey @fmunozmiranda with v0.6.19-beta im getting different error now:

terraform plan                             
data.ciscoise_network_access_policy_set.example: Reading...

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Failure when setting GetNetworkAccessPolicySets response
│ 
│   with data.ciscoise_network_access_policy_set.example,
│   on [main.tf](https://main.tf/) line 10, in data "ciscoise_network_access_policy_set" "example":
│   10: data "ciscoise_network_access_policy_set" "example" {
│ 
│ Invalid address to set: []string{"items", "0", "rank"}
╵
fmunozmiranda commented 1 year ago

@KubaMazurkiewicz please try it again with 0.6.20-beta and let us know how does it go.

KubaMazurkiewicz commented 1 year ago

@fmunozmiranda with 0.6.20-beta it works fine. Thanks