Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not find VM with the ID xxxxxxxxx #1159

Closed
nsharabati opened this issue Mar 22, 2024 · 13 comments · Fixed by #1187
Closed

Can not find VM with the ID xxxxxxxxx #1159

nsharabati opened this issue Mar 22, 2024 · 13 comments · Fixed by #1187
Assignees
Labels
bug Bug

Comments

@nsharabati
Copy link

Describe the bug

Tag should be assigned to the VM with the ID xxxxxxx

However, NSX-T is responding back with "can not find VM with ID xxxxxx", even that the ID appears on the UI.

Reproduction steps

Main.tf:
resource "nsxt_policy_vm_tags" "srv101066" {
instance_id = "42316ee9-71e5-3e69-6651-4088377d8469"
dynamic "tag" {
for_each = var.nsx_t_tags
content {
scope = tag.value
tag = tag.value
}
}
}

Variables.tf:
variable "nsx_t_tags" {
type=list(string)
}

provider.tf:
terraform {
required_providers {
nsxt = {
source = "vmware/nsxt"
version = "3.4.0"
}
}
}
provider "nsxt" {
host = "YYYYYYY"
username = var.username
password = var.password
allow_unverified_ssl = true
max_retries = 2
}

Terraform Version:
Terraform v1.7.3
on windows_386

Expected behavior

Tag should be assigned to the VM with the ID xxxxxxx

However, NSX-T is responding back with "can not find VM with ID xxxxxx", even that the ID appears on the UI.

Additional context

No response

@nsharabati nsharabati added the bug Bug label Mar 22, 2024
@nsharabati
Copy link
Author

Doc1.docx

@annakhm
Copy link
Collaborator

annakhm commented Mar 22, 2024

Hi @nsharabati, which ID are you using? UI displays quite a few different IDs and it can be confusing

@nsharabati
Copy link
Author

Hi @annakhm, i used BIOS & Instance IDs. I had the same error for both IDs.

@annakhm
Copy link
Collaborator

annakhm commented Mar 25, 2024

Could you please post the apply output with verbose debug logs?
TF_LOG="debug"
TF_LOG_PROVIDER_NSX_HTTP="debug"

This would show NSX response and hopefully we'll be able to figure out what goes wrong. Feel free to remove all info that might be confidential from the output, we only need the VM ids.

@nsharabati

This comment was marked as duplicate.

@nsharabati
Copy link
Author

nsharabati commented Mar 26, 2024

@annakhm: Here is the Output as plain text
2024-03-26T09:55:47.088+0100 [INFO] Terraform version: 1.7.3
2024-03-26T09:55:47.269+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.41.0
2024-03-26T09:55:47.269+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.19.1
2024-03-26T09:55:47.269+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-03-26T09:55:47.269+0100 [DEBUG] using github.com/zclconf/go-cty v1.14.1
2024-03-26T09:55:47.269+0100 [INFO] Go runtime version: go1.21.5
2024-03-26T09:55:47.269+0100 [INFO] CLI args: []string{"C:\Program Files\Terraform\terraform.exe", "apply"}
2024-03-26T09:55:47.277+0100 [DEBUG] Attempting to open CLI config file: C:\Users\nsharabati\AppData\Roaming\terraform.rc
2024-03-26T09:55:47.278+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-03-26T09:55:47.279+0100 [INFO] Loading CLI configuration from C:\Users\nsharabati\AppData\Roaming\terraform.d\credentials.tfrc.json
2024-03-26T09:55:47.280+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-03-26T09:55:47.281+0100 [DEBUG] ignoring non-existing provider search directory C:\Users\nsharabati\AppData\Roaming\terraform.d\plugins
2024-03-26T09:55:47.283+0100 [DEBUG] ignoring non-existing provider search directory C:\Users\nsharabati\AppData\Roaming\HashiCorp\Terraform\plugins
2024-03-26T09:55:47.291+0100 [INFO] CLI command args: []string{"apply"}
2024-03-26T09:55:47.295+0100 [DEBUG] New state was assigned lineage "0a7293d2-d3cf-2775-612e-b8a6f8804aff"
2024-03-26T09:55:47.689+0100 [DEBUG] checking for provisioner in "."
2024-03-26T09:55:47.691+0100 [DEBUG] checking for provisioner in "C:\Program Files\Terraform"
2024-03-26T09:55:47.693+0100 [INFO] backend/local: starting Apply operation
2024-03-26T09:55:47.757+0100 [DEBUG] backend/local: will prompt for input of unset required variables [nsx_t_tags]
2024-03-26T09:55:47.758+0100 [DEBUG] command: asking for input: "var.nsx_t_tags"
var.nsx_t_tags
Enter a value: ["TEST"]

2024-03-26T09:55:52.135+0100 [DEBUG] created provider logger: level=debug
2024-03-26T09:55:52.135+0100 [INFO] provider: configuring client automatic mTLS
2024-03-26T09:55:52.427+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe args=[".terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe"]
2024-03-26T09:55:52.433+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=9048
2024-03-26T09:55:52.433+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe
2024-03-26T09:55:52.668+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: configuring server automatic mTLS: timestamp="2024-03-26T09:55:52.478+0100"
2024-03-26T09:55:52.973+0100 [DEBUG] provider: using plugin: version=5
2024-03-26T09:55:52.973+0100 [DEBUG] provider.terraform-provider-nsxt_v3.4.0.exe: plugin address: address=127.0.0.1:10000 network=tcp timestamp="2024-03-26T09:55:52.972+0100"
2024-03-26T09:55:53.213+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-03-26T09:55:53.247+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=9048
2024-03-26T09:55:53.248+0100 [DEBUG] provider: plugin exited
2024-03-26T09:55:53.249+0100 [DEBUG] Building and walking validate graph
2024-03-26T09:55:53.250+0100 [DEBUG] ProviderTransformer: "nsxt_policy_vm_tags.srv101066" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/vmware/nsxt"]
2024-03-26T09:55:53.251+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066" references: [var.nsx_t_tags]
2024-03-26T09:55:53.252+0100 [DEBUG] ReferenceTransformer: "var.username" references: []
2024-03-26T09:55:53.252+0100 [DEBUG] ReferenceTransformer: "var.password" references: []
2024-03-26T09:55:53.252+0100 [DEBUG] ReferenceTransformer: "var.nsx_t_tags" references: []
2024-03-26T09:55:53.252+0100 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/vmware/nsxt"]" references: [var.username var.password]
2024-03-26T09:55:53.253+0100 [DEBUG] Starting graph walk: walkValidate
2024-03-26T09:55:53.254+0100 [DEBUG] created provider logger: level=debug
2024-03-26T09:55:53.255+0100 [INFO] provider: configuring client automatic mTLS
2024-03-26T09:55:53.371+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe args=[".terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe"]
2024-03-26T09:55:53.377+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=17240
2024-03-26T09:55:53.377+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe
2024-03-26T09:55:53.605+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: configuring server automatic mTLS: timestamp="2024-03-26T09:55:53.418+0100"
2024-03-26T09:55:53.922+0100 [DEBUG] provider: using plugin: version=5
2024-03-26T09:55:53.922+0100 [DEBUG] provider.terraform-provider-nsxt_v3.4.0.exe: plugin address: address=127.0.0.1:10000 network=tcp timestamp="2024-03-26T09:55:53.922+0100"
2024-03-26T09:55:54.197+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-03-26T09:55:54.245+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=17240
2024-03-26T09:55:54.246+0100 [DEBUG] provider: plugin exited
2024-03-26T09:55:54.247+0100 [INFO] backend/local: apply calling Plan
2024-03-26T09:55:54.248+0100 [DEBUG] Building and walking plan graph for NormalMode
2024-03-26T09:55:54.249+0100 [DEBUG] ProviderTransformer: "nsxt_policy_vm_tags.srv101066 (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/vmware/nsxt"]
2024-03-26T09:55:54.250+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066 (expand)" references: [var.nsx_t_tags]
2024-03-26T09:55:54.251+0100 [DEBUG] ReferenceTransformer: "var.username" references: []
2024-03-26T09:55:54.251+0100 [DEBUG] ReferenceTransformer: "var.password" references: []
2024-03-26T09:55:54.252+0100 [DEBUG] ReferenceTransformer: "var.nsx_t_tags" references: []
2024-03-26T09:55:54.252+0100 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/vmware/nsxt"]" references: [var.password var.username]
2024-03-26T09:55:54.253+0100 [DEBUG] Starting graph walk: walkPlan
2024-03-26T09:55:54.254+0100 [DEBUG] created provider logger: level=debug
2024-03-26T09:55:54.254+0100 [INFO] provider: configuring client automatic mTLS
2024-03-26T09:55:54.375+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe args=[".terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe"]
2024-03-26T09:55:54.381+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=3812
2024-03-26T09:55:54.381+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe
2024-03-26T09:55:54.611+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: configuring server automatic mTLS: timestamp="2024-03-26T09:55:54.425+0100"
2024-03-26T09:55:54.917+0100 [DEBUG] provider: using plugin: version=5
2024-03-26T09:55:54.918+0100 [DEBUG] provider.terraform-provider-nsxt_v3.4.0.exe: plugin address: network=tcp address=127.0.0.1:10000 timestamp="2024-03-26T09:55:54.917+0100"
2024-03-26T09:55:55.183+0100 [WARN] ValidateProviderConfig from "provider["registry.terraform.io/vmware/nsxt"]" changed the config value, but that value is unused
2024-03-26T09:55:55.540+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 [INFO]: Session headers configured for policy objects: timestamp="2024-03-26T09:55:55.540+0100"
2024-03-26T09:55:55.541+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 [INFO]: Session headers configured for policy objects: timestamp="2024-03-26T09:55:55.540+0100"
2024-03-26T09:55:55.542+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 SecurityContext schemeID is: %!(EXTRA *string=0x137d8438): timestamp="2024-03-26T09:55:55.540+0100"
2024-03-26T09:55:55.544+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 Invoking action: "GET" and url:
2024-03-26T09:55:55.545+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 Issuing request towards NSX:

Content-Type: application/json Cookie: JSESSIONID=FEEF4B4F5EBBC0D98759AE721FF5359E; Vapi-Ctx-Opid: 598f1540-67bc-41ba-99c1-122c00283f0f X-Xsrf-Token: db77144c-bfa2-4ad5-af2d-68646e8b957c Accept-Encoding: gzip

{}: timestamp="2024-03-26T09:55:55.541+0100"
2024-03-26T09:55:55.984+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 Received NSX response:
HTTP/1.1 200
Content-Length: 85
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json
Date: Tue, 26 Mar 2024 08:55:55 GMT
Expires: 0
Pragma: no-cache
Server: NSX
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Vmw-Task-Id: 43092642-9c85-d22e-4a2b-6ec0f487e6fc_eee26337-11cc-4bee-af7e-6ad4e5f19087
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{
"node_version": "3.1.3.7.0.19380482",
"product_version": "3.1.3.7.0.19380457"
}: timestamp="2024-03-26T09:55:55.984+0100"
2024-03-26T09:55:55.986+0100 [DEBUG] Resource instance state not found for node "nsxt_policy_vm_tags.srv101066", instance nsxt_policy_vm_tags.srv101066
2024-03-26T09:55:55.993+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:55 [DEBUG] NSX version is 3.1.3.7.0.19380482: timestamp="2024-03-26T09:55:55.984+0100"
2024-03-26T09:55:55.996+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066" references: []
2024-03-26T09:55:55.998+0100 [DEBUG] refresh: nsxt_policy_vm_tags.srv101066: no state, so not refreshing
2024-03-26T09:55:56.004+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-03-26T09:55:56.045+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=3812
2024-03-26T09:55:56.046+0100 [DEBUG] provider: plugin exited
2024-03-26T09:55:56.047+0100 [DEBUG] building apply graph to check for errors
2024-03-26T09:55:56.047+0100 [DEBUG] Resource state not found for node "nsxt_policy_vm_tags.srv101066", instance nsxt_policy_vm_tags.srv101066
2024-03-26T09:55:56.049+0100 [DEBUG] ProviderTransformer: "nsxt_policy_vm_tags.srv101066 (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/vmware/nsxt"]
2024-03-26T09:55:56.050+0100 [DEBUG] ProviderTransformer: "nsxt_policy_vm_tags.srv101066" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/vmware/nsxt"]
2024-03-26T09:55:56.051+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066 (expand)" references: [var.nsx_t_tags]
2024-03-26T09:55:56.051+0100 [DEBUG] ReferenceTransformer: "var.username" references: []
2024-03-26T09:55:56.051+0100 [DEBUG] ReferenceTransformer: "var.password" references: []
2024-03-26T09:55:56.052+0100 [DEBUG] ReferenceTransformer: "var.nsx_t_tags" references: []
2024-03-26T09:55:56.053+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066" references: [var.nsx_t_tags]
2024-03-26T09:55:56.053+0100 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/vmware/nsxt"]" references: [var.username var.password]

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

  • create

Terraform will perform the following actions:

nsxt_policy_vm_tags.srv101066 will be created

  • resource "nsxt_policy_vm_tags" "srv101066" {
    • id = (known after apply)

    • instance_id = "42316ee9-71e5-3e69-6651-4088377d8469"

    • tag {

      • scope = "TEST"
      • tag = "TEST"
        }
        }

Plan: 1 to add, 0 to change, 0 to destroy.
2024-03-26T09:55:56.062+0100 [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

2024-03-26T09:55:58.142+0100 [INFO] backend/local: apply calling Apply
2024-03-26T09:55:58.142+0100 [DEBUG] Building and walking apply graph for NormalMode plan
2024-03-26T09:55:58.143+0100 [DEBUG] Resource state not found for node "nsxt_policy_vm_tags.srv101066", instance nsxt_policy_vm_tags.srv101066
2024-03-26T09:55:58.143+0100 [DEBUG] ProviderTransformer: "nsxt_policy_vm_tags.srv101066 (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/vmware/nsxt"]
2024-03-26T09:55:58.144+0100 [DEBUG] ProviderTransformer: "nsxt_policy_vm_tags.srv101066" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/vmware/nsxt"]
2024-03-26T09:55:58.145+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066" references: [var.nsx_t_tags]
2024-03-26T09:55:58.145+0100 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/vmware/nsxt"]" references: [var.password var.username]
2024-03-26T09:55:58.146+0100 [DEBUG] ReferenceTransformer: "nsxt_policy_vm_tags.srv101066 (expand)" references: [var.nsx_t_tags]
2024-03-26T09:55:58.146+0100 [DEBUG] ReferenceTransformer: "var.username" references: []
2024-03-26T09:55:58.146+0100 [DEBUG] ReferenceTransformer: "var.password" references: []
2024-03-26T09:55:58.146+0100 [DEBUG] ReferenceTransformer: "var.nsx_t_tags" references: []
2024-03-26T09:55:58.147+0100 [DEBUG] Starting graph walk: walkApply
2024-03-26T09:55:58.148+0100 [DEBUG] created provider logger: level=debug
2024-03-26T09:55:58.148+0100 [INFO] provider: configuring client automatic mTLS
2024-03-26T09:55:58.261+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe args=[".terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe"]
2024-03-26T09:55:58.267+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=824
2024-03-26T09:55:58.268+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe
2024-03-26T09:55:58.497+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: configuring server automatic mTLS: timestamp="2024-03-26T09:55:58.305+0100"
2024-03-26T09:55:58.801+0100 [DEBUG] provider.terraform-provider-nsxt_v3.4.0.exe: plugin address: address=127.0.0.1:10000 network=tcp timestamp="2024-03-26T09:55:58.800+0100"
2024-03-26T09:55:58.801+0100 [DEBUG] provider: using plugin: version=5
2024-03-26T09:55:59.069+0100 [WARN] ValidateProviderConfig from "provider["registry.terraform.io/vmware/nsxt"]" changed the config value, but that value is unused
2024-03-26T09:55:59.549+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:59 [INFO]: Session headers configured for policy objects: timestamp="2024-03-26T09:55:59.549+0100"
2024-03-26T09:55:59.551+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:59 [INFO]: Session headers configured for policy objects: timestamp="2024-03-26T09:55:59.549+0100"
2024-03-26T09:55:59.553+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:59 SecurityContext schemeID is: %!(EXTRA *string=0x1378a420): timestamp="2024-03-26T09:55:59.549+0100"
2024-03-26T09:55:59.554+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:59 Invoking action:
2024-03-26T09:55:59.555+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:55:59 Issuing request towards NSX:

Content-Length: 2

Content-Type: application/json
Cookie: JSESSIONID=AA8F26E7B5F8268A9F7FFF08D87FF169;
Vapi-Ctx-Opid: f2c7fb32-402e-45ef-a0c8-246382b9e436
X-Xsrf-Token: 6bb5a4ee-51a4-47e0-9996-799e2930169f
Accept-Encoding: gzip

{}: timestamp="2024-03-26T09:55:59.551+0100"
2024-03-26T09:56:00.046+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 Received NSX response:
HTTP/1.1 200
Content-Length: 85
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json
Date: Tue, 26 Mar 2024 08:56:00 GMT
Expires: 0
Pragma: no-cache
Server: NSX
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Vmw-Task-Id: 43092642-9c85-d22e-4a2b-6ec0f487e6fc_69908c45-864e-47ad-971a-af600cc7fa47
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{
"node_version": "3.1.3.7.0.19380482",
"product_version": "3.1.3.7.0.19380457"
}: timestamp="2024-03-26T09:56:00.046+0100"
2024-03-26T09:56:00.050+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 [DEBUG] NSX version is 3.1.3.7.0.19380482: timestamp="2024-03-26T09:56:00.046+0100"
nsxt_policy_vm_tags.srv101066: Creating...
2024-03-26T09:56:00.053+0100 [INFO] Starting apply for nsxt_policy_vm_tags.srv101066
2024-03-26T09:56:00.054+0100 [DEBUG] nsxt_policy_vm_tags.srv101066: applying the planned Create change
2024-03-26T09:56:00.057+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 [INFO]: Session headers configured for policy objects: timestamp="2024-03-26T09:56:00.057+0100"
2024-03-26T09:56:00.057+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 SecurityContext schemeID is: %!(EXTRA *string=0x1378baf8): timestamp="2024-03-26T09:56:00.057+0100"
2024-03-26T09:56:00.058+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 Invoking action: "GET" and url:
2024-03-26T09:56:00.059+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 Issuing request towards NSX:

User-Agent: vAPI/0.7.0 Go/go1.19.13 (windows; 386)
Content-Length: 2

Content-Type: application/json
Cookie: JSESSIONID=AA8F26E7B5F8268A9F7FFF08D87FF169;
Vapi-Ctx-Opid: 8bd368a1-5a50-4dc6-ab3c-86f1669fe304
X-Xsrf-Token: 6bb5a4ee-51a4-47e0-9996-799e2930169f
Accept-Encoding: gzip

{}: timestamp="2024-03-26T09:56:00.057+0100"
2024-03-26T09:56:00.120+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 Received NSX response:
HTTP/1.1 403
Transfer-Encoding: chunked
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json
Date: Tue, 26 Mar 2024 08:55:59 GMT
Expires: 0
Keep-Alive: timeout=60
Pragma: no-cache
Server: NSX
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Vary: accept-encoding
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Nsx-Requestid: fef379a9-fcb1-4948-bfc8-95f26e655035
X-Xss-Protection: 1; mode=block

ee
{
"httpStatus" : "FORBIDDEN",
"error_code" : 401,
"module_name" : "common-services",
"error_message" : "User is not authorized to perform this operation on the application. Please contact the system administrator to get access."
}
0
: timestamp="2024-03-26T09:56:00.120+0100"
2024-03-26T09:56:00.123+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-03-26T09:56:00.127+0100 [INFO] provider.terraform-provider-nsxt_v3.4.0.exe: 2024/03/26 09:56:00 [INFO] Error reading Virtual Machines when looking for ID: 42316ee9-71e5-3e69-6651-4088377d8469: timestamp="2024-03-26T09:56:00.120+0100"
2024-03-26T09:56:00.127+0100 [ERROR] vertex "nsxt_policy_vm_tags.srv101066" error: Cannot find VM with ID 42316ee9-71e5-3e69-6651-4088377d8469

│ Error: Cannot find VM with ID 42316ee9-71e5-3e69-6651-4088377d8469

│ with nsxt_policy_vm_tags.srv101066,
│ on main.tf line 1, in resource "nsxt_policy_vm_tags" "srv101066":
│ 1: resource "nsxt_policy_vm_tags" "srv101066" {


2024-03-26T09:56:00.134+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-03-26T09:56:00.149+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/vmware/nsxt/3.4.0/windows_386/terraform-provider-nsxt_v3.4.0.exe pid=824
2024-03-26T09:56:00.149+0100 [DEBUG] provider: plugin exited
PS C:\Users\nsharabati\Desktop\Terraform\NSX-T-Tag#>

@annakhm
Copy link
Collaborator

annakhm commented Mar 26, 2024

Looks like the user configured in the provider is not authorized to access the VMs. Is this the same user that is able to add VM tags via UI?
In this case error message should be returned by the resource - we will fix that.

@nsharabati
Copy link
Author

@annakhm: Thank you for your response.
With the same user i am able to assign Tag to a VM via UI.

Thanks in advanced.

@annakhm annakhm self-assigned this Apr 12, 2024
@annakhm annakhm linked a pull request Apr 18, 2024 that will close this issue
@nsharabati
Copy link
Author

@annakhm Thank you very much for your efforts.
I have tested the resource again with version 3.6.0, however, i have got the same old error.
Could you please tell me if the Bug is fixed in the Terraform Provider 3.6.0?

I am using this resource and the NSX version is higher than 4.1.1.

@annakhm
Copy link
Collaborator

annakhm commented Apr 24, 2024

@nsharabati sorry, unfortunately the fix was merged a couple of days after the 3.6.0 release. It will be included in 3.6.1

@nsharabati
Copy link
Author

@annakhm when should we expect the version 3.6.1?

@annakhm
Copy link
Collaborator

annakhm commented Apr 25, 2024

early July
If you would like to validate the fix works for your use case, its possible to compile it locally and test (details here)

@annakhm
Copy link
Collaborator

annakhm commented May 3, 2024

Hi @nsharabati, 3.6.1 was released yesterday (earlier than anticipated), the issue should be solved with this release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants