Skip to content

Commit

Permalink
Merge pull request #5621 from terraform-providers/b-aws_db_instance-s…
Browse files Browse the repository at this point in the history
…napshot_identifier-2x

resource/aws_db_instance: Prevent double apply for snapshot_identifier with multiple other arguments
  • Loading branch information
bflad authored Aug 22, 2018
2 parents adfd61a + 09be94f commit 7b0a1d4
Show file tree
Hide file tree
Showing 2 changed files with 391 additions and 2 deletions.
31 changes: 29 additions & 2 deletions aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,13 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
var requiresModifyDbInstance bool

opts := rds.RestoreDBInstanceFromDBSnapshotInput{
AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)),
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
DBInstanceClass: aws.String(d.Get("instance_class").(string)),
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
DBSnapshotIdentifier: aws.String(d.Get("snapshot_identifier").(string)),
AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)),
PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)),
Tags: tags,
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
}

if attr, ok := d.GetOk("name"); ok {
Expand All @@ -696,6 +696,14 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.AvailabilityZone = aws.String(attr.(string))
}

if _, ok := d.GetOk("backup_retention_period"); ok {
requiresModifyDbInstance = true
}

if _, ok := d.GetOk("backup_window"); ok {
requiresModifyDbInstance = true
}

if attr, ok := d.GetOk("db_subnet_group_name"); ok {
opts.DBSubnetGroupName = aws.String(attr.(string))
}
Expand All @@ -708,6 +716,10 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.Engine = aws.String(attr.(string))
}

if _, ok := d.GetOk("iam_database_authentication_enabled"); ok {
requiresModifyDbInstance = true
}

if attr, ok := d.GetOk("iops"); ok {
opts.Iops = aws.Int64(int64(attr.(int)))
}
Expand All @@ -716,6 +728,18 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.LicenseModel = aws.String(attr.(string))
}

if _, ok := d.GetOk("maintenance_window"); ok {
requiresModifyDbInstance = true
}

if _, ok := d.GetOk("monitoring_interval"); ok {
requiresModifyDbInstance = true
}

if _, ok := d.GetOk("monitoring_role_arn"); ok {
requiresModifyDbInstance = true
}

if attr, ok := d.GetOk("multi_az"); ok {
// When using SQL Server engine with MultiAZ enabled, its not
// possible to immediately enable mirroring since
Expand All @@ -732,7 +756,10 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error

if attr, ok := d.GetOk("option_group_name"); ok {
opts.OptionGroupName = aws.String(attr.(string))
}

if _, ok := d.GetOk("parameter_group_name"); ok {
requiresModifyDbInstance = true
}

if _, ok := d.GetOk("password"); ok {
Expand Down
Loading

0 comments on commit 7b0a1d4

Please sign in to comment.