Skip to content

Acceptance test import verification fails with Terraform 1.14.3 (ImportStateVerify): “Failed state verification, resource with ID … not found” #1255

@Haroon-Dweikat-Ntx

Description

@Haroon-Dweikat-Ntx

Suggested GitHub issue title

Acceptance test import verification fails with Terraform 1.14.3 (ImportStateVerify): “Failed state verification, resource with ID … not found”


Module version

# go list -m github.com/hashicorp/terraform-plugin-sdk/v2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1

Relevant provider source code

We run an acceptance test that creates a resource, then performs terraform import via ImportState with verification enabled. This worked with Terraform v1.2.9, but fails with Terraform v1.14.3 during the import verification step.

func TestAccNutanixSubnet_basic(t *testing.T) {
	r := randIntBetween(31, 40)
	subnetName := fmt.Sprintf("acctest-managed-%d", r)

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { acc.TestAccPreCheck(t) },
		Providers:    acc.TestAccProviders,
		CheckDestroy: testAccCheckNutanixSubnetDestroy,
		Steps: []resource.TestStep{
			{
				Config: testAccNutanixSubnetConfig(r),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckNutanixSubnetExists(resourceNameSubnet),
					resource.TestCheckResourceAttr(resourceNameSubnet, "name", subnetName),
					resource.TestCheckResourceAttr(resourceNameSubnet, "description", "Description of my unit test VLAN"),
				),
			},
			{
				ResourceName:            resourceNameSubnet,
				ImportState:             true,
				ImportStateVerify:       true,
				ImportStateVerifyIgnore: []string{"description"},
			},
		},
	})
}

Terraform Configuration Files

func testAccNutanixSubnetConfig(r int) string {
	return fmt.Sprintf(`
data "nutanix_clusters" "clusters" {}

locals {
	cluster1 = [
	for cluster in data.nutanix_clusters.clusters.entities :
	cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL"
	][0]
}

resource "nutanix_subnet" "acctest-managed" {
  	cluster_uuid = local.cluster1
	name        = "acctest-managed-%[1]d"
	description = "Description of my unit test VLAN"
	vlan_id     = %[1]d
	subnet_type = "VLAN"
	subnet_ip          = "10.250.140.0"
  default_gateway_ip = "10.250.140.1"
  prefix_length = 24
  dhcp_options = {
		boot_file_name   = "bootfile"
		domain_name      = "nutanix"
		tftp_server_name = "10.250.140.200"
	}
	dhcp_domain_name_server_list = ["8.8.8.8", "4.2.2.2"]
	dhcp_domain_search_list      = ["terraform.nutanix.com", "terraform.unit.test.com"]
}
`, r)
}

Expected Behavior

ImportStateVerify should successfully import the resource and verify state (same behavior as with Terraform v1.2.9).

Actual Behavior

With Terraform v1.14.3, the import verification step fails:

Failed state verification, resource with ID terraform-202601061429166713000000c0 not found

The create step succeeds; the failure happens in step 2 (import + verification).

Steps to Reproduce

  1. Ensure Terraform v1.14.3 is installed/active (e.g., via tfenv) and confirm with terraform version.
  2. Run the acceptance test with TF_ACC enabled:
    • TF_ACC=1 go test ./... -run TestAccNutanixSubnet_basic -v
  3. Observe failure during the import verification step.
  4. Switch to Terraform v1.2.9 and rerun the same command.
  5. Observe the test passes with Terraform v1.2.9.

Environment

  • OS: Linux (WSL2) (linux 5.15.150.1-microsoft-standard-WSL2)
  • Terraform: v1.2.9 (pass) vs v1.14.3 (fail)
  • Go: go1.25.3 linux/amd64
  • Additional relevant deps : github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions