Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import for google_essential_contacts_contact #19877

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/11995.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
essentialcontacts: fixed `google_essential_contacts_contact` import to include required parent field.
```
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ func resourceEssentialContactsContactImport(d *schema.ResourceData, meta interfa
}
d.SetId(id)

// Split resource name into tokens
nameTokens := strings.SplitAfterN(d.Id(), "/", 3)

if err := d.Set("parent", nameTokens[0]+strings.Trim(nameTokens[1], "/")); err != nil {
return nil, fmt.Errorf("error getting parent for the contact : %s", err)
}

return []*schema.ResourceData{d}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ func TestAccEssentialContactsContact_update(t *testing.T) {
),
},
{
ResourceName: "google_essential_contacts_contact.contact",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"parent"},
ResourceName: "google_essential_contacts_contact.contact",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccEssentialContactsContact_v2(context),
Expand All @@ -42,10 +41,9 @@ func TestAccEssentialContactsContact_update(t *testing.T) {
),
},
{
ResourceName: "google_essential_contacts_contact.contact",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"parent"},
ResourceName: "google_essential_contacts_contact.contact",
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand Down