Skip to content

Commit a324cca

Browse files
ttewaritewartr
authored andcommitted
Fix import for google_essential_contacts_contact (GoogleCloudPlatform#11995)
Co-authored-by: Tripti Tewari <[email protected]>
1 parent 7d3af71 commit a324cca

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

mmv1/products/essentialcontacts/Contact.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ timeouts:
3838
update_minutes: 20
3939
delete_minutes: 20
4040
custom_code:
41+
post_import: 'templates/terraform/post_import/essential_contacts_contact.go.tmpl'
4142
examples:
4243
- name: 'essential_contact'
4344
primary_resource_id: 'contact'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Split resource name into tokens
2+
nameTokens := strings.SplitAfterN(d.Id(), "/", 3)
3+
4+
if err := d.Set("parent", nameTokens[0]+strings.Trim(nameTokens[1], "/")); err != nil {
5+
return nil, fmt.Errorf("error getting parent for the contact : %s", err)
6+
}

mmv1/third_party/terraform/services/essentialcontacts/resource_essential_contacts_contact_test.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ func TestAccEssentialContactsContact_update(t *testing.T) {
2727
),
2828
},
2929
{
30-
ResourceName: "google_essential_contacts_contact.contact",
31-
ImportState: true,
32-
ImportStateVerify: true,
33-
ImportStateVerifyIgnore: []string{"parent"},
30+
ResourceName: "google_essential_contacts_contact.contact",
31+
ImportState: true,
32+
ImportStateVerify: true,
3433
},
3534
{
3635
Config: testAccEssentialContactsContact_v2(context),
@@ -40,10 +39,9 @@ func TestAccEssentialContactsContact_update(t *testing.T) {
4039
),
4140
},
4241
{
43-
ResourceName: "google_essential_contacts_contact.contact",
44-
ImportState: true,
45-
ImportStateVerify: true,
46-
ImportStateVerifyIgnore: []string{"parent"},
42+
ResourceName: "google_essential_contacts_contact.contact",
43+
ImportState: true,
44+
ImportStateVerify: true,
4745
},
4846
},
4947
})

0 commit comments

Comments
 (0)