From 7d414658ea54f82482d743e4e6be0d442272d394 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 26 Sep 2023 13:46:54 +0000 Subject: [PATCH] fixed import on google_tags_tag_binding (#9054) * fixed import on google_tags_tag_binding * added d.setid() --------- Co-authored-by: Edward Sun Signed-off-by: Modular Magician --- .changelog/9054.txt | 3 +++ google-beta/services/tags/resource_tags_tag_binding.go | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 .changelog/9054.txt diff --git a/.changelog/9054.txt b/.changelog/9054.txt new file mode 100644 index 0000000000..9a46cdc596 --- /dev/null +++ b/.changelog/9054.txt @@ -0,0 +1,3 @@ +```release-note:bug +tags: fixed import failure on `google_tags_tag_binding` +``` diff --git a/google-beta/services/tags/resource_tags_tag_binding.go b/google-beta/services/tags/resource_tags_tag_binding.go index 97849b29a1..1ae963fbf1 100644 --- a/google-beta/services/tags/resource_tags_tag_binding.go +++ b/google-beta/services/tags/resource_tags_tag_binding.go @@ -288,6 +288,14 @@ func resourceTagsTagBindingImport(d *schema.ResourceData, meta interface{}) ([]* return nil, err } + stringParts := strings.Split(d.Get("name").(string), "/") + if len(stringParts) < 3 { + return nil, fmt.Errorf("Error parsing parent name. Should be in form {{parent}}/tagValues/{{tag_value}}") + } + if err := d.Set("parent", stringParts[0]); err != nil { + return nil, fmt.Errorf("Error setting parent, %s", err) + } + name := d.Get("name").(string) d.SetId(name)