From 12d51edeb6024e0f976368368222d11b23b59285 Mon Sep 17 00:00:00 2001 From: Chris Busbey Date: Tue, 17 Nov 2015 12:48:56 -0800 Subject: [PATCH] allow spaces in db subnet name --- .../providers/aws/resource_aws_db_subnet_group.go | 4 ++-- .../aws/resource_aws_db_subnet_group_test.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_subnet_group.go b/builtin/providers/aws/resource_aws_db_subnet_group.go index e6b17ea1f..cbfed609a 100644 --- a/builtin/providers/aws/resource_aws_db_subnet_group.go +++ b/builtin/providers/aws/resource_aws_db_subnet_group.go @@ -29,9 +29,9 @@ func resourceAwsDbSubnetGroup() *schema.Resource { Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexp.MustCompile(`^[.0-9A-Za-z-_]+$`).MatchString(value) { + if !regexp.MustCompile(`^[ .0-9A-Za-z-_]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( - "only alphanumeric characters, hyphens, underscores, and periods allowed in %q", k)) + "only alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } if len(value) > 255 { errors = append(errors, fmt.Errorf( diff --git a/builtin/providers/aws/resource_aws_db_subnet_group_test.go b/builtin/providers/aws/resource_aws_db_subnet_group_test.go index e189b1e21..d943294a9 100644 --- a/builtin/providers/aws/resource_aws_db_subnet_group_test.go +++ b/builtin/providers/aws/resource_aws_db_subnet_group_test.go @@ -51,12 +51,14 @@ func TestAccAWSDBSubnetGroup_withUndocumentedCharacters(t *testing.T) { CheckDestroy: testAccCheckDBSubnetGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDBSubnetGroupConfig_withUnderscoresAndPeriods, + Config: testAccDBSubnetGroupConfig_withUnderscoresAndPeriodsAndSpaces, Check: resource.ComposeTestCheckFunc( testAccCheckDBSubnetGroupExists( "aws_db_subnet_group.underscores", &v), testAccCheckDBSubnetGroupExists( "aws_db_subnet_group.periods", &v), + testAccCheckDBSubnetGroupExists( + "aws_db_subnet_group.spaces", &v), testCheck, ), }, @@ -156,7 +158,7 @@ resource "aws_db_subnet_group" "foo" { } ` -const testAccDBSubnetGroupConfig_withUnderscoresAndPeriods = ` +const testAccDBSubnetGroupConfig_withUnderscoresAndPeriodsAndSpaces = ` resource "aws_vpc" "main" { cidr_block = "192.168.0.0/16" } @@ -184,4 +186,10 @@ resource "aws_db_subnet_group" "periods" { description = "Our main group of subnets" subnet_ids = ["${aws_subnet.frontend.id}", "${aws_subnet.backend.id}"] } + +resource "aws_db_subnet_group" "spaces" { + name = "with spaces" + description = "Our main group of subnets" + subnet_ids = ["${aws_subnet.frontend.id}", "${aws_subnet.backend.id}"] +} `