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

Terraform provider doesn't check for uniqueness when adding MAC addresses #46

Closed netsecprogrammer closed 1 year ago

netsecprogrammer commented 2 years ago

Prerequisites

Describe the bug The terraform provider does not verify that a mac address [endpoint] already exists when creating a resource. What I have noticed is that if I declare a resource in terraform to add a mac address [endpoint] that already exists in the endpoint database, the terraform provider says it successfully added it which is false.

Expected behavior The terraform provider should return the message that I see when I perform the same operation from the API: "title": "Unable to create the endpoint. Endpoint \"00:04:4B:86:40:67\" already exists.",

Screenshots postman-ise

image

Environment (please complete the following information):

Resource code: resource "ciscoise_endpoint" "mydevice" {

provider = ciscoise parameters { description = "Terraform managed" group_id = "0b5a32b0-ad6a-11e9-b12f-a6a2aaa3119d" mac = "00:04:4B:86:40:67" name = "00:04:4B:86:40:67" static_group_assignment = "true" } }

fmunozmiranda commented 2 years ago

Hi @netsecprogrammer, could you please export following env variables and please show me whole answer please? Variables:

Thanks.

netsecprogrammer commented 2 years ago

`Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. user48-mac:terraform-ise-staging user$ terraform apply 2022-08-16T18:57:30.340-0600 [INFO] Terraform version: 1.2.7 2022-08-16T18:57:30.340-0600 [DEBUG] using github.com/hashicorp/go-tfe v1.0.0 2022-08-16T18:57:30.340-0600 [DEBUG] using github.com/hashicorp/hcl/v2 v2.12.0 2022-08-16T18:57:30.340-0600 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 2022-08-16T18:57:30.340-0600 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 2022-08-16T18:57:30.340-0600 [DEBUG] using github.com/zclconf/go-cty v1.10.0 2022-08-16T18:57:30.340-0600 [INFO] Go runtime version: go1.18.1 2022-08-16T18:57:30.340-0600 [INFO] CLI args: []string{"terraform", "apply"} 2022-08-16T18:57:30.340-0600 [DEBUG] Attempting to open CLI config file: /Users/user/.terraformrc 2022-08-16T18:57:30.340-0600 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2022-08-16T18:57:30.340-0600 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2022-08-16T18:57:30.340-0600 [DEBUG] ignoring non-existing provider search directory /Users/user/.terraform.d/plugins 2022-08-16T18:57:30.340-0600 [DEBUG] ignoring non-existing provider search directory /Users/user/Library/Application Support/io.terraform/plugins 2022-08-16T18:57:30.340-0600 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins 2022-08-16T18:57:30.340-0600 [INFO] CLI command args: []string{"apply"} 2022-08-16T18:57:30.343-0600 [DEBUG] New state was assigned lineage "83a939b6-29ca-95b2-96f3-11bf6ee24178" 2022-08-16T18:57:30.446-0600 [DEBUG] checking for provisioner in "." 2022-08-16T18:57:30.447-0600 [DEBUG] checking for provisioner in "/usr/local/bin" 2022-08-16T18:57:30.448-0600 [INFO] backend/local: starting Apply operation 2022-08-16T18:57:30.451-0600 [DEBUG] created provider logger: level=debug 2022-08-16T18:57:30.451-0600 [INFO] provider: configuring client automatic mTLS 2022-08-16T18:57:30.470-0600 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta args=[.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta] 2022-08-16T18:57:30.474-0600 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64138 2022-08-16T18:57:30.474-0600 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta 2022-08-16T18:57:30.485-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: configuring server automatic mTLS: timestamp=2022-08-16T18:57:30.485-0600 2022-08-16T18:57:30.504-0600 [DEBUG] provider: using plugin: version=5 2022-08-16T18:57:30.504-0600 [DEBUG] provider.terraform-provider-ciscoise_v0.6.4-beta: plugin address: network=unix address=/var/folders/hn/vb99_75j3t74v6zsr98plw9s081d33/T/plugin4294144804 timestamp=2022-08-16T18:57:30.504-0600 2022-08-16T18:57:30.595-0600 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2022-08-16T18:57:30.597-0600 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64138 2022-08-16T18:57:30.597-0600 [DEBUG] provider: plugin exited 2022-08-16T18:57:30.597-0600 [DEBUG] Building and walking validate graph 2022-08-16T18:57:30.598-0600 [DEBUG] ProviderTransformer: "ciscoise_endpoint.mydevice" (terraform.NodeValidatableResource) needs provider["registry.terraform.io/ciscoise/ciscoise"] 2022-08-16T18:57:30.598-0600 [DEBUG] ReferenceTransformer: "var.IOT_CRUD_DEVICES" references: [] 2022-08-16T18:57:30.598-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_ids" references: [] 2022-08-16T18:57:30.598-0600 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/ciscoise/ciscoise\"]" references: [] 2022-08-16T18:57:30.598-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice" references: [] 2022-08-16T18:57:30.598-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_names" references: [] 2022-08-16T18:57:30.598-0600 [DEBUG] Starting graph walk: walkValidate 2022-08-16T18:57:30.598-0600 [DEBUG] created provider logger: level=debug 2022-08-16T18:57:30.598-0600 [INFO] provider: configuring client automatic mTLS 2022-08-16T18:57:30.617-0600 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta args=[.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta] 2022-08-16T18:57:30.622-0600 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64139 2022-08-16T18:57:30.622-0600 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta 2022-08-16T18:57:30.636-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: configuring server automatic mTLS: timestamp=2022-08-16T18:57:30.635-0600 2022-08-16T18:57:30.655-0600 [DEBUG] provider: using plugin: version=5 2022-08-16T18:57:30.655-0600 [DEBUG] provider.terraform-provider-ciscoise_v0.6.4-beta: plugin address: address=/var/folders/hn/vb99_75j3t74v6zsr98plw9s081d33/T/plugin2145390281 network=unix timestamp=2022-08-16T18:57:30.655-0600 2022-08-16T18:57:30.772-0600 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2022-08-16T18:57:30.774-0600 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64139 2022-08-16T18:57:30.774-0600 [DEBUG] provider: plugin exited 2022-08-16T18:57:30.774-0600 [INFO] backend/local: apply calling Plan 2022-08-16T18:57:30.774-0600 [DEBUG] Building and walking plan graph for NormalMode 2022-08-16T18:57:30.774-0600 [DEBUG] ProviderTransformer: "ciscoise_endpoint.mydevice (expand)" (terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/ciscoise/ciscoise"] 2022-08-16T18:57:30.774-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice (expand)" references: [] 2022-08-16T18:57:30.774-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_ids" references: [] 2022-08-16T18:57:30.774-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_names" references: [] 2022-08-16T18:57:30.774-0600 [DEBUG] ReferenceTransformer: "var.IOT_CRUD_DEVICES" references: [] 2022-08-16T18:57:30.774-0600 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/ciscoise/ciscoise\"]" references: [] 2022-08-16T18:57:30.774-0600 [DEBUG] Starting graph walk: walkPlan 2022-08-16T18:57:30.774-0600 [DEBUG] created provider logger: level=debug 2022-08-16T18:57:30.774-0600 [INFO] provider: configuring client automatic mTLS 2022-08-16T18:57:30.792-0600 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta args=[.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta] 2022-08-16T18:57:30.796-0600 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64140 2022-08-16T18:57:30.797-0600 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta 2022-08-16T18:57:30.807-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: configuring server automatic mTLS: timestamp=2022-08-16T18:57:30.807-0600 2022-08-16T18:57:30.833-0600 [DEBUG] provider: using plugin: version=5 2022-08-16T18:57:30.833-0600 [DEBUG] provider.terraform-provider-ciscoise_v0.6.4-beta: plugin address: address=/var/folders/hn/vb99_75j3t74v6zsr98plw9s081d33/T/plugin692679349 network=unix timestamp=2022-08-16T18:57:30.831-0600 2022-08-16T18:57:30.970-0600 [DEBUG] Resource instance state not found for node "ciscoise_endpoint.mydevice", instance ciscoise_endpoint.mydevice 2022-08-16T18:57:30.971-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice" references: [] 2022-08-16T18:57:30.971-0600 [DEBUG] refresh: ciscoise_endpoint.mydevice: no state, so not refreshing 2022-08-16T18:57:30.974-0600 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2022-08-16T18:57:30.976-0600 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64140 2022-08-16T18:57:30.976-0600 [DEBUG] provider: plugin exited 2022-08-16T18:57:30.976-0600 [DEBUG] building apply graph to check for errors 2022-08-16T18:57:30.976-0600 [DEBUG] Resource state not found for node "ciscoise_endpoint.mydevice", instance ciscoise_endpoint.mydevice 2022-08-16T18:57:30.977-0600 [DEBUG] ProviderTransformer: "ciscoise_endpoint.mydevice" (terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/ciscoise/ciscoise"] 2022-08-16T18:57:30.977-0600 [DEBUG] ProviderTransformer: "ciscoise_endpoint.mydevice (expand)" (terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/ciscoise/ciscoise"] 2022-08-16T18:57:30.977-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_ids" references: [] 2022-08-16T18:57:30.977-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_names" references: [] 2022-08-16T18:57:30.977-0600 [DEBUG] ReferenceTransformer: "var.IOT_CRUD_DEVICES" references: [] 2022-08-16T18:57:30.977-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice" references: [] 2022-08-16T18:57:30.977-0600 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/ciscoise/ciscoise\"]" references: [] 2022-08-16T18:57:30.977-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice (expand)" references: []

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

ciscoise_endpoint.mydevice will be created

Plan: 1 to add, 0 to change, 0 to destroy. 2022-08-16T18:57:30.977-0600 [DEBUG] command: asking for input: "\nDo you want to perform these actions?"

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

2022-08-16T18:57:32.209-0600 [INFO] backend/local: apply calling Apply 2022-08-16T18:57:32.209-0600 [DEBUG] Building and walking apply graph for NormalMode plan 2022-08-16T18:57:32.209-0600 [DEBUG] Resource state not found for node "ciscoise_endpoint.mydevice", instance ciscoise_endpoint.mydevice 2022-08-16T18:57:32.209-0600 [DEBUG] ProviderTransformer: "ciscoise_endpoint.mydevice" (terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/ciscoise/ciscoise"] 2022-08-16T18:57:32.209-0600 [DEBUG] ProviderTransformer: "ciscoise_endpoint.mydevice (expand)" (terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/ciscoise/ciscoise"] 2022-08-16T18:57:32.209-0600 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/ciscoise/ciscoise\"]" references: [] 2022-08-16T18:57:32.209-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice (expand)" references: [] 2022-08-16T18:57:32.209-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_names" references: [] 2022-08-16T18:57:32.209-0600 [DEBUG] ReferenceTransformer: "var.IOT_CRUD_DEVICES" references: [] 2022-08-16T18:57:32.209-0600 [DEBUG] ReferenceTransformer: "var.allpolicy_set_ids" references: [] 2022-08-16T18:57:32.209-0600 [DEBUG] ReferenceTransformer: "ciscoise_endpoint.mydevice" references: [] 2022-08-16T18:57:32.210-0600 [DEBUG] Starting graph walk: walkApply 2022-08-16T18:57:32.210-0600 [DEBUG] created provider logger: level=debug 2022-08-16T18:57:32.210-0600 [INFO] provider: configuring client automatic mTLS 2022-08-16T18:57:32.229-0600 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta args=[.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta] 2022-08-16T18:57:32.232-0600 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64149 2022-08-16T18:57:32.232-0600 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta 2022-08-16T18:57:32.244-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: configuring server automatic mTLS: timestamp=2022-08-16T18:57:32.243-0600 2022-08-16T18:57:32.262-0600 [DEBUG] provider: using plugin: version=5 2022-08-16T18:57:32.263-0600 [DEBUG] provider.terraform-provider-ciscoise_v0.6.4-beta: plugin address: address=/var/folders/hn/vb99_75j3t74v6zsr98plw9s081d33/T/plugin4243402755 network=unix timestamp=2022-08-16T18:57:32.262-0600 ciscoise_endpoint.mydevice: Creating... 2022-08-16T18:57:32.397-0600 [INFO] Starting apply for ciscoise_endpoint.mydevice 2022-08-16T18:57:32.398-0600 [DEBUG] ciscoise_endpoint.mydevice: applying the planned Create change 2022-08-16T18:57:32.398-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] setting computed for "item" from ComputedKeys: timestamp=2022-08-16T18:57:32.398-0600 2022-08-16T18:57:32.398-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] Beginning Endpoint create: timestamp=2022-08-16T18:57:32.398-0600 2022-08-16T18:57:32.398-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] request sent => {"ERSEndPoint":{"name":"00:04:4B:86:40:67","description":"Terraform managed","mac":"00:04:4B:86:40:67","groupId":"0b5a32b0-ad6a-11e9-b12f-a6a2aaa3119d","staticGroupAssignment":true}}: timestamp=2022-08-16T18:57:32.398-0600 2022-08-16T18:57:32.857-0600 [INFO] provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] [RESTY]


GET  /ers/config/endpoint/name/00:04:4B:86:40:67  HTTP/1.1
HOST   : ise:9060
HEADERS:
        Accept: application/json
        Authorization: Basic ZXJzdXNlcjpiMklyNGRnNTNiWElucUVCdW4xYw==
        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  : 2022-08-16T18:57:32.857389-06:00
TIME DURATION: 458.487767ms
HEADERS      :
        Cache-Control: no-cache, no-store, must-revalidate
        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;charset=utf-8
        Date: Wed, 17 Aug 2022 00:57:32 GMT
        Expires: Thu, 01 Jan 1970 00:00:00 GMT
        Pragma: no-cache
        Server:
        Set-Cookie: JSESSIONIDSSO=F574829C0F4CE2AFB7C14A5BEB152061; Path=/; Secure; HttpOnly, APPSESSIONID=3D3BB1DB6857E70329E1ECA9006286C1; Path=/ers; Secure; HttpOnly
        Strict-Transport-Security: max-age=31536000; includeSubDomains
        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-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         :
{
   "ERSEndPoint": {
      "id": "982dc040-3525-11ec-a9bd-92a157dd7b25",
      "name": "00:04:4B:86:40:67",
      "description": "",
      "mac": "00:04:4B:86:40:67",
      "profileId": "1080b360-1f9e-11e2-96ee-0050568e002d",
      "staticProfileAssignment": false,
      "staticProfileAssignmentDefined": true,
      "groupId": "0b5a32b0-ad6a-11e9-b12f-a6a2aaa3119d",
      "staticGroupAssignment": true,
      "staticGroupAssignmentDefined": true,
      "portalUser": "",
      "identityStore": "",
      "identityStoreId": "",
      "customAttributes": {
         "customAttributes": {
            "Owner": ""
         }
      },
      "link": {
         "rel": "self",
         "href": "https://ise:9060/ers/config/endpoint/name/00:04:4B:86:40:67",
         "type": "application/json"
      }
   }
}
==============================================================================: timestamp=2022-08-16T18:57:32.857-0600
2022-08-16T18:57:32.858-0600 [INFO]  provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] Beginning Endpoint read for id=[name:=00:04:4B:86:40:67]: timestamp=2022-08-16T18:57:32.857-0600
2022-08-16T18:57:32.858-0600 [INFO]  provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] Selecting method. Method 1 [false]: timestamp=2022-08-16T18:57:32.857-0600
2022-08-16T18:57:32.858-0600 [INFO]  provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] Selecting method. Method 2 [true]: timestamp=2022-08-16T18:57:32.857-0600
2022-08-16T18:57:32.858-0600 [INFO]  provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:32 [DEBUG] Selected method: GetEndpointByName: timestamp=2022-08-16T18:57:32.857-0600
2022-08-16T18:57:33.025-0600 [INFO]  provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:33 [DEBUG] [RESTY] 
==============================================================================
~~~ REQUEST ~~~
GET  /ers/config/endpoint/name/00:04:4B:86:40:67  HTTP/1.1
HOST   : ise:9060
HEADERS:
        Accept: application/json
        Authorization: Basic ZXJzdXNlcjpiMklyNGRnNTNiWElucUVCdW4xYw==
        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  : 2022-08-16T18:57:33.024888-06:00
TIME DURATION: 166.949946ms
HEADERS      :
        Cache-Control: no-cache, no-store, must-revalidate
        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;charset=utf-8
        Date: Wed, 17 Aug 2022 00:57:33 GMT
        Expires: Thu, 01 Jan 1970 00:00:00 GMT
        Pragma: no-cache
        Server:
        Strict-Transport-Security: max-age=31536000; includeSubDomains
        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-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         :
{
   "ERSEndPoint": {
      "id": "982dc040-3525-11ec-a9bd-92a157dd7b25",
      "name": "00:04:4B:86:40:67",
      "description": "",
      "mac": "00:04:4B:86:40:67",
      "profileId": "1080b360-1f9e-11e2-96ee-0050568e002d",
      "staticProfileAssignment": false,
      "staticProfileAssignmentDefined": true,
      "groupId": "0b5a32b0-ad6a-11e9-b12f-a6a2aaa3119d",
      "staticGroupAssignment": true,
      "staticGroupAssignmentDefined": true,
      "portalUser": "",
      "identityStore": "",
      "identityStoreId": "",
      "customAttributes": {
         "customAttributes": {
            "Owner": ""
         }
      },
      "link": {
         "rel": "self",
         "href": "https://ise:9060/ers/config/endpoint/name/00:04:4B:86:40:67",
         "type": "application/json"
      }
   }
}
==============================================================================: timestamp=2022-08-16T18:57:33.024-0600
2022-08-16T18:57:33.025-0600 [INFO]  provider.terraform-provider-ciscoise_v0.6.4-beta: 2022/08/16 18:57:33 [DEBUG] Retrieved response {"ERSEndPoint":{"id":"982dc040-3525-11ec-a9bd-92a157dd7b25","name":"00:04:4B:86:40:67","mac":"00:04:4B:86:40:67","profileId":"1080b360-1f9e-11e2-96ee-0050568e002d","staticProfileAssignment":false,"groupId":"0b5a32b0-ad6a-11e9-b12f-a6a2aaa3119d","staticGroupAssignment":true,"customAttributes":{"customAttributes":{"Owner":""}},"link":{"rel":"self","href":"https://ise:9060/ers/config/endpoint/name/00:04:4B:86:40:67","type":"application/json"}}}: timestamp=2022-08-16T18:57:33.025-0600
2022-08-16T18:57:33.026-0600 [WARN]  Provider "provider[\"registry.terraform.io/ciscoise/ciscoise\"]" produced an unexpected new value for ciscoise_endpoint.mydevice, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .parameters[0].static_profile_assignment: was null, but now cty.StringVal("")
      - .parameters[0].id: was null, but now cty.StringVal("")
      - .parameters[0].portal_user: was null, but now cty.StringVal("")
      - .parameters[0].identity_store_id: was null, but now cty.StringVal("")
      - .parameters[0].profile_id: was null, but now cty.StringVal("")
      - .parameters[0].identity_store: was null, but now cty.StringVal("")
ciscoise_endpoint.mydevice: Creation complete after 1s [id=name:=00:04:4B:86:40:67]
2022-08-16T18:57:33.052-0600 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-08-16T18:57:33.055-0600 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ciscoise/ciscoise/0.6.4-beta/darwin_amd64/terraform-provider-ciscoise_v0.6.4-beta pid=64149
2022-08-16T18:57:33.055-0600 [DEBUG] provider: plugin exited

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.`
fmunozmiranda commented 2 years ago

Hey @netsecprogrammer, our provider does not fail to create an existing resource since internally, it does not create it again, but when it exists, it searches for it and loads it to handle it as a resource, if you look at the tfstate file, probably when adding the resource you will have all the data of it accessible.

netsecprogrammer commented 2 years ago

Hi @fmunozmiranda thank you for the quick reply. If I understand you correctly, it sounds like the provider is doing a tf import in the instance it encounters a pre-existing mac address. I did check my tfstate file and as you stated, the resource is in there.

The first issue is I don't know if a mac address is pre-existing ahead of time. The second issue is that the object that already exists in this case, isn't getting modified when the plan is executed. It appears that the provider is importing the existing object into the tfstate and the provider believes it pushed down the settings I have in my resource but that second step where the pre-existing resource needs to be modified isn't happening.

I noticed that if I make a second change to my resource (lets say I update the description), the provider will then recognize that there is a modification and will now push all the modifications. Basically the provider isn't able to do that state import and modify at the same time it appears.

fmunozmiranda commented 1 year ago

Hey @netsecprogrammer , a new functionality in new provider version (0.6.6-beta) has been added for the provider, this consists of an environment variable or provider (enable_auto_import) that enables or disables the autoimport behavior.

Here I leave the documentation.

https://registry.terraform.io/providers/CiscoISE/ciscoise/latest/docs

Here an example

provider "ciscoise" {
  enable_auto_import = "true"
}
resource "ciscoise_endpoint" "example" {
  provider   = ciscoise
  depends_on = [data.ciscoise_endpoint_group.found]
  parameters {
    name                      = "11:22:33:44:55:66"
    description               = "My Test Endpoint 1"
    mac                       = "11:22:33:44:55:66"
    profile_id                = "67a6ca50-edc9-4236-ada4-225559ed54d6"
    group_id                  = "67a6ca50-edc9-4236-ada4-225559ed54d6"
    static_profile_assignment = "false"
    static_group_assignment   = "false"
    portal_user               = "portalUser"
    identity_store            = "identityStore"
    identity_store_id         = "identityStoreId"
    custom_attributes {
      custom_attributes = {
        Authorization = "Internet"
        Owner         = "wilhelm"
        Department    = "Eng"
        Model         = "1111"
        Manufacturer  = "Cisco"
        iPSK          = "abc123"
        Created       = 1234567890
        Expired       = 2134567890
      }
    }
  }
}

In Addition

Now if you run tf file a second time (after tf import), without make any changes on your tf file, if there are differences between your new and old configuration, terraform will update the configuration to the one in the tf file.

Let us know if there is something else we can help you, if there's not, please close issue.


NOTE

Variable default is false, so you may only especify if you want to enable it.


fmunozmiranda commented 1 year ago

Hey @netsecprogrammer if we don't get answer in next 24 hours, this issue will be close due inactivity.

fmunozmiranda commented 1 year ago

Closing due inactivity.