Skip to content

Commit 1f7e84c

Browse files
Kit EwbankKit Ewbank
Kit Ewbank
authored and
Kit Ewbank
committed
Call 'parseLoggingSinkId' to parse logging project sink ID.
1 parent a51117c commit 1f7e84c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

google/resource_logging_project_sink.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package google
22

33
import (
44
"fmt"
5-
"strings"
65

76
"github.com/hashicorp/terraform/helper/schema"
87
)
@@ -106,13 +105,16 @@ func resourceLoggingProjectSinkDelete(d *schema.ResourceData, meta interface{})
106105
}
107106

108107
func resourceLoggingProjectSinkImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
109-
parts := strings.Split(d.Id(), "/")
110-
if len(parts) != 4 {
111-
return nil, fmt.Errorf("Invalid logging sink specifier. Expecting projects/{project_id}/sinks/{sink_id}")
108+
config := meta.(*Config)
109+
110+
loggingSinkId, err := parseLoggingSinkId(d.Id())
111+
if err != nil {
112+
return nil, err
112113
}
113114

114-
project := parts[1]
115-
d.Set("project", project)
115+
if config.Project != loggingSinkId.resourceId {
116+
d.Set("project", loggingSinkId.resourceId)
117+
}
116118

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

0 commit comments

Comments
 (0)