Skip to content

Commit de390a8

Browse files
Fix import for google_essential_contacts_contact (#11995) (#8423)
[upstream:9c0bb5a1c67a81f8b1dfc20a661368efbaa90e7a] Signed-off-by: Modular Magician <[email protected]>
1 parent ed7d19f commit de390a8

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.changelog/11995.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
essentialcontacts: fixed `google_essential_contacts_contact` import to include required parent field.
3+
```

google-beta/services/essentialcontacts/resource_essential_contacts_contact.go

+7
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ func resourceEssentialContactsContactImport(d *schema.ResourceData, meta interfa
334334
}
335335
d.SetId(id)
336336

337+
// Split resource name into tokens
338+
nameTokens := strings.SplitAfterN(d.Id(), "/", 3)
339+
340+
if err := d.Set("parent", nameTokens[0]+strings.Trim(nameTokens[1], "/")); err != nil {
341+
return nil, fmt.Errorf("error getting parent for the contact : %s", err)
342+
}
343+
337344
return []*schema.ResourceData{d}, nil
338345
}
339346

google-beta/services/essentialcontacts/resource_essential_contacts_contact_test.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ func TestAccEssentialContactsContact_update(t *testing.T) {
2929
),
3030
},
3131
{
32-
ResourceName: "google_essential_contacts_contact.contact",
33-
ImportState: true,
34-
ImportStateVerify: true,
35-
ImportStateVerifyIgnore: []string{"parent"},
32+
ResourceName: "google_essential_contacts_contact.contact",
33+
ImportState: true,
34+
ImportStateVerify: true,
3635
},
3736
{
3837
Config: testAccEssentialContactsContact_v2(context),
@@ -42,10 +41,9 @@ func TestAccEssentialContactsContact_update(t *testing.T) {
4241
),
4342
},
4443
{
45-
ResourceName: "google_essential_contacts_contact.contact",
46-
ImportState: true,
47-
ImportStateVerify: true,
48-
ImportStateVerifyIgnore: []string{"parent"},
44+
ResourceName: "google_essential_contacts_contact.contact",
45+
ImportState: true,
46+
ImportStateVerify: true,
4947
},
5048
},
5149
})

0 commit comments

Comments
 (0)