terraform-provider-google: terraform import doesn't work with cloud DNS in GCP

I am trying to import cloud dns A record from GCP using terraform import but it throws error. The record already exists so the error for non-existent resource doesn’t make sense below. Did anyone try it before? module.cloud_dns.google_dns_record_set.a: Importing from ID “production-us-east1/server1/A”… module.cloud_dns.google_dns_record_set.a: Import complete! Imported google_dns_record_set (ID: production-us-east1/server1/A) module.cloud_dns.google_dns_record_set.a: Refreshing state… (ID: production-us-east1/server1/A)

Error: module.cloud_dns.google_dns_record_set.a[0] (import id: production-us-east1/server1/A): 1 error(s) occurred:

import module.cloud_dns.google_dns_record_set.a[0] result: production-us-east1/server1/A: import module.cloud_dns.google_dns_record_set.a (id: production-us-east1/server1/A): Terraform detected a resource with this ID doesn’t exist. Please verify the ID is correct. You cannot import non-existent resources using Terraform import.

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 version Terraform v0.11.10

  • provider.google v1.20.0
  • provider.template v2.0.0

Affected Resource(s)

  • google_dns_record_set

Terraform Configuration Files

# Copy-paste your Terraform configurations here - 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

Panic Output

Expected Behavior

google dns a record imported.

Actual Behavior

module.cloud_dns.google_dns_record_set.a: Importing from ID “production-us-east1/server1/A”… module.cloud_dns.google_dns_record_set.a: Import complete! Imported google_dns_record_set (ID: production-us-east1/server1/A) module.cloud_dns.google_dns_record_set.a: Refreshing state… (ID: production-us-east1/server1/A)

Error: module.cloud_dns.google_dns_record_set.a[0] (import id: production-us-east1/server1/A): 1 error(s) occurred:

import module.cloud_dns.google_dns_record_set.a[0] result: production-us-east1/server1/A: import module.cloud_dns.google_dns_record_set.a (id: production-us-east1/server1/A): Terraform detected a resource with this ID doesn’t exist. Please verify the ID is correct. You cannot import non-existent resources using Terraform import.

Steps to Reproduce

following terraform doc online https://www.terraform.io/docs/providers/google/r/dns_record_set.html

terraform import google_dns_record_set.frontend prod-zone/frontend.prod.mydomain.com./A

Important Factoids

References

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (2 by maintainers)

Most upvoted comments

@Preete is the DNS record you’re trying to import in the same project as the one specified in your provider block?

That is how I have encountered this issue, it appears there is no way to specify the project to import the record from. Our workaround has been to temporarily change the project in the provider block, import the resource, then change it back.