Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import google_compute_network_peering resources fails for global networks #9829

Closed
mans0954 opened this issue Aug 17, 2021 · 8 comments
Closed
Assignees
Labels

Comments

@mans0954
Copy link

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 me too comments, 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.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.0.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v3.80.0

Affected Resource(s)

google_compute_network_peering

Terraform Configuration Files

variable "mongo_atlas_network" {
  type = string
}

variable "redis_labs_network" {
  type = string
}

...
resource "google_compute_network" "ol-net01" {
  name                    = "ol-net01"
  auto_create_subnetworks = false
  description             = "Shared VPC"
}

resource "google_compute_network_peering" "mongo-atlas" {
  name         = "mongo-atlas-vpc-peering"
  network      = "${google_compute_network.ol-net01.self_link}"
  peer_network = var.mongo_atlas_network
}

resource "google_compute_network_peering" "redis-labs" {
  name         = "redis-labs-vpc-peering"
  network      = "${google_compute_network.ol-net01.self_link}"
  peer_network = var.redis_labs_network
}

Debug Output

Panic Output

terraform import --var-file=stag.tfvars google_compute_network_peering.mongo-atlas mongo-atlas-vpc-peering
google_compute_network_peering.mongo-atlas: Importing from ID "mongo-atlas-vpc-peering"...
╷
│ Error: Error parsing network peering import format, expected: {project}/{network}/{name}
│ 
│ 
╵

terraform import --var-file=stag.tfvars google_compute_network_peering.redis-labs redis-labs-vpc-peering
google_compute_network_peering.redis-labs: Importing from ID "redis-labs-vpc-peering"...
╷
│ Error: Error parsing network peering import format, expected: {project}/{network}/{name}
│ 
│ 

Expected Behavior

I was expecting the mongo-atlas-vpc-peering peering to be imported to the google_compute_network_peering.mongo-atlas mongo-atlas-vpc-peering resource and the redis-labs-vpc-peering peering to be imported to the google_compute_network_peering.redis-labs resource.

Actual Behavior

The resources are not imported due to the error above.

Steps to Reproduce

  1. terraform import

Important Factoids

The external networks are formatted as follows:

mongo_atlas_network = "projects/<project>/global/networks/<network>"
redis_labs_network = "projects/<project>/global/networks/<network>"

References

  • #0000
@mans0954 mans0954 added the bug label Aug 17, 2021
@edwardmedia edwardmedia self-assigned this Aug 17, 2021
@edwardmedia
Copy link
Contributor

@mans0954 can you review the issue here to see if that helps?

@mans0954
Copy link
Author

@mans0954 can you review the issue here to see if that helps?

Do you mean

export GOOGLE_CLOUD_PROJECT=<my_project_id>
terraform import --var-file=stag.tfvars google_compute_network_peering.mongo-atlas mongo-atlas-vpc-peering

? That still gives the same error.

@mans0954
Copy link
Author

I think the problem is probably here:

- it's not allowing for the possibility of the extra /global/ in the network name?

@edwardmedia
Copy link
Contributor

@mans0954 can you try something like below?

resource "google_compute_network_peering" "mongo-atlas" {
}

terraform import google_compute_network_peering.mongo-atlas project-name/network-name/peering-name

@mans0954
Copy link
Author

@edwardmedia Thanks. Same response as before:

terraform import --var-file=stag.tfvars google_compute_network_peering.redis-labs redis-labs-vpc-peering
google_compute_network_peering.redis-labs: Importing from ID "redis-labs-vpc-peering"...
╷
│ Error: Error parsing network peering import format, expected: {project}/{network}/{name}
│ 
│ 
╵

terraform import --var-file=stag.tfvars google_compute_network_peering.mongo-atlas mongo-atlas-vpc-peering
google_compute_network_peering.mongo-atlas: Importing from ID "mongo-atlas-vpc-peering"...
╷
│ Error: Error parsing network peering import format, expected: {project}/{network}/{name}
│ 
│ 
╵

@edwardmedia
Copy link
Contributor

@mans0954 do you have project-name/network-name/ in your command?

project-name/network-name/peering-name ( from example )

redis-labs-vpc-peering (from yours)

@mans0954
Copy link
Author

@mans0954 do you have project-name/network-name/ in your command?

This works!

terraform import --var-file=stag.tfvars google_compute_network_peering.mongo-atlas my-project/my-network/mongo-atlas-vpc-peering
google_compute_network_peering.mongo-atlas: Importing from ID "my-project/my-network/mongo-atlas-vpc-peering"...
google_compute_network_peering.mongo-atlas: Import prepared!
  Prepared google_compute_network_peering for import
google_compute_network_peering.mongo-atlas: Refreshing state... [id=my-network/mongo-atlas-vpc-peering]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2021
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-network-peering labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants