terraform-provider-ibm icon indicating copy to clipboard operation
terraform-provider-ibm copied to clipboard

ibm_tg_gateway failed on second execution with tags

Open powellquiring opened this issue 2 years ago • 3 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform IBM Provider Version

(transit_vpc) transit_vpc $ tf version
Terraform v1.3.2
on darwin_amd64

Affected Resource(s)

  • ibm_tg_gateway

Terraform Configuration Files

This is in the context of a large configuration. Here is the relevant section. The debug output below demonstrates that the only perceived change was the tags. There was no change in the tags. Maybe this is another bug that the tags were not initially added to the state?

variable "settings" {}
variable "enterprise_vpc" {}
variable "transit_vpc" {}

locals {
  settings       = var.settings
  transit_vpc    = var.transit_vpc
  enterprise_vpc = var.enterprise_vpc
}

resource "ibm_tg_gateway" "tgw" {
  name           = "${local.settings.basename}-tgw-link"
  location       = local.settings.region
  global         = false
  resource_group = local.settings.resource_group_id
  tags           = local.settings.tags
}

Debug Output

>>> creating resources with terraform in the enterprise_link_tf/ directory
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- terraform.io/builtin/terraform is built in to Terraform
- Reusing previous version of ibm-cloud/ibm from the dependency lock file
- Using previously-installed ibm-cloud/ibm v1.46.0

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
data.terraform_remote_state.spokes: Reading...
data.terraform_remote_state.vpe_spokes: Reading...
data.terraform_remote_state.transit: Reading...
data.terraform_remote_state.enterprise: Reading...
data.terraform_remote_state.config: Reading...
data.terraform_remote_state.vpe_spokes: Read complete after 0s
data.terraform_remote_state.config: Read complete after 0s
data.terraform_remote_state.transit: Read complete after 0s
data.terraform_remote_state.spokes: Read complete after 0s
data.terraform_remote_state.enterprise: Read complete after 0s
module.enterpise_link_tgw[0].ibm_tg_gateway.tgw: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7]
module.enterpise_link_tgw[0].ibm_tg_connection.enterprise_link["enterprise"]: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7/eed2e62c-9d49-4f3e-95e8-52171cef1576]
module.enterpise_link_tgw[0].ibm_tg_connection.enterprise_link["transit"]: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7/1bdb6a73-5608-43d9-b578-2378b3615477]
data.terraform_remote_state.transit: Reading...
data.terraform_remote_state.transit: Read complete after 0s
data.terraform_remote_state.config: Reading...
data.terraform_remote_state.config: Read complete after 0s
data.terraform_remote_state.vpe_spokes: Reading...
data.terraform_remote_state.vpe_spokes: Read complete after 0s
data.terraform_remote_state.enterprise: Reading...
data.terraform_remote_state.enterprise: Read complete after 0s
data.terraform_remote_state.spokes: Reading...
data.terraform_remote_state.spokes: Read complete after 0s
module.enterpise_link_tgw[0].ibm_tg_gateway.tgw: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7]
module.enterpise_link_tgw[0].ibm_tg_connection.enterprise_link["enterprise"]: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7/eed2e62c-9d49-4f3e-95e8-52171cef1576]
module.enterpise_link_tgw[0].ibm_tg_connection.enterprise_link["transit"]: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7/1bdb6a73-5608-43d9-b578-2378b3615477]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.enterpise_link_tgw[0].ibm_tg_gateway.tgw will be updated in-place
  ~ resource "ibm_tg_gateway" "tgw" {
        id                      = "2f16832a-38f1-48c4-ab5e-e744063d6fb7"
        name                    = "tvpc-tgw-link"
      ~ tags                    = [
          + "basename:tvpc",
          + "dir:_Users_pquiring_github.ibm.com_portfolio-solutions_transit_vpc_config_tf",
        ]
        # (12 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
module.enterpise_link_tgw[0].ibm_tg_gateway.tgw: Modifying... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7]
╷
│ Error: The information given was invalid, malformed, or missing a required field.
│
│   with module.enterpise_link_tgw[0].ibm_tg_gateway.tgw,
│   on ../modules/enterprise_link_tgw/enterprise_link_tgw.tf line 11, in resource "ibm_tg_gateway" "tgw":
│   11: resource "ibm_tg_gateway" "tgw" {
│
╵
FAILED

Panic Output

Expected Behavior

It took two applies to demonstrate the bug. The first apply must not have persisted the tags in the state. The second apply demonstrated the bug. A third apply reported no changes (so the apply2 must have changed the tags?).

apply3:

(transit_vpc) enterprise_link_tf $ tfa
data.terraform_remote_state.spokes: Reading...
data.terraform_remote_state.vpe_spokes: Reading...
data.terraform_remote_state.transit: Reading...
data.terraform_remote_state.vpe_spokes: Read complete after 0s
data.terraform_remote_state.config: Reading...
data.terraform_remote_state.enterprise: Reading...
data.terraform_remote_state.config: Read complete after 0s
data.terraform_remote_state.transit: Read complete after 0s
data.terraform_remote_state.enterprise: Read complete after 0s
data.terraform_remote_state.spokes: Read complete after 0s
module.enterpise_link_tgw[0].ibm_tg_gateway.tgw: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7]
module.enterpise_link_tgw[0].ibm_tg_connection.enterprise_link["enterprise"]: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7/eed2e62c-9d49-4f3e-95e8-52171cef1576]
module.enterpise_link_tgw[0].ibm_tg_connection.enterprise_link["transit"]: Refreshing state... [id=2f16832a-38f1-48c4-ab5e-e744063d6fb7/1bdb6a73-5608-43d9-b578-2378b3615477]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Actual Behavior

Steps to Reproduce

A cut down is not currently available. Let me know if you have a problem reproducing this and I can work on a cutdown. I'm currently working in this repo: https://github.ibm.com/portfolio-solutions/transit_vpc

The bug is in https://github.ibm.com/portfolio-solutions/transit_vpc/tree/master/enterprise_link_tf

Important Factoids

References

  • #0000

powellquiring avatar Oct 12 '22 12:10 powellquiring

If you have have problems reproducing this please reach out.

powellquiring avatar Oct 12 '22 12:10 powellquiring

Just ran into this again.

powellquiring avatar Apr 20 '24 14:04 powellquiring

Wrote a simple test to reproduce and could not reproduce.

variable "region" {}
variable "prefix" {}
variable "resource_group" {}

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

/////////////////////////////////////////
data "ibm_resource_group" "group" {
  name = var.resource_group
}


/////////////////////////////////////////
locals {
  settings = {
    basename = var.prefix
    region = var.region
    resource_group_id = data.ibm_resource_group.group.id
    tags = [
          "basename:tvpc",
          "dir:_Users_pquiring_github.ibm.com_portfolio-solutions_transit_vpc_config_tf",
          ]
  }
}

resource "ibm_tg_gateway" "tgw" {
  name           = "${local.settings.basename}-tgw-link"
  location       = local.settings.region
  global         = false
  resource_group = local.settings.resource_group_id
  tags           = local.settings.tags
}

powellquiring avatar Jun 18 '24 15:06 powellquiring