hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.34k stars 1.75k forks source link

`default_labels` not applied to `google_sql_database_instance` #16375

Open florianmutter opened 1 year ago

florianmutter commented 1 year ago

Community Note

Terraform Version

Terraform v1.6.2
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.3.0
+ provider registry.terraform.io/hashicorp/random v3.5.1

Affected Resource(s)

Terraform Configuration Files

terraform {
  required_version = ">=1.6.2"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.3.0"
    }
  }
}

provider "google" {
  default_labels = {
    team   = "example"
  }
}

resource "google_sql_database_instance" "example" {
  name             = "example"
  database_version = "POSTGRES_15"
  region           = "europe-west4"

  settings {
    tier = "db-f1-micro"
  }
}

Debug Output

Panic Output

Expected Behavior

default_labels are applied to google_sql_database_instance.

Actual Behavior

Resource does not get any labels. Probably because the argument for google_sql_database_instance is named user_labels.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

b/308122817

kustodian commented 11 months ago

Noticed the same problem.

melinath commented 7 months ago

Closing as a duplicate of https://github.com/hashicorp/terraform-provider-google/issues/16219

github-actions[bot] commented 6 months ago

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.

zli82016 commented 3 months ago

The default_labels is not going to be applied to google_sql_database_instance resource as user_labels is nested inside settings and there is a bug in terraform sdk that SetNew is not working in the nested fields. It needs to wait until the resource is migrated to plugin framework.

The default_labels will be available in the data source google_client_config (https://github.com/hashicorp/terraform-provider-google/issues/19140)