hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Incorrect import format for google_edgecontainer_vpn_connection #16598

Open gemmahou opened 11 months ago

gemmahou commented 11 months ago

Community Note

Terraform Version

v5.1.0

Affected Resource(s)

google_edgecontainer_vpn_connection

Terraform Configuration Files

resource "google_edgecontainer_cluster" "cluster" {
  name = "default"
  location = "us-central1"

  authorization {
    admin_users {
      username = "admin@hashicorptest.com"
    }
  }

  networking {
    cluster_ipv4_cidr_blocks = ["10.0.0.0/16"]
    services_ipv4_cidr_blocks = ["10.1.0.0/16"]
  }

  fleet {
    project = "projects/${data.google_project.project.number}"
  }
}

resource "google_edgecontainer_node_pool" "node_pool" {
  name = "nodepool-1"
  cluster = google_edgecontainer_cluster.cluster.name
  location = "us-central1"
  node_location = "us-central1-edge-example-edgesite"
  node_count = 3
}

resource "google_edgecontainer_vpn_connection" "default" {
  depends_on = [google_edgecontainer_node_pool.node_pool]
  name = "vpn-connection-1"
  location = "us-central1"
  cluster = "projects/${data.google_project.project.number}/locations/us-east1/clusters/${google_edgecontainer_cluster.cluster.name}"
  vpc = google_compute_network.vpc.name
  enable_high_availability = true
}

resource "google_compute_network" "vpc" {
  name = "example-vpc"
}

data "google_project" "project" {}

Debug Output

Panic Output

Expected Behavior

The import formats should accept projects/{{project}}/locations/{{location}}/vpnConnections/{{name}}

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/edgecontainer_vpn_connection#import

Actual Behavior

The import formats only accept projects/{{project}}/locations/{{location}}/vpnConnections

error message:

Update call failed: error fetching live state: error importing resource: Import id \"projects/mock-project/locations/us-central1/vpnConnections/edgecontainervpnconnection-j4idl7vcq3lgwjrbhwmq\" doesn't match any of the accepted formats: [^projects/(?P<project>[^/]+)/locations/(?P<location>[^/]+)/vpnConnections$ ^(?P<project>[^/]+)/(?P<location>[^/]+)$ ^(?P<location>[^/]+)$]"

Steps to Reproduce

  1. terraform apply

Important Factoids

References

b/314287055

gemmahou commented 11 months ago

I'm also wondering how the import format is generated? other similar resource like edgecontainer_nodepool does not have this issue: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/edgecontainer_node_pool#import

edwardmedia commented 11 months ago

@gemmahou I wonder what update (from below error) is supposed to do for the import. Can you share your import command and the debug log?

Update call failed: error fetching....
edwardmedia commented 11 months ago

@gemmahou is this still an issue?

gemmahou commented 11 months ago

Yes, let me try get you the log ASAP

gemmahou commented 11 months ago

I'm not super familiar with this API but per the service team, this resource has specific requirements to be created so I'm unsure if I'm able to create a resource and get the import log.

I found this official doc: https://cloud.google.com/distributed-cloud/edge/latest/docs/vpn-connections#status, as you can see, we have to specify the VPN_CONNECTION_NAME to be able to make the call, I assume terraform should follow the similar behavior?

edwardmedia commented 11 months ago

@gemmahou can you share the exact import command you used and its debug log?

gemmahou commented 11 months ago

I would transfer this ticket to the service team of this edge_container_vpn_connection resource.

@rayccz2 would you mind taking a look at this Terraform issue and see if you are able to share the import command and the debug log? Thanks!

rayccz2 commented 10 months ago

@gemmahou The issue has been resolve with fix https://github.com/GoogleCloudPlatform/magic-modules/pull/9764