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

Creation of GRE Tunnel using ibm_tg_connection resource fails when remote_bgp_asn parameter is specified #4223

Closed robleyhall closed 1 year ago

robleyhall commented 1 year ago

Community Note

Terraform CLI and Terraform IBM Provider Version

➜  vpc-transit-gateway tf -v
Terraform v1.3.6
on darwin_amd64
+ provider registry.terraform.io/ibm-cloud/ibm v1.48.0
+ provider registry.terraform.io/vmware/vcd v3.8.0
➜  vpc-transit-gateway

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.


terraform {
  required_providers {
    vcd = {
      source = "vmware/vcd"
    }
    ibm = {
       source = "IBM-Cloud/ibm"
       version = "1.48"
     }
  }
}

data "ibm_tg_gateway" "tgw" {
     name="robley-tgw-dal"
     }

resource "ibm_tg_connection" "gre-dir03-1" {
  network_type = "gre_tunnel"
  base_connection_id = "70582a8a-5822-4c07-bd40-6bddb90d4ab5"
  zone = "us-south-1"
  gateway = data.ibm_tg_gateway.tgw.id
  name         = "gre-tunnel-dal10-dir03-1"
  remote_bgp_asn = 65010
  local_gateway_ip = "192.168.195.1"
  local_tunnel_ip = "192.168.173.2"
  remote_gateway_ip = "10.176.179.227"
  remote_tunnel_ip = "192.168.173.1"
}

Debug Output

https://gist.github.com/robleyhall/06c46d9daecad8585fe7bbb9ce2bb597

Panic Output

No crash.log file was produced.

Expected Behavior

The gre tunnel resource should have been created.

Actual Behavior

The resource was not created and the following output was displayed:

➜  vpc-transit-gateway terraform apply  --auto-approve
data.ibm_is_vpc.vpc: Reading...
data.ibm_is_ssh_key.robley-iperf: Reading...
data.ibm_is_image.iperf-image: Reading...
data.ibm_tg_gateway.tgw: Reading...
data.ibm_is_subnet.primary-subnet: Reading...
data.ibm_is_ssh_key.robley-iperf: Read complete after 2s [id=r006-d2a1e6c8-b562-45be-80d9-12903a767acb]
data.ibm_is_image.iperf-image: Read complete after 2s [id=r006-cc249354-0dc2-4ecc-83d5-66c708cdc24d]
data.ibm_is_subnet.primary-subnet: Read complete after 3s [id=0717-6f91f9eb-e32e-4265-96bb-33c3e9a9ad0d]
data.ibm_is_vpc.vpc: Read complete after 3s [id=r006-a3f21eee-e8a3-4558-bc5c-17446d8825b1]
data.ibm_tg_gateway.tgw: Read complete after 4s [id=2fa2cbe6-644c-4e78-b958-78f58a0a7f9e]

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_tg_connection.gre-dir03-1 will be created
  + resource "ibm_tg_connection" "gre-dir03-1" {
      + base_connection_id = "70582a8a-5822-4c07-bd40-6bddb90d4ab5"
      + connection_id      = (known after apply)
      + created_at         = (known after apply)
      + gateway            = "2fa2cbe6-644c-4e78-b958-78f58a0a7f9e"
      + id                 = (known after apply)
      + local_gateway_ip   = "192.168.195.1"
      + local_tunnel_ip    = "192.168.173.2"
      + name               = "gre-tunnel-dal10-dir03-1"
      + network_account_id = (known after apply)
      + network_id         = (known after apply)
      + network_type       = "gre_tunnel"
      + related_crn        = (known after apply)
      + remote_bgp_asn     = 65010
      + remote_gateway_ip  = "10.176.179.227"
      + remote_tunnel_ip   = "192.168.173.1"
      + request_status     = (known after apply)
      + status             = (known after apply)
      + updated_at         = (known after apply)
      + zone               = "us-south-1"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
ibm_tg_connection.gre-dir03-1: Creating...
╷
│ Error: Plugin did not respond
│
│   with ibm_tg_connection.gre-dir03-1,
│   on gre_tunnel.tf line 1, in resource "ibm_tg_connection" "gre-dir03-1":
│    1: resource "ibm_tg_connection" "gre-dir03-1" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin
│ logs may contain more details.
╵

Stack trace from the terraform-provider-ibm_v1.48.0 plugin:

panic: interface conversion: interface {} is int, not string

goroutine 127 [running]:
github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/transitgateway.resourceIBMTransitGatewayConnectionCreate(0xc0014a7b80, {0x43ede40?, 0xc000230d00})
    github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/transitgateway/resource_ibm_tg_gateway_connection.go:240 +0xcd4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x4b55e40?, {0x4b55e40?, 0xc001566000?}, 0xd?, {0x43ede40?, 0xc000230d00?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/resource.go:695 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc001218b60, {0x4b55e40, 0xc001566000}, 0xc000e7c1a0, 0xc0014a7880, {0x43ede40, 0xc000230d00})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/resource.go:837 +0xa7a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00054b278, {0x4b55e40?, 0xc001561cb0?}, 0xc00144e460)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0008aaa00, {0x4b55e40?, 0xc001533740?}, 0xc0015ad650)
    github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x429b960?, 0xc0008aaa00}, {0x4b55e40, 0xc001533740}, 0xc0015ad5e0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000001e0, {0x4b5c880, 0xc00134d860}, 0xc0014b6c60, 0xc001345200, 0x62efb60, 0x0)
    google.golang.org/grpc@v1.48.0/server.go:1295 +0xb0b
google.golang.org/grpc.(*Server).handleStream(0xc0000001e0, {0x4b5c880, 0xc00134d860}, 0xc0014b6c60, 0x0)
    google.golang.org/grpc@v1.48.0/server.go:1636 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
    google.golang.org/grpc@v1.48.0/server.go:932 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.48.0/server.go:930 +0x28a

Error: The terraform-provider-ibm_v1.48.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Steps to Reproduce

  1. terraform apply

Important Factoids

This is not an "atypical" aspect, but note that removing the remote_bgp_asn parameter allows the GRE Tunnel to be created, although it does not have the correct AS Number so it is not usable.

Also, specifying the remote_bgp_asn parameter as either an integer or a string results in the same failure.

References

sarah-ulmer commented 1 year ago

A fix for this was included in https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4213 and should be included in the next release.

robleyhall commented 1 year ago

Thanks, @sarah-ulmer