From b60ae601f3225be1915d93c496ea159055d8e22e Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Fri, 20 Mar 2020 23:47:27 +0000 Subject: [PATCH] Allow import of logging_metric in a non-default project. (#3270) Signed-off-by: Modular Magician --- .changelog/3270.txt | 3 +++ google/resource_bigquery_data_transfer_config.go | 2 +- google/resource_logging_metric.go | 2 +- google/resource_monitoring_alert_policy.go | 2 +- google/resource_monitoring_group.go | 2 +- google/resource_monitoring_notification_channel.go | 2 +- google/resource_monitoring_uptime_check_config.go | 2 +- website/docs/r/logging_metric.html.markdown | 1 + 8 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changelog/3270.txt diff --git a/.changelog/3270.txt b/.changelog/3270.txt new file mode 100644 index 00000000000..2886c39c821 --- /dev/null +++ b/.changelog/3270.txt @@ -0,0 +1,3 @@ +```release-note:bug +logging: Fixed import issue with `google_logging_metric` in a non-default project. +``` diff --git a/google/resource_bigquery_data_transfer_config.go b/google/resource_bigquery_data_transfer_config.go index 6e3f141a692..38f21e4f88c 100644 --- a/google/resource_bigquery_data_transfer_config.go +++ b/google/resource_bigquery_data_transfer_config.go @@ -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.+)"}, d, config); err != nil { + if err := parseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { return nil, err } diff --git a/google/resource_logging_metric.go b/google/resource_logging_metric.go index 8b3bf61d298..5aa056a48cb 100644 --- a/google/resource_logging_metric.go +++ b/google/resource_logging_metric.go @@ -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.+)"}, d, config); err != nil { + if err := parseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { return nil, err } diff --git a/google/resource_monitoring_alert_policy.go b/google/resource_monitoring_alert_policy.go index 5acbf96f904..52eea048aab 100644 --- a/google/resource_monitoring_alert_policy.go +++ b/google/resource_monitoring_alert_policy.go @@ -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.+)"}, d, config); err != nil { + if err := parseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { return nil, err } diff --git a/google/resource_monitoring_group.go b/google/resource_monitoring_group.go index 946f6ce806c..7309fc2eaf3 100644 --- a/google/resource_monitoring_group.go +++ b/google/resource_monitoring_group.go @@ -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.+)"}, d, config); err != nil { + if err := parseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { return nil, err } diff --git a/google/resource_monitoring_notification_channel.go b/google/resource_monitoring_notification_channel.go index 2121236468e..c00313e5969 100644 --- a/google/resource_monitoring_notification_channel.go +++ b/google/resource_monitoring_notification_channel.go @@ -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.+)"}, d, config); err != nil { + if err := parseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { return nil, err } diff --git a/google/resource_monitoring_uptime_check_config.go b/google/resource_monitoring_uptime_check_config.go index 7f0dee7cff9..7af6d7a0674 100644 --- a/google/resource_monitoring_uptime_check_config.go +++ b/google/resource_monitoring_uptime_check_config.go @@ -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.+)"}, d, config); err != nil { + if err := parseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { return nil, err } diff --git a/website/docs/r/logging_metric.html.markdown b/website/docs/r/logging_metric.html.markdown index 9a8f09ead58..f7be1eff680 100644 --- a/website/docs/r/logging_metric.html.markdown +++ b/website/docs/r/logging_metric.html.markdown @@ -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}} ```