Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ committed Apr 30, 2020
1 parent d34abc5 commit dda9caf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Expand Up @@ -3,7 +3,6 @@ package parse
import (
"fmt"
"regexp"
"strings"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)
Expand Down Expand Up @@ -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 {
Expand All @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/maintenance_assignment.html.markdown
Expand Up @@ -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

Expand Down

0 comments on commit dda9caf

Please sign in to comment.