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.33k stars 1.73k forks source link

google_tags_tag_key import does not support purpose_data #20073

Open joekohlsdorf opened 1 week ago

joekohlsdorf commented 1 week ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.9.6 on darwin_amd64

Affected Resource(s)

google_tags_tag_key

Terraform Configuration

resource "google_tags_tag_key" "tag_key" {
  parent = "projects/123"
  short_name = "test-tag"
  purpose = "GCE_FIREWALL"
  purpose_data = {
    network = "123/vpc-us-west1"
  }
}

Debug Output

No response

Expected Behavior

After creating the resource, removing it from state and then importing it again should not cause any changes to be detected.

Actual Behavior

After terraform import, the state does not contain purpose_data leading to a plan which will replace the resource:

 -/+ destroy and then create replacement
 Terraform will perform the following actions:
   # google_tags_tag_key.tag_key must be replaced
 -/+ resource "google_tags_tag_key" "tag_key" {
       ~ create_time     = "2024-10-29T15:21:57.059029Z" -> (known after apply)
       ~ id              = "tagKeys/281477391791474" -> (known after apply)
       ~ name            = "281477391791474" -> (known after apply)
       ~ namespaced_name = "test-project-123/test-tag" -> (known after apply)
       ~ parent          = "projects/123" -> "projects/test-project-123"
       + purpose_data    = { # forces replacement
           + "network" = "test-project-123/vpc-us-west1"
         }
       ~ update_time     = "2024-10-29T15:21:57.059029Z" -> (known after apply)
         # (3 unchanged attributes hidden)
     }
 Plan: 1 to add, 0 to change, 1 to destroy.

Steps to reproduce

  1. terraform apply
  2. note down Tag key ID for step 4
  3. terraform state rm 'google_tags_tag_key.tag_key'
  4. terraform import 'google_tags_tag_key.tag_key' tagKeys/***TAGKEYID***
  5. terraform plan

Important Factoids

No response

References

No response

b/377568938

ggtisc commented 1 day ago

Confirmed issue!

After doing the import the purpose_data doesn't appear on the tfstate file, but it was added successfully on GCP, and after running a terraform plan it results in a replacement even if there are no changes.