Skip to content

Commit 2943125

Browse files
tags: fixed permadiff for parent argument on google_tags_location_tag_binding (#14220) (#23331)
[upstream:732c7e545d70a00dd8c0d29cbca207b50e6fc15a] Signed-off-by: Modular Magician <[email protected]>
1 parent ba5166c commit 2943125

File tree

3 files changed

+78
-4
lines changed

3 files changed

+78
-4
lines changed

.changelog/14220.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
tags: fixed perma-diff for `parent` field in `google_tags_location_tag_binding` resource
3+
```

google/services/tags/resource_tags_location_tag_binding.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ func ResourceTagsLocationTagBinding() *schema.Resource {
4848

4949
Schema: map[string]*schema.Schema{
5050
"parent": {
51-
Type: schema.TypeString,
52-
Required: true,
53-
ForceNew: true,
54-
Description: `The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123`,
51+
Type: schema.TypeString,
52+
Required: true,
53+
ForceNew: true,
54+
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
55+
Description: `The full resource name of the resource the TagValue is bound to. E.g. //cloudresourcemanager.googleapis.com/projects/123`,
5556
},
5657
"tag_value": {
5758
Type: schema.TypeString,

google/services/tags/resource_tags_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,76 @@ resource "google_tags_location_tag_binding" "binding" {
889889
`, context)
890890
}
891891

892+
func TestAccTagsLocationTagBinding_locationTagBindingBasicWithProjectId(t *testing.T) {
893+
t.Parallel()
894+
895+
context := map[string]interface{}{
896+
"random_suffix": acctest.RandString(t, 10),
897+
}
898+
899+
acctest.VcrTest(t, resource.TestCase{
900+
PreCheck: func() { acctest.AccTestPreCheck(t) },
901+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
902+
ExternalProviders: map[string]resource.ExternalProvider{
903+
"random": {},
904+
},
905+
CheckDestroy: testAccCheckTagsLocationTagBindingDestroyProducer(t),
906+
Steps: []resource.TestStep{
907+
{
908+
Config: testAccTagsLocationTagBinding_locationTagBindingBasicExampleWithProjectId(context),
909+
},
910+
{
911+
ResourceName: "google_tags_location_tag_binding.binding",
912+
ImportState: true,
913+
ImportStateVerify: true,
914+
},
915+
},
916+
})
917+
}
918+
919+
func testAccTagsLocationTagBinding_locationTagBindingBasicExampleWithProjectId(context map[string]interface{}) string {
920+
return acctest.Nprintf(`
921+
data "google_project" "project" {
922+
}
923+
924+
resource "google_tags_tag_key" "key" {
925+
parent = "organizations/${data.google_project.project.org_id}"
926+
short_name = "keyname%{random_suffix}"
927+
description = "For a certain set of resources."
928+
}
929+
930+
resource "google_tags_tag_value" "value" {
931+
parent = google_tags_tag_key.key.id
932+
short_name = "foo%{random_suffix}"
933+
description = "For foo%{random_suffix} resources."
934+
}
935+
936+
resource "google_cloud_run_service" "default" {
937+
name = "tf-test-cloudrun-srv%{random_suffix}"
938+
location = "us-central1"
939+
940+
template {
941+
spec {
942+
containers {
943+
image = "us-docker.pkg.dev/cloudrun/container/hello"
944+
}
945+
}
946+
}
947+
948+
traffic {
949+
percent = 100
950+
latest_revision = true
951+
}
952+
}
953+
954+
resource "google_tags_location_tag_binding" "binding" {
955+
parent = "//run.googleapis.com/projects/${data.google_project.project.project_id}/locations/${google_cloud_run_service.default.location}/services/${google_cloud_run_service.default.name}"
956+
tag_value = google_tags_tag_value.value.id
957+
location = "us-central1"
958+
}
959+
`, context)
960+
}
961+
892962
func testAccCheckTagsLocationTagBindingDestroyProducer(t *testing.T) func(s *terraform.State) error {
893963
return func(s *terraform.State) error {
894964
for name, rs := range s.RootModule().Resources {

0 commit comments

Comments
 (0)