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

Bigquery routines are not updated as expected #10264

Closed
tgmof opened this issue Oct 6, 2021 · 1 comment · Fixed by GoogleCloudPlatform/magic-modules#5298, hashicorp/terraform-provider-google-beta#3849 or #10546
Assignees
Labels

Comments

@tgmof
Copy link

tgmof commented Oct 6, 2021

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.5

Affected Resource(s)

google_bigquery_routine

Terraform Configuration Files

I want to update this resource ID from "variables_m5" to "vars_t5". See below the "updated TF routine". So it assumes that it has been applied once with routine_id=variables_m5.

resource "google_bigquery_routine" "procedure_variables_t5" {
  dataset_id      = "mydataset"
  project         = "myproject"
  routine_id      = "vars_t5"
  routine_type    = "PROCEDURE"
  language        = "SQL"
  definition_body = "DECLARE myvar STRING;"
  return_type     = null
  description     = "Does nothing"
}

Debug Output

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.dev-terraform.module.udfs_and_procedures.google_bigquery_routine.procedure_variables_t5 will be updated in-place
  ~ resource "google_bigquery_routine" "procedure_variables_t5" {
        id                 = "projects/myproject/datasets/mydataset/routines/variables_m5"
      ~ routine_id         = "variables_m5" -> "vars_t5"
        # (9 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
│ Error: Error updating Routine "projects/myproject/datasets/mydataset/routines/variables_m5": googleapi: Error 404: Not found: Routine myproject:variables.vars_t5, notFound

Panic Output

Expected Behavior

I want to update the resource ID. Since Google doesn't allow to do that in place "rename", then the resource should be deleted and another one re-created.

Actual Behavior

Terraform tries to update the resource in-place and fails during the plan. Then it fails during the apply.
Another apply solves the issue. Here is the output:

Terraform detected the following changes made outside of Terraform since the
last "terraform apply":

  # google_bigquery_routine.procedure_variables_t5 has been deleted

Terraform will perform the following actions:

  # google_bigquery_routine.procedure_variables_t5 will be created

Steps to Reproduce

  1. Create a simple google_bigquery_routine
  2. terraform apply
  3. Update the routine_id to something else
  4. terraform apply

Important Factoids

References

@tgmof tgmof added the bug label Oct 6, 2021
tgmof added a commit to tgmof/terraform-provider-google that referenced this issue Oct 6, 2021
See bug raised here:
hashicorp#10264
TLDR: dataset_id and routine_id are part of the underling ID and thus the resource need to be re-created and can't be "renamed"
@nat-henderson nat-henderson self-assigned this Oct 8, 2021
@github-actions
Copy link

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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.