mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Remove sentinel value default for RDS instance; default 1 to match API
This commit is contained in:
parent
bb94eaa50d
commit
5252623656
@ -13,12 +13,6 @@ import (
|
|||||||
"github.com/hashicorp/terraform/helper/schema"
|
"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 {
|
func resourceAwsDbInstance() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
Create: resourceAwsDbInstanceCreate,
|
Create: resourceAwsDbInstanceCreate,
|
||||||
@ -91,9 +85,8 @@ func resourceAwsDbInstance() *schema.Resource {
|
|||||||
"backup_retention_period": &schema.Schema{
|
"backup_retention_period": &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Default: backupRetentionPeriodUnset,
|
Default: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
"backup_window": &schema.Schema{
|
"backup_window": &schema.Schema{
|
||||||
@ -208,11 +201,8 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
|
|||||||
opts.StorageType = aws.String(attr.(string))
|
opts.StorageType = aws.String(attr.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare the backup_retention_period value to the Default. This allows a
|
if attr, ok := d.GetOk("backup_retention_period"); ok {
|
||||||
// zero value for backup_retention_period, disabling backups.
|
opts.BackupRetentionPeriod = aws.Integer(attr.(int))
|
||||||
brp := d.Get("backup_retention_period")
|
|
||||||
if brp != backupRetentionPeriodUnset {
|
|
||||||
opts.BackupRetentionPeriod = aws.Integer(brp.(int))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if attr, ok := d.GetOk("iops"); ok {
|
if attr, ok := d.GetOk("iops"); ok {
|
||||||
|
@ -84,11 +84,15 @@ func testAccCheckAWSDBInstanceAttributes(v *rds.DBInstance) resource.TestCheckFu
|
|||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
|
|
||||||
if *v.Engine != "mysql" {
|
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" {
|
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
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user