IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
338 stars 662 forks source link

Terraform state is no longer consistent after setting boot volume to not be deleted on instance delete. #4324

Open dprosper opened 1 year ago

dprosper commented 1 year ago

Community Note

Terraform CLI and Terraform IBM Provider Version

$ terraform -v
Terraform v1.3.5
on windows_amd64
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/hashicorp/tls v4.0.4
+ provider registry.terraform.io/ibm-cloud/ibm v1.50.0

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please share a link to the ZIP file.
resource "ibm_is_instance" "vsi_app" {
  count          = 1
  name           = "${var.resources_prefix}-vsi-${count.index + 1}"
  vpc            = ibm_is_vpc.vpc.id
  zone           = "${var.vpc_region}-${count.index + 1}"
  keys           = var.vpc_ssh_key
  image          = data.ibm_is_image.app_image_name.id
  profile        = var.vpc_app_image_profile
  resource_group = data.ibm_resource_group.group.id

  boot_volume {
    name               = "save-boot"
    auto_delete_volume = false
  }

  primary_network_interface {
    subnet          = element(ibm_is_subnet.sub_app.*.id, count.index)
    security_groups = [ibm_is_security_group.sg_maintenance.id]
  }
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior / Actual Behavior

When deleting the VSI (setting the count = 0) the VSI is deleted as expected, and the boot volume is NOT deleted as expected. However, what is NOT expected is the terraform.state file no longer contains ANY reference to the boot volume. The boot volume continues to exist in my account (which I expect), but the Terraform state file no longer contains that information.

Steps to Reproduce

  1. terraform apply
  2. review the terraform.state file and notice the boot_volume is in the state file.
  3. set the is_instance count to 0
  4. terraform apply
  5. validate using the VPC UI that the boot_volume that was created during the first terraform apply is still available, however the terraform.state file no longer contains it.

Important Factoids

N/A

References

ujjwal-ibm commented 1 year ago

looking into it