From d5a228360e680791287ff1abe574529763a0679f Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Tue, 31 Mar 2020 08:45:07 -0500 Subject: [PATCH] support volumes created before name rules changed (#404) * support volumes created before name rules changed In 2019, DigitalOcean accepted volumes created with underscores in the name. In 2020, this is no longer the case but it leaves us without a way to work with volumes created in the old rules. * Add comment on why regexp does not match message. Co-authored-by: Andrew Starr-Bochicchio --- digitalocean/resource_digitalocean_volume.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/digitalocean/resource_digitalocean_volume.go b/digitalocean/resource_digitalocean_volume.go index 263e9ab9..2c868a34 100644 --- a/digitalocean/resource_digitalocean_volume.go +++ b/digitalocean/resource_digitalocean_volume.go @@ -34,10 +34,12 @@ func resourceDigitalOceanVolume() *schema.Resource { }, "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z0-9\-]+$`), "Names must be lowercase and be composed only of numbers, letters and \"-\"."), + Type: schema.TypeString, + Required: true, + ForceNew: true, + // Underscores (_) allowed for backwards compatibility. + // See: https://github.com/terraform-providers/terraform-provider-digitalocean/pull/404 + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z0-9\-_]+$`), "Names must be lowercase and be composed only of numbers, letters and \"-\"."), }, "urn": { Type: schema.TypeString,