diff --git a/azurerm/internal/services/maintenance/parse/maintenance_assignment.go b/azurerm/internal/services/maintenance/parse/maintenance_assignment.go index 9025038228d5e..dacaff662addd 100644 --- a/azurerm/internal/services/maintenance/parse/maintenance_assignment.go +++ b/azurerm/internal/services/maintenance/parse/maintenance_assignment.go @@ -3,7 +3,6 @@ package parse import ( "fmt" "regexp" - "strings" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) @@ -71,11 +70,11 @@ func TargetResourceID(input string) (TargetResourceId, error) { id, err := azure.ParseAzureResourceID(input) if err != nil { - return nil, fmt.Errorf("parsing target resource id %q: %+v", input, err) + return nil, fmt.Errorf("cannot parse target resource id %q: %+v", input, err) } if len(id.Path) != 1 && len(id.Path) != 2 { - return nil, fmt.Errorf("parsing target resource id %q", input) + return nil, fmt.Errorf("cannot parse target resource id %q: too many segments", input) } if len(id.Path) == 1 { @@ -94,11 +93,9 @@ func TargetResourceID(input string) (TargetResourceId, error) { }, nil } - resourceId := strings.TrimPrefix(input, "/") - resourceId = strings.TrimSuffix(resourceId, "/") - groups := regexp.MustCompile(`^subscriptions/.+/resource[gG]roups/.+/providers/.+/(.+)/(.+)/(.+)/(.+)$`).FindStringSubmatch(resourceId) + groups := regexp.MustCompile(`^/subscriptions/[^/]+/resource[gG]roups/[^/]+/providers/[^/]+/([^/]+)/([^/]+)/([^/]+)/([^/]+)$`).FindStringSubmatch(input) if len(groups) != 5 { - return nil, fmt.Errorf("parsing target resource id: %q", resourceId) + return nil, fmt.Errorf("cannot parse target resource id: %q", input) } return ScopeInResource{ diff --git a/website/docs/r/maintenance_assignment.html.markdown b/website/docs/r/maintenance_assignment.html.markdown index 82210e2bc2d51..72a732a1b332b 100644 --- a/website/docs/r/maintenance_assignment.html.markdown +++ b/website/docs/r/maintenance_assignment.html.markdown @@ -96,9 +96,9 @@ The following arguments are supported: * `location` - (Required) Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created. -* `maintenance_configuration_id` - (Required) Specified the id of Maintenance Configuration Resource. Changing this forces a new resource to be created. +* `maintenance_configuration_id` - (Required) Specified the ID of Maintenance Configuration Resource. Changing this forces a new resource to be created. -* `target_resource_id` - (Required) Specified the target resource id where the Maintenance Configuration will be assigned to. Currently, only `Virtual Machine` and `Dedicated Host` resources are supported. Changing this forces a new resource to be created. +* `target_resource_id` - (Required) Specified the target resource ID where the Maintenance Configuration will be assigned to. Currently, only `Virtual Machine` and `Dedicated Host` resources are supported. Changing this forces a new resource to be created. ## Attributes Reference