IBM-Cloud / terraform-provider-ibm

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

How to avoid routing table route re-creation each time we plan/apply the config #4397

Open jmereaux opened 1 year ago

jmereaux commented 1 year ago

Community Note

Question

After successfully creating a routing table route (with the sample code below), if I re-run a terraform plan next, the route is deleted / re-created because the creator attribute has to be modified. I would expect there would be no change. Is there a way to avoid the route re-creation ?

New or Affected Resource(s) or Datasource(s)

Potential Terraform Configuration

# Resource Group
resource "ibm_resource_group" "resource_group" {
  name = var.prefix
}

# VPC
resource "ibm_is_vpc" "vpc" {
  name                        = "${var.prefix}-vpc"
  resource_group              = ibm_resource_group.resource_group.id
  default_network_acl_name    = "${var.prefix}-acl0"
  default_security_group_name = "${var.prefix}-sg0"
  default_routing_table_name  = "${var.prefix}-rt0"
}

# Dummy route in the VPC default routing table
resource "ibm_is_vpc_routing_table_route" "route" {
  vpc           = ibm_is_vpc.vpc.id
  routing_table = ibm_is_vpc.vpc.default_routing_table
  zone          = var.vpc_zone
  name          = "test-route"
  destination   = "192.168.10.0/24"
  action        = "deliver"
  next_hop      = "10.10.11.1"
}
ujjwal-ibm commented 1 year ago

looking into it

ujjwal-ibm commented 1 year ago

fixed #4518 verified, no changes shown now. Will be available with v1.53.0-beta0 onwards

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:

  # ibm_is_vpc.vpc will be created
  + resource "ibm_is_vpc" "vpc" {
      + access_tags                 = (known after apply)
      + address_prefix_management   = "auto"
      + classic_access              = false
      + crn                         = (known after apply)
      + cse_source_addresses        = (known after apply)
      + default_network_acl         = (known after apply)
      + default_network_acl_crn     = (known after apply)
      + default_network_acl_name    = "tfp-test-acl0"
      + default_routing_table       = (known after apply)
      + default_routing_table_name  = "tfp-test-rt0"
      + default_security_group      = (known after apply)
      + default_security_group_crn  = (known after apply)
      + default_security_group_name = "tfp-test-sg0"
      + id                          = (known after apply)
      + name                        = "tfp-test-vpc"
      + resource_controller_url     = (known after apply)
      + resource_crn                = (known after apply)
      + resource_group              = (known after apply)
      + resource_group_name         = (known after apply)
      + resource_name               = (known after apply)
      + resource_status             = (known after apply)
      + security_group              = (known after apply)
      + status                      = (known after apply)
      + subnets                     = (known after apply)
      + tags                        = (known after apply)
    }

  # ibm_is_vpc_routing_table_route.route will be created
  + resource "ibm_is_vpc_routing_table_route" "route" {
      + action          = "deliver"
      + created_at      = (known after apply)
      + creator         = (known after apply)
      + destination     = "192.168.10.0/24"
      + href            = (known after apply)
      + id              = (known after apply)
      + lifecycle_state = (known after apply)
      + name            = "test-route"
      + next_hop        = "10.10.11.1"
      + origin          = (known after apply)
      + priority        = (known after apply)
      + route_id        = (known after apply)
      + routing_table   = (known after apply)
      + vpc             = (known after apply)
      + zone            = "us-south-1"
    }

Plan: 2 to add, 0 to change, 0 to destroy.
ibm_is_vpc.vpc: Creating...
ibm_is_vpc.vpc: Still creating... [10s elapsed]
ibm_is_vpc.vpc: Still creating... [20s elapsed]
ibm_is_vpc.vpc: Creation complete after 23s [id=r006-32373c07-cd72-4b33-b9b7-5183c20b6c6e]
ibm_is_vpc_routing_table_route.route: Creating...
ibm_is_vpc_routing_table_route.route: Creation complete after 2s [id=r006-32373c07-cd72-4b33-b9b7-5183c20b6c6e/r006-0ebf6c23-9c94-4b9d-beff-96c75c78ab8c/r006-7715b666-c2a1-4e17-8a68-9e9e00423112]

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

% terraform plan

ibm_is_vpc.vpc: Refreshing state... [id=r006-32373c07-cd72-4b33-b9b7-5183c20b6c6e]
ibm_is_vpc_routing_table_route.route: Refreshing state... [id=r006-32373c07-cd72-4b33-b9b7-5183c20b6c6e/r006-0ebf6c23-9c94-4b9d-beff-96c75c78ab8c/r006-7715b666-c2a1-4e17-8a68-9e9e00423112]

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.