Skip to content

Spanner instance not updated properly when changing only the force destroy #13749

@dbrasseur-aneo

Description

@dbrasseur-aneo

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

1.3.8

Affected Resource(s)

Not sure which one, or both of :

  • google_spanner_instance
  • google_spanner_database

Terraform Configuration Files

provider "google" {
  project = var.project
  region = var.region
}

terraform {
  required_version = "1.3.8"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "4.53"
    }
  }
}

resource "google_spanner_instance" "supply_chain" {
  name             = "test-db"
  display_name     = "Test DB"
  config           = "regional-${var.region}"
  processing_units = 100
  force_destroy    = var.enable_force_destroy
}

resource "google_spanner_database" "supply_chain" {
  instance                 = google_spanner_instance.supply_chain.name
  name                     = "test"
  deletion_protection      = !var.enable_force_destroy
}

variable "project" {
  type = string
}

variable "region" {
  type = string
}

variable "enable_force_destroy"{
  type = bool
  default = true
}

Debug Output

https://gist.github.com/dbrasseur-aneo/fb557fa1c19e7a604e6a9d23154586f8

Panic Output

Expected Behavior

Both database and spanner instances shoud have been updated by changing their force_destroy and deletion_protection

Actual Behavior

Only the database is updated correctly, the instance doesn't update with the error :

| Error: Error updating Instance "prj-resim/test-db": googleapi: Error 400: Invalid UpdateInstance request.
│ Details:
│ [
│   {
│     "@type": "type.googleapis.com/google.rpc.BadRequest",
│     "fieldViolations": [
│       {
│         "description": "Must specify a non-empty field mask.",
│         "field": "field_mask"
│       }
│     ]
│   }
│ ]
│
│   with google_spanner_instance.supply_chain,
│   on main.tf line 16, in resource "google_spanner_instance" "supply_chain":
│   16: resource "google_spanner_instance" "supply_chain"

However, a second apply with the same values succeeds

Steps to Reproduce

With no deployment :

  1. terraform init
  2. terraform apply -var=project=PROJECT -var=region=REGION -var=enable_force_destroy=true -auto-approve
  3. terraform apply -var=project=PROJECT -var=region=REGION -var=enable_force_destroy=false -auto-approve
    The deployment should have failed
  4. terraform apply -var=project=PROJECT -var=region=REGION -var=enable_force_destroy=false -auto-approve
    The deployment should have succeeded
  5. terraform apply -var=project=PROJECT -var=region=REGION -var=enable_force_destroy=true -auto-approve
    The deployment should have failed
  6. terraform apply -var=project=PROJECT -var=region=REGION -var=enable_force_destroy=true -auto-approve
    The deployment should have succeeded

Important Factoids

References

Same error but different reason :

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions