Skip to content

Commit

Permalink
Fix import for google_essential_contacts_contact (#11995) (#19877)
Browse files Browse the repository at this point in the history
[upstream:9c0bb5a1c67a81f8b1dfc20a661368efbaa90e7a]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 16, 2024
1 parent 89f3a49 commit 4af9f32
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
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

0 comments on commit 4af9f32

Please sign in to comment.