provider/aws: Force lowercasing for DB Option group name or name_prefix (#14366)
This commit is contained in:
parent
d203131bf2
commit
24e00af217
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue