From 33ed47c94081273d71f6fc870fbc2ef2e7947d23 Mon Sep 17 00:00:00 2001 From: Bertrand Roussel Date: Sat, 14 Jul 2018 16:30:38 -0700 Subject: [PATCH] Allow - in disk snapshot names It appears that - was omitted from the possible character in snapshot names. It doesn't seem like there is any issue when using - in the name, as I was able to create snapshots with dashes both from the portal and through this plugin (with this patch applied). --- azurerm/resource_arm_snapshot.go | 4 ++-- azurerm/resource_arm_snapshot_test.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_snapshot.go b/azurerm/resource_arm_snapshot.go index ce1579632fb8..1652acdf66a8 100644 --- a/azurerm/resource_arm_snapshot.go +++ b/azurerm/resource_arm_snapshot.go @@ -216,10 +216,10 @@ func resourceArmSnapshotDelete(d *schema.ResourceData, meta interface{}) error { } func validateSnapshotName(v interface{}, k string) (ws []string, errors []error) { - // a-z, A-Z, 0-9 and _. The max name length is 80 + // a-z, A-Z, 0-9, _ and -. The max name length is 80 value := v.(string) - r, _ := regexp.Compile("^[A-Za-z0-9_]+$") + r, _ := regexp.Compile("^[A-Za-z0-9_-]+$") if !r.MatchString(value) { errors = append(errors, fmt.Errorf("Snapshot Names can only contain alphanumeric characters and underscores.")) } diff --git a/azurerm/resource_arm_snapshot_test.go b/azurerm/resource_arm_snapshot_test.go index d996ead4bf32..4e9d78f944a0 100644 --- a/azurerm/resource_arm_snapshot_test.go +++ b/azurerm/resource_arm_snapshot_test.go @@ -30,12 +30,16 @@ func TestSnapshotName_validation(t *testing.T) { }, { Value: "hello-world", - ErrCount: 1, + ErrCount: 0, }, { Value: "hello_world", ErrCount: 0, }, + { + Value: "hello+world", + ErrCount: 1, + }, { Value: str, ErrCount: 0,