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

Can't import google_compute_subnetwork.networkname, would collide with an existing resource #415

Closed
kevinconstantine opened this issue Sep 12, 2017 · 3 comments
Assignees

Comments

@kevinconstantine
Copy link

I'm running into an issue where I may be doing something wrong, but it also might just be a bug.

When I try to import an already existing network and subnetwork into my terraform template, I get the following error:

Error importing: 1 error(s) occurred:

  • google_compute_subnetwork.wdas-172-30-64 (import id: us-west1/wdas-172-30-64): Can't import google_compute_subnetwork.wdas-172-30-64, would collide with an existing resource.
    Please remove or rename this resource before continuing.

Terraform Version

Terraform v0.10.4

Affected Resource(s)

Please list the resources as a list, for example:

  • google_compute_network
  • google_compute_subnetwork

Terraform Configuration Files

#
# VPC Subnetwork: Imported
#
resource "google_compute_subnetwork" "net-172-30-64" {
    name                        = "net-172-30-64"
    ip_cidr_range               = "172.30.64.0/24"
    network                     = "${google_compute_network.net-gcp-net.self_link}"
    region                      = "us-west1"
    private_ip_google_access    = true
    lifecycle {
        prevent_destroy         = true
    }
}

#
# VPC Network: Imported
#
resource "google_compute_network" "net-gcp-net" {
    name                        = "net-gcp-net"
    lifecycle {
        prevent_destroy         = true
    }
}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform import google_compute_subnetwork.net-172-30-64 us-west1/net-172-30-64
  2. terraform import google_compute_network.net-gcp-net net-gcp-net
  3. terraform apply
@selmanj
Copy link
Contributor

selmanj commented Sep 22, 2017

Usually you get that error when the resource has already been imported. Try running:

$ echo "google_compute_subnetwork.wdas-172-30-64.id" | terraform console

If you see us-west1/wdas-172-30-64 (or some other value for the id) then that means that resource has already been imported and you can begin defining what you want the resource to look like in your terraform config.

Does that sound right? This page has a lot of details on how to use import but I agree that it can be confusing.

Let me know if that helps

@selmanj
Copy link
Contributor

selmanj commented Oct 2, 2017

Closing due to inactivity; please reopen if this is still an issue.

@selmanj selmanj closed this as completed Oct 2, 2017
luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this issue May 21, 2019
@ghost
Copy link

ghost commented Mar 30, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants