Skip to content

Commit

Permalink
fixed import on google_tags_tag_binding (#9054) (#16005)
Browse files Browse the repository at this point in the history
* fixed import on google_tags_tag_binding

* added d.setid()

---------

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun committed Sep 26, 2023
1 parent f63822d commit a41d22d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/9054.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
tags: fixed import failure on `google_tags_tag_binding`
```
8 changes: 8 additions & 0 deletions google/services/tags/resource_tags_tag_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a41d22d

Please sign in to comment.