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

service/rds: Remove deprecated (helper/schema.ResourceData).Partial() and (helper/schema.ResourceData).SetPartial() #12477

Merged
merged 1 commit into from
Mar 30, 2020
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
2 changes: 0 additions & 2 deletions aws/resource_aws_db_cluster_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ func resourceAwsdbClusterSnapshotUpdate(d *schema.ResourceData, meta interface{}
if err := keyvaluetags.RdsUpdateTags(conn, d.Get("db_cluster_snapshot_arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS DB Cluster Snapshot (%s) tags: %s", d.Get("db_cluster_snapshot_arn").(string), err)
}

d.SetPartial("tags")
}

return nil
Expand Down
10 changes: 0 additions & 10 deletions aws/resource_aws_db_event_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ func resourceAwsDbEventSubscriptionRetrieve(name string, conn *rds.RDS) (*rds.Ev
func resourceAwsDbEventSubscriptionUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn

d.Partial(true)
requestUpdate := false

req := &rds.ModifyEventSubscriptionInput{
Expand Down Expand Up @@ -293,10 +292,6 @@ func resourceAwsDbEventSubscriptionUpdate(d *schema.ResourceData, meta interface
if err != nil {
return fmt.Errorf("Modifying RDS Event Subscription %s failed: %s", d.Id(), err)
}
d.SetPartial("event_categories")
d.SetPartial("enabled")
d.SetPartial("sns_topic")
d.SetPartial("source_type")
}

if d.HasChange("tags") {
Expand All @@ -305,8 +300,6 @@ func resourceAwsDbEventSubscriptionUpdate(d *schema.ResourceData, meta interface
if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS Event Subscription (%s) tags: %s", d.Get("arn").(string), err)
}

d.SetPartial("tags")
}

if d.HasChange("source_ids") {
Expand Down Expand Up @@ -348,11 +341,8 @@ func resourceAwsDbEventSubscriptionUpdate(d *schema.ResourceData, meta interface
}
}
}
d.SetPartial("source_ids")
}

d.Partial(false)

return nil
}

Expand Down
36 changes: 0 additions & 36 deletions aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,81 +1470,64 @@ func waitUntilAwsDbInstanceIsDeleted(id string, conn *rds.RDS, timeout time.Dura
func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn

d.Partial(true)

req := &rds.ModifyDBInstanceInput{
ApplyImmediately: aws.Bool(d.Get("apply_immediately").(bool)),
DBInstanceIdentifier: aws.String(d.Id()),
}

d.SetPartial("apply_immediately")

if !aws.BoolValue(req.ApplyImmediately) {
log.Println("[INFO] Only settings updating, instance changes will be applied in next maintenance window")
}

requestUpdate := false
if d.HasChange("allocated_storage") || d.HasChange("iops") {
d.SetPartial("allocated_storage")
d.SetPartial("iops")
req.Iops = aws.Int64(int64(d.Get("iops").(int)))
req.AllocatedStorage = aws.Int64(int64(d.Get("allocated_storage").(int)))
requestUpdate = true
}
if d.HasChange("allow_major_version_upgrade") {
d.SetPartial("allow_major_version_upgrade")
req.AllowMajorVersionUpgrade = aws.Bool(d.Get("allow_major_version_upgrade").(bool))
// Having allowing_major_version_upgrade by itself should not trigger ModifyDBInstance
// as it results in InvalidParameterCombination: No modifications were requested
}
if d.HasChange("backup_retention_period") {
d.SetPartial("backup_retention_period")
req.BackupRetentionPeriod = aws.Int64(int64(d.Get("backup_retention_period").(int)))
requestUpdate = true
}
if d.HasChange("copy_tags_to_snapshot") {
d.SetPartial("copy_tags_to_snapshot")
req.CopyTagsToSnapshot = aws.Bool(d.Get("copy_tags_to_snapshot").(bool))
requestUpdate = true
}
if d.HasChange("ca_cert_identifier") {
d.SetPartial("ca_cert_identifier")
req.CACertificateIdentifier = aws.String(d.Get("ca_cert_identifier").(string))
requestUpdate = true
}
if d.HasChange("deletion_protection") {
d.SetPartial("deletion_protection")
req.DeletionProtection = aws.Bool(d.Get("deletion_protection").(bool))
requestUpdate = true
}
if d.HasChange("instance_class") {
d.SetPartial("instance_class")
req.DBInstanceClass = aws.String(d.Get("instance_class").(string))
requestUpdate = true
}
if d.HasChange("parameter_group_name") {
d.SetPartial("parameter_group_name")
req.DBParameterGroupName = aws.String(d.Get("parameter_group_name").(string))
requestUpdate = true
}
if d.HasChange("engine_version") {
d.SetPartial("engine_version")
req.EngineVersion = aws.String(d.Get("engine_version").(string))
req.AllowMajorVersionUpgrade = aws.Bool(d.Get("allow_major_version_upgrade").(bool))
requestUpdate = true
}
if d.HasChange("backup_window") {
d.SetPartial("backup_window")
req.PreferredBackupWindow = aws.String(d.Get("backup_window").(string))
requestUpdate = true
}
if d.HasChange("maintenance_window") {
d.SetPartial("maintenance_window")
req.PreferredMaintenanceWindow = aws.String(d.Get("maintenance_window").(string))
requestUpdate = true
}
if d.HasChange("max_allocated_storage") {
d.SetPartial("max_allocated_storage")
mas := d.Get("max_allocated_storage").(int)

// The API expects the max allocated storage value to be set to the allocated storage
Expand All @@ -1558,22 +1541,18 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
requestUpdate = true
}
if d.HasChange("password") {
d.SetPartial("password")
req.MasterUserPassword = aws.String(d.Get("password").(string))
requestUpdate = true
}
if d.HasChange("multi_az") {
d.SetPartial("multi_az")
req.MultiAZ = aws.Bool(d.Get("multi_az").(bool))
requestUpdate = true
}
if d.HasChange("publicly_accessible") {
d.SetPartial("publicly_accessible")
req.PubliclyAccessible = aws.Bool(d.Get("publicly_accessible").(bool))
requestUpdate = true
}
if d.HasChange("storage_type") {
d.SetPartial("storage_type")
req.StorageType = aws.String(d.Get("storage_type").(string))
requestUpdate = true

Expand All @@ -1582,19 +1561,16 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
}
}
if d.HasChange("auto_minor_version_upgrade") {
d.SetPartial("auto_minor_version_upgrade")
req.AutoMinorVersionUpgrade = aws.Bool(d.Get("auto_minor_version_upgrade").(bool))
requestUpdate = true
}

if d.HasChange("monitoring_role_arn") {
d.SetPartial("monitoring_role_arn")
req.MonitoringRoleArn = aws.String(d.Get("monitoring_role_arn").(string))
requestUpdate = true
}

if d.HasChange("monitoring_interval") {
d.SetPartial("monitoring_interval")
req.MonitoringInterval = aws.Int64(int64(d.Get("monitoring_interval").(int)))
requestUpdate = true
}
Expand All @@ -1614,24 +1590,20 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
}

if d.HasChange("option_group_name") {
d.SetPartial("option_group_name")
req.OptionGroupName = aws.String(d.Get("option_group_name").(string))
requestUpdate = true
}

if d.HasChange("port") {
d.SetPartial("port")
req.DBPortNumber = aws.Int64(int64(d.Get("port").(int)))
requestUpdate = true
}
if d.HasChange("db_subnet_group_name") {
d.SetPartial("db_subnet_group_name")
req.DBSubnetGroupName = aws.String(d.Get("db_subnet_group_name").(string))
requestUpdate = true
}

if d.HasChange("enabled_cloudwatch_logs_exports") {
d.SetPartial("enabled_cloudwatch_logs_exports")
req.CloudwatchLogsExportConfiguration = buildCloudwatchLogsExportConfiguration(d)
requestUpdate = true
}
Expand All @@ -1642,24 +1614,19 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
}

if d.HasChange("domain") || d.HasChange("domain_iam_role_name") {
d.SetPartial("domain")
d.SetPartial("domain_iam_role_name")
req.Domain = aws.String(d.Get("domain").(string))
req.DomainIAMRoleName = aws.String(d.Get("domain_iam_role_name").(string))
requestUpdate = true
}

if d.HasChange("performance_insights_enabled") || d.HasChange("performance_insights_kms_key_id") || d.HasChange("performance_insights_retention_period") {
d.SetPartial("performance_insights_enabled")
req.EnablePerformanceInsights = aws.Bool(d.Get("performance_insights_enabled").(bool))

if v, ok := d.GetOk("performance_insights_kms_key_id"); ok {
d.SetPartial("performance_insights_kms_key_id")
req.PerformanceInsightsKMSKeyId = aws.String(v.(string))
}

if v, ok := d.GetOk("performance_insights_retention_period"); ok {
d.SetPartial("performance_insights_retention_period")
req.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int)))
}

Expand Down Expand Up @@ -1729,11 +1696,8 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("error updating RDS DB Instance (%s) tags: %s", d.Get("arn").(string), err)
}

d.SetPartial("tags")
}

d.Partial(false)

return resourceAwsDbInstanceRead(d, meta)
}

Expand Down
3 changes: 0 additions & 3 deletions aws/resource_aws_db_option_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ func resourceAwsDbOptionGroupUpdate(d *schema.ResourceData, meta interface{}) er
if err != nil {
return fmt.Errorf("Error modifying DB Option Group: %s", err)
}
d.SetPartial("option")
}
}

Expand All @@ -295,8 +294,6 @@ func resourceAwsDbOptionGroupUpdate(d *schema.ResourceData, meta interface{}) er
if err := keyvaluetags.RdsUpdateTags(rdsconn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS Option Group (%s) tags: %s", d.Get("arn").(string), err)
}

d.SetPartial("tags")
}

return resourceAwsDbOptionGroupRead(d, meta)
Expand Down
12 changes: 0 additions & 12 deletions aws/resource_aws_db_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error creating DB Parameter Group: %s", err)
}

d.Partial(true)
d.SetPartial("name")
d.SetPartial("family")
d.SetPartial("description")
d.Partial(false)

d.SetId(aws.StringValue(resp.DBParameterGroup.DBParameterGroupName))
d.Set("arn", resp.DBParameterGroup.DBParameterGroupArn)
log.Printf("[INFO] DB Parameter Group ID: %s", d.Id())
Expand Down Expand Up @@ -246,8 +240,6 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn

d.Partial(true)

if d.HasChange("parameter") {
o, n := d.GetChange("parameter")
if o == nil {
Expand Down Expand Up @@ -327,12 +319,8 @@ func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{})
if err := keyvaluetags.RdsUpdateTags(rdsconn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS DB Parameter Group (%s) tags: %s", d.Get("arn").(string), err)
}

d.SetPartial("tags")
}

d.Partial(false)

return resourceAwsDbParameterGroupRead(d, meta)
}

Expand Down
5 changes: 0 additions & 5 deletions aws/resource_aws_db_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,12 @@ func resourceAwsDbSecurityGroupRead(d *schema.ResourceData, meta interface{}) er
func resourceAwsDbSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn

d.Partial(true)

if d.HasChange("tags") {
o, n := d.GetChange("tags")

if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS DB Security Group (%s) tags: %s", d.Get("arn").(string), err)
}

d.SetPartial("tags")
}

if d.HasChange("ingress") {
Expand Down Expand Up @@ -243,7 +239,6 @@ func resourceAwsDbSecurityGroupUpdate(d *schema.ResourceData, meta interface{})
}
}
}
d.Partial(false)

return resourceAwsDbSecurityGroupRead(d, meta)
}
Expand Down
2 changes: 0 additions & 2 deletions aws/resource_aws_db_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ func resourceAwsDbSnapshotUpdate(d *schema.ResourceData, meta interface{}) error
if err := keyvaluetags.RdsUpdateTags(conn, d.Get("db_snapshot_arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS DB Snapshot (%s) tags: %s", d.Get("db_snapshot_arn").(string), err)
}

d.SetPartial("tags")
}

return nil
Expand Down
2 changes: 0 additions & 2 deletions aws/resource_aws_db_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ func resourceAwsDbSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) er
if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating RDS DB Subnet Group (%s) tags: %s", d.Get("arn").(string), err)
}

d.SetPartial("tags")
}

return resourceAwsDbSubnetGroupRead(d, meta)
Expand Down
6 changes: 0 additions & 6 deletions aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ func resourceAwsRDSClusterUpdate(d *schema.ResourceData, meta interface{}) error
}

if d.HasChange("db_cluster_parameter_group_name") {
d.SetPartial("db_cluster_parameter_group_name")
req.DBClusterParameterGroupName = aws.String(d.Get("db_cluster_parameter_group_name").(string))
requestUpdate = true
}
Expand All @@ -1134,19 +1133,16 @@ func resourceAwsRDSClusterUpdate(d *schema.ResourceData, meta interface{}) error
}

if d.HasChange("enabled_cloudwatch_logs_exports") {
d.SetPartial("enabled_cloudwatch_logs_exports")
req.CloudwatchLogsExportConfiguration = buildCloudwatchLogsExportConfiguration(d)
requestUpdate = true
}

if d.HasChange("scaling_configuration") {
d.SetPartial("scaling_configuration")
req.ScalingConfiguration = expandRdsClusterScalingConfiguration(d.Get("scaling_configuration").([]interface{}), d.Get("engine_mode").(string))
requestUpdate = true
}

if d.HasChange("enable_http_endpoint") {
d.SetPartial("enable_http_endpoint")
req.EnableHttpEndpoint = aws.Bool(d.Get("enable_http_endpoint").(bool))
requestUpdate = true
}
Expand Down Expand Up @@ -1242,8 +1238,6 @@ func resourceAwsRDSClusterUpdate(d *schema.ResourceData, meta interface{}) error

if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating tags: %s", err)
} else {
d.SetPartial("tags")
}
}

Expand Down
Loading