Skip to content

Commit

Permalink
Merge pull request #30679 from hashicorp/b-rds-parameter-group-regres…
Browse files Browse the repository at this point in the history
…sion

rds/cluster: Parameter group regression fix
  • Loading branch information
YakDriver authored Apr 12, 2023
2 parents 653ed72 + c5fac0d commit d22e27d
Show file tree
Hide file tree
Showing 59 changed files with 120 additions and 134 deletions.
3 changes: 3 additions & 0 deletions .changelog/30679.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_rds_cluster: Prevent `db_instance_parameter_group_name` from causing errors on minor upgrades
```
1 change: 0 additions & 1 deletion internal/service/rds/certificate_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func dataSourceCertificateRead(ctx context.Context, d *schema.ResourceData, meta
}
return !lastPage
})

if err != nil {
return sdkdiag.AppendErrorf(diags, "reading RDS Certificates: %s", err)
}
Expand Down
15 changes: 7 additions & 8 deletions internal/service/rds/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
return conn.RestoreDBClusterFromSnapshotWithContext(ctx, input)
},
errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions")

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating RDS Cluster (restore from snapshot) (%s): %s", identifier, err)
}
Expand Down Expand Up @@ -757,7 +756,6 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
return false, err
},
)

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating RDS Cluster (restore from S3) (%s): %s", identifier, err)
}
Expand Down Expand Up @@ -869,7 +867,6 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int

log.Printf("[DEBUG] Creating RDS Cluster: %s", input)
_, err := conn.RestoreDBClusterToPointInTimeWithContext(ctx, input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating RDS Cluster (restore to point-in-time) (%s): %s", identifier, err)
}
Expand Down Expand Up @@ -1016,7 +1013,6 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
return conn.CreateDBClusterWithContext(ctx, input)
},
errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions")

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating RDS Cluster (%s): %s", identifier, err)
}
Expand Down Expand Up @@ -1221,6 +1217,8 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int
// DB instance parameter group name is not currently returned from the
// DescribeDBClusters API. This means there is no drift detection, so when
// set, the configured attribute should always be sent on modify.
// Except, this causes an error on a minor version upgrade, so it is
// removed during update retry, if necessary.
if v, ok := d.GetOk("db_instance_parameter_group_name"); ok || d.HasChange("db_instance_parameter_group_name") {
input.DBInstanceParameterGroupName = aws.String(v.(string))
}
Expand Down Expand Up @@ -1334,10 +1332,14 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int
return true, err
}

if tfawserr.ErrMessageContains(err, errCodeInvalidParameterCombination, "db-instance-parameter-group-name can only be specified for a major") {
input.DBInstanceParameterGroupName = nil
return true, err
}

return false, err
},
)

if err != nil {
return sdkdiag.AppendErrorf(diags, "updating RDS Cluster (%s): %s", d.Id(), err)
}
Expand Down Expand Up @@ -1464,7 +1466,6 @@ func resourceClusterDelete(ctx context.Context, d *schema.ResourceData, meta int
return false, err
},
)

if err != nil {
return false, fmt.Errorf("modifying RDS Cluster (%s) DeletionProtection=false: %s", d.Id(), err)
}
Expand Down Expand Up @@ -1519,7 +1520,6 @@ func addIAMRoleToCluster(ctx context.Context, conn *rds.RDS, clusterID, roleARN
}

_, err := conn.AddRoleToDBClusterWithContext(ctx, input)

if err != nil {
return fmt.Errorf("adding IAM Role (%s) to RDS Cluster (%s): %s", roleARN, clusterID, err)
}
Expand All @@ -1534,7 +1534,6 @@ func removeIAMRoleFromCluster(ctx context.Context, conn *rds.RDS, clusterID, rol
}

_, err := conn.RemoveRoleFromDBClusterWithContext(ctx, input)

if err != nil {
return fmt.Errorf("removing IAM Role (%s) from RDS Cluster (%s): %s", roleARN, clusterID, err)
}
Expand Down
3 changes: 0 additions & 3 deletions internal/service/rds/cluster_activity_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func resourceClusterActivityStreamCreate(ctx context.Context, d *schema.Resource
}

_, err := conn.StartActivityStreamWithContext(ctx, input)

if err != nil {
return diag.Errorf("creating RDS Cluster Activity Stream (%s): %s", arn, err)
}
Expand Down Expand Up @@ -117,7 +116,6 @@ func resourceClusterActivityStreamDelete(ctx context.Context, d *schema.Resource
ApplyImmediately: aws.Bool(true),
ResourceArn: aws.String(d.Id()),
})

if err != nil {
return diag.Errorf("stopping RDS Cluster Activity Stream (%s): %s", d.Id(), err)
}
Expand All @@ -131,7 +129,6 @@ func resourceClusterActivityStreamDelete(ctx context.Context, d *schema.Resource

func FindDBClusterWithActivityStream(ctx context.Context, conn *rds.RDS, arn string) (*rds.DBCluster, error) {
output, err := FindDBClusterByID(ctx, conn, arn)

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion internal/service/rds/cluster_activity_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func testAccCheckClusterActivityStreamExists(ctx context.Context, n string, v *r
conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn()

output, err := tfrds.FindDBClusterWithActivityStream(ctx, conn, rs.Primary.ID)

if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions internal/service/rds/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int

dbClusterID := d.Get("cluster_identifier").(string)
dbc, err := FindDBClusterByID(ctx, conn, dbClusterID)

if err != nil {
return sdkdiag.AppendErrorf(diags, "reading RDS Cluster (%s): %s", dbClusterID, err)
}
Expand Down Expand Up @@ -231,7 +230,6 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int
d.Set("vpc_security_group_ids", securityGroupIDs)

tags, err := ListTags(ctx, conn, clusterARN)

if err != nil {
return sdkdiag.AppendErrorf(diags, "listing tags for RDS Cluster (%s): %s", d.Id(), err)
}
Expand Down
4 changes: 0 additions & 4 deletions internal/service/rds/cluster_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func resourceClusterEndpointCreate(ctx context.Context, d *schema.ResourceData,
}

_, err := conn.CreateDBClusterEndpointWithContext(ctx, input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating RDS Cluster Endpoint (%s): %s", endpointID, err)
}
Expand Down Expand Up @@ -174,7 +173,6 @@ func resourceClusterEndpointUpdate(ctx context.Context, d *schema.ResourceData,
}

_, err := conn.ModifyDBClusterEndpointWithContext(ctx, input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "modifying RDS Cluster Endpoint (%s): %s", d.Id(), err)
}
Expand All @@ -191,7 +189,6 @@ func resourceClusterEndpointDelete(ctx context.Context, d *schema.ResourceData,
_, err := conn.DeleteDBClusterEndpointWithContext(ctx, &rds.DeleteDBClusterEndpointInput{
DBClusterEndpointIdentifier: aws.String(d.Id()),
})

if err != nil {
return sdkdiag.AppendErrorf(diags, "deleting RDS Cluster Endpoint (%s): %s", d.Id(), err)
}
Expand All @@ -209,7 +206,6 @@ func FindDBClusterEndpointByID(ctx context.Context, conn *rds.RDS, id string) (*
}

output, err := conn.DescribeDBClusterEndpointsWithContext(ctx, input)

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion internal/service/rds/cluster_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func testAccCheckClusterEndpointExists(ctx context.Context, n string, v *rds.DBC
conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn()

output, err := tfrds.FindDBClusterEndpointByID(ctx, conn, rs.Primary.ID)

if err != nil {
return err
}
Expand Down
3 changes: 0 additions & 3 deletions internal/service/rds/cluster_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData,
return conn.CreateDBInstanceWithContext(ctx, input)
},
errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions")

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating RDS Cluster (%s) Instance (%s): %s", clusterID, identifier, err)
}
Expand Down Expand Up @@ -365,7 +364,6 @@ func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, me
}

dbc, err := FindDBClusterByID(ctx, conn, dbClusterID)

if err != nil {
return sdkdiag.AppendErrorf(diags, "reading RDS Cluster (%s): %s", dbClusterID, err)
}
Expand Down Expand Up @@ -490,7 +488,6 @@ func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData,
return conn.ModifyDBInstanceWithContext(ctx, input)
},
errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions")

if err != nil {
return sdkdiag.AppendErrorf(diags, "updating RDS Cluster Instance (%s): %s", d.Id(), err)
}
Expand Down
1 change: 0 additions & 1 deletion internal/service/rds/cluster_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,6 @@ func testAccCheckClusterInstanceExists(ctx context.Context, n string, v *rds.DBI
conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn()

output, err := tfrds.FindDBInstanceByID(ctx, conn, rs.Primary.ID)

if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions internal/service/rds/cluster_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func resourceClusterParameterGroupCreate(ctx context.Context, d *schema.Resource
}

output, err := conn.CreateDBClusterParameterGroupWithContext(ctx, input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating DB Cluster Parameter Group (%s): %s", groupName, err)
}
Expand Down Expand Up @@ -249,7 +248,6 @@ func resourceClusterParameterGroupUpdate(ctx context.Context, d *schema.Resource
}

_, err := conn.ModifyDBClusterParameterGroupWithContext(ctx, input)

if err != nil {
return sdkdiag.AppendErrorf(diags, "modifying DB Cluster Parameter Group (%s): %s", d.Id(), err)
}
Expand Down
1 change: 0 additions & 1 deletion internal/service/rds/cluster_parameter_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ func testAccCheckClusterParameterGroupExists(ctx context.Context, n string, v *r
conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn()

output, err := tfrds.FindDBClusterParameterGroupByName(ctx, conn, rs.Primary.ID)

if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions internal/service/rds/cluster_role_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func resourceClusterRoleAssociationRead(ctx context.Context, d *schema.ResourceD
conn := meta.(*conns.AWSClient).RDSConn()

dbClusterID, roleARN, err := ClusterRoleAssociationParseResourceID(d.Id())

if err != nil {
return sdkdiag.AppendErrorf(diags, "parsing RDS DB Cluster IAM Role Association ID: %s", err)
}
Expand Down Expand Up @@ -123,7 +122,6 @@ func resourceClusterRoleAssociationDelete(ctx context.Context, d *schema.Resourc
conn := meta.(*conns.AWSClient).RDSConn()

dbClusterID, roleARN, err := ClusterRoleAssociationParseResourceID(d.Id())

if err != nil {
return sdkdiag.AppendErrorf(diags, "parsing RDS DB Cluster IAM Role Association ID: %s", err)
}
Expand Down
3 changes: 0 additions & 3 deletions internal/service/rds/cluster_role_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ func testAccCheckClusterRoleAssociationExists(ctx context.Context, resourceName
}

dbClusterID, roleARN, err := tfrds.ClusterRoleAssociationParseResourceID(rs.Primary.ID)

if err != nil {
return err
}

conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn()

role, err := tfrds.FindDBClusterRoleByDBClusterIDAndRoleARN(ctx, conn, dbClusterID, roleARN)

if err != nil {
return err
}
Expand All @@ -160,7 +158,6 @@ func testAccCheckClusterRoleAssociationDestroy(ctx context.Context) resource.Tes
}

dbClusterID, roleARN, err := tfrds.ClusterRoleAssociationParseResourceID(rs.Primary.ID)

if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions internal/service/rds/cluster_snapshot_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func DataSourceClusterSnapshot() *schema.Resource {
ReadWithoutTimeout: dataSourceClusterSnapshotRead,

Schema: map[string]*schema.Schema{
//selection criteria
// selection criteria
"db_cluster_identifier": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -55,7 +55,7 @@ func DataSourceClusterSnapshot() *schema.Resource {
Default: false,
},

//Computed values returned
// Computed values returned
"allocated_storage": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -186,7 +186,6 @@ func dataSourceClusterSnapshotRead(ctx context.Context, d *schema.ResourceData,
d.Set("vpc_id", snapshot.VpcId)

tags, err := ListTags(ctx, conn, d.Get("db_cluster_snapshot_arn").(string))

if err != nil {
return sdkdiag.AppendErrorf(diags, "listing tags for RDS DB Cluster Snapshot (%s): %s", d.Get("db_cluster_snapshot_arn").(string), err)
}
Expand Down
Loading

0 comments on commit d22e27d

Please sign in to comment.