@@ -889,6 +889,76 @@ resource "google_tags_location_tag_binding" "binding" {
889
889
` , context )
890
890
}
891
891
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
+
892
962
func testAccCheckTagsLocationTagBindingDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
893
963
return func (s * terraform.State ) error {
894
964
for name , rs := range s .RootModule ().Resources {
0 commit comments