-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Importing google_compute_project_metadata_item fails with "Error: project: required field is not set" #5742
Comments
Hmm, this issue does not happen with an new empty state:
Mine was just upgraded from 2.20.2 to 3.9.0. |
Import also works with an empty state when resources are in a module:
provider "google" {
version = "3.9.0"
project = "myproject"
region = "europe-west1"
}
module "root_state" {
source = "./root_state"
}
resource "google_project" "project" {
name = "myproject"
project_id = "myproject"
billing_account = "123456-123456-123456"
}
resource "google_compute_project_metadata_item" "project_disable_legacy_endpoints" {
project = google_project.project.project_id
key = "disable-legacy-endpoints"
value = "TRUE"
} # terraform import module.root_state.google_compute_project_metadata_item.project_disable_legacy_endpoints disable-legacy-endpoints
module.root_state.google_compute_project_metadata_item.project_disable_legacy_endpoints: Importing from ID "disable-legacy-endpoints"...
module.root_state.google_compute_project_metadata_item.project_disable_legacy_endpoints: Import prepared!
Prepared google_compute_project_metadata_item for import
module.root_state.google_compute_project_metadata_item.project_disable_legacy_endpoints: Refreshing state... [id=disable-legacy-endpoints]
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. |
@pdecat you provided two cases in which import works for
|
I just added that
The first version of the state for that stack was created in 2016 (terraform 0.7.4 at the time, before the big provider split) and was upgraded to almost all versions of terraform and the google provider since then. I wanted to import the project metadata item resource to avoid updating the Google Compute Metadata and faced the issue described here. |
@pdecat can you try to import if you have the config like below, then manually add the key / value in the config accordingly?
|
@edwardmedia, thanks for the help on this issue! I've tried commenting these fields but the same issue still happened. Doing further tests, I've managed to locate the cause.
The underlying issue is described here: hashicorp/terraform#16835 I replaced it with the following and the import worked:
I guess we can close this issue. Best regards, |
@pdecat Great. I am glad you have identified the problem. I am closing this issue now. Thank you for using the tool |
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! |
Community Note
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 tohashibot
, a community member has claimed the issue already.Terraform Version
Note: same issue happens with provider version 2.20.2.
Affected Resource(s)
google_compute_project_metadata_item
Terraform Configuration Files
Debug Output
https://gist.github.com/pdecat/95b65fcc68f834bc42837a3d79d62b7c
Panic Output
N/A
Expected Behavior
Import should be successful.
Actual Behavior
Import fails:
Steps to Reproduce
terraform import google_compute_project_metadata_item.project_disable_legacy_endpoints disable-legacy-endpoints
Important Factoids
References
The text was updated successfully, but these errors were encountered: