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

Invalid ID accepted by terraform import despite docs #4050

Closed
ghost opened this issue Jul 17, 2019 · 3 comments
Closed

Invalid ID accepted by terraform import despite docs #4050

ghost opened this issue Jul 17, 2019 · 3 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jul 17, 2019

This issue was originally opened by @nyurik as hashicorp/terraform#22109. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.2
+ provider.google v2.10.0
+ provider.random v2.1.2
+ provider.vault v2.0.0

Terraform Configuration Files

resource "google_project" "project" {
  name            = var.name
  project_id      = var.project_id
  billing_account = var.billing_account
  org_id          = var.org_id
  labels          = var.labels

  lifecycle {
    prevent_destroy = true
  }
}

Expected Behavior

terraform import google_project.project (project number) should fail.

Actual Behavior

terraform import google_project.project (project number) succeeded, but later the terraform plan showed an error specifying that the project has to be destroyed and recreated, but cannot due to prevent_destroy = true

Steps to Reproduce

  1. For a GCP project with some "name", "project_id", and "project_number", use project number instead of project id when importing it with terraform import google_project.project (project number). It will succeed, even though an error was expected.
  2. Try running make plan to see an error.

Links

import documentation states has this text about IDs: If you're unsure, feel free to just try an ID. If the ID is invalid, you'll just receive an error message.

@slevenick
Copy link
Collaborator

Looking at fixing this by adding regex checking during import

@slevenick
Copy link
Collaborator

Will be released with the next terraform release. Thanks for the report!

@ghost
Copy link
Author

ghost commented Aug 17, 2019

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 Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant