From 0bb6511ffa7ce5c82aaeda9fb7460cd433906d8a Mon Sep 17 00:00:00 2001 From: "Michael \"Gilli\" Gilliland" Date: Sun, 2 Jul 2017 22:14:22 -0400 Subject: [PATCH 1/2] Fix azure table storage name length requirement. https://docs.microsoft.com/en-us/rest/api/storageservices/Understanding-the-Table-Service-Data-Model?redirectedfrom=MSDN#table-names. --- azurerm/resource_arm_storage_table.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_storage_table.go b/azurerm/resource_arm_storage_table.go index 3db39165a93e..f82ec1d8338c 100644 --- a/azurerm/resource_arm_storage_table.go +++ b/azurerm/resource_arm_storage_table.go @@ -43,9 +43,9 @@ func validateArmStorageTableName(v interface{}, k string) (ws []string, errors [ "Table Storage %q cannot use the word `table`: %q", k, value)) } - if !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]{6,63}$`).MatchString(value) { + if !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]{2,62}$`).MatchString(value) { errors = append(errors, fmt.Errorf( - "Table Storage %q cannot begin with a numeric character, only alphanumeric characters are allowed and must be between 6 and 63 characters long: %q", + "Table Storage %q cannot begin with a numeric character, only alphanumeric characters are allowed and must be between 3 and 63 characters long: %q", k, value)) } From d9f6c25d939ac84e65a8142dafe46988aa35fa0a Mon Sep 17 00:00:00 2001 From: "Michael \"Gilli\" Gilliland" Date: Mon, 3 Jul 2017 20:45:57 -0400 Subject: [PATCH 2/2] Add some boundary tests around storage table name length requirements. --- azurerm/resource_arm_storage_table_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_storage_table_test.go b/azurerm/resource_arm_storage_table_test.go index 33cc095aa738..f3b99f5441ec 100644 --- a/azurerm/resource_arm_storage_table_test.go +++ b/azurerm/resource_arm_storage_table_test.go @@ -192,6 +192,8 @@ func TestValidateArmStorageTableName(t *testing.T) { "mytable", "myTable", "MYTABLE", + "tbl", + strings.Repeat("w", 63), } for _, v := range validNames { _, errors := validateArmStorageTableName(v, "name") @@ -206,7 +208,7 @@ func TestValidateArmStorageTableName(t *testing.T) { "invalid_name", "invalid!", "ww", - strings.Repeat("w", 65), + strings.Repeat("w", 64), } for _, v := range invalidNames { _, errors := validateArmStorageTableName(v, "name")