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

TF import GCP backend_service #6786

Closed
robertrockjr opened this issue Jul 13, 2020 · 10 comments
Closed

TF import GCP backend_service #6786

robertrockjr opened this issue Jul 13, 2020 · 10 comments
Assignees
Labels

Comments

@robertrockjr
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 v0.12.28

  • provider.google v3.29.0

Affected Resource(s)

google_compute_backend_service

Terraform Configuration Files

# Copy-paste your Terraform configurations here.
provider "google" {
  credentials = "****"
  project       = "asc-ahnat-rstudio-team-prd"
  region        = "us-central1"
  zone          = "us-central1-a"
  }

terraform {
  backend "gcs" {
    bucket      = "asc-terraform-prod"
    prefix      = "terraform/prod/import_test_ilb"
    credentials = "****"
  }
}

resource "google_compute_backend_service" "default" {
}

# For large Terraform configs, please use a service like Dropbox and share a link to the ZIP file.
# For security, you can also encrypt the files using our GPG public key:
#    https://www.hashicorp.com/security
#
# If reproducing the bug involves modifying the config file (e.g., apply a config,
# change a value, apply the config again, see the bug), then please include both:
# * the version of the config before the change, and
# * the version of the config after the change.

Debug Output

$ tf import google_compute_backend_service.default 1848053231971369158
google_compute_backend_service.default: Importing from ID "rstudio-connect-tcp-ilb"...
google_compute_backend_service.default: Import prepared!
Prepared google_compute_backend_service for import
google_compute_backend_service.default: Refreshing state... [id=projects/asc-ahnat-rstudio-team-prd/global/backendServices/rstudio-connect-tcp-ilb]

Error: Cannot import non-existent remote object

While attempting to import an existing object to
google_compute_backend_service.default, the provider detected that no object
exists with the given id. Only pre-existing objects can be imported; check
that the id is correct and that it is associated with the provider's
configured region or endpoint, or use "terraform apply" to create a new remote
object for this resource.

Panic Output

Expected Behavior

I would expect the resource would be imported into the state file.

Actual Behavior

Error: Cannot import non-existent remote object

While attempting to import an existing object to
google_compute_backend_service.default, the provider detected that no object
exists with the given id. Only pre-existing objects can be imported; check
that the id is correct and that it is associated with the provider's
configured region or endpoint, or use "terraform apply" to create a new remote
object for this resource.

Steps to Reproduce

  1. tf import google_compute_backend_service.default 1848053231971369158

Important Factoids

References

$ terraform import google_compute_backend_service.default projects/{{project}}/global/backendServices/{{name}}
$ terraform import google_compute_backend_service.default {{project}}/{{name}}
$ terraform import google_compute_backend_service.default {{name}}

  • #0000
@ghost ghost added the bug label Jul 13, 2020
@edwardmedia edwardmedia self-assigned this Jul 13, 2020
@edwardmedia
Copy link
Contributor

@robertrockjr can you verify the name of the backend-services? What do you see gcloud compute backend-services list?

@robertrockjr
Copy link
Author

robertrockjr commented Jul 13, 2020 via email

@ghost ghost removed the waiting-response label Jul 13, 2020
@edwardmedia
Copy link
Contributor

@robertrockjr Can you run
$ terraform import google_compute_backend_service.default us-central1-a/instanceGroups/connect-uig

@robertrockjr
Copy link
Author

robertrockjr commented Jul 13, 2020 via email

@ghost ghost removed the waiting-response label Jul 13, 2020
@edwardmedia
Copy link
Contributor

edwardmedia commented Jul 13, 2020

Try this
$ terraform import google_compute_backend_service.default projects/asc-ahnat-rstudio-team-prd/regions/us-central1/backendServices/rstudio-connect-tcp-ilb

@robertrockjr
Copy link
Author

robertrockjr commented Jul 14, 2020 via email

@ghost ghost removed the waiting-response label Jul 14, 2020
@edwardmedia
Copy link
Contributor

You may use google_compute_region_backend_service instead, and then
$ terraform import google_compute_region_backend_service.default projects/asc-ahnat-rstudio-team-prd/regions/us-central1/backendServices/rstudio-connect-tcp-ilb

@robertrockjr
Copy link
Author

robertrockjr commented Jul 14, 2020 via email

@edwardmedia
Copy link
Contributor

Great. I am glad it works for you. Closing the issue then

@ghost
Copy link

ghost commented Aug 14, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 14, 2020
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-l7-load-balancer 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