provider/aws: Remove sentinel value default for RDS instance; default 1 to match API

This commit is contained in:
Clint Shryock 2015-02-25 10:44:10 -06:00
parent bb94eaa50d
commit 5252623656
2 changed files with 9 additions and 15 deletions

View File

@ -13,12 +13,6 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)
// Establish a sentinel value to allow Backup Rention to 0, disabling backups of
// the RDS Instance. This is needed to distinguish between a zero value in the
// configuration, or no value provided. The default on AWS is 1 (one day).
// See http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html
const backupRetentionPeriodUnset = -1
func resourceAwsDbInstance() *schema.Resource {
return &schema.Resource{
Create: resourceAwsDbInstanceCreate,
@ -91,9 +85,8 @@ func resourceAwsDbInstance() *schema.Resource {
"backup_retention_period": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
Default: backupRetentionPeriodUnset,
Default: 1,
},
"backup_window": &schema.Schema{
@ -208,11 +201,8 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.StorageType = aws.String(attr.(string))
}
// Compare the backup_retention_period value to the Default. This allows a
// zero value for backup_retention_period, disabling backups.
brp := d.Get("backup_retention_period")
if brp != backupRetentionPeriodUnset {
opts.BackupRetentionPeriod = aws.Integer(brp.(int))
if attr, ok := d.GetOk("backup_retention_period"); ok {
opts.BackupRetentionPeriod = aws.Integer(attr.(int))
}
if attr, ok := d.GetOk("iops"); ok {

View File

@ -84,11 +84,15 @@ func testAccCheckAWSDBInstanceAttributes(v *rds.DBInstance) resource.TestCheckFu
return func(s *terraform.State) error {
if *v.Engine != "mysql" {
return fmt.Errorf("bad engine: %#v", v.Engine)
return fmt.Errorf("bad engine: %#v", *v.Engine)
}
if *v.EngineVersion != "5.6.21" {
return fmt.Errorf("bad engine_version: %#v", v.EngineVersion)
return fmt.Errorf("bad engine_version: %#v", *v.EngineVersion)
}
if *v.BackupRetentionPeriod != 0 {
return fmt.Errorf("bad backup_retention_period: %#v", *v.BackupRetentionPeriod)
}
return nil