allow spaces in db subnet name

This commit is contained in:
Chris Busbey 2015-11-17 12:48:56 -08:00
parent e7a054c9dd
commit 12d51edeb6
2 changed files with 12 additions and 4 deletions

View File

@ -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(

View File

@ -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}"]
}
`