Skip to content

Commit

Permalink
Merge pull request #7 from wayfair/ishashchuk_notifications
Browse files Browse the repository at this point in the history
Using ImportStatePassthrough
  • Loading branch information
amoiseiev authored Feb 5, 2018
2 parents 93dd896 + 4794d18 commit c4b6a26
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions google/resource_storage_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func resourceStorageNotification() *schema.Resource {
Read: resourceStorageNotificationRead,
Delete: resourceStorageNotificationDelete,
Importer: &schema.ResourceImporter{
State: resourceStorageNotificationImportState,
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -114,6 +114,7 @@ func resourceStorageNotificationRead(d *schema.ResourceData, meta interface{}) e
return handleNotFoundError(err, d, fmt.Sprintf("Notification configuration %s for bucket %s", notificationID, bucket))
}

d.Set("bucket", bucket)
d.Set("payload_format", res.PayloadFormat)
d.Set("topic", res.Topic)
d.Set("object_name_prefix", res.ObjectNamePrefix)
Expand All @@ -137,18 +138,6 @@ func resourceStorageNotificationDelete(d *schema.ResourceData, meta interface{})
return nil
}

func resourceStorageNotificationImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
bucket, _ := resourceStorageNotificationParseID(d.Id())

d.Set("bucket", bucket)

if err := resourceStorageNotificationRead(d, meta); err != nil {
return nil, err
}

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

func resourceStorageNotificationParseID(id string) (string, string) {
//bucket, NotificationID
parts := strings.Split(id, "/")
Expand Down

0 comments on commit c4b6a26

Please sign in to comment.