IBM-Cloud / terraform-provider-ibm

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

ibm_is_volume continually plans to set catalog_offering but does not #5512

Open davesteinberg opened 1 month ago

davesteinberg commented 1 month ago

Community Note

Terraform CLI and Terraform IBM Provider Version

$ terraform -v
Terraform v1.5.7
on darwin_amd64
+ provider registry.terraform.io/ibm-cloud/ibm v1.67.1

Affected Resource(s)

Terraform Configuration Files

The following simple Terraform creates a VPC block storage volume.

terraform {
  required_version = "~>1.5"

  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      version = "~>1.67.1"
    }
  }
}

provider "ibm" {
  ibmcloud_api_key = var.ibmcloud_api_key
  region           = var.region
}

variable "ibmcloud_api_key" {
  description = "API key for use by this Terraform module."
  type        = string
  sensitive   = true
}

variable "region" {
  description = "Region where resources will be provisioned."
  type        = string
  default     = "ca-tor"
}

variable "prefix" {
  description = "Name prefix for common resources."
  type        = string
  default     = "bug"
}

# Resource group
resource "ibm_resource_group" "rg" {
  name = var.prefix
}

resource "ibm_is_volume" "volume" {
  name           = "${var.prefix}-volume"
  resource_group = ibm_resource_group.rg.id
  zone           = "${var.region}-1"
  capacity       = 100
  profile        = "general-purpose"
}

The problem is that the plan for this Terraform shows that it will set catalog_offering to a value known after apply, but after applying, it is null in the terraform.tfstate. Next time you plan, it wants to set catalog_offering again. You can apply indefinitely, but the planned state is never in sync with the actual state.

Steps to Reproduce

  1. Create a terraform.tfvars with an ibmcloud_api_key for your account.
  2. Run terraform init.
  3. Run terraform apply.
  4. Run terraform plan.

Expected Behavior

The apply correctly creates the resources. The subsequent plan shows no actions.

Actual Behavior

The subsequent plan shows an action:

Terraform will perform the following actions:

  # ibm_is_volume.volume will be updated in-place
  ~ resource "ibm_is_volume" "volume" {
      + catalog_offering        = (known after apply)
        id                      = "r038-f3bbc298-bbed-4e9c-8ca3-583edf28838b"
        name                    = "bug-volume"
        tags                    = []
        # (19 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Important Factoids

This problem appeared for me when trying to upgrade from version 1.63.0 of the provider to 1.67.1.

Also, while creating this bug report, I found it extremely slow to refresh state for the volume several times. However, at some point, the performance become more normal.

deepaksibm commented 1 month ago

@sreekarbvibm

deepaksibm commented 1 month ago

@sumitkumartiwari This can be closed