diff --git a/builtin/providers/aws/resource_aws_db_option_group.go b/builtin/providers/aws/resource_aws_db_option_group.go index f1d962923..cf6065ac0 100644 --- a/builtin/providers/aws/resource_aws_db_option_group.go +++ b/builtin/providers/aws/resource_aws_db_option_group.go @@ -37,10 +37,6 @@ func resourceAwsDbOptionGroup() *schema.Resource { ForceNew: true, ConflictsWith: []string{"name_prefix"}, ValidateFunc: validateDbOptionGroupName, - StateFunc: func(v interface{}) string { - value := v.(string) - return strings.ToLower(value) - }, }, "name_prefix": &schema.Schema{ Type: schema.TypeString, @@ -48,10 +44,6 @@ func resourceAwsDbOptionGroup() *schema.Resource { Computed: true, ForceNew: true, ValidateFunc: validateDbOptionGroupNamePrefix, - StateFunc: func(v interface{}) string { - value := v.(string) - return strings.ToLower(value) - }, }, "engine_name": &schema.Schema{ Type: schema.TypeString, @@ -148,7 +140,7 @@ func resourceAwsDbOptionGroupCreate(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("Error creating DB Option Group: %s", err) } - d.SetId(groupName) + d.SetId(strings.ToLower(groupName)) log.Printf("[INFO] DB Option Group ID: %s", d.Id()) return resourceAwsDbOptionGroupUpdate(d, meta) diff --git a/builtin/providers/aws/resource_aws_db_option_group_test.go b/builtin/providers/aws/resource_aws_db_option_group_test.go index a39aeb0bf..8e9b22e1b 100644 --- a/builtin/providers/aws/resource_aws_db_option_group_test.go +++ b/builtin/providers/aws/resource_aws_db_option_group_test.go @@ -49,7 +49,7 @@ func TestAccAWSDBOptionGroup_namePrefix(t *testing.T) { testAccCheckAWSDBOptionGroupExists("aws_db_option_group.test", &v), testAccCheckAWSDBOptionGroupAttributes(&v), resource.TestMatchResourceAttr( - "aws_db_option_group.test", "name", regexp.MustCompile("^tf-TEST-")), + "aws_db_option_group.test", "name", regexp.MustCompile("^tf-test-")), ), }, }, @@ -112,7 +112,7 @@ func TestAccAWSDBOptionGroup_basicDestroyWithInstance(t *testing.T) { func TestAccAWSDBOptionGroup_OptionSettings(t *testing.T) { var v rds.OptionGroup - rName := fmt.Sprintf("option-group-TEST-terraform-%s", acctest.RandString(5)) + rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -149,7 +149,7 @@ func TestAccAWSDBOptionGroup_OptionSettings(t *testing.T) { func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) { var v rds.OptionGroup - rName := fmt.Sprintf("option-group-TEST-terraform-%s", acctest.RandString(5)) + rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -181,7 +181,7 @@ func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) { func TestAccAWSDBOptionGroup_multipleOptions(t *testing.T) { var v rds.OptionGroup - rName := fmt.Sprintf("option-group-TEST-terraform-%s", acctest.RandString(5)) + rName := fmt.Sprintf("option-group-test-terraform-%s", acctest.RandString(5)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -434,7 +434,7 @@ resource "aws_db_option_group" "test" { func testAccAWSDBOptionGroup_defaultDescription(n int) string { return fmt.Sprintf(` resource "aws_db_option_group" "test" { - name = "tf-TEST-%d" + name = "tf-test-%d" engine_name = "mysql" major_engine_version = "5.6" } diff --git a/builtin/providers/aws/validators.go b/builtin/providers/aws/validators.go index f09745491..f46c550d2 100644 --- a/builtin/providers/aws/validators.go +++ b/builtin/providers/aws/validators.go @@ -1141,9 +1141,9 @@ func validateDbOptionGroupName(v interface{}, k string) (ws []string, errors []e errors = append(errors, fmt.Errorf( "first character of %q must be a letter", k)) } - if !regexp.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(value) { + if !regexp.MustCompile(`^[0-9a-z-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( - "only alphanumeric characters and hyphens allowed in %q", k)) + "only lowercase alphanumeric characters and hyphens allowed in %q", k)) } if regexp.MustCompile(`--`).MatchString(value) { errors = append(errors, fmt.Errorf( @@ -1166,7 +1166,7 @@ func validateDbOptionGroupNamePrefix(v interface{}, k string) (ws []string, erro errors = append(errors, fmt.Errorf( "first character of %q must be a letter", k)) } - if !regexp.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(value) { + if !regexp.MustCompile(`^[0-9a-z-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only alphanumeric characters and hyphens allowed in %q", k)) } diff --git a/website/source/docs/providers/aws/r/db_option_group.html.markdown b/website/source/docs/providers/aws/r/db_option_group.html.markdown index db2657a31..8c9b17e42 100644 --- a/website/source/docs/providers/aws/r/db_option_group.html.markdown +++ b/website/source/docs/providers/aws/r/db_option_group.html.markdown @@ -38,8 +38,8 @@ resource "aws_db_option_group" "bar" { The following arguments are supported: -* `name` - (Optional, Forces new resource) The name of the option group. If omitted, Terraform will assign a random, unique name. This is converted to lowercase, as is stored in AWS. -* `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with `name`. This is converted to lowercase, as is stored in AWS. +* `name` - (Optional, Forces new resource) The name of the option group. If omitted, Terraform will assign a random, unique name. Must be lowercase, to match as it is stored in AWS. +* `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with `name`. Must be lowercase, to match as it is stored in AWS. * `option_group_description` - (Optional) The description of the option group. Defaults to "Managed by Terraform". * `engine_name` - (Required) Specifies the name of the engine that this option group should be associated with. * `major_engine_version` - (Required) Specifies the major version of the engine that this option group should be associated with.