provider/aws: validate RDS final_snapshot_identifier

fixes #2250
This commit is contained in:
Paul Hinze 2015-06-07 20:49:48 -05:00
parent 61fee6735d
commit 37b234e42b
1 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package aws
import ( import (
"fmt" "fmt"
"log" "log"
"regexp"
"strings" "strings"
"time" "time"
@ -153,6 +154,20 @@ func resourceAwsDbInstance() *schema.Resource {
"final_snapshot_identifier": &schema.Schema{ "final_snapshot_identifier": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ValidateFunc: func(v interface{}) (ws []string, es []error) {
fsi := v.(string)
if !regexp.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(fsi) {
es = append(es, fmt.Errorf(
"only alphanumeric characters and hyphens allowed"))
}
if regexp.MustCompile(`--`).MatchString(fsi) {
es = append(es, fmt.Errorf("cannot contain two consecutive hyphens"))
}
if regexp.MustCompile(`-$`).MatchString(fsi) {
es = append(es, fmt.Errorf("cannot end in a hyphen"))
}
return
},
}, },
"db_subnet_group_name": &schema.Schema{ "db_subnet_group_name": &schema.Schema{