CiscoISE / terraform-provider-ciscoise

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

Resource ciscoise_network_access_policy_set fails #51

Closed wiwa1978 closed 1 year ago

wiwa1978 commented 1 year ago

Prerequisites

Describe the bug When using ciscoise_network_access_policy_set resource, Terraform outputs that id and name are not expected.

resource "ciscoise_network_access_policy_set" "example" {
  provider = ciscoise
  parameters {
    condition {
      condition_type = "ConditionReference"
      id             = "898c705e-d80c-4c88-bc2a-f0900488e430"
      is_negate      = "false"
      name           = "My New Condition"
    }
    default      = "false"
    description  = "New Policy Set test 1"
    hit_counts   = 0
    is_proxy     = "false"
    name         = "New Policy Set 1"
    rank         = 0
    service_name = "Default Network Access"
    state        = "disabled"
  }
}

Results in:

terraform plan               
╷
│ Error: Unsupported argument
│ 
│   on network_access_policy_set.tf line 14, in resource "ciscoise_network_access_policy_set" "example":
│   14:       id             = "898c705e-d80c-4c88-bc2a-f0900488e430"
│ 
│ An argument named "id" is not expected here.
╵
╷
│ Error: Unsupported argument
│ 
│   on network_access_policy_set.tf line 16, in resource "ciscoise_network_access_policy_set" "example":
│   16:       name           = "My New Condition"
│ 
│ An argument named "name" is not expected here.

If I remove id and name from the condition, then I would get:

│ Error: Failure when executing CreateNetworkAccessPolicySet
│ 
│   with ciscoise_network_access_policy_set.example,
│   on network_access_policy_set.tf line 9, in resource "ciscoise_network_access_policy_set" "example":
│    9: resource "ciscoise_network_access_policy_set" "example" {
│ 
│ error with operation CreateNetworkAccessPolicySet
│ {
│   "message" : "request has bad input format in the body",
│   "code" : 400
│ }

Expected behavior As per documentation, the id and name are expected attributes, even though they are optional. They should be accepted if passed along.

Environment (please complete the following information):

fmunozmiranda commented 1 year ago

Hey @wiwa1978 do you have some screenshot of a valid API call? Could you pass it?

wiwa1978 commented 1 year ago

It works when using Swagger:

REQUEST: image

RESPONSE image

Cisco ISE UI

image

The equivalent using Terraform is in below code and gives the error:

resource "ciscoise_network_access_policy_set" "example" {
  provider = ciscoise
  parameters {
    condition {
      link           = null
      condition_type = "ConditionReference"
      is_negate      = false
      name           = "Wired_MAB"
      id             = "9aab0da7-e3e3-4cd7-81c2-18c3ebbe6a96"
      description    = "A condition to match MAC Authentication Bypass service based authentication requests from switches, according to the corresponding MAB attributes defined in the device profile."
    }
    description = "New Policy Set test 1"
    is_proxy    = "false"
    link {
      href = "https://{{ISE_IP}}/api/v1/policy/{{protocol}}/policy-set/{{resource-id}}"
      rel  = "self"
      type = "application/json"
    }
    name         = "New Policy Set 1"
    rank         = 0
    service_name = "Default Network Access"
    state        = "disabled"
  }
}

The above Terraform snippet gives the following response:

 terraform apply
╷
│ Error: Unsupported argument
│ 
│   on network_access_policy_set.tf line 16, in resource "ciscoise_network_access_policy_set" "example":
│   16:       name           = "Wired_MAB"
│ 
│ An argument named "name" is not expected here.
╵
╷
│ Error: Unsupported argument
│ 
│   on network_access_policy_set.tf line 17, in resource "ciscoise_network_access_policy_set" "example":
│   17:       id             = "9aab0da7-e3e3-4cd7-81c2-18c3ebbe6a96"
│ 
│ An argument named "id" is not expected here.
╵
╷
│ Error: Unsupported argument
│ 
│   on network_access_policy_set.tf line 18, in resource "ciscoise_network_access_policy_set" "example":
│   18:       description    = "A condition to match MAC Authentication Bypass service based authentication requests from switches, according to the corresponding MAB attributes defined in the device profile."
│ 
│ An argument named "description" is not expected here.
fmunozmiranda commented 1 year ago

Hi @wiwa1978, there's new provider version (v0.6.7) try this again and let us know if it works for you. Here's a valid, terraform file to this resource:

resource "ciscoise_network_access_policy_set" "example" {
  provider = ciscoise
  parameters {
    condition {
      condition_type = "ConditionReference"
      id             = "898c705e-d80c-4c88-bc2a-f0900488e430"
      is_negate      = "false"
      name           = "My New Condition"
    }
    default      = "false"
    description  = "New Policy Set test 1"
    hit_counts   = 0
    is_proxy     = "false"
    name         = "New Policy Set 1"
    rank         = 0
    service_name = "Default Network Access"
    state        = "disabled"
  }
}

Note:

wiwa1978 commented 1 year ago

It works using 0.6.7. I found another issue though which I added as a new issue in Github (issue #53). This issue can be closed.