diff --git a/azurerm/resource_arm_management_lock.go b/azurerm/resource_arm_management_lock.go index 47e661bb1144..70b4ebdd7504 100644 --- a/azurerm/resource_arm_management_lock.go +++ b/azurerm/resource_arm_management_lock.go @@ -161,8 +161,12 @@ func parseAzureRMLockId(id string) (*AzureManagementLockId, error) { func validateArmManagementLockName(v interface{}, k string) (ws []string, es []error) { input := v.(string) - if !regexp.MustCompile(`\A([A-Za-z0-9\-_]{1, 260})\z`).MatchString(input) { - es = append(es, fmt.Errorf("%s can only consist of alphanumeric characters, dashes and underscores - and must be a maxiumum of 260 characters", k)) + if !regexp.MustCompile(`[A-Za-z0-9-_]`).MatchString(input) { + es = append(es, fmt.Errorf("%s can only consist of alphanumeric characters, dashes and underscores", k)) + } + + if len(input) >= 260 { + es = append(es, fmt.Errorf("%s can only be a maximum of 260 characters", k)) } return diff --git a/azurerm/resource_arm_management_lock_test.go b/azurerm/resource_arm_management_lock_test.go index 9c57436b6f08..e75d7113c5a1 100644 --- a/azurerm/resource_arm_management_lock_test.go +++ b/azurerm/resource_arm_management_lock_test.go @@ -31,7 +31,7 @@ func TestValidateManagementLockName(t *testing.T) { } for _, test := range testCases { - _, es := validateArmStorageAccountName(test.input, "name") + _, es := validateArmManagementLockName(test.input, "name") if test.shouldError && len(es) == 0 { t.Fatalf("Expected validating name %q to fail", test.input)