Skip to content

Commit

Permalink
Allow import of logging_metric in a non-default project. (#3270) (#5944)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Mar 20, 2020
1 parent 96f640e commit 740822e
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/3270.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
logging: Fixed import issue with `google_logging_metric` in a non-default project.
```
2 changes: 1 addition & 1 deletion google/resource_bigquery_data_transfer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func resourceBigqueryDataTransferConfigImport(d *schema.ResourceData, meta inter
config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
if err := parseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion google/resource_logging_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func resourceLoggingMetricImport(d *schema.ResourceData, meta interface{}) ([]*s
config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
if err := parseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion google/resource_monitoring_alert_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ func resourceMonitoringAlertPolicyImport(d *schema.ResourceData, meta interface{
config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
if err := parseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion google/resource_monitoring_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func resourceMonitoringGroupImport(d *schema.ResourceData, meta interface{}) ([]
config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
if err := parseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion google/resource_monitoring_notification_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func resourceMonitoringNotificationChannelImport(d *schema.ResourceData, meta in
config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
if err := parseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion google/resource_monitoring_uptime_check_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func resourceMonitoringUptimeCheckConfigImport(d *schema.ResourceData, meta inte
config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
if err := parseImportId([]string{"(?P<project>[^ ]+) (?P<name>[^ ]+)", "(?P<name>[^ ]+)"}, d, config); err != nil {
return nil, err
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/logging_metric.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ This resource provides the following
Metric can be imported using any of these accepted formats:

```
$ terraform import google_logging_metric.default {{project}} {{name}}
$ terraform import google_logging_metric.default {{name}}
```

Expand Down

0 comments on commit 740822e

Please sign in to comment.