Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_db_instance: Prevent double apply for snapshot_identifier with multiple other arguments #5621

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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