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

google_bigquery_table import is failing without any meaningful error #10471

Closed
g-nikolay opened this issue Nov 1, 2021 · 16 comments · Fixed by GoogleCloudPlatform/magic-modules#5428, hashicorp/terraform-provider-google-beta#3839 or #10521
Assignees
Labels

Comments

@g-nikolay
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 v1.0.9
on linux_amd64
provider registry.terraform.io/hashicorp/google v3.90.0

Affected Resource(s)

  • google_bigquery_table

Terraform Configuration Files

resource "google_bigquery_dataset" "dataset_gcp_res_import_test" {
  labels = {
    from = "my-test"
  }
  description = "my test"
  default_table_expiration_ms = 7200000
  location = "us-west1"
  dataset_id = "dataset_gcp_import_test"
}

resource "google_bigquery_table" "table_gcp_res_import_test" {
  dataset_id = google_bigquery_dataset.dataset_gcp_res_import_test.dataset_id
  table_id = "table_gcp_import_test"
}

Debug Output

gist

Panic Output

Expected Behavior

Actual Behavior

terraform is failing with the following message

│ Error: 1 error occurred:
│       * ForceNew: No changes for schema
│
│
│
│   with google_bigquery_table.table_gcp_res_import_test,
│   on main.tf line 11, in resource "google_bigquery_table" "table_gcp_res_import_test":
│   11: resource "google_bigquery_table" "table_gcp_res_import_test" {
│

Steps to Reproduce

  1. Create GCP bq and table
  2. Import created resources using attached config
  3. terraform import
  4. terraform plan

Important Factoids

References

  • #0000
@g-nikolay g-nikolay added the bug label Nov 1, 2021
@edwardmedia edwardmedia self-assigned this Nov 2, 2021
@edwardmedia
Copy link
Contributor

@g-nikolay what config and command did you use?

Import created resources using attached config

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_table#import

@g-nikolay
Copy link
Author

g-nikolay commented Nov 2, 2021

@edwardmedia basically I did 2 tests - 1 manually created resources, 2 using dm config below:

resources:
- type: gcp-types/bigquery-v2:datasets
  name: dataset-gcp-res-import-test
  properties:
    labels:
      from: my-test
    defaultTableExpirationMs: 7200000
    location: us-west1
    description: 'my test'
    datasetReference:
      datasetId: dataset_gcp_import_test
- type: gcp-types/bigquery-v2:tables
  name: table-gcp-res-import-test
  properties:
    datasetId: $(ref.dataset-gcp-res-import-test.datasetReference.datasetId)
    tableReference:
      tableId: table_gcp_import_test

@edwardmedia
Copy link
Contributor

@g-nikolay have you tried import following the link I provided above? If it still fails, can you share your config and the command you are using?

@g-nikolay
Copy link
Author

@edwardmedia sure, this is import commands

terraform import google_bigquery_dataset.dataset_gcp_res_import_test my-project/dataset_gcp_import_test
terraform import google_bigquery_table.table_gcp_res_import_test my-project/dataset_gcp_import_test/table_gcp_import_test

TF config is attached to ticket, DM config is attached to the comment above

@edwardmedia
Copy link
Contributor

@g-nikolay can you try below config for your import?

resource "google_bigquery_dataset" "dataset_gcp_res_import_test" {
}

resource "google_bigquery_table" "table_gcp_res_import_test" {
}

@g-nikolay
Copy link
Author

@edwardmedia getting this output

│ Error: Missing required argument
│
│   on main.tf line 1, in resource "google_bigquery_dataset" "dataset_gcp_res_import_test":
│    1: resource "google_bigquery_dataset" "dataset_gcp_res_import_test" {
│
│ The argument "dataset_id" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│
│   on main.tf line 4, in resource "google_bigquery_table" "table_gcp_res_import_test":
│    4: resource "google_bigquery_table" "table_gcp_res_import_test" {
│
│ The argument "table_id" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│
│   on main.tf line 4, in resource "google_bigquery_table" "table_gcp_res_import_test":
│    4: resource "google_bigquery_table" "table_gcp_res_import_test" {
│
│ The argument "dataset_id" is required, but no definition was found.

@edwardmedia
Copy link
Contributor

edwardmedia commented Nov 3, 2021

@g-nikolay what commands were you using? Did you apply or import?

terraform import google_bigquery_dataset.dataset_gcp_res_import_test my-project/dataset_gcp_import_test
terraform import google_bigquery_table.table_gcp_res_import_test my-project/dataset_gcp_import_test/table_gcp_import_test

Here is the Import Usage doc which says

If desired, you can leave the body of the resource block blank for now and return to fill it in once the instance is imported.

@g-nikolay
Copy link
Author

@edwardmedia import then plan as it's described in repro steps

@edwardmedia
Copy link
Contributor

@g-nikolay import brings the attributes to the state. It does not auto fill the config. I guess you need to manually add them into config before you run plan. Does that make sense?

@g-nikolay
Copy link
Author

@edwardmedia sorry, I'm a little bit confused. I have created ticket with the config which I used for import and plan, then you asked me test again with empty config. Is there anything wrong with the config from the bug description?

@edwardmedia
Copy link
Contributor

edwardmedia commented Nov 4, 2021

@g-nikolay the config in this block is used to manage resource (plan and apply). The config in this block is used to import. Do you see the difference between them? Here is the explanation for the difference. The subject of this issue is import is failing. Which config did you use for the import? Your import commands look good to me.

Did you modify the config between import and plan in your test here?

Is this helpful? If I misunderstood your questions, please advise.

@g-nikolay
Copy link
Author

@edwardmedia please create bq dataset and table either using DM config above or manually, then try import and plan using terraform config from the ticket description.

@edwardmedia
Copy link
Contributor

@g-nikolay what do you mean import and plan? I am not going to use the same config for terraform import and terraform plan. Like I said here, the config code is different. Does this make sense?

try import and plan using terraform config from the ticket description.

@slevenick
Copy link
Collaborator

I think the confusion here is that the import command does succeed, but the next time terraform plan is run it causes the error. This is likely due to some failure in the import function for this resource (or the customize diff that I assume is being called here), and causes the resource to be unmanageable.

Regardless of where exactly the error is happening (import or plan) this is definitely a bug in the provider and should be fixed

@edwardmedia
Copy link
Contributor

I see where the problem is. Thanks @slevenick

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.