From 03e17e1998974ee80e6bc456e06222d26cc87344 Mon Sep 17 00:00:00 2001 From: Anthony Wat Date: Sat, 29 Jun 2024 00:47:07 -0400 Subject: [PATCH 01/15] fix: Align name and name_prefix validation with AWS API for aws_db_event_subscription --- .changelog/38194.txt | 3 ++ internal/service/rds/event_subscription.go | 2 +- internal/service/rds/validate.go | 32 ++++++++++++++- internal/service/rds/validate_test.go | 45 ++++++++++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .changelog/38194.txt diff --git a/.changelog/38194.txt b/.changelog/38194.txt new file mode 100644 index 00000000000..1600e2917b9 --- /dev/null +++ b/.changelog/38194.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_db_event_subscription: Fix validation for `name` and `name_prefix` +``` diff --git a/internal/service/rds/event_subscription.go b/internal/service/rds/event_subscription.go index f4760047969..98eeebaf415 100644 --- a/internal/service/rds/event_subscription.go +++ b/internal/service/rds/event_subscription.go @@ -80,7 +80,7 @@ func resourceEventSubscription() *schema.Resource { Computed: true, ForceNew: true, ConflictsWith: []string{names.AttrName}, - ValidateFunc: validEventSubscriptionName, + ValidateFunc: validEventSubscriptionNamePrefix, }, "sns_topic": { Type: schema.TypeString, diff --git a/internal/service/rds/validate.go b/internal/service/rds/validate.go index 1647dc456f3..0373b5608d7 100644 --- a/internal/service/rds/validate.go +++ b/internal/service/rds/validate.go @@ -5,15 +5,25 @@ package rds import ( "fmt" + "strings" "github.com/YakDriver/regexache" ) func validEventSubscriptionName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(value) { + if !regexache.MustCompile(`^[A-Za-z][0-9A-Za-z-]*$`).MatchString(value) { errors = append(errors, fmt.Errorf( - "only alphanumeric characters and hyphens allowed in %q", k)) + "only ASCII letters, digits, and hyphens allowed in %q, and it must begin with a letter", k)) + } + // When using name prefix, the generated suffix will always end with a number, so this check is not relevant + if strings.HasSuffix(value, "-") { + errors = append(errors, fmt.Errorf( + "%q cannot end with a hyphen", k)) + } + if strings.Contains(value, "--") { + errors = append(errors, fmt.Errorf( + "%q cannot contain two consecutive hyphens", k)) } if len(value) > 255 { errors = append(errors, fmt.Errorf( @@ -22,6 +32,24 @@ func validEventSubscriptionName(v interface{}, k string) (ws []string, errors [] return } +func validEventSubscriptionNamePrefix(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if !regexache.MustCompile(`^[A-Za-z][0-9A-Za-z-]*$`).MatchString(value) { + errors = append(errors, fmt.Errorf( + "only ASCII letters, digits, and hyphens allowed in %q, and it must begin with a letter", k)) + } + if strings.Contains(value, "--") { + errors = append(errors, fmt.Errorf( + "%q cannot contain two consecutive hyphens", k)) + } + // When using name prefix, the limit must account for the generated suffix that is 26 characters long + if len(value) > 229 { + errors = append(errors, fmt.Errorf( + "%q cannot be longer than 229 characters", k)) + } + return +} + func validOptionGroupName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) if !regexache.MustCompile(`^[a-z]`).MatchString(value) { diff --git a/internal/service/rds/validate_test.go b/internal/service/rds/validate_test.go index 0d366b0dfa9..12850dda8ef 100644 --- a/internal/service/rds/validate_test.go +++ b/internal/service/rds/validate_test.go @@ -27,6 +27,11 @@ func TestValidEventSubscriptionName(t *testing.T) { } invalidNames := []string{ + "invalid_name", + "invalid-name-", + "-invalid-name", + "0invalid-name", + "invalid--name", "Here is a name with: colon", "and here is another * invalid name", "also $ invalid", @@ -46,6 +51,46 @@ func TestValidEventSubscriptionName(t *testing.T) { } } +func TestValidEventSubscriptionNamePrefix(t *testing.T) { + t.Parallel() + + validNames := []string{ + "valid-name", + "valid02-name", + "Valid-Name1", + "valid-name-", + } + for _, v := range validNames { + _, errors := validEventSubscriptionNamePrefix(v, names.AttrNamePrefix) + if len(errors) != 0 { + t.Fatalf("%q should be a valid RDS Event Subscription Name: %q", v, errors) + } + } + + invalidNames := []string{ + "invalid_name", + "-invalid-name", + "0invalid-name", + "invalid--name", + "Here is a name with: colon", + "and here is another * invalid name", + "also $ invalid", + "This . is also %% invalid@!)+(", + "*", + "", + " ", + "_", + // length > 229 + strings.Repeat("W", 230), + } + for _, v := range invalidNames { + _, errors := validEventSubscriptionNamePrefix(v, names.AttrNamePrefix) + if len(errors) == 0 { + t.Fatalf("%q should be an invalid RDS Event Subscription Name Prefix", v) + } + } +} + func TestValidOptionGroupName(t *testing.T) { t.Parallel() From 4aebc3443a1436b4876c448be238cc89eeb4d804 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 08:54:54 -0400 Subject: [PATCH 02/15] Tweak CHANGELOG entry. --- .changelog/38194.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changelog/38194.txt b/.changelog/38194.txt index 1600e2917b9..bd41aac97da 100644 --- a/.changelog/38194.txt +++ b/.changelog/38194.txt @@ -1,3 +1,3 @@ -```release-note:enhancement -resource/aws_db_event_subscription: Fix validation for `name` and `name_prefix` +```release-note:bug +resource/aws_db_event_subscription: Fix plan-time validation of `name` and `name_prefix` ``` From 87fc8352dc444019f98a7b8a643f1449131296c1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 10:14:13 -0400 Subject: [PATCH 03/15] r/aws_db_instance: Migrate to AWS SDK for Go v2. --- internal/service/rds/exports_test.go | 5 +- internal/service/rds/instance.go | 603 ++++++++---------- .../instance_automated_backups_replication.go | 2 +- .../service/rds/instance_role_association.go | 2 +- internal/service/rds/service_package_gen.go | 2 +- 5 files changed, 263 insertions(+), 351 deletions(-) diff --git a/internal/service/rds/exports_test.go b/internal/service/rds/exports_test.go index f57240368c1..cd4b732467a 100644 --- a/internal/service/rds/exports_test.go +++ b/internal/service/rds/exports_test.go @@ -15,6 +15,7 @@ var ( ResourceCustomDBEngineVersion = resourceCustomDBEngineVersion ResourceEventSubscription = resourceEventSubscription ResourceGlobalCluster = resourceGlobalCluster + ResourceInstance = resourceInstance ResourceInstanceAutomatedBackupsReplication = resourceInstanceAutomatedBackupsReplication ResourceInstanceRoleAssociation = resourceInstanceRoleAssociation ResourceIntegration = newIntegrationResource @@ -38,7 +39,7 @@ var ( FindDBClusterSnapshotByID = findDBClusterSnapshotByID FindDBClusterWithActivityStream = findDBClusterWithActivityStream FindDBInstanceAutomatedBackupByARN = findDBInstanceAutomatedBackupByARN - FindDBInstanceByID = findDBInstanceByIDSDKv1 + FindDBInstanceByID = findDBInstanceByID FindDBInstanceRoleByTwoPartKey = findDBInstanceRoleByTwoPartKey FindDBParameterGroupByName = findDBParameterGroupByName FindDBProxyByName = findDBProxyByName @@ -60,7 +61,7 @@ var ( ProxyTargetParseResourceID = proxyTargetParseResourceID WaitBlueGreenDeploymentDeleted = waitBlueGreenDeploymentDeleted WaitBlueGreenDeploymentAvailable = waitBlueGreenDeploymentAvailable - WaitDBInstanceAvailable = waitDBInstanceAvailableSDKv2 + WaitDBInstanceAvailable = waitDBInstanceAvailable WaitDBInstanceDeleted = waitDBInstanceDeleted ErrCodeInvalidAction = errCodeInvalidAction diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index bd645450a8b..ef61fa33919 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -14,13 +14,11 @@ import ( "time" "github.com/YakDriver/regexache" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/arn" - rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" + "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/rds/types" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/rds" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" - tfawserr_sdkv2 "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" + "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -29,6 +27,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" + "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" @@ -54,7 +53,7 @@ import ( // @Tags(identifierAttribute="arn") // @Testing(existsType="github.com/aws/aws-sdk-go/service/rds;rds.DBInstance") // @Testing(importIgnore="apply_immediately;password") -func ResourceInstance() *schema.Resource { +func resourceInstance() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceInstanceCreate, ReadWithoutTimeout: resourceInstanceRead, @@ -530,10 +529,10 @@ func ResourceInstance() *schema.Resource { Default: false, }, "replica_mode": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: validation.StringInSlice(rds.ReplicaMode_Values(), false), + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateDiagFunc: enum.Validate[types.ReplicaMode](), }, "replicas": { Type: schema.TypeList, @@ -714,7 +713,7 @@ func ResourceInstance() *schema.Resource { func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) // Some API calls (e.g. CreateDBInstanceReadReplica, RestoreDBInstanceFromDBSnapshot // RestoreDBInstanceToPointInTime do not support all parameters to @@ -764,7 +763,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), SourceDBInstanceIdentifier: aws.String(sourceDBInstanceID), - Tags: getTagsIn(ctx), + Tags: getTagsInV2(ctx), } if _, ok := d.GetOk(names.AttrAllocatedStorage); ok { @@ -791,7 +790,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && v.(*schema.Set).Len() > 0 { - input.EnableCloudwatchLogsExports = flex.ExpandStringSet(v.(*schema.Set)) + input.EnableCloudwatchLogsExports = flex.ExpandStringValueSet(v.(*schema.Set)) } if v, ok := d.GetOk("iam_database_authentication_enabled"); ok { @@ -799,7 +798,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrIOPS); ok { - input.Iops = aws.Int64(int64(v.(int))) + input.Iops = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrKMSKeyID); ok { @@ -810,7 +809,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("monitoring_interval"); ok { - input.MonitoringInterval = aws.Int64(int64(v.(int))) + input.MonitoringInterval = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("monitoring_role_arn"); ok { @@ -852,20 +851,20 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("performance_insights_retention_period"); ok { - input.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int))) + input.PerformanceInsightsRetentionPeriod = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrPort); ok { - input.Port = aws.Int64(int64(v.(int))) + input.Port = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("replica_mode"); ok { - input.ReplicaMode = aws.String(v.(string)) + input.ReplicaMode = types.ReplicaMode(v.(string)) requiresModifyDbInstance = true } if v, ok := d.GetOk("storage_throughput"); ok { - input.StorageThroughput = aws.Int64(int64(v.(int))) + input.StorageThroughput = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrStorageType); ok { @@ -877,14 +876,14 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrVPCSecurityGroupIDs); ok && v.(*schema.Set).Len() > 0 { - input.VpcSecurityGroupIds = flex.ExpandStringSet(v.(*schema.Set)) + input.VpcSecurityGroupIds = flex.ExpandStringValueSet(v.(*schema.Set)) } output, err := dbInstanceCreateReadReplica(ctx, conn, input) // Some engines (e.g. PostgreSQL) you cannot specify a custom parameter group for the read replica during creation. // See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html#USER_ReadRepl.XRgn.Cnsdr. - if input.DBParameterGroupName != nil && tfawserr.ErrMessageContains(err, "InvalidParameterCombination", "A parameter group can't be specified during Read Replica creation for the following DB engine") { + if input.DBParameterGroupName != nil && tfawserr.ErrMessageContains(err, errCodeInvalidParameterCombination, "A parameter group can't be specified during Read Replica creation for the following DB engine") { input.DBParameterGroupName = nil output, err = dbInstanceCreateReadReplica(ctx, conn, input) @@ -894,7 +893,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "creating RDS DB Instance (read replica) (%s): %s", identifier, err) } - resourceID = aws.StringValue(output.DBInstance.DbiResourceId) + resourceID = aws.ToString(output.DBInstance.DbiResourceId) d.SetId(resourceID) if v, ok := d.GetOk(names.AttrAllowMajorVersionUpgrade); ok { @@ -904,28 +903,28 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("backup_retention_period"); ok { - if current, desired := aws.Int64Value(output.DBInstance.BackupRetentionPeriod), int64(v.(int)); current != desired { - modifyDbInstanceInput.BackupRetentionPeriod = aws.Int64(desired) + if current, desired := aws.ToInt32(output.DBInstance.BackupRetentionPeriod), int32(v.(int)); current != desired { + modifyDbInstanceInput.BackupRetentionPeriod = aws.Int32(desired) requiresModifyDbInstance = true } } if v, ok := d.GetOk("backup_window"); ok { - if current, desired := aws.StringValue(output.DBInstance.PreferredBackupWindow), v.(string); current != desired { + if current, desired := aws.ToString(output.DBInstance.PreferredBackupWindow), v.(string); current != desired { modifyDbInstanceInput.PreferredBackupWindow = aws.String(desired) requiresModifyDbInstance = true } } if v, ok := d.GetOk("ca_cert_identifier"); ok { - if current, desired := aws.StringValue(output.DBInstance.CACertificateIdentifier), v.(string); current != desired { + if current, desired := aws.ToString(output.DBInstance.CACertificateIdentifier), v.(string); current != desired { modifyDbInstanceInput.CACertificateIdentifier = aws.String(desired) requiresModifyDbInstance = true } } if v, ok := d.GetOk("maintenance_window"); ok { - if current, desired := aws.StringValue(output.DBInstance.PreferredMaintenanceWindow), v.(string); current != desired { + if current, desired := aws.ToString(output.DBInstance.PreferredMaintenanceWindow), v.(string); current != desired { modifyDbInstanceInput.PreferredMaintenanceWindow = aws.String(desired) requiresModifyDbInstance = true } @@ -941,15 +940,15 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("max_allocated_storage"); ok { - if current, desired := aws.Int64Value(output.DBInstance.MaxAllocatedStorage), int64(v.(int)); current != desired { - modifyDbInstanceInput.MaxAllocatedStorage = aws.Int64(desired) + if current, desired := aws.ToInt32(output.DBInstance.MaxAllocatedStorage), int32(v.(int)); current != desired { + modifyDbInstanceInput.MaxAllocatedStorage = aws.Int32(desired) requiresModifyDbInstance = true } } if v, ok := d.GetOk(names.AttrParameterGroupName); ok { if len(output.DBInstance.DBParameterGroups) > 0 { - if current, desired := aws.StringValue(output.DBInstance.DBParameterGroups[0].DBParameterGroupName), v.(string); current != desired { + if current, desired := aws.ToString(output.DBInstance.DBParameterGroups[0].DBParameterGroupName), v.(string); current != desired { modifyDbInstanceInput.DBParameterGroupName = aws.String(desired) requiresModifyDbInstance = true requiresRebootDbInstance = true @@ -977,9 +976,9 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in tfMap := v.([]interface{})[0].(map[string]interface{}) input := &rds.RestoreDBInstanceFromS3Input{ - AllocatedStorage: aws.Int64(int64(d.Get(names.AttrAllocatedStorage).(int))), + AllocatedStorage: aws.Int32(int32(d.Get(names.AttrAllocatedStorage).(int))), AutoMinorVersionUpgrade: aws.Bool(d.Get(names.AttrAutoMinorVersionUpgrade).(bool)), - BackupRetentionPeriod: aws.Int64(int64(d.Get("backup_retention_period").(int))), + BackupRetentionPeriod: aws.Int32(int32(d.Get("backup_retention_period").(int))), CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceIdentifier: aws.String(identifier), @@ -995,7 +994,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in SourceEngine: aws.String(tfMap["source_engine"].(string)), SourceEngineVersion: aws.String(tfMap["source_engine_version"].(string)), StorageEncrypted: aws.Bool(d.Get(names.AttrStorageEncrypted).(bool)), - Tags: getTagsIn(ctx), + Tags: getTagsInV2(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZone); ok { @@ -1023,7 +1022,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrIOPS); ok { - input.Iops = aws.Int64(int64(v.(int))) + input.Iops = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrKMSKeyID); ok { @@ -1047,7 +1046,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("monitoring_interval"); ok { - input.MonitoringInterval = aws.Int64(int64(v.(int))) + input.MonitoringInterval = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("monitoring_role_arn"); ok { @@ -1083,15 +1082,15 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("performance_insights_retention_period"); ok { - input.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int))) + input.PerformanceInsightsRetentionPeriod = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrPort); ok { - input.Port = aws.Int64(int64(v.(int))) + input.Port = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("storage_throughput"); ok { - input.StorageThroughput = aws.Int64(int64(v.(int))) + input.StorageThroughput = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrStorageType); ok { @@ -1099,12 +1098,12 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrVPCSecurityGroupIDs); ok && v.(*schema.Set).Len() > 0 { - input.VpcSecurityGroupIds = flex.ExpandStringSet(v.(*schema.Set)) + input.VpcSecurityGroupIds = flex.ExpandStringValueSet(v.(*schema.Set)) } outputRaw, err := tfresource.RetryWhen(ctx, propagationTimeout, func() (interface{}, error) { - return conn.RestoreDBInstanceFromS3WithContext(ctx, input) + return conn.RestoreDBInstanceFromS3(ctx, input) }, func(err error) (bool, error) { if tfawserr.ErrMessageContains(err, errCodeInvalidParameterValue, "ENHANCED_MONITORING") { @@ -1130,7 +1129,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in output := outputRaw.(*rds.RestoreDBInstanceFromS3Output) - resourceID = aws.StringValue(output.DBInstance.DbiResourceId) + resourceID = aws.ToString(output.DBInstance.DbiResourceId) d.SetId(resourceID) } else if v, ok := d.GetOk("snapshot_identifier"); ok { input := &rds.RestoreDBInstanceFromDBSnapshotInput{ @@ -1141,7 +1140,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DBSnapshotIdentifier: aws.String(v.(string)), DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), - Tags: getTagsIn(ctx), + Tags: getTagsInV2(ctx), } engine := strings.ToLower(d.Get(names.AttrEngine).(string)) @@ -1157,7 +1156,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrAllocatedStorage); ok { - modifyDbInstanceInput.AllocatedStorage = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.AllocatedStorage = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } @@ -1172,7 +1171,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOkExists("backup_retention_period"); ok { - modifyDbInstanceInput.BackupRetentionPeriod = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.BackupRetentionPeriod = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } @@ -1210,7 +1209,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("domain_dns_ips"); ok && len(v.([]interface{})) > 0 { - input.DomainDnsIps = flex.ExpandStringList(v.([]interface{})) + input.DomainDnsIps = flex.ExpandStringValueList(v.([]interface{})) } if v, ok := d.GetOk("domain_fqdn"); ok { @@ -1226,7 +1225,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && v.(*schema.Set).Len() > 0 { - input.EnableCloudwatchLogsExports = flex.ExpandStringSet(v.(*schema.Set)) + input.EnableCloudwatchLogsExports = flex.ExpandStringValueSet(v.(*schema.Set)) } if engine != "" { @@ -1247,7 +1246,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrIOPS); ok { - modifyDbInstanceInput.Iops = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.Iops = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } @@ -1271,12 +1270,12 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("max_allocated_storage"); ok { - modifyDbInstanceInput.MaxAllocatedStorage = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.MaxAllocatedStorage = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } if v, ok := d.GetOk("monitoring_interval"); ok { - modifyDbInstanceInput.MonitoringInterval = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.MonitoringInterval = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } @@ -1326,16 +1325,16 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("performance_insights_retention_period"); ok { - modifyDbInstanceInput.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.PerformanceInsightsRetentionPeriod = aws.Int32(int32(v.(int))) } } if v, ok := d.GetOk(names.AttrPort); ok { - input.Port = aws.Int64(int64(v.(int))) + input.Port = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("storage_throughput"); ok { - modifyDbInstanceInput.StorageThroughput = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.StorageThroughput = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } @@ -1349,12 +1348,12 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v := d.Get(names.AttrVPCSecurityGroupIDs).(*schema.Set); v.Len() > 0 { - input.VpcSecurityGroupIds = flex.ExpandStringSet(v) + input.VpcSecurityGroupIds = flex.ExpandStringValueSet(v) } outputRaw, err := tfresource.RetryWhen(ctx, propagationTimeout, func() (interface{}, error) { - return conn.RestoreDBInstanceFromDBSnapshotWithContext(ctx, input) + return conn.RestoreDBInstanceFromDBSnapshot(ctx, input) }, func(err error) (bool, error) { if tfawserr.ErrMessageContains(err, errCodeValidationError, "RDS couldn't fetch the role from instance profile") { @@ -1383,14 +1382,14 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in input.MultiAZ = aws.Bool(false) modifyDbInstanceInput.MultiAZ = aws.Bool(true) requiresModifyDbInstance = true - output, err = conn.RestoreDBInstanceFromDBSnapshotWithContext(ctx, input) + output, err = conn.RestoreDBInstanceFromDBSnapshot(ctx, input) } if err != nil { return sdkdiag.AppendErrorf(diags, "creating RDS DB Instance (restore from snapshot) (%s): %s", identifier, err) } - resourceID = aws.StringValue(output.DBInstance.DbiResourceId) + resourceID = aws.ToString(output.DBInstance.DbiResourceId) d.SetId(resourceID) } else if v, ok := d.GetOk("restore_to_point_in_time"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) @@ -1400,7 +1399,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DBInstanceClass: aws.String(d.Get("instance_class").(string)), DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), - Tags: getTagsIn(ctx), + Tags: getTagsInV2(ctx), TargetDBInstanceIdentifier: aws.String(identifier), } @@ -1475,11 +1474,11 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("domain_dns_ips"); ok && len(v.([]interface{})) > 0 { - input.DomainDnsIps = flex.ExpandStringList(v.([]interface{})) + input.DomainDnsIps = flex.ExpandStringValueList(v.([]interface{})) } if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && v.(*schema.Set).Len() > 0 { - input.EnableCloudwatchLogsExports = flex.ExpandStringSet(v.(*schema.Set)) + input.EnableCloudwatchLogsExports = flex.ExpandStringValueSet(v.(*schema.Set)) } if v, ok := d.GetOk(names.AttrEngine); ok { @@ -1495,7 +1494,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrIOPS); ok { - input.Iops = aws.Int64(int64(v.(int))) + input.Iops = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("license_model"); ok { @@ -1503,7 +1502,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("max_allocated_storage"); ok { - input.MaxAllocatedStorage = aws.Int64(int64(v.(int))) + input.MaxAllocatedStorage = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("manage_master_user_password"); ok { @@ -1517,7 +1516,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("monitoring_interval"); ok { - modifyDbInstanceInput.MonitoringInterval = aws.Int64(int64(v.(int))) + modifyDbInstanceInput.MonitoringInterval = aws.Int32(int32(v.(int))) requiresModifyDbInstance = true } @@ -1544,7 +1543,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrPort); ok { - input.Port = aws.Int64(int64(v.(int))) + input.Port = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrStorageType); ok { @@ -1560,12 +1559,12 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrVPCSecurityGroupIDs); ok && v.(*schema.Set).Len() > 0 { - input.VpcSecurityGroupIds = flex.ExpandStringSet(v.(*schema.Set)) + input.VpcSecurityGroupIds = flex.ExpandStringValueSet(v.(*schema.Set)) } outputRaw, err := tfresource.RetryWhen(ctx, propagationTimeout, func() (interface{}, error) { - return conn.RestoreDBInstanceToPointInTimeWithContext(ctx, input) + return conn.RestoreDBInstanceToPointInTime(ctx, input) }, func(err error) (bool, error) { if tfawserr.ErrMessageContains(err, errCodeValidationError, "RDS couldn't fetch the role from instance profile") { @@ -1582,7 +1581,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in output := outputRaw.(*rds.RestoreDBInstanceToPointInTimeOutput) - resourceID = aws.StringValue(output.DBInstance.DbiResourceId) + resourceID = aws.ToString(output.DBInstance.DbiResourceId) d.SetId(resourceID) } else { if _, ok := d.GetOk(names.AttrAllocatedStorage); !ok { @@ -1599,9 +1598,9 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } input := &rds.CreateDBInstanceInput{ - AllocatedStorage: aws.Int64(int64(d.Get(names.AttrAllocatedStorage).(int))), + AllocatedStorage: aws.Int32(int32(d.Get(names.AttrAllocatedStorage).(int))), AutoMinorVersionUpgrade: aws.Bool(d.Get(names.AttrAutoMinorVersionUpgrade).(bool)), - BackupRetentionPeriod: aws.Int64(int64(d.Get("backup_retention_period").(int))), + BackupRetentionPeriod: aws.Int32(int32(d.Get("backup_retention_period").(int))), CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceIdentifier: aws.String(identifier), @@ -1612,7 +1611,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in MasterUsername: aws.String(d.Get(names.AttrUsername).(string)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), StorageEncrypted: aws.Bool(d.Get(names.AttrStorageEncrypted).(bool)), - Tags: getTagsIn(ctx), + Tags: getTagsInV2(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZone); ok { @@ -1656,7 +1655,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("domain_dns_ips"); ok && len(v.([]interface{})) > 0 { - input.DomainDnsIps = flex.ExpandStringList(v.([]interface{})) + input.DomainDnsIps = flex.ExpandStringValueList(v.([]interface{})) } if v, ok := d.GetOk("domain_fqdn"); ok { @@ -1672,7 +1671,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && v.(*schema.Set).Len() > 0 { - input.EnableCloudwatchLogsExports = flex.ExpandStringSet(v.(*schema.Set)) + input.EnableCloudwatchLogsExports = flex.ExpandStringValueSet(v.(*schema.Set)) } if v, ok := d.GetOk("engine_lifecycle_support"); ok { @@ -1684,7 +1683,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk(names.AttrIOPS); ok { - input.Iops = aws.Int64(int64(v.(int))) + input.Iops = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrKMSKeyID); ok { @@ -1708,11 +1707,11 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("max_allocated_storage"); ok { - input.MaxAllocatedStorage = aws.Int64(int64(v.(int))) + input.MaxAllocatedStorage = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("monitoring_interval"); ok { - input.MonitoringInterval = aws.Int64(int64(v.(int))) + input.MonitoringInterval = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("monitoring_role_arn"); ok { @@ -1752,15 +1751,15 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v, ok := d.GetOk("performance_insights_retention_period"); ok { - input.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int))) + input.PerformanceInsightsRetentionPeriod = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrPort); ok { - input.Port = aws.Int64(int64(v.(int))) + input.Port = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("storage_throughput"); ok { - input.StorageThroughput = aws.Int64(int64(v.(int))) + input.StorageThroughput = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk(names.AttrStorageType); ok { @@ -1772,12 +1771,12 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in } if v := d.Get(names.AttrVPCSecurityGroupIDs).(*schema.Set); v.Len() > 0 { - input.VpcSecurityGroupIds = flex.ExpandStringSet(v) + input.VpcSecurityGroupIds = flex.ExpandStringValueSet(v) } outputRaw, err := tfresource.RetryWhen(ctx, propagationTimeout, func() (interface{}, error) { - return conn.CreateDBInstanceWithContext(ctx, input) + return conn.CreateDBInstance(ctx, input) }, func(err error) (bool, error) { if tfawserr.ErrMessageContains(err, errCodeInvalidParameterValue, "ENHANCED_MONITORING") { @@ -1797,24 +1796,24 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in output := outputRaw.(*rds.CreateDBInstanceOutput) - resourceID = aws.StringValue(output.DBInstance.DbiResourceId) + resourceID = aws.ToString(output.DBInstance.DbiResourceId) d.SetId(resourceID) // This is added here to avoid unnecessary modification when ca_cert_identifier is the default one - if v, ok := d.GetOk("ca_cert_identifier"); ok && v.(string) != aws.StringValue(output.DBInstance.CACertificateIdentifier) { + if v, ok := d.GetOk("ca_cert_identifier"); ok && v.(string) != aws.ToString(output.DBInstance.CACertificateIdentifier) { modifyDbInstanceInput.CACertificateIdentifier = aws.String(v.(string)) requiresModifyDbInstance = true } } - var instance *rds.DBInstance + var instance *types.DBInstance var err error - if instance, err = waitDBInstanceAvailableSDKv1(ctx, conn, identifier, d.Timeout(schema.TimeoutCreate)); err != nil { + if instance, err = waitDBInstanceAvailable(ctx, conn, identifier, d.Timeout(schema.TimeoutCreate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS DB Instance (%s) create: %s", identifier, err) } if resourceID == "" { - resourceID = aws.StringValue(instance.DbiResourceId) + resourceID = aws.ToString(instance.DbiResourceId) } if d.Id() == "" { @@ -1824,25 +1823,27 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in if requiresModifyDbInstance { modifyDbInstanceInput.DBInstanceIdentifier = aws.String(identifier) - _, err := conn.ModifyDBInstanceWithContext(ctx, modifyDbInstanceInput) + _, err := conn.ModifyDBInstance(ctx, modifyDbInstanceInput) + if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", identifier, err) } - if _, err := waitDBInstanceAvailableSDKv1(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { + if _, err := waitDBInstanceAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS DB Instance (%s) update: %s", identifier, err) } } if requiresRebootDbInstance { - _, err := conn.RebootDBInstanceWithContext(ctx, &rds.RebootDBInstanceInput{ + _, err := conn.RebootDBInstance(ctx, &rds.RebootDBInstanceInput{ DBInstanceIdentifier: aws.String(identifier), }) + if err != nil { return sdkdiag.AppendErrorf(diags, "rebooting RDS DB Instance (%s): %s", identifier, err) } - if _, err := waitDBInstanceAvailableSDKv1(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { + if _, err := waitDBInstanceAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS DB Instance (%s) update: %s", identifier, err) } } @@ -1852,20 +1853,20 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) var ( - v *rds.DBInstance + v *types.DBInstance err error ) if d.IsNewResource() { - v, err = findDBInstanceByIDSDKv1(ctx, conn, d.Id()) + v, err = findDBInstanceByID(ctx, conn, d.Id()) } else { - v, err = findDBInstanceByIDSDKv1(ctx, conn, d.Id()) + v, err = findDBInstanceByID(ctx, conn, d.Id()) if tfresource.NotFound(err) { // nosemgrep:ci.semgrep.errors.notfound-without-err-checks // Retry with `identifier` - v, err = findDBInstanceByIDSDKv1(ctx, conn, d.Get(names.AttrIdentifier).(string)) + v, err = findDBInstanceByID(ctx, conn, d.Get(names.AttrIdentifier).(string)) if tfresource.NotFound(err) { // nosemgrep:ci.semgrep.errors.notfound-without-err-checks log.Printf("[WARN] RDS DB Instance (%s) not found, removing from state", d.Get(names.AttrIdentifier).(string)) d.SetId("") @@ -1878,8 +1879,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "reading RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } - d.SetId(aws.StringValue(v.DbiResourceId)) - + d.SetId(aws.ToString(v.DbiResourceId)) d.Set(names.AttrAllocatedStorage, v.AllocatedStorage) d.Set(names.AttrARN, v.DBInstanceArn) d.Set(names.AttrAutoMinorVersionUpgrade, v.AutoMinorVersionUpgrade) @@ -1898,11 +1898,11 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte } d.Set("dedicated_log_volume", v.DedicatedLogVolume) d.Set(names.AttrDeletionProtection, v.DeletionProtection) - if len(v.DomainMemberships) > 0 && v.DomainMemberships[0] != nil { + if len(v.DomainMemberships) > 0 { v := v.DomainMemberships[0] d.Set(names.AttrDomain, v.Domain) d.Set("domain_auth_secret_arn", v.AuthSecretArn) - d.Set("domain_dns_ips", aws.StringValueSlice(v.DnsIps)) + d.Set("domain_dns_ips", v.DnsIps) d.Set("domain_fqdn", v.FQDN) d.Set("domain_iam_role_name", v.IAMRoleName) d.Set("domain_ou", v.OU) @@ -1914,17 +1914,17 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("domain_iam_role_name", nil) d.Set("domain_ou", nil) } - d.Set("enabled_cloudwatch_logs_exports", aws.StringValueSlice(v.EnabledCloudwatchLogsExports)) + d.Set("enabled_cloudwatch_logs_exports", v.EnabledCloudwatchLogsExports) d.Set(names.AttrEngine, v.Engine) d.Set("engine_lifecycle_support", v.EngineLifecycleSupport) d.Set("iam_database_authentication_enabled", v.IAMDatabaseAuthenticationEnabled) d.Set(names.AttrIdentifier, v.DBInstanceIdentifier) - d.Set("identifier_prefix", create.NamePrefixFromName(aws.StringValue(v.DBInstanceIdentifier))) + d.Set("identifier_prefix", create.NamePrefixFromName(aws.ToString(v.DBInstanceIdentifier))) d.Set("instance_class", v.DBInstanceClass) d.Set(names.AttrIOPS, v.Iops) d.Set(names.AttrKMSKeyID, v.KmsKeyId) if v.LatestRestorableTime != nil { - d.Set("latest_restorable_time", aws.TimeValue(v.LatestRestorableTime).Format(time.RFC3339)) + d.Set("latest_restorable_time", aws.ToTime(v.LatestRestorableTime).Format(time.RFC3339)) } else { d.Set("latest_restorable_time", nil) } @@ -1942,7 +1942,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte // Expose the MasterUserSecret structure as a computed attribute // https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/create-db-cluster.html#:~:text=for%20future%20use.-,MasterUserSecret,-%2D%3E%20(structure) if v.MasterUserSecret != nil { - if err := d.Set("master_user_secret", []interface{}{flattenManagedMasterUserSecretV1(v.MasterUserSecret)}); err != nil { + if err := d.Set("master_user_secret", []interface{}{flattenManagedMasterUserSecret(v.MasterUserSecret)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting master_user_secret: %s", err) } } else { @@ -1955,10 +1955,10 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("multi_az", v.MultiAZ) d.Set("nchar_character_set_name", v.NcharCharacterSetName) d.Set("network_type", v.NetworkType) - if len(v.OptionGroupMemberships) > 0 && v.OptionGroupMemberships[0] != nil { + if len(v.OptionGroupMemberships) > 0 { d.Set("option_group_name", v.OptionGroupMemberships[0].OptionGroupName) } - if len(v.DBParameterGroups) > 0 && v.DBParameterGroups[0] != nil { + if len(v.DBParameterGroups) > 0 { d.Set(names.AttrParameterGroupName, v.DBParameterGroups[0].DBParameterGroupName) } d.Set("performance_insights_enabled", v.PerformanceInsightsEnabled) @@ -1967,7 +1967,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set(names.AttrPort, v.DbInstancePort) d.Set(names.AttrPubliclyAccessible, v.PubliclyAccessible) d.Set("replica_mode", v.ReplicaMode) - d.Set("replicas", aws.StringValueSlice(v.ReadReplicaDBInstanceIdentifiers)) + d.Set("replicas", v.ReadReplicaDBInstanceIdentifiers) d.Set("replicate_source_db", v.ReadReplicaSourceDBInstanceIdentifier) d.Set(names.AttrResourceID, v.DbiResourceId) d.Set(names.AttrStatus, v.DBInstanceStatus) @@ -1976,16 +1976,14 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set(names.AttrStorageType, v.StorageType) d.Set("timezone", v.Timezone) d.Set(names.AttrUsername, v.MasterUsername) - var vpcSecurityGroupIDs []string - for _, v := range v.VpcSecurityGroups { - vpcSecurityGroupIDs = append(vpcSecurityGroupIDs, aws.StringValue(v.VpcSecurityGroupId)) - } - d.Set(names.AttrVPCSecurityGroupIDs, vpcSecurityGroupIDs) + d.Set(names.AttrVPCSecurityGroupIDs, tfslices.ApplyToAll(v.VpcSecurityGroups, func(v types.VpcSecurityGroupMembership) string { + return aws.ToString(v.VpcSecurityGroupId) + })) if v.Endpoint != nil { d.Set(names.AttrAddress, v.Endpoint.Address) if v.Endpoint.Address != nil && v.Endpoint.Port != nil { - d.Set(names.AttrEndpoint, fmt.Sprintf("%s:%d", aws.StringValue(v.Endpoint.Address), aws.Int64Value(v.Endpoint.Port))) + d.Set(names.AttrEndpoint, fmt.Sprintf("%s:%d", aws.ToString(v.Endpoint.Address), aws.ToInt32(v.Endpoint.Port))) } d.Set(names.AttrHostedZoneID, v.Endpoint.HostedZoneId) d.Set(names.AttrPort, v.Endpoint.Port) @@ -2001,7 +1999,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte dbSetResourceDataEngineVersionFromInstance(d, v) - setTagsOut(ctx, v.TagList) + setTagsOutV2(ctx, v.TagList) return diags } @@ -2014,7 +2012,7 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta in // Separate request to promote a database. if d.HasChange("replicate_source_db") { if d.Get("replicate_source_db").(string) == "" { - input := &rds_sdkv2.PromoteReadReplicaInput{ + input := &rds.PromoteReadReplicaInput{ BackupRetentionPeriod: aws.Int32(int32(d.Get("backup_retention_period").(int))), DBInstanceIdentifier: aws.String(d.Get(names.AttrIdentifier).(string)), } @@ -2024,11 +2022,12 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta in } _, err := conn.PromoteReadReplica(ctx, input) + if err != nil { return sdkdiag.AppendErrorf(diags, "promoting RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } - if _, err := waitDBInstanceAvailableSDKv2(ctx, conn, d.Id(), deadline.Remaining()); err != nil { + if _, err := waitDBInstanceAvailable(ctx, conn, d.Id(), deadline.Remaining()); err != nil { return sdkdiag.AppendErrorf(diags, "promoting RDS DB Instance (%s): waiting for completion: %s", d.Get(names.AttrIdentifier).(string), err) } } else { @@ -2087,106 +2086,114 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta in } // Ensure that the Blue/Green Deployment is always cleaned up - input := &rds_sdkv2.DeleteBlueGreenDeploymentInput{ + input := &rds.DeleteBlueGreenDeploymentInput{ BlueGreenDeploymentIdentifier: deploymentIdentifier, } - if aws.StringValue(dep.Status) != "SWITCHOVER_COMPLETED" { + if aws.ToString(dep.Status) != "SWITCHOVER_COMPLETED" { input.DeleteTarget = aws.Bool(true) } + _, err = conn.DeleteBlueGreenDeployment(ctx, input) + if err != nil { diags = sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): deleting Blue/Green Deployment: %s", d.Get(names.AttrIdentifier).(string), err) return } - orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds_sdkv2.Client, optFns ...tfresource.OptionsFunc) { - _, err = waitBlueGreenDeploymentDeleted(ctx, conn, aws.StringValue(deploymentIdentifier), deadline.Remaining(), optFns...) - if err != nil { + orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds.Client, optFns ...tfresource.OptionsFunc) { + if _, err := waitBlueGreenDeploymentDeleted(ctx, conn, aws.ToString(deploymentIdentifier), deadline.Remaining(), optFns...); err != nil { diags = sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): deleting Blue/Green Deployment: waiting for completion: %s", d.Get(names.AttrIdentifier).(string), err) } }) }() - dep, err = orchestrator.waitForDeploymentAvailable(ctx, aws.StringValue(dep.BlueGreenDeploymentIdentifier), deadline.Remaining()) + dep, err = orchestrator.waitForDeploymentAvailable(ctx, aws.ToString(dep.BlueGreenDeploymentIdentifier), deadline.Remaining()) if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } - targetARN, err := parseDBInstanceARN(aws.StringValue(dep.Target)) + targetARN, err := parseDBInstanceARN(aws.ToString(dep.Target)) if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): creating Blue/Green Deployment: waiting for Green environment: %s", d.Get(names.AttrIdentifier).(string), err) } - _, err = waitDBInstanceAvailableSDKv2(ctx, conn, targetARN.Identifier, deadline.Remaining()) - if err != nil { + + if _, err := waitDBInstanceAvailable(ctx, conn, targetARN.Identifier, deadline.Remaining()); err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): creating Blue/Green Deployment: waiting for Green environment: %s", d.Get(names.AttrIdentifier).(string), err) } - err = handler.modifyTarget(ctx, targetARN.Identifier, d, deadline.Remaining(), fmt.Sprintf("Updating RDS DB Instance (%s)", d.Get(names.AttrIdentifier).(string))) - if err != nil { + if err := handler.modifyTarget(ctx, targetARN.Identifier, d, deadline.Remaining(), fmt.Sprintf("Updating RDS DB Instance (%s)", d.Get(names.AttrIdentifier).(string))); err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } log.Printf("[DEBUG] Updating RDS DB Instance (%s): Switching over Blue/Green Deployment", d.Get(names.AttrIdentifier).(string)) - dep, err = orchestrator.Switchover(ctx, aws.StringValue(dep.BlueGreenDeploymentIdentifier), deadline.Remaining()) + dep, err = orchestrator.Switchover(ctx, aws.ToString(dep.BlueGreenDeploymentIdentifier), deadline.Remaining()) if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } - target, err := findDBInstanceByIDSDKv2(ctx, conn, d.Get(names.AttrIdentifier).(string)) + target, err := findDBInstanceByID(ctx, conn, d.Get(names.AttrIdentifier).(string)) if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } // id changes here - d.SetId(aws.StringValue(target.DbiResourceId)) + d.SetId(aws.ToString(target.DbiResourceId)) d.Set(names.AttrResourceID, target.DbiResourceId) log.Printf("[DEBUG] Updating RDS DB Instance (%s): Deleting Blue/Green Deployment source", d.Get(names.AttrIdentifier).(string)) - sourceARN, err := parseDBInstanceARN(aws.StringValue(dep.Source)) + sourceARN, err := parseDBInstanceARN(aws.ToString(dep.Source)) if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): deleting Blue/Green Deployment source: %s", d.Get(names.AttrIdentifier).(string), err) } + if d.Get(names.AttrDeletionProtection).(bool) { - input := &rds_sdkv2.ModifyDBInstanceInput{ + input := &rds.ModifyDBInstanceInput{ ApplyImmediately: aws.Bool(true), DBInstanceIdentifier: aws.String(sourceARN.Identifier), DeletionProtection: aws.Bool(false), } + err := dbInstanceModify(ctx, conn, d.Id(), input, deadline.Remaining()) + if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): deleting Blue/Green Deployment source: disabling deletion protection: %s", d.Get(names.AttrIdentifier).(string), err) } } - deleteInput := &rds_sdkv2.DeleteDBInstanceInput{ + + input := &rds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(sourceARN.Identifier), SkipFinalSnapshot: aws.Bool(true), } - _, err = tfresource.RetryWhen(ctx, 5*time.Minute, + + const ( + timeout = 5 * time.Minute + ) + _, err = tfresource.RetryWhen(ctx, timeout, func() (any, error) { - return conn.DeleteDBInstance(ctx, deleteInput) + return conn.DeleteDBInstance(ctx, input) }, func(err error) (bool, error) { // Retry for IAM eventual consistency. - if tfawserr_sdkv2.ErrMessageContains(err, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") { + if tfawserr.ErrMessageContains(err, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") { return true, err } - if tfawserr_sdkv2.ErrMessageContains(err, errCodeInvalidParameterCombination, "disable deletion pro") { + if tfawserr.ErrMessageContains(err, errCodeInvalidParameterCombination, "disable deletion pro") { return true, err } return false, err }, ) + if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): deleting Blue/Green Deployment source: %s", d.Get(names.AttrIdentifier).(string), err) } - orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds_sdkv2.Client, optFns ...tfresource.OptionsFunc) { - _, err = waitDBInstanceDeleted(ctx, meta.(*conns.AWSClient).RDSConn(ctx), sourceARN.Identifier, deadline.Remaining(), optFns...) - if err != nil { + orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds.Client, optFns ...tfresource.OptionsFunc) { + if _, err := waitDBInstanceDeleted(ctx, conn, sourceARN.Identifier, deadline.Remaining(), optFns...); err != nil { diags = sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): deleting Blue/Green Deployment source: waiting for completion: %s", d.Get(names.AttrIdentifier).(string), err) } }) @@ -2202,7 +2209,7 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta in } applyImmediately := d.Get(names.AttrApplyImmediately).(bool) - input := &rds_sdkv2.ModifyDBInstanceInput{ + input := &rds.ModifyDBInstanceInput{ ApplyImmediately: aws.Bool(applyImmediately), DBInstanceIdentifier: aws.String(oldID), } @@ -2226,6 +2233,7 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta in } err := dbInstanceModify(ctx, conn, d.Id(), input, deadline.Remaining()) + if err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } @@ -2237,7 +2245,7 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta in func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) input := &rds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(d.Get(names.AttrIdentifier).(string)), @@ -2257,13 +2265,13 @@ func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, meta in } log.Printf("[DEBUG] Deleting RDS DB Instance: %s", d.Get(names.AttrIdentifier).(string)) - _, err := conn.DeleteDBInstanceWithContext(ctx, input) + _, err := conn.DeleteDBInstance(ctx, input) if tfawserr.ErrMessageContains(err, errCodeInvalidParameterCombination, "disable deletion pro") { if v, ok := d.GetOk(names.AttrDeletionProtection); (!ok || !v.(bool)) && d.Get(names.AttrApplyImmediately).(bool) { _, ierr := tfresource.RetryWhen(ctx, d.Timeout(schema.TimeoutUpdate), func() (interface{}, error) { - return conn.ModifyDBInstanceWithContext(ctx, &rds.ModifyDBInstanceInput{ + return conn.ModifyDBInstance(ctx, &rds.ModifyDBInstanceInput{ ApplyImmediately: aws.Bool(true), DBInstanceIdentifier: aws.String(d.Get(names.AttrIdentifier).(string)), DeletionProtection: aws.Bool(false), @@ -2276,7 +2284,7 @@ func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, meta in } // "InvalidDBInstanceState: RDS is configuring Enhanced Monitoring or Performance Insights for this DB instance. Try your request later." - if tfawserr.ErrMessageContains(err, rds.ErrCodeInvalidDBInstanceStateFault, "your request later") { + if errs.IsAErrorMessageContains[*types.InvalidDBInstanceStateFault](err, "your request later") { return true, err } @@ -2288,19 +2296,19 @@ func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "updating RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } - if _, ierr := waitDBInstanceAvailableSDKv1(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); ierr != nil { + if _, ierr := waitDBInstanceAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); ierr != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS DB Instance (%s) update: %s", d.Get(names.AttrIdentifier).(string), ierr) } - _, err = conn.DeleteDBInstanceWithContext(ctx, input) + _, err = conn.DeleteDBInstance(ctx, input) } } - if tfawserr.ErrCodeEquals(err, rds.ErrCodeDBInstanceNotFoundFault) { + if errs.IsA[*types.DBInstanceNotFoundFault](err) { return diags } - if err != nil && !tfawserr.ErrMessageContains(err, rds.ErrCodeInvalidDBInstanceStateFault, "is already being deleted") { + if err != nil && !errs.IsAErrorMessageContains[*types.InvalidDBInstanceStateFault](err, "is already being deleted") { return sdkdiag.AppendErrorf(diags, "deleting RDS DB Instance (%s): %s", d.Get(names.AttrIdentifier).(string), err) } @@ -2320,10 +2328,10 @@ func resourceInstanceImport(_ context.Context, d *schema.ResourceData, meta inte return []*schema.ResourceData{d}, nil } -func dbInstanceCreateReadReplica(ctx context.Context, conn *rds.RDS, input *rds.CreateDBInstanceReadReplicaInput) (*rds.CreateDBInstanceReadReplicaOutput, error) { +func dbInstanceCreateReadReplica(ctx context.Context, conn *rds.Client, input *rds.CreateDBInstanceReadReplicaInput) (*rds.CreateDBInstanceReadReplicaOutput, error) { outputRaw, err := tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) { - return conn.CreateDBInstanceReadReplicaWithContext(ctx, input) + return conn.CreateDBInstanceReadReplica(ctx, input) }, errCodeInvalidParameterValue, "ENHANCED_MONITORING") @@ -2334,7 +2342,7 @@ func dbInstanceCreateReadReplica(ctx context.Context, conn *rds.RDS, input *rds. return outputRaw.(*rds.CreateDBInstanceReadReplicaOutput), nil } -func dbInstancePopulateModify(input *rds_sdkv2.ModifyDBInstanceInput, d *schema.ResourceData) bool { +func dbInstancePopulateModify(input *rds.ModifyDBInstanceInput, d *schema.ResourceData) bool { needsModify := false if d.HasChanges(names.AttrAllocatedStorage, names.AttrIOPS) { @@ -2554,7 +2562,7 @@ func dbInstancePopulateModify(input *rds_sdkv2.ModifyDBInstanceInput, d *schema. needsModify = true input.StorageType = aws.String(d.Get(names.AttrStorageType).(string)) - if slices.Contains([]string{storageTypeIO1, storageTypeIO2}, aws.StringValue(input.StorageType)) { + if slices.Contains([]string{storageTypeIO1, storageTypeIO2}, aws.ToString(input.StorageType)) { input.Iops = aws.Int32(int32(d.Get(names.AttrIOPS).(int))) } } @@ -2569,18 +2577,18 @@ func dbInstancePopulateModify(input *rds_sdkv2.ModifyDBInstanceInput, d *schema. return needsModify } -func dbInstanceModify(ctx context.Context, conn *rds_sdkv2.Client, resourceID string, input *rds_sdkv2.ModifyDBInstanceInput, timeout time.Duration) error { +func dbInstanceModify(ctx context.Context, conn *rds.Client, resourceID string, input *rds.ModifyDBInstanceInput, timeout time.Duration) error { _, err := tfresource.RetryWhen(ctx, timeout, func() (interface{}, error) { return conn.ModifyDBInstance(ctx, input) }, func(err error) (bool, error) { // Retry for IAM eventual consistency. - if tfawserr_sdkv2.ErrMessageContains(err, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") { + if tfawserr.ErrMessageContains(err, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") { return true, err } - if tfawserr_sdkv2.ErrMessageContains(err, errCodeInvalidParameterCombination, "previous storage change is being optimized") { + if tfawserr.ErrMessageContains(err, errCodeInvalidParameterCombination, "previous storage change is being optimized") { return true, err } @@ -2591,13 +2599,15 @@ func dbInstanceModify(ctx context.Context, conn *rds_sdkv2.Client, resourceID st return false, err }, ) + if err != nil { return err } - if _, err := waitDBInstanceAvailableSDKv2(ctx, conn, resourceID, timeout); err != nil { + if _, err := waitDBInstanceAvailable(ctx, conn, resourceID, timeout); err != nil { return fmt.Errorf("waiting for completion: %w", err) } + return nil } @@ -2619,12 +2629,12 @@ func isStorageTypeGP3BelowAllocatedStorageThreshold(d *schema.ResourceData) bool return false } -func dbSetResourceDataEngineVersionFromInstance(d *schema.ResourceData, c *rds.DBInstance) { +func dbSetResourceDataEngineVersionFromInstance(d *schema.ResourceData, c *types.DBInstance) { oldVersion := d.Get(names.AttrEngineVersion).(string) - newVersion := aws.StringValue(c.EngineVersion) + newVersion := aws.ToString(c.EngineVersion) var pendingVersion string if c.PendingModifiedValues != nil && c.PendingModifiedValues.EngineVersion != nil { - pendingVersion = aws.StringValue(c.PendingModifiedValues.EngineVersion) + pendingVersion = aws.ToString(c.PendingModifiedValues.EngineVersion) } compareActualEngineVersion(d, oldVersion, newVersion, pendingVersion) } @@ -2654,33 +2664,33 @@ func parseDBInstanceARN(s string) (dbInstanceARN, error) { return result, nil } -// findDBInstanceByIDSDKv1 in general should be called with a DbiResourceId of the form +// findDBInstanceByID in general should be called with a DbiResourceId of the form // "db-BE6UI2KLPQP3OVDYD74ZEV6NUM" rather than a DB identifier. However, in some cases only // the identifier is available, and can be used. -func findDBInstanceByIDSDKv1(ctx context.Context, conn *rds.RDS, id string) (*rds.DBInstance, error) { - idLooksLikeDbiResourceId := regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) +func findDBInstanceByID(ctx context.Context, conn *rds.Client, id string, optFns ...func(*rds.Options)) (*types.DBInstance, error) { + idLooksLikeDbiResourceID := regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) input := &rds.DescribeDBInstancesInput{} - if idLooksLikeDbiResourceId { - input.Filters = []*rds.Filter{ + if idLooksLikeDbiResourceID { + input.Filters = []types.Filter{ { Name: aws.String("dbi-resource-id"), - Values: aws.StringSlice([]string{id}), + Values: []string{id}, }, } } else { input.DBInstanceIdentifier = aws.String(id) } - output, err := findDBInstanceSDKv1(ctx, conn, input, tfslices.PredicateTrue[*rds.DBInstance]()) + output, err := findDBInstance(ctx, conn, input, tfslices.PredicateTrue[*types.DBInstance](), optFns...) // in case a DB has an *identifier* starting with "db-"" - if idLooksLikeDbiResourceId && tfresource.NotFound(err) { - input := &rds.DescribeDBInstancesInput{ + if idLooksLikeDbiResourceID && tfresource.NotFound(err) { + input = &rds.DescribeDBInstancesInput{ DBInstanceIdentifier: aws.String(id), } - output, err = findDBInstanceSDKv1(ctx, conn, input, tfslices.PredicateTrue[*rds.DBInstance]()) + output, err = findDBInstance(ctx, conn, input, tfslices.PredicateTrue[*types.DBInstance](), optFns...) } if err != nil { @@ -2690,111 +2700,47 @@ func findDBInstanceByIDSDKv1(ctx context.Context, conn *rds.RDS, id string) (*rd return output, nil } -func findDBInstanceSDKv1(ctx context.Context, conn *rds.RDS, input *rds.DescribeDBInstancesInput, filter tfslices.Predicate[*rds.DBInstance]) (*rds.DBInstance, error) { - output, err := findDBInstancesSDKv1(ctx, conn, input, filter) +func findDBInstance(ctx context.Context, conn *rds.Client, input *rds.DescribeDBInstancesInput, filter tfslices.Predicate[*types.DBInstance], optFns ...func(*rds.Options)) (*types.DBInstance, error) { + output, err := findDBInstances(ctx, conn, input, filter, optFns...) if err != nil { return nil, err } - return tfresource.AssertSinglePtrResult(output) + return tfresource.AssertSingleValueResult(output) } -func findDBInstancesSDKv1(ctx context.Context, conn *rds.RDS, input *rds.DescribeDBInstancesInput, filter tfslices.Predicate[*rds.DBInstance]) ([]*rds.DBInstance, error) { - var output []*rds.DBInstance +func findDBInstances(ctx context.Context, conn *rds.Client, input *rds.DescribeDBInstancesInput, filter tfslices.Predicate[*types.DBInstance], optFns ...func(*rds.Options)) ([]types.DBInstance, error) { + var output []types.DBInstance - err := conn.DescribeDBInstancesPagesWithContext(ctx, input, func(page *rds.DescribeDBInstancesOutput, lastPage bool) bool { - if page == nil { - return !lastPage - } + pages := rds.NewDescribeDBInstancesPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx, optFns...) - for _, v := range page.DBInstances { - if v != nil && filter(v) { - output = append(output, v) + if errs.IsA[*types.DBInstanceNotFoundFault](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, } } - return !lastPage - }) - - if tfawserr.ErrCodeEquals(err, rds.ErrCodeDBInstanceNotFoundFault) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, - } - } - - if err != nil { - return nil, err - } - - return output, nil -} - -// findDBInstanceByIDSDKv2 in general should be called with a DbiResourceId of the form -// "db-BE6UI2KLPQP3OVDYD74ZEV6NUM" rather than a DB identifier. However, in some cases only -// the identifier is available, and can be used. -func findDBInstanceByIDSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id string, optFns ...func(*rds_sdkv2.Options)) (*types.DBInstance, error) { - input := &rds_sdkv2.DescribeDBInstancesInput{} - - if regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) { - input.Filters = []types.Filter{ - { - Name: aws.String("dbi-resource-id"), - Values: []string{id}, - }, - } - } else { - input.DBInstanceIdentifier = aws.String(id) - } - - output, err := conn.DescribeDBInstances(ctx, input, optFns...) - - // in case a DB has an *identifier* starting with "db-"" - if regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) && (output == nil || len(output.DBInstances) == 0) { - input = &rds_sdkv2.DescribeDBInstancesInput{ - DBInstanceIdentifier: aws.String(id), + if err != nil { + return nil, err } - output, err = conn.DescribeDBInstances(ctx, input, optFns...) - } - if errs.IsA[*types.DBInstanceNotFoundFault](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, + for _, v := range page.DBInstances { + if filter(&v) { + output = append(output, v) + } } } - if err != nil { - return nil, err - } - - if output == nil { - return nil, tfresource.NewEmptyResultError(input) - } - - return tfresource.AssertSingleValueResult(output.DBInstances) -} - -func statusDBInstanceSDKv1(ctx context.Context, conn *rds.RDS, id string) retry.StateRefreshFunc { - return func() (interface{}, string, error) { - output, err := findDBInstanceByIDSDKv1(ctx, conn, id) - - if tfresource.NotFound(err) { - return nil, "", nil - } - - if err != nil { - return nil, "", err - } - - return output, aws.StringValue(output.DBInstanceStatus), nil - } + return output, nil } -func statusDBInstanceSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id string) retry.StateRefreshFunc { +func statusDBInstance(ctx context.Context, conn *rds.Client, id string, optFns ...func(*rds.Options)) retry.StateRefreshFunc { return func() (interface{}, string, error) { - output, err := findDBInstanceByIDSDKv2(ctx, conn, id) + output, err := findDBInstanceByID(ctx, conn, id, optFns...) if tfresource.NotFound(err) { return nil, "", nil @@ -2804,11 +2750,11 @@ func statusDBInstanceSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id strin return nil, "", err } - return output, aws.StringValue(output.DBInstanceStatus), nil + return output, aws.ToString(output.DBInstanceStatus), nil } } -func waitDBInstanceAvailableSDKv1(ctx context.Context, conn *rds.RDS, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*rds.DBInstance, error) { +func waitDBInstanceAvailable(ctx context.Context, conn *rds.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.DBInstance, error) { options := tfresource.Options{ PollInterval: 10 * time.Second, Delay: 1 * time.Minute, @@ -2837,64 +2783,21 @@ func waitDBInstanceAvailableSDKv1(ctx context.Context, conn *rds.RDS, id string, InstanceStatusUpgrading, }, Target: []string{InstanceStatusAvailable, InstanceStatusStorageOptimization}, - Refresh: statusDBInstanceSDKv1(ctx, conn, id), + Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, } options.Apply(stateConf) outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*rds.DBInstance); ok { + if output, ok := outputRaw.(*types.DBInstance); ok { return output, err } return nil, err } -func waitDBInstanceAvailableSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*rds.DBInstance, error) { - options := tfresource.Options{ - PollInterval: 10 * time.Second, - Delay: 1 * time.Minute, - ContinuousTargetOccurence: 3, - } - for _, fn := range optFns { - fn(&options) - } - - stateConf := &retry.StateChangeConf{ - Pending: []string{ - InstanceStatusBackingUp, - InstanceStatusConfiguringEnhancedMonitoring, - InstanceStatusConfiguringIAMDatabaseAuth, - InstanceStatusConfiguringLogExports, - InstanceStatusCreating, - InstanceStatusMaintenance, - InstanceStatusModifying, - InstanceStatusMovingToVPC, - InstanceStatusRebooting, - InstanceStatusRenaming, - InstanceStatusResettingMasterCredentials, - InstanceStatusStarting, - InstanceStatusStopping, - InstanceStatusStorageFull, - InstanceStatusUpgrading, - }, - Target: []string{InstanceStatusAvailable, InstanceStatusStorageOptimization}, - Refresh: statusDBInstanceSDKv2(ctx, conn, id), - Timeout: timeout, - } - options.Apply(stateConf) - - outputRaw, err := stateConf.WaitForStateContext(ctx) - - if output, ok := outputRaw.(*rds.DBInstance); ok { - return output, err - } - - return nil, err -} - -func waitDBInstanceDeleted(ctx context.Context, conn *rds.RDS, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*rds.DBInstance, error) { +func waitDBInstanceDeleted(ctx context.Context, conn *rds.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.DBInstance, error) { options := tfresource.Options{ PollInterval: 10 * time.Second, Delay: 1 * time.Minute, @@ -2922,55 +2825,83 @@ func waitDBInstanceDeleted(ctx context.Context, conn *rds.RDS, id string, timeou InstanceStatusStorageOptimization, }, Target: []string{}, - Refresh: statusDBInstanceSDKv1(ctx, conn, id), + Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, } options.Apply(stateConf) outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*rds.DBInstance); ok { + if output, ok := outputRaw.(*types.DBInstance); ok { return output, err } return nil, err } -func findBlueGreenDeploymentByID(ctx context.Context, conn *rds_sdkv2.Client, id string) (*types.BlueGreenDeployment, error) { - input := &rds_sdkv2.DescribeBlueGreenDeploymentsInput{ +func findBlueGreenDeploymentByID(ctx context.Context, conn *rds.Client, id string) (*types.BlueGreenDeployment, error) { + input := &rds.DescribeBlueGreenDeploymentsInput{ BlueGreenDeploymentIdentifier: aws.String(id), } - output, err := conn.DescribeBlueGreenDeployments(ctx, input) + output, err := findBlueGreenDeployment(ctx, conn, input, tfslices.PredicateTrue[*types.BlueGreenDeployment]()) + + if err != nil { + return nil, err + } - if errs.IsA[*types.BlueGreenDeploymentNotFoundFault](err) { + // Eventual consistency check. + if aws.ToString(output.BlueGreenDeploymentIdentifier) != id { return nil, &retry.NotFoundError{ - LastError: err, LastRequest: input, } } + + return output, nil +} + +func findBlueGreenDeployment(ctx context.Context, conn *rds.Client, input *rds.DescribeBlueGreenDeploymentsInput, filter tfslices.Predicate[*types.BlueGreenDeployment]) (*types.BlueGreenDeployment, error) { + output, err := findBlueGreenDeployments(ctx, conn, input, filter) + if err != nil { return nil, err } - if output == nil || len(output.BlueGreenDeployments) == 0 { - return nil, tfresource.NewEmptyResultError(input) - } + return tfresource.AssertSingleValueResult(output) +} - deployment := output.BlueGreenDeployments[0] +func findBlueGreenDeployments(ctx context.Context, conn *rds.Client, input *rds.DescribeBlueGreenDeploymentsInput, filter tfslices.Predicate[*types.BlueGreenDeployment]) ([]types.BlueGreenDeployment, error) { + var output []types.BlueGreenDeployment - if aws.StringValue(deployment.BlueGreenDeploymentIdentifier) != id { - return nil, &retry.NotFoundError{ - LastRequest: input, + pages := rds.NewDescribeBlueGreenDeploymentsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if errs.IsA[*types.BlueGreenDeploymentNotFoundFault](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + + if err != nil { + return nil, err + } + + for _, v := range page.BlueGreenDeployments { + if filter(&v) { + output = append(output, v) + } } } - return &deployment, nil + return output, nil } -func statusBlueGreenDeployment(ctx context.Context, conn *rds_sdkv2.Client, id string) retry.StateRefreshFunc { +func statusBlueGreenDeployment(ctx context.Context, conn *rds.Client, id string) retry.StateRefreshFunc { return func() (interface{}, string, error) { output, err := findBlueGreenDeploymentByID(ctx, conn, id) + if tfresource.NotFound(err) { return nil, "", nil } @@ -2978,11 +2909,11 @@ func statusBlueGreenDeployment(ctx context.Context, conn *rds_sdkv2.Client, id s return nil, "", err } - return output, aws.StringValue(output.Status), nil + return output, aws.ToString(output.Status), nil } } -func waitBlueGreenDeploymentAvailable(ctx context.Context, conn *rds_sdkv2.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.BlueGreenDeployment, error) { +func waitBlueGreenDeploymentAvailable(ctx context.Context, conn *rds.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.BlueGreenDeployment, error) { options := tfresource.Options{ PollInterval: 10 * time.Second, Delay: 1 * time.Minute, @@ -3008,7 +2939,7 @@ func waitBlueGreenDeploymentAvailable(ctx context.Context, conn *rds_sdkv2.Clien return nil, err } -func waitBlueGreenDeploymentSwitchoverCompleted(ctx context.Context, conn *rds_sdkv2.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.BlueGreenDeployment, error) { +func waitBlueGreenDeploymentSwitchoverCompleted(ctx context.Context, conn *rds.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.BlueGreenDeployment, error) { options := tfresource.Options{ PollInterval: 10 * time.Second, Delay: 1 * time.Minute, @@ -3028,8 +2959,8 @@ func waitBlueGreenDeploymentSwitchoverCompleted(ctx context.Context, conn *rds_s outputRaw, err := stateConf.WaitForStateContext(ctx) if output, ok := outputRaw.(*types.BlueGreenDeployment); ok { - if status := aws.StringValue(output.Status); status == "INVALID_CONFIGURATION" || status == "SWITCHOVER_FAILED" { - tfresource.SetLastError(err, errors.New(aws.StringValue(output.StatusDetails))) + if status := aws.ToString(output.Status); status == "INVALID_CONFIGURATION" || status == "SWITCHOVER_FAILED" { + tfresource.SetLastError(err, errors.New(aws.ToString(output.StatusDetails))) } return output, err @@ -3038,7 +2969,7 @@ func waitBlueGreenDeploymentSwitchoverCompleted(ctx context.Context, conn *rds_s return nil, err } -func waitBlueGreenDeploymentDeleted(ctx context.Context, conn *rds_sdkv2.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.BlueGreenDeployment, error) { +func waitBlueGreenDeploymentDeleted(ctx context.Context, conn *rds.Client, id string, timeout time.Duration, optFns ...tfresource.OptionsFunc) (*types.BlueGreenDeployment, error) { options := tfresource.Options{ PollInterval: 10 * time.Second, Delay: 1 * time.Minute, @@ -3072,7 +3003,7 @@ func dbInstanceValidBlueGreenEngines() []string { } } -func flattenEndpoint(apiObject *rds.Endpoint) map[string]interface{} { +func flattenEndpoint(apiObject *types.Endpoint) map[string]interface{} { if apiObject == nil { return nil } @@ -3080,35 +3011,15 @@ func flattenEndpoint(apiObject *rds.Endpoint) map[string]interface{} { tfMap := map[string]interface{}{} if v := apiObject.Address; v != nil { - tfMap[names.AttrAddress] = aws.StringValue(v) + tfMap[names.AttrAddress] = aws.ToString(v) } if v := apiObject.HostedZoneId; v != nil { - tfMap[names.AttrHostedZoneID] = aws.StringValue(v) + tfMap[names.AttrHostedZoneID] = aws.ToString(v) } if v := apiObject.Port; v != nil { - tfMap[names.AttrPort] = aws.Int64Value(v) - } - - return tfMap -} - -// TODO Remove once migrated to AWS SDK for Go v2. -func flattenManagedMasterUserSecretV1(apiObject *rds.MasterUserSecret) map[string]interface{} { - if apiObject == nil { - return nil - } - - tfMap := map[string]interface{}{} - if v := apiObject.KmsKeyId; v != nil { - tfMap[names.AttrKMSKeyID] = aws.StringValue(v) - } - if v := apiObject.SecretArn; v != nil { - tfMap["secret_arn"] = aws.StringValue(v) - } - if v := apiObject.SecretStatus; v != nil { - tfMap["secret_status"] = aws.StringValue(v) + tfMap[names.AttrPort] = aws.ToInt32(v) } return tfMap diff --git a/internal/service/rds/instance_automated_backups_replication.go b/internal/service/rds/instance_automated_backups_replication.go index 9738ef5611d..f53a4b6f7c3 100644 --- a/internal/service/rds/instance_automated_backups_replication.go +++ b/internal/service/rds/instance_automated_backups_replication.go @@ -288,7 +288,7 @@ func waitDBInstanceAutomatedBackupDeleted(ctx context.Context, conn *rds.Client, var output *types.DBInstance _, err := tfresource.RetryUntilEqual(ctx, timeout, false, func() (bool, error) { - dbInstance, err := findDBInstanceByIDSDKv2(ctx, conn, dbInstanceID, optFns...) + dbInstance, err := findDBInstanceByID(ctx, conn, dbInstanceID, optFns...) if tfresource.NotFound(err) { return false, nil diff --git a/internal/service/rds/instance_role_association.go b/internal/service/rds/instance_role_association.go index 55803f1aa25..4b9baa63818 100644 --- a/internal/service/rds/instance_role_association.go +++ b/internal/service/rds/instance_role_association.go @@ -178,7 +178,7 @@ func instanceRoleAssociationParseResourceID(id string) (string, string, error) { } func findDBInstanceRoleByTwoPartKey(ctx context.Context, conn *rds.Client, dbInstanceIdentifier, roleARN string) (*types.DBInstanceRole, error) { - dbInstance, err := findDBInstanceByIDSDKv2(ctx, conn, dbInstanceIdentifier) + dbInstance, err := findDBInstanceByID(ctx, conn, dbInstanceIdentifier) if err != nil { return nil, err diff --git a/internal/service/rds/service_package_gen.go b/internal/service/rds/service_package_gen.go index 18277899fa0..c38712c54eb 100644 --- a/internal/service/rds/service_package_gen.go +++ b/internal/service/rds/service_package_gen.go @@ -139,7 +139,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka }, }, { - Factory: ResourceInstance, + Factory: resourceInstance, TypeName: "aws_db_instance", Name: "DB Instance", Tags: &types.ServicePackageResourceTags{ From 255e02937b36c37159d4f0f0ee032c4fe2e573ae Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 10:21:36 -0400 Subject: [PATCH 04/15] r/aws_db_instance: Migrate acceptance tests to AWS SDK for Go v2. --- internal/service/rds/instance.go | 2 +- .../service/rds/instance_tags_gen_test.go | 38 +- internal/service/rds/instance_test.go | 421 +++++++++--------- 3 files changed, 228 insertions(+), 233 deletions(-) diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index ef61fa33919..fe031b25094 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -51,7 +51,7 @@ import ( // @SDKResource("aws_db_instance", name="DB Instance") // @Tags(identifierAttribute="arn") -// @Testing(existsType="github.com/aws/aws-sdk-go/service/rds;rds.DBInstance") +// @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/rds/types;types.DBInstance") // @Testing(importIgnore="apply_immediately;password") func resourceInstance() *schema.Resource { return &schema.Resource{ diff --git a/internal/service/rds/instance_tags_gen_test.go b/internal/service/rds/instance_tags_gen_test.go index 09acb82722b..218cf6d3f4f 100644 --- a/internal/service/rds/instance_tags_gen_test.go +++ b/internal/service/rds/instance_tags_gen_test.go @@ -5,7 +5,7 @@ package rds_test import ( "testing" - "github.com/aws/aws-sdk-go/service/rds" + "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/hashicorp/terraform-plugin-testing/config" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -19,7 +19,7 @@ import ( func TestAccRDSDBInstance_tags(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -202,7 +202,7 @@ func TestAccRDSDBInstance_tags(t *testing.T) { func TestAccRDSDBInstance_tags_null(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -265,7 +265,7 @@ func TestAccRDSDBInstance_tags_null(t *testing.T) { func TestAccRDSDBInstance_tags_AddOnUpdate(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -345,7 +345,7 @@ func TestAccRDSDBInstance_tags_AddOnUpdate(t *testing.T) { func TestAccRDSDBInstance_tags_EmptyTag_OnCreate(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -436,7 +436,7 @@ func TestAccRDSDBInstance_tags_EmptyTag_OnCreate(t *testing.T) { func TestAccRDSDBInstance_tags_EmptyTag_OnUpdate_Add(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -569,7 +569,7 @@ func TestAccRDSDBInstance_tags_EmptyTag_OnUpdate_Add(t *testing.T) { func TestAccRDSDBInstance_tags_EmptyTag_OnUpdate_Replace(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -655,7 +655,7 @@ func TestAccRDSDBInstance_tags_EmptyTag_OnUpdate_Replace(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_providerOnly(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -848,7 +848,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_providerOnly(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_nonOverlapping(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1017,7 +1017,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_nonOverlapping(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_overlapping(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1202,7 +1202,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_overlapping(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_updateToProviderOnly(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1295,7 +1295,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_updateToProviderOnly(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_updateToResourceOnly(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1387,7 +1387,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_updateToResourceOnly(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_emptyResourceTag(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1455,7 +1455,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_emptyResourceTag(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_emptyProviderOnlyTag(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1515,7 +1515,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_emptyProviderOnlyTag(t *testing.T) { func TestAccRDSDBInstance_tags_DefaultTags_nullOverlappingResourceTag(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1580,7 +1580,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_nullOverlappingResourceTag(t *testing func TestAccRDSDBInstance_tags_DefaultTags_nullNonOverlappingResourceTag(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1645,7 +1645,7 @@ func TestAccRDSDBInstance_tags_DefaultTags_nullNonOverlappingResourceTag(t *test func TestAccRDSDBInstance_tags_ComputedTag_OnCreate(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1702,7 +1702,7 @@ func TestAccRDSDBInstance_tags_ComputedTag_OnCreate(t *testing.T) { func TestAccRDSDBInstance_tags_ComputedTag_OnUpdate_Add(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1795,7 +1795,7 @@ func TestAccRDSDBInstance_tags_ComputedTag_OnUpdate_Add(t *testing.T) { func TestAccRDSDBInstance_tags_ComputedTag_OnUpdate_Replace(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index ab8d3e4bd72..541657fcb2f 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -13,11 +13,10 @@ import ( "time" "github.com/YakDriver/regexache" - rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/rds/types" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/rds" - tfawserr_sdkv2 "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" + "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" @@ -38,7 +37,7 @@ func TestAccRDSInstance_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -119,7 +118,7 @@ func TestAccRDSInstance_identifierPrefix(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" resource.ParallelTest(t, resource.TestCase{ @@ -155,7 +154,7 @@ func TestAccRDSInstance_identifierGenerated(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" resource.ParallelTest(t, resource.TestCase{ @@ -191,7 +190,7 @@ func TestAccRDSInstance_disappears(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -219,7 +218,7 @@ func TestAccRDSInstance_engineLifecycleSupport_disabled(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -263,7 +262,7 @@ func TestAccRDSInstance_Versions_onlyMajor(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -301,7 +300,7 @@ func TestAccRDSInstance_kmsKey(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance kmsKeyResourceName := "aws_kms_key.test" resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -342,7 +341,7 @@ func TestAccRDSInstance_customIAMInstanceProfile(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -372,7 +371,7 @@ func TestAccRDSInstance_DBSubnetGroupName_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" dbSubnetGroupResourceName2 := "aws_db_subnet_group.test2" @@ -409,7 +408,7 @@ func TestAccRDSInstance_networkType(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -443,7 +442,7 @@ func TestAccRDSInstance_optionGroup(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -471,7 +470,7 @@ func TestAccRDSInstance_iamAuth(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -499,7 +498,7 @@ func TestAccRDSInstance_Versions_allowMajor(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance1 rds.DBInstance + var dbInstance1 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -546,7 +545,7 @@ func TestAccRDSInstance_db2(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -573,7 +572,7 @@ func TestAccRDSInstance_db2(t *testing.T) { func TestAccRDSInstance_DBSubnetGroupName_ramShared(t *testing.T) { ctx := acctest.Context(t) - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" resourceName := "aws_db_instance.test" @@ -605,7 +604,7 @@ func TestAccRDSInstance_DBSubnetGroupName_vpcSecurityGroupIDs(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" resourceName := "aws_db_instance.test" @@ -633,7 +632,7 @@ func TestAccRDSInstance_deletionProtection(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -680,7 +679,7 @@ func TestAccRDSInstance_FinalSnapshotIdentifier_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName1 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) rName2 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -717,7 +716,7 @@ func TestAccRDSInstance_FinalSnapshotIdentifier_skipFinalSnapshot(t *testing.T) t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -743,7 +742,7 @@ func TestAccRDSInstance_isAlreadyBeingDeleted(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -763,12 +762,12 @@ func TestAccRDSInstance_isAlreadyBeingDeleted(t *testing.T) { { PreConfig: func() { // Get Database Instance into deleting state - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) input := &rds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(rName), SkipFinalSnapshot: aws.Bool(true), } - _, err := conn.DeleteDBInstanceWithContext(ctx, input) + _, err := conn.DeleteDBInstance(ctx, input) if err != nil { t.Fatalf("error deleting Database Instance: %s", err) } @@ -786,7 +785,7 @@ func TestAccRDSInstance_Storage_maxAllocated(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -835,7 +834,7 @@ func TestAccRDSInstance_password(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -882,7 +881,7 @@ func TestAccRDSInstance_password(t *testing.T) { func TestAccRDSInstance_ManageMasterPassword_basic(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -920,7 +919,7 @@ func TestAccRDSInstance_ManageMasterPassword_basic(t *testing.T) { func TestAccRDSInstance_ManageMasterPassword_kmsKey(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -963,7 +962,7 @@ func TestAccRDSInstance_ManageMasterPassword_convertToManaged(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbCluster1, dbCluster2 rds.DBInstance + var dbCluster1, dbCluster2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -1009,7 +1008,7 @@ func TestAccRDSInstance_ReplicateSourceDB_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1083,7 +1082,7 @@ func TestAccRDSInstance_ReplicateSourceDB_upgradeStorageConfig(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1114,7 +1113,7 @@ func TestAccRDSInstance_ReplicateSourceDB_namePrefix(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance sourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) const identifierPrefix = "tf-acc-test-prefix-" @@ -1153,7 +1152,7 @@ func TestAccRDSInstance_ReplicateSourceDB_nameGenerated(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance sourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) const resourceName = "aws_db_instance.test" @@ -1191,7 +1190,7 @@ func TestAccRDSInstance_ReplicateSourceDB_addLater(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1227,7 +1226,7 @@ func TestAccRDSInstance_ReplicateSourceDB_allocatedStorage(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1258,7 +1257,7 @@ func TestAccRDSInstance_ReplicateSourceDB_iops(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1289,7 +1288,7 @@ func TestAccRDSInstance_ReplicateSourceDB_allocatedStorageAndIops(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1321,7 +1320,7 @@ func TestAccRDSInstance_ReplicateSourceDB_allowMajorVersionUpgrade(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1352,7 +1351,7 @@ func TestAccRDSInstance_ReplicateSourceDB_autoMinorVersionUpgrade(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1383,7 +1382,7 @@ func TestAccRDSInstance_ReplicateSourceDB_availabilityZone(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1413,7 +1412,7 @@ func TestAccRDSInstance_ReplicateSourceDB_backupRetentionPeriod(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" resourceName := "aws_db_instance.test" @@ -1443,7 +1442,7 @@ func TestAccRDSInstance_ReplicateSourceDB_backupWindow(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1474,7 +1473,7 @@ func TestAccRDSInstance_ReplicateSourceDB_dbSubnetGroupName(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" resourceName := "aws_db_instance.test" @@ -1505,7 +1504,7 @@ func TestAccRDSInstance_ReplicateSourceDB_dbSubnetGroupNameRAMShared(t *testing. t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" resourceName := "aws_db_instance.test" @@ -1538,7 +1537,7 @@ func TestAccRDSInstance_ReplicateSourceDB_dbSubnetGroupNameVPCSecurityGroupIDs(t t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" resourceName := "aws_db_instance.test" @@ -1578,7 +1577,7 @@ func TestAccRDSInstance_ReplicateSourceDB_deletionProtection(t *testing.T) { ctx := acctest.Context(t) - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1619,7 +1618,7 @@ func TestAccRDSInstance_ReplicateSourceDB_iamDatabaseAuthenticationEnabled(t *te t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1650,7 +1649,7 @@ func TestAccRDSInstance_ReplicateSourceDB_maintenanceWindow(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1681,7 +1680,7 @@ func TestAccRDSInstance_ReplicateSourceDB_maxAllocatedStorage(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1712,7 +1711,7 @@ func TestAccRDSInstance_ReplicateSourceDB_monitoring(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1743,7 +1742,7 @@ func TestAccRDSInstance_ReplicateSourceDB_monitoring_sourceAlreadyExists(t *test t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1780,7 +1779,7 @@ func TestAccRDSInstance_ReplicateSourceDB_multiAZ(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1811,7 +1810,7 @@ func TestAccRDSInstance_ReplicateSourceDB_networkType(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1842,7 +1841,7 @@ func TestAccRDSInstance_ReplicateSourceDB_parameterGroupNameSameSetOnBoth(t *tes t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1876,7 +1875,7 @@ func TestAccRDSInstance_ReplicateSourceDB_parameterGroupNameDifferentSetOnBoth(t t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1910,7 +1909,7 @@ func TestAccRDSInstance_ReplicateSourceDB_parameterGroupNameReplicaCopiesValue(t t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1943,7 +1942,7 @@ func TestAccRDSInstance_ReplicateSourceDB_parameterGroupNameSetOnReplica(t *test t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -1975,7 +1974,7 @@ func TestAccRDSInstance_ReplicateSourceDB_port(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -2006,7 +2005,7 @@ func TestAccRDSInstance_ReplicateSourceDB_vpcSecurityGroupIDs(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -2037,7 +2036,7 @@ func TestAccRDSInstance_ReplicateSourceDB_caCertificateIdentifier(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -2070,7 +2069,7 @@ func TestAccRDSInstance_ReplicateSourceDB_characterSet_Source(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -2115,7 +2114,7 @@ func TestAccRDSInstance_ReplicateSourceDB_characterSet_Replica(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -2147,7 +2146,7 @@ func TestAccRDSInstance_ReplicateSourceDB_replicaMode(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_db_instance.source" @@ -2160,12 +2159,12 @@ func TestAccRDSInstance_ReplicateSourceDB_replicaMode(t *testing.T) { CheckDestroy: testAccCheckDBInstanceDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccInstanceConfig_ReplicateSourceDB_replicaMode(rName, rds.ReplicaModeMounted), + Config: testAccInstanceConfig_ReplicateSourceDB_replicaMode(rName, string(types.ReplicaModeMounted)), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDBInstanceExists(ctx, sourceResourceName, &sourceDbInstance), testAccCheckDBInstanceExists(ctx, resourceName, &dbInstance), testAccCheckInstanceReplicaAttributes(&sourceDbInstance, &dbInstance), - resource.TestCheckResourceAttr(resourceName, "replica_mode", rds.ReplicaModeMounted), + resource.TestCheckResourceAttr(resourceName, "replica_mode", string(types.ReplicaModeMounted)), ), }, { @@ -2182,12 +2181,12 @@ func TestAccRDSInstance_ReplicateSourceDB_replicaMode(t *testing.T) { }, }, { - Config: testAccInstanceConfig_ReplicateSourceDB_replicaMode(rName, rds.ReplicaModeOpenReadOnly), + Config: testAccInstanceConfig_ReplicateSourceDB_replicaMode(rName, string(types.ReplicaModeOpenReadOnly)), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDBInstanceExists(ctx, sourceResourceName, &sourceDbInstance), testAccCheckDBInstanceExists(ctx, resourceName, &dbInstance), testAccCheckInstanceReplicaAttributes(&sourceDbInstance, &dbInstance), - resource.TestCheckResourceAttr(resourceName, "replica_mode", rds.ReplicaModeOpenReadOnly), + resource.TestCheckResourceAttr(resourceName, "replica_mode", string(types.ReplicaModeOpenReadOnly)), ), }, }, @@ -2207,7 +2206,7 @@ func TestAccRDSInstance_ReplicateSourceDB_parameterGroupTwoStep(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -2250,7 +2249,7 @@ func TestAccRDSInstance_ReplicateSourceDB_CrossRegion_parameterGroupNameEquivale t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var providers []*schema.Provider rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2294,7 +2293,7 @@ func TestAccRDSInstance_ReplicateSourceDB_CrossRegion_parameterGroupNamePostgres t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var providers []*schema.Provider rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2339,7 +2338,7 @@ func TestAccRDSInstance_ReplicateSourceDB_CrossRegion_characterSet(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var providers []*schema.Provider rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2380,7 +2379,7 @@ func TestAccRDSInstance_s3Import(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -2417,7 +2416,7 @@ func TestAccRDSInstance_SnapshotIdentifier_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2462,7 +2461,7 @@ func TestAccRDSInstance_SnapshotIdentifier_ManageMasterPasswordKMSKey(t *testing t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2512,7 +2511,7 @@ func TestAccRDSInstance_SnapshotIdentifier_namePrefix(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance sourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) const identifierPrefix = "tf-acc-test-prefix-" @@ -2552,7 +2551,7 @@ func TestAccRDSInstance_SnapshotIdentifier_nameGenerated(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance sourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) const resourceName = "aws_db_instance.test" @@ -2591,7 +2590,7 @@ func TestAccRDSInstance_SnapshotIdentifier_AssociationRemoved(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance1, dbInstance2 rds.DBInstance + var dbInstance1, dbInstance2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceDbResourceName := "aws_db_instance.source" @@ -2629,7 +2628,7 @@ func TestAccRDSInstance_SnapshotIdentifier_allocatedStorage(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2662,7 +2661,7 @@ func TestAccRDSInstance_SnapshotIdentifier_io1Storage(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2695,7 +2694,7 @@ func TestAccRDSInstance_SnapshotIdentifier_io2Storage(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2728,7 +2727,7 @@ func TestAccRDSInstance_SnapshotIdentifier_allowMajorVersionUpgrade(t *testing.T t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2761,7 +2760,7 @@ func TestAccRDSInstance_SnapshotIdentifier_autoMinorVersionUpgrade(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2794,7 +2793,7 @@ func TestAccRDSInstance_SnapshotIdentifier_availabilityZone(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2826,7 +2825,7 @@ func TestAccRDSInstance_SnapshotIdentifier_backupRetentionPeriodOverride(t *test t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2859,7 +2858,7 @@ func TestAccRDSInstance_SnapshotIdentifier_backupRetentionPeriodUnset(t *testing t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2892,7 +2891,7 @@ func TestAccRDSInstance_SnapshotIdentifier_backupWindow(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -2925,7 +2924,7 @@ func TestAccRDSInstance_SnapshotIdentifier_dbSubnetGroupName(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" @@ -2958,7 +2957,7 @@ func TestAccRDSInstance_SnapshotIdentifier_dbSubnetGroupNameRAMShared(t *testing t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" @@ -2995,7 +2994,7 @@ func TestAccRDSInstance_SnapshotIdentifier_dbSubnetGroupNameVPCSecurityGroupIDs( t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dbSubnetGroupResourceName := "aws_db_subnet_group.test" @@ -3028,7 +3027,7 @@ func TestAccRDSInstance_SnapshotIdentifier_deletionProtection(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3071,7 +3070,7 @@ func TestAccRDSInstance_SnapshotIdentifier_iamDatabaseAuthenticationEnabled(t *t t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3104,7 +3103,7 @@ func TestAccRDSInstance_SnapshotIdentifier_maintenanceWindow(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3137,7 +3136,7 @@ func TestAccRDSInstance_SnapshotIdentifier_maxAllocatedStorage(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3170,7 +3169,7 @@ func TestAccRDSInstance_SnapshotIdentifier_monitoring(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3203,7 +3202,7 @@ func TestAccRDSInstance_SnapshotIdentifier_multiAZ(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3236,7 +3235,7 @@ func TestAccRDSInstance_SnapshotIdentifier_multiAZSQLServer(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3270,7 +3269,7 @@ func TestAccRDSInstance_SnapshotIdentifier_parameterGroupName(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3304,7 +3303,7 @@ func TestAccRDSInstance_SnapshotIdentifier_port(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3337,7 +3336,7 @@ func TestAccRDSInstance_SnapshotIdentifier_tags(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3381,7 +3380,7 @@ func TestAccRDSInstance_SnapshotIdentifier_tagsRemove(t *testing.T) { ctx := acctest.Context(t) - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3423,7 +3422,7 @@ func TestAccRDSInstance_SnapshotIdentifier_vpcSecurityGroupIDs(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3459,7 +3458,7 @@ func TestAccRDSInstance_SnapshotIdentifier_vpcSecurityGroupIDsTags(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3493,7 +3492,7 @@ func TestAccRDSInstance_monitoringInterval(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3552,7 +3551,7 @@ func TestAccRDSInstance_MonitoringRoleARN_enabledToDisabled(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance iamRoleResourceName := "aws_iam_role.test" resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3598,7 +3597,7 @@ func TestAccRDSInstance_MonitoringRoleARN_enabledToRemoved(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance iamRoleResourceName := "aws_iam_role.test" resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3643,7 +3642,7 @@ func TestAccRDSInstance_MonitoringRoleARN_removedToEnabled(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance iamRoleResourceName := "aws_iam_role.test" resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3691,7 +3690,7 @@ func TestAccRDSInstance_Storage_separateIOPSUpdate_Io1(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3726,7 +3725,7 @@ func TestAccRDSInstance_Storage_separateIOPSUpdate_Io2(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3761,7 +3760,7 @@ func TestAccRDSInstance_portUpdate(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -3797,7 +3796,7 @@ func TestAccRDSInstance_MSSQL_tz(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -3836,7 +3835,7 @@ func TestAccRDSInstance_MSSQL_domain(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var vBefore, vAfter rds.DBInstance + var vBefore, vAfter types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3878,7 +3877,7 @@ func TestAccRDSInstance_MSSQL_domainSnapshotRestore(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v, vRestoredInstance rds.DBInstance + var v, vRestoredInstance types.DBInstance resourceName := "aws_db_instance.test" originResourceName := "aws_db_instance.origin" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -3910,7 +3909,7 @@ func TestAccRDSInstance_MSSQL_selfManagedDomain(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var vBefore, vAfter rds.DBInstance + var vBefore, vAfter types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) domain := acctest.RandomDomain().String() @@ -3954,7 +3953,7 @@ func TestAccRDSInstance_MSSQL_selfManagedDomainSingleDomainDNSIP(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) domain := acctest.RandomDomain().String() @@ -3988,7 +3987,7 @@ func TestAccRDSInstance_MSSQL_selfManagedDomainSnapshotRestore(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v, vRestoredInstance rds.DBInstance + var v, vRestoredInstance types.DBInstance resourceName := "aws_db_instance.test" originResourceName := "aws_db_instance.origin" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4023,7 +4022,7 @@ func TestAccRDSInstance_MySQL_snapshotRestoreWithEngineVersion(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v, vRestoredInstance rds.DBInstance + var v, vRestoredInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" restoreResourceName := "aws_db_instance.restore" @@ -4054,7 +4053,7 @@ func TestAccRDSInstance_Versions_minor(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ @@ -4079,7 +4078,7 @@ func TestAccRDSInstance_CloudWatchLogsExport_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4120,7 +4119,7 @@ func TestAccRDSInstance_CloudWatchLogsExport_db2(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" // Requires an IBM Db2 License set as environmental variable. @@ -4162,7 +4161,7 @@ func TestAccRDSInstance_CloudWatchLogsExport_mySQL(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4218,7 +4217,7 @@ func TestAccRDSInstance_CloudWatchLogsExport_msSQL(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4256,7 +4255,7 @@ func TestAccRDSInstance_CloudWatchLogsExport_oracle(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4295,7 +4294,7 @@ func TestAccRDSInstance_CloudWatchLogsExport_postgresql(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4334,7 +4333,7 @@ func TestAccRDSInstance_dedicatedLogVolume_enableOnCreate(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4370,7 +4369,7 @@ func TestAccRDSInstance_dedicatedLogVolume_enableOnUpdate(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4429,7 +4428,7 @@ func TestAccRDSInstance_noDeleteAutomatedBackups(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4457,7 +4456,7 @@ func TestAccRDSInstance_PerformanceInsights_disabledToEnabled(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4505,7 +4504,7 @@ func TestAccRDSInstance_PerformanceInsights_enabledToDisabled(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4553,7 +4552,7 @@ func TestAccRDSInstance_PerformanceInsights_kmsKeyID(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) kmsKeyResourceName := "aws_kms_key.test" resourceName := "aws_db_instance.test" @@ -4612,7 +4611,7 @@ func TestAccRDSInstance_PerformanceInsights_retentionPeriod(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4670,7 +4669,7 @@ func TestAccRDSInstance_ReplicateSourceDB_performanceInsightsEnabled(t *testing. t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) kmsKeyResourceName := "aws_kms_key.test" @@ -4707,7 +4706,7 @@ func TestAccRDSInstance_SnapshotIdentifier_performanceInsightsEnabled(t *testing t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4746,7 +4745,7 @@ func TestAccRDSInstance_caCertificateIdentifier(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" dataSourceName := "data.aws_rds_certificate.latest" @@ -4774,7 +4773,7 @@ func TestAccRDSInstance_RestoreToPointInTime_sourceIdentifier(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance sourceName := "aws_db_instance.test" resourceName := "aws_db_instance.restore" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4816,7 +4815,7 @@ func TestAccRDSInstance_RestoreToPointInTime_sourceResourceID(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance sourceName := "aws_db_instance.test" resourceName := "aws_db_instance.restore" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4858,7 +4857,7 @@ func TestAccRDSInstance_RestoreToPointInTime_monitoring(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance sourceName := "aws_db_instance.test" resourceName := "aws_db_instance.restore" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4887,7 +4886,7 @@ func TestAccRDSInstance_RestoreToPointInTime_manageMasterPassword(t *testing.T) t.Skip("skipping long-running test in short mode") } - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance sourceName := "aws_db_instance.test" resourceName := "aws_db_instance.restore" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -4935,7 +4934,7 @@ func TestAccRDSInstance_Oracle_nationalCharacterSet(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -4975,7 +4974,7 @@ func TestAccRDSInstance_Oracle_noNationalCharacterSet(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5011,7 +5010,7 @@ func TestAccRDSInstance_Oracle_noNationalCharacterSet(t *testing.T) { func TestAccRDSInstance_Outposts_coIPEnabled(t *testing.T) { ctx := acctest.Context(t) - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5036,7 +5035,7 @@ func TestAccRDSInstance_Outposts_coIPEnabled(t *testing.T) { func TestAccRDSInstance_Outposts_coIPDisabledToEnabled(t *testing.T) { ctx := acctest.Context(t) - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5077,7 +5076,7 @@ func TestAccRDSInstance_Outposts_coIPDisabledToEnabled(t *testing.T) { func TestAccRDSInstance_Outposts_coIPEnabledToDisabled(t *testing.T) { ctx := acctest.Context(t) - var dbInstance rds.DBInstance + var dbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5118,7 +5117,7 @@ func TestAccRDSInstance_Outposts_coIPEnabledToDisabled(t *testing.T) { func TestAccRDSInstance_Outposts_coIPRestoreToPointInTime(t *testing.T) { ctx := acctest.Context(t) - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceName := "aws_db_instance.test" resourceName := "aws_db_instance.restore" @@ -5157,7 +5156,7 @@ func TestAccRDSInstance_Outposts_coIPRestoreToPointInTime(t *testing.T) { func TestAccRDSInstance_Outposts_coIPSnapshotIdentifier(t *testing.T) { ctx := acctest.Context(t) - var dbInstance, sourceDbInstance rds.DBInstance + var dbInstance, sourceDbInstance types.DBInstance var dbSnapshot types.DBSnapshot rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -5190,7 +5189,7 @@ func TestAccRDSInstance_Outposts_backupTarget(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5218,7 +5217,7 @@ func TestAccRDSInstance_license(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5264,7 +5263,7 @@ func TestAccRDSInstance_BlueGreenDeployment_updateEngineVersion(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5315,7 +5314,7 @@ func TestAccRDSInstance_BlueGreenDeployment_updateParameterGroup(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" parameterGroupResourceName := "aws_db_parameter_group.test" @@ -5369,7 +5368,7 @@ func TestAccRDSInstance_BlueGreenDeployment_tags(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5420,7 +5419,7 @@ func TestAccRDSInstance_BlueGreenDeployment_updateInstanceClass(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5471,7 +5470,7 @@ func TestAccRDSInstance_BlueGreenDeployment_updateAndPromoteReplica(t *testing.T t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" sourceResourceName := "aws_db_instance.source" @@ -5524,7 +5523,7 @@ func TestAccRDSInstance_BlueGreenDeployment_updateAndEnableBackups(t *testing.T) t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5576,7 +5575,7 @@ func TestAccRDSInstance_BlueGreenDeployment_deletionProtectionBypassesBlueGreen( t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5641,7 +5640,7 @@ func TestAccRDSInstance_BlueGreenDeployment_passwordBypassesBlueGreen(t *testing t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5676,7 +5675,7 @@ func TestAccRDSInstance_BlueGreenDeployment_updateWithDeletionProtection(t *test t.Skip("skipping long-running test in short mode") } - var v1, v2, v3 rds.DBInstance + var v1, v2, v3 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -5752,7 +5751,7 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" var updateVersion string @@ -5783,7 +5782,7 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { orchestrator := tfrds.NewBlueGreenOrchestrator(conn) defer orchestrator.CleanUp(ctx) - input := &rds_sdkv2.CreateBlueGreenDeploymentInput{ + input := &rds.CreateBlueGreenDeploymentInput{ BlueGreenDeploymentName: aws.String(rName), Source: v1.DBInstanceArn, TargetEngineVersion: aws.String(updateVersion), @@ -5798,10 +5797,10 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { defer func() { // Ensure that the Blue/Green Deployment is always cleaned up - input := &rds_sdkv2.DeleteBlueGreenDeploymentInput{ + input := &rds.DeleteBlueGreenDeploymentInput{ BlueGreenDeploymentIdentifier: deploymentIdentifier, } - if aws.StringValue(dep.Status) != "SWITCHOVER_COMPLETED" { + if aws.ToString(dep.Status) != "SWITCHOVER_COMPLETED" { input.DeleteTarget = aws.Bool(true) } _, err = conn.DeleteBlueGreenDeployment(ctx, input) @@ -5809,19 +5808,19 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { t.Fatalf("deleting Blue/Green Deployment: %s", err) } - orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds_sdkv2.Client, optFns ...tfresource.OptionsFunc) { - _, err = tfrds.WaitBlueGreenDeploymentDeleted(ctx, conn, aws.StringValue(deploymentIdentifier), deadline.Remaining(), optFns...) + orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds.Client, optFns ...tfresource.OptionsFunc) { + _, err = tfrds.WaitBlueGreenDeploymentDeleted(ctx, conn, aws.ToString(deploymentIdentifier), deadline.Remaining(), optFns...) if err != nil { t.Fatalf("waiting for Blue/Green Deployment to be deleted: %s", err) } }) }() - dep, err = tfrds.WaitBlueGreenDeploymentAvailable(ctx, conn, aws.StringValue(deploymentIdentifier), deadline.Remaining()) + dep, err = tfrds.WaitBlueGreenDeploymentAvailable(ctx, conn, aws.ToString(deploymentIdentifier), deadline.Remaining()) if err != nil { t.Fatalf("waiting for Blue/Green Deployment to be available: %s", err) } - targetARN, err := tfrds.ParseDBInstanceARN(aws.StringValue(dep.Target)) + targetARN, err := tfrds.ParseDBInstanceARN(aws.ToString(dep.Target)) if err != nil { t.Fatalf("parsing target ARN: %s", err) } @@ -5830,17 +5829,17 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { t.Fatalf("waiting for Green instance to be available: %s", err) } - dep, err = orchestrator.Switchover(ctx, aws.StringValue(dep.BlueGreenDeploymentIdentifier), deadline.Remaining()) + dep, err = orchestrator.Switchover(ctx, aws.ToString(dep.BlueGreenDeploymentIdentifier), deadline.Remaining()) if err != nil { t.Fatalf("switching over: %s", err) } - sourceARN, err := tfrds.ParseDBInstanceARN(aws.StringValue(dep.Source)) + sourceARN, err := tfrds.ParseDBInstanceARN(aws.ToString(dep.Source)) if err != nil { t.Fatalf("parsing source ARN: %s", err) } - deleteInput := &rds_sdkv2.DeleteDBInstanceInput{ + deleteInput := &rds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(sourceARN.Identifier), SkipFinalSnapshot: aws.Bool(true), } @@ -5850,11 +5849,11 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { }, func(err error) (bool, error) { // Retry for IAM eventual consistency. - if tfawserr_sdkv2.ErrMessageContains(err, tfrds.ErrCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") { + if tfawserr.ErrMessageContains(err, tfrds.ErrCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") { return true, err } - if tfawserr_sdkv2.ErrMessageContains(err, tfrds.ErrCodeInvalidParameterCombination, "disable deletion pro") { + if tfawserr.ErrMessageContains(err, tfrds.ErrCodeInvalidParameterCombination, "disable deletion pro") { return true, err } @@ -5865,8 +5864,8 @@ func TestAccRDSInstance_BlueGreenDeployment_outOfBand(t *testing.T) { t.Fatalf("deleting source instance: %s", err) } - orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds_sdkv2.Client, optFns ...tfresource.OptionsFunc) { - _, err = tfrds.WaitDBInstanceDeleted(ctx, meta.RDSConn(ctx), sourceARN.Identifier, deadline.Remaining(), optFns...) + orchestrator.AddCleanupWaiter(func(ctx context.Context, conn *rds.Client, optFns ...tfresource.OptionsFunc) { + _, err = tfrds.WaitDBInstanceDeleted(ctx, conn, sourceARN.Identifier, deadline.Remaining(), optFns...) if err != nil { t.Fatalf("waiting for source instance to be deleted: %s", err) } @@ -5910,7 +5909,7 @@ func TestAccRDSInstance_Storage_gp3MySQL(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -5963,7 +5962,7 @@ func TestAccRDSInstance_Storage_gp3Postgres(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6016,7 +6015,7 @@ func TestAccRDSInstance_Storage_gp3SQLServer(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6070,7 +6069,7 @@ func TestAccRDSInstance_Storage_changeThroughput(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6109,7 +6108,7 @@ func TestAccRDSInstance_Storage_changeIOPSThroughput(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6148,7 +6147,7 @@ func TestAccRDSInstance_Storage_changeIOPS(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6187,7 +6186,7 @@ func TestAccRDSInstance_Storage_throughputSSE(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6225,7 +6224,7 @@ func TestAccRDSInstance_Storage_typePostgres(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_db_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -6278,7 +6277,7 @@ func TestAccRDSInstance_newIdentifier_Pending(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) rName2 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -6324,7 +6323,7 @@ func TestAccRDSInstance_newIdentifier_Immediately(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v1, v2 rds.DBInstance + var v1, v2 types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) rName2 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_db_instance.test" @@ -6364,7 +6363,7 @@ func TestAccRDSInstance_newIdentifier_Immediately(t *testing.T) { func testAccCheckInstanceAutomatedBackupsDelete(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_db_instance" { @@ -6372,7 +6371,7 @@ func testAccCheckInstanceAutomatedBackupsDelete(ctx context.Context) resource.Te } log.Printf("[INFO] Trying to locate the DBInstance Automated Backup") - describeOutput, err := conn.DescribeDBInstanceAutomatedBackupsWithContext(ctx, &rds.DescribeDBInstanceAutomatedBackupsInput{ + describeOutput, err := conn.DescribeDBInstanceAutomatedBackups(ctx, &rds.DescribeDBInstanceAutomatedBackupsInput{ DBInstanceIdentifier: aws.String(rs.Primary.Attributes[names.AttrIdentifier]), }) if err != nil { @@ -6384,7 +6383,7 @@ func testAccCheckInstanceAutomatedBackupsDelete(ctx context.Context) resource.Te } log.Printf("[INFO] Deleting automated backup for %s", rs.Primary.Attributes[names.AttrIdentifier]) - _, err = conn.DeleteDBInstanceAutomatedBackupWithContext(ctx, &rds.DeleteDBInstanceAutomatedBackupInput{ + _, err = conn.DeleteDBInstanceAutomatedBackup(ctx, &rds.DeleteDBInstanceAutomatedBackupInput{ DbiResourceId: describeOutput.DBInstanceAutomatedBackups[0].DbiResourceId, }) if err != nil { @@ -6398,7 +6397,7 @@ func testAccCheckInstanceAutomatedBackupsDelete(ctx context.Context) resource.Te func testAccCheckDBInstanceDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_db_instance" { @@ -6435,7 +6434,7 @@ func testAccCheckRetrieveValue(name, key string, v *string) resource.TestCheckFu } } -func testAccCheckInstanceAttributes(v *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckInstanceAttributes(v *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { if *v.Engine != tfrds.InstanceEngineMySQL { return fmt.Errorf("bad engine: %#v", *v.Engine) @@ -6453,7 +6452,7 @@ func testAccCheckInstanceAttributes(v *rds.DBInstance) resource.TestCheckFunc { } } -func testAccCheckInstanceAttributes_MSSQL(v *rds.DBInstance, tz string) resource.TestCheckFunc { +func testAccCheckInstanceAttributes_MSSQL(v *types.DBInstance, tz string) resource.TestCheckFunc { return func(s *terraform.State) error { if *v.Engine != tfrds.InstanceEngineSQLServerExpress { return fmt.Errorf("bad engine: %#v", *v.Engine) @@ -6472,7 +6471,7 @@ func testAccCheckInstanceAttributes_MSSQL(v *rds.DBInstance, tz string) resource } } -func testAccCheckInstanceDomainAttributes(domain string, v *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckInstanceDomainAttributes(domain string, v *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { for _, dm := range v.DomainMemberships { if *dm.FQDN != domain { @@ -6486,13 +6485,13 @@ func testAccCheckInstanceDomainAttributes(domain string, v *rds.DBInstance) reso } } -func testAccCheckInstanceParameterApplyStatusInSync(dbInstance *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckInstanceParameterApplyStatusInSync(dbInstance *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { for _, dbParameterGroup := range dbInstance.DBParameterGroups { - parameterApplyStatus := aws.StringValue(dbParameterGroup.ParameterApplyStatus) + parameterApplyStatus := aws.ToString(dbParameterGroup.ParameterApplyStatus) if parameterApplyStatus != "in-sync" { - id := aws.StringValue(dbInstance.DBInstanceIdentifier) - parameterGroupName := aws.StringValue(dbParameterGroup.DBParameterGroupName) + id := aws.ToString(dbInstance.DBInstanceIdentifier) + parameterGroupName := aws.ToString(dbParameterGroup.DBParameterGroupName) return fmt.Errorf("expected DB Instance (%s) Parameter Group (%s) apply status to be: \"in-sync\", got: %q", id, parameterGroupName, parameterApplyStatus) } } @@ -6501,7 +6500,7 @@ func testAccCheckInstanceParameterApplyStatusInSync(dbInstance *rds.DBInstance) } } -func testAccCheckInstanceReplicaAttributes(source, replica *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckInstanceReplicaAttributes(source, replica *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { if replica.ReadReplicaSourceDBInstanceIdentifier != nil && *replica.ReadReplicaSourceDBInstanceIdentifier != *source.DBInstanceIdentifier { return fmt.Errorf("bad source identifier for replica, expected: '%s', got: '%s'", *source.DBInstanceIdentifier, *replica.ReadReplicaSourceDBInstanceIdentifier) @@ -6532,7 +6531,7 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. return err } - tags, err := tfrds.ListTags(ctx, conn1, aws.StringValue(output.DBSnapshotArn)) + tags, err := tfrds.ListTags(ctx, conn1, aws.ToString(output.DBSnapshotArn)) if err != nil { return err } @@ -6541,7 +6540,7 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. return fmt.Errorf("Name tag not found") } - _, err = conn2.DeleteDBSnapshot(ctx, &rds_sdkv2.DeleteDBSnapshotInput{ + _, err = conn2.DeleteDBSnapshot(ctx, &rds.DeleteDBSnapshotInput{ DBSnapshotIdentifier: aws.String(finalSnapshotID), }) @@ -6549,7 +6548,7 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. return err } - _, err = tfrds.FindDBInstanceByID(ctx, conn1, rs.Primary.Attributes[names.AttrIdentifier]) + _, err = tfrds.FindDBInstanceByID(ctx, conn2, rs.Primary.Attributes[names.AttrIdentifier]) if tfresource.NotFound(err) { continue @@ -6571,8 +6570,7 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. // - No DBSnapshot has been produced func testAccCheckInstanceDestroyWithoutFinalSnapshot(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn1 := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) - conn2 := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_db_instance" { @@ -6580,7 +6578,7 @@ func testAccCheckInstanceDestroyWithoutFinalSnapshot(ctx context.Context) resour } finalSnapshotID := rs.Primary.Attributes[names.AttrFinalSnapshotIdentifier] - _, err := tfrds.FindDBSnapshotByID(ctx, conn2, finalSnapshotID) + _, err := tfrds.FindDBSnapshotByID(ctx, conn, finalSnapshotID) if err != nil { if !tfresource.NotFound(err) { @@ -6590,7 +6588,7 @@ func testAccCheckInstanceDestroyWithoutFinalSnapshot(ctx context.Context) resour return fmt.Errorf("RDS DB Snapshot %s exists", finalSnapshotID) } - _, err = tfrds.FindDBInstanceByID(ctx, conn1, rs.Primary.Attributes[names.AttrIdentifier]) + _, err = tfrds.FindDBInstanceByID(ctx, conn, rs.Primary.Attributes[names.AttrIdentifier]) if tfresource.NotFound(err) { continue @@ -6607,7 +6605,7 @@ func testAccCheckInstanceDestroyWithoutFinalSnapshot(ctx context.Context) resour } } -func testAccCheckDBInstanceRecreated(i, j *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckDBInstanceRecreated(i, j *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { if dbInstanceIdentityEqual(i, j) { return fmt.Errorf("RDS DB Instance not recreated") @@ -6616,7 +6614,7 @@ func testAccCheckDBInstanceRecreated(i, j *rds.DBInstance) resource.TestCheckFun } } -func testAccCheckDBInstanceNotRecreated(i, j *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckDBInstanceNotRecreated(i, j *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { if !dbInstanceIdentityEqual(i, j) { return fmt.Errorf("RDS DB Instance recreated") @@ -6625,32 +6623,29 @@ func testAccCheckDBInstanceNotRecreated(i, j *rds.DBInstance) resource.TestCheck } } -func dbInstanceIdentityEqual(i, j *rds.DBInstance) bool { +func dbInstanceIdentityEqual(i, j *types.DBInstance) bool { return dbInstanceIdentity(i) == dbInstanceIdentity(j) } -func dbInstanceIdentity(v *rds.DBInstance) string { - return aws.StringValue(v.DbiResourceId) +func dbInstanceIdentity(v *types.DBInstance) string { + return aws.ToString(v.DbiResourceId) } -func testAccCheckDBInstanceExists(ctx context.Context, n string, v *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckDBInstanceExists(ctx context.Context, n string, v *types.DBInstance) resource.TestCheckFunc { return testAccCheckDBInstanceExistsWithProvider(ctx, n, v, func() *schema.Provider { return acctest.Provider }) } -func testAccCheckDBInstanceExistsWithProvider(ctx context.Context, n string, v *rds.DBInstance, providerF func() *schema.Provider) resource.TestCheckFunc { +func testAccCheckDBInstanceExistsWithProvider(ctx context.Context, n string, v *types.DBInstance, providerF func() *schema.Provider) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { return fmt.Errorf("Not found: %s", n) } - if rs.Primary.Attributes[names.AttrIdentifier] == "" { - return fmt.Errorf("No RDS DB Instance ID is set") - } - - conn := providerF().Meta().(*conns.AWSClient).RDSConn(ctx) + conn := providerF().Meta().(*conns.AWSClient).RDSClient(ctx) output, err := tfrds.FindDBInstanceByID(ctx, conn, rs.Primary.ID) + if err != nil { return err } From 177187416bf040a73a7b67625503146f812396d4 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 10:26:50 -0400 Subject: [PATCH 05/15] d/aws_db_instances: Migrate to AWS SDK for Go v2. --- internal/service/rds/instances_data_source.go | 27 ++++++++++--------- .../service/rds/instances_data_source_test.go | 7 ----- internal/service/rds/service_package_gen.go | 3 ++- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/internal/service/rds/instances_data_source.go b/internal/service/rds/instances_data_source.go index 05e1059b351..d92f266bbf9 100644 --- a/internal/service/rds/instances_data_source.go +++ b/internal/service/rds/instances_data_source.go @@ -6,21 +6,22 @@ package rds import ( "context" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/rds" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rds" + "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters" - namevaluesfiltersv1 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v1" + namevaluesfiltersv2 "github.com/hashicorp/terraform-provider-aws/internal/namevaluesfilters/v2" tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKDataSource("aws_db_instances") -func DataSourceInstances() *schema.Resource { +// @SDKDataSource("aws_db_instances", name="DB Instances") +func dataSourceInstances() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceInstancesRead, @@ -43,22 +44,22 @@ func DataSourceInstances() *schema.Resource { func dataSourceInstancesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) input := &rds.DescribeDBInstancesInput{} if v, ok := d.GetOk(names.AttrFilter); ok { - input.Filters = namevaluesfiltersv1.New(v.(*schema.Set)).RDSFilters() + input.Filters = namevaluesfiltersv2.New(v.(*schema.Set)).RDSFilters() } - filter := tfslices.PredicateTrue[*rds.DBInstance]() + filter := tfslices.PredicateTrue[*types.DBInstance]() if v, ok := d.GetOk(names.AttrTags); ok { - filter = func(x *rds.DBInstance) bool { - return KeyValueTags(ctx, x.TagList).ContainsAll(tftags.New(ctx, v.(map[string]interface{}))) + filter = func(x *types.DBInstance) bool { + return keyValueTagsV2(ctx, x.TagList).ContainsAll(tftags.New(ctx, v.(map[string]interface{}))) } } - instances, err := findDBInstancesSDKv1(ctx, conn, input, filter) + instances, err := findDBInstances(ctx, conn, input, filter) if err != nil { return sdkdiag.AppendErrorf(diags, "reading RDS DB Instances: %s", err) @@ -68,8 +69,8 @@ func dataSourceInstancesRead(ctx context.Context, d *schema.ResourceData, meta i var instanceIdentifiers []string for _, instance := range instances { - instanceARNS = append(instanceARNS, aws.StringValue(instance.DBInstanceArn)) - instanceIdentifiers = append(instanceIdentifiers, aws.StringValue(instance.DBInstanceIdentifier)) + instanceARNS = append(instanceARNS, aws.ToString(instance.DBInstanceArn)) + instanceIdentifiers = append(instanceIdentifiers, aws.ToString(instance.DBInstanceIdentifier)) } d.SetId(meta.(*conns.AWSClient).Region) diff --git a/internal/service/rds/instances_data_source_test.go b/internal/service/rds/instances_data_source_test.go index 7608f298f27..a6c142434dd 100644 --- a/internal/service/rds/instances_data_source_test.go +++ b/internal/service/rds/instances_data_source_test.go @@ -7,7 +7,6 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/service/rds" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -16,7 +15,6 @@ import ( func TestAccRDSInstancesDataSource_filter(t *testing.T) { ctx := acctest.Context(t) - var dbInstance rds.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dataSourceName := "data.aws_db_instances.test" resourceName := "aws_db_instance.test" @@ -25,12 +23,10 @@ func TestAccRDSInstancesDataSource_filter(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: testAccCheckDBInstanceDestroy(ctx), Steps: []resource.TestStep{ { Config: testAccInstancesDataSourceConfig_filter(rName), Check: resource.ComposeTestCheckFunc( - testAccCheckDBInstanceExists(ctx, resourceName, &dbInstance), resource.TestCheckResourceAttr(dataSourceName, "instance_arns.#", acctest.Ct1), resource.TestCheckResourceAttrPair(dataSourceName, "instance_arns.0", resourceName, names.AttrARN), resource.TestCheckResourceAttr(dataSourceName, "instance_identifiers.#", acctest.Ct1), @@ -43,7 +39,6 @@ func TestAccRDSInstancesDataSource_filter(t *testing.T) { func TestAccRDSInstancesDataSource_matchTags(t *testing.T) { ctx := acctest.Context(t) - var dbInstance rds.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) dataSourceName := "data.aws_db_instances.test" resourceName := "aws_db_instance.test" @@ -52,12 +47,10 @@ func TestAccRDSInstancesDataSource_matchTags(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: testAccCheckDBInstanceDestroy(ctx), Steps: []resource.TestStep{ { Config: testAccInstancesDataSourceConfig_matchTags(rName), Check: resource.ComposeTestCheckFunc( - testAccCheckDBInstanceExists(ctx, resourceName, &dbInstance), resource.TestCheckResourceAttr(dataSourceName, "instance_arns.#", acctest.Ct1), resource.TestCheckResourceAttrPair(dataSourceName, "instance_arns.0", resourceName, names.AttrARN), resource.TestCheckResourceAttr(dataSourceName, "instance_identifiers.#", acctest.Ct1), diff --git a/internal/service/rds/service_package_gen.go b/internal/service/rds/service_package_gen.go index c38712c54eb..3689998f044 100644 --- a/internal/service/rds/service_package_gen.go +++ b/internal/service/rds/service_package_gen.go @@ -62,8 +62,9 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac Tags: &types.ServicePackageResourceTags{}, }, { - Factory: DataSourceInstances, + Factory: dataSourceInstances, TypeName: "aws_db_instances", + Name: "DB Instances", }, { Factory: dataSourceParameterGroup, From 3301f0021593627cc9c6f8b358315fcc5e8b4146 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 11:46:06 -0400 Subject: [PATCH 06/15] d/aws_db_instance: Migrate to AWS SDK for Go v2. --- internal/service/rds/instance_data_source.go | 52 ++++++++++---------- internal/service/rds/service_package_gen.go | 2 +- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/internal/service/rds/instance_data_source.go b/internal/service/rds/instance_data_source.go index b335c1a1937..83fe2cdfdd5 100644 --- a/internal/service/rds/instance_data_source.go +++ b/internal/service/rds/instance_data_source.go @@ -7,8 +7,9 @@ import ( "context" "fmt" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/rds" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rds" + "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -20,7 +21,7 @@ import ( // @SDKDataSource("aws_db_instance", name="DB Instance") // @Tags -func DataSourceInstance() *schema.Resource { +func dataSourceInstance() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceInstanceRead, @@ -217,20 +218,20 @@ func DataSourceInstance() *schema.Resource { func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) - var instance *rds.DBInstance + var instance *types.DBInstance - filter := tfslices.PredicateTrue[*rds.DBInstance]() + filter := tfslices.PredicateTrue[*types.DBInstance]() if tags := getTagsIn(ctx); len(tags) > 0 { - filter = func(v *rds.DBInstance) bool { - return KeyValueTags(ctx, v.TagList).ContainsAll(KeyValueTags(ctx, tags)) + filter = func(v *types.DBInstance) bool { + return keyValueTagsV2(ctx, v.TagList).ContainsAll(KeyValueTags(ctx, tags)) } } if v, ok := d.GetOk("db_instance_identifier"); ok { id := v.(string) - output, err := findDBInstanceByIDSDKv1(ctx, conn, id) + output, err := findDBInstanceByID(ctx, conn, id) if err != nil { return sdkdiag.AppendErrorf(diags, "reading RDS DB Instance (%s): %s", id, err) @@ -243,7 +244,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in instance = output } else { input := &rds.DescribeDBInstancesInput{} - output, err := findDBInstanceSDKv1(ctx, conn, input, filter) + output, err := findDBInstance(ctx, conn, input, filter) if err != nil { return sdkdiag.AppendErrorf(diags, "reading RDS DB Instance: %s", err) @@ -252,7 +253,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in instance = output } - d.SetId(aws.StringValue(instance.DBInstanceIdentifier)) + d.SetId(aws.ToString(instance.DBInstanceIdentifier)) d.Set(names.AttrAllocatedStorage, instance.AllocatedStorage) d.Set(names.AttrAutoMinorVersionUpgrade, instance.AutoMinorVersionUpgrade) d.Set(names.AttrAvailabilityZone, instance.AvailabilityZone) @@ -263,16 +264,15 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("db_instance_class", instance.DBInstanceClass) d.Set("db_instance_port", instance.DbInstancePort) d.Set("db_name", instance.DBName) - parameterGroupNames := tfslices.ApplyToAll(instance.DBParameterGroups, func(v *rds.DBParameterGroupStatus) string { - return aws.StringValue(v.DBParameterGroupName) - }) - d.Set("db_parameter_groups", parameterGroupNames) + d.Set("db_parameter_groups", tfslices.ApplyToAll(instance.DBParameterGroups, func(v types.DBParameterGroupStatus) string { + return aws.ToString(v.DBParameterGroupName) + })) if instance.DBSubnetGroup != nil { d.Set("db_subnet_group", instance.DBSubnetGroup.DBSubnetGroupName) } else { d.Set("db_subnet_group", "") } - d.Set("enabled_cloudwatch_logs_exports", aws.StringValueSlice(instance.EnabledCloudwatchLogsExports)) + d.Set("enabled_cloudwatch_logs_exports", instance.EnabledCloudwatchLogsExports) d.Set(names.AttrEngine, instance.Engine) d.Set(names.AttrEngineVersion, instance.EngineVersion) d.Set(names.AttrIOPS, instance.Iops) @@ -280,7 +280,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("license_model", instance.LicenseModel) d.Set("master_username", instance.MasterUsername) if instance.MasterUserSecret != nil { - if err := d.Set("master_user_secret", []interface{}{flattenManagedMasterUserSecretV1(instance.MasterUserSecret)}); err != nil { + if err := d.Set("master_user_secret", []interface{}{flattenManagedMasterUserSecret(instance.MasterUserSecret)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting master_user_secret: %s", err) } } @@ -289,10 +289,9 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("monitoring_role_arn", instance.MonitoringRoleArn) d.Set("multi_az", instance.MultiAZ) d.Set("network_type", instance.NetworkType) - optionGroupNames := tfslices.ApplyToAll(instance.OptionGroupMemberships, func(v *rds.OptionGroupMembership) string { - return aws.StringValue(v.OptionGroupName) - }) - d.Set("option_group_memberships", optionGroupNames) + d.Set("option_group_memberships", tfslices.ApplyToAll(instance.OptionGroupMemberships, func(v types.OptionGroupMembership) string { + return aws.ToString(v.OptionGroupName) + })) d.Set("preferred_backup_window", instance.PreferredBackupWindow) d.Set(names.AttrPreferredMaintenanceWindow, instance.PreferredMaintenanceWindow) d.Set(names.AttrPubliclyAccessible, instance.PubliclyAccessible) @@ -302,16 +301,15 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("storage_throughput", instance.StorageThroughput) d.Set(names.AttrStorageType, instance.StorageType) d.Set("timezone", instance.Timezone) - vpcSecurityGroupIDs := tfslices.ApplyToAll(instance.VpcSecurityGroups, func(v *rds.VpcSecurityGroupMembership) string { - return aws.StringValue(v.VpcSecurityGroupId) - }) - d.Set("vpc_security_groups", vpcSecurityGroupIDs) + d.Set("vpc_security_groups", tfslices.ApplyToAll(instance.VpcSecurityGroups, func(v types.VpcSecurityGroupMembership) string { + return aws.ToString(v.VpcSecurityGroupId) + })) // Per AWS SDK Go docs: // The endpoint might not be shown for instances whose status is creating. if dbEndpoint := instance.Endpoint; dbEndpoint != nil { d.Set(names.AttrAddress, dbEndpoint.Address) - d.Set(names.AttrEndpoint, fmt.Sprintf("%s:%d", aws.StringValue(dbEndpoint.Address), aws.Int64Value(dbEndpoint.Port))) + d.Set(names.AttrEndpoint, fmt.Sprintf("%s:%d", aws.ToString(dbEndpoint.Address), aws.ToInt32(dbEndpoint.Port))) d.Set(names.AttrHostedZoneID, dbEndpoint.HostedZoneId) d.Set(names.AttrPort, dbEndpoint.Port) } else { @@ -321,7 +319,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrPort, nil) } - setTagsOut(ctx, instance.TagList) + setTagsOutV2(ctx, instance.TagList) return diags } diff --git a/internal/service/rds/service_package_gen.go b/internal/service/rds/service_package_gen.go index 3689998f044..15246c50bab 100644 --- a/internal/service/rds/service_package_gen.go +++ b/internal/service/rds/service_package_gen.go @@ -56,7 +56,7 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac Name: "Event Categories", }, { - Factory: DataSourceInstance, + Factory: dataSourceInstance, TypeName: "aws_db_instance", Name: "DB Instance", Tags: &types.ServicePackageResourceTags{}, From bc0d5b183992a53cd827d5ef641eab63f257eddc Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:04:04 -0400 Subject: [PATCH 07/15] r/aws_rds_cluster_instance: Migrate to AWS SDK for Go v2. --- internal/service/rds/cluster_instance.go | 173 ++++++------------ internal/service/rds/cluster_instance_test.go | 104 +++++------ internal/service/rds/exports_test.go | 1 + internal/service/rds/service_package_gen.go | 2 +- 4 files changed, 106 insertions(+), 174 deletions(-) diff --git a/internal/service/rds/cluster_instance.go b/internal/service/rds/cluster_instance.go index f61b26e8291..359028633fb 100644 --- a/internal/service/rds/cluster_instance.go +++ b/internal/service/rds/cluster_instance.go @@ -11,18 +11,17 @@ import ( "time" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/rds" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rds" + "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" - tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -32,7 +31,7 @@ import ( // @SDKResource("aws_rds_cluster_instance", name="Cluster Instance") // @Tags(identifierAttribute="arn") // @Testing(tagsTest=false) -func ResourceClusterInstance() *schema.Resource { +func resourceClusterInstance() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceClusterInstanceCreate, ReadWithoutTimeout: resourceClusterInstanceRead, @@ -243,7 +242,7 @@ func ResourceClusterInstance() *schema.Resource { func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) clusterID := d.Get(names.AttrClusterIdentifier).(string) identifier := create.NewNameGenerator( @@ -258,9 +257,9 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceIdentifier: aws.String(identifier), Engine: aws.String(d.Get(names.AttrEngine).(string)), - PromotionTier: aws.Int64(int64(d.Get("promotion_tier").(int))), + PromotionTier: aws.Int32(int32(d.Get("promotion_tier").(int))), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), - Tags: getTagsIn(ctx), + Tags: getTagsInV2(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZone); ok { @@ -284,7 +283,7 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, } if v, ok := d.GetOk("monitoring_interval"); ok { - input.MonitoringInterval = aws.Int64(int64(v.(int))) + input.MonitoringInterval = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("monitoring_role_arn"); ok { @@ -300,7 +299,7 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, } if v, ok := d.GetOk("performance_insights_retention_period"); ok { - input.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int))) + input.PerformanceInsightsRetentionPeriod = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("preferred_backup_window"); ok { @@ -313,7 +312,7 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, outputRaw, err := tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) { - return conn.CreateDBInstanceWithContext(ctx, input) + return conn.CreateDBInstance(ctx, input) }, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") if err != nil { @@ -322,35 +321,36 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, output := outputRaw.(*rds.CreateDBInstanceOutput) - d.SetId(aws.StringValue(output.DBInstance.DBInstanceIdentifier)) + d.SetId(aws.ToString(output.DBInstance.DBInstanceIdentifier)) if _, err := waitDBClusterInstanceCreated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS Cluster Instance (%s) create: %s", d.Id(), err) } - if v, ok := d.GetOk("ca_cert_identifier"); ok && v.(string) != aws.StringValue(output.DBInstance.CACertificateIdentifier) { + if v, ok := d.GetOk("ca_cert_identifier"); ok && v.(string) != aws.ToString(output.DBInstance.CACertificateIdentifier) { input := &rds.ModifyDBInstanceInput{ ApplyImmediately: aws.Bool(true), CACertificateIdentifier: aws.String(v.(string)), DBInstanceIdentifier: aws.String(d.Id()), } - if _, err := conn.ModifyDBInstanceWithContext(ctx, input); err != nil { + if _, err := conn.ModifyDBInstance(ctx, input); err != nil { return sdkdiag.AppendErrorf(diags, "updating RDS Cluster Instance (%s): %s", d.Id(), err) } - if _, err := waitDBInstanceAvailableSDKv1(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { + if _, err := waitDBInstanceAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS Cluster Instance (%s) update: %s", d.Id(), err) } - _, err = conn.RebootDBInstanceWithContext(ctx, &rds.RebootDBInstanceInput{ + _, err = conn.RebootDBInstance(ctx, &rds.RebootDBInstanceInput{ DBInstanceIdentifier: aws.String(d.Id()), }) + if err != nil { return sdkdiag.AppendErrorf(diags, "rebooting RDS Cluster Instance (%s): %s", d.Id(), err) } - if _, err := waitDBInstanceAvailableSDKv1(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { + if _, err := waitDBInstanceAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for RDS Cluster Instance (%s) update: %s", d.Id(), err) } } @@ -360,32 +360,35 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) + + db, err := findDBInstanceByID(ctx, conn, d.Id()) - db, err := findDBInstanceByIDSDKv1(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] RDS Cluster Instance (%s) not found, removing from state", d.Id()) d.SetId("") return diags } + if err != nil { return sdkdiag.AppendErrorf(diags, "reading RDS Cluster Instance (%s): %s", d.Id(), err) } - dbClusterID := aws.StringValue(db.DBClusterIdentifier) + dbClusterID := aws.ToString(db.DBClusterIdentifier) if dbClusterID == "" { return sdkdiag.AppendErrorf(diags, "DBClusterIdentifier is missing from RDS Cluster Instance (%s). The aws_db_instance resource should be used for non-Aurora instances", d.Id()) } - dbc, err := findDBClusterByIDV1(ctx, conn, dbClusterID) + dbc, err := findDBClusterByID(ctx, conn, dbClusterID) + if err != nil { return sdkdiag.AppendErrorf(diags, "reading RDS Cluster (%s): %s", dbClusterID, err) } for _, m := range dbc.DBClusterMembers { - if aws.StringValue(m.DBInstanceIdentifier) == d.Id() { - if aws.BoolValue(m.IsClusterWriter) { + if aws.ToString(m.DBInstanceIdentifier) == d.Id() { + if aws.ToBool(m.IsClusterWriter) { d.Set("writer", true) } else { d.Set("writer", false) @@ -405,7 +408,7 @@ func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, me d.Set(names.AttrClusterIdentifier, db.DBClusterIdentifier) d.Set("copy_tags_to_snapshot", db.CopyTagsToSnapshot) d.Set("custom_iam_instance_profile", db.CustomIamInstanceProfile) - if len(db.DBParameterGroups) > 0 && db.DBParameterGroups[0] != nil { + if len(db.DBParameterGroups) > 0 { d.Set("db_parameter_group_name", db.DBParameterGroups[0].DBParameterGroupName) } if db.DBSubnetGroup != nil { @@ -414,7 +417,7 @@ func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, me d.Set("dbi_resource_id", db.DbiResourceId) d.Set(names.AttrEngine, db.Engine) d.Set(names.AttrIdentifier, db.DBInstanceIdentifier) - d.Set("identifier_prefix", create.NamePrefixFromName(aws.StringValue(db.DBInstanceIdentifier))) + d.Set("identifier_prefix", create.NamePrefixFromName(aws.ToString(db.DBInstanceIdentifier))) d.Set("instance_class", db.DBInstanceClass) d.Set(names.AttrKMSKeyID, db.KmsKeyId) d.Set("monitoring_interval", db.MonitoringInterval) @@ -431,13 +434,13 @@ func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, me clusterSetResourceDataEngineVersionFromClusterInstance(d, db) - setTagsOut(ctx, db.TagList) + setTagsOutV2(ctx, db.TagList) return diags } func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) (diags diag.Diagnostics) { - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) { input := &rds.ModifyDBInstanceInput{ @@ -466,7 +469,7 @@ func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData, } if d.HasChange("monitoring_interval") { - input.MonitoringInterval = aws.Int64(int64(d.Get("monitoring_interval").(int))) + input.MonitoringInterval = aws.Int32(int32(d.Get("monitoring_interval").(int))) } if d.HasChange("monitoring_role_arn") { @@ -481,7 +484,7 @@ func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData, } if v, ok := d.GetOk("performance_insights_retention_period"); ok { - input.PerformanceInsightsRetentionPeriod = aws.Int64(int64(v.(int))) + input.PerformanceInsightsRetentionPeriod = aws.Int32(int32(v.(int))) } } @@ -494,19 +497,19 @@ func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData, } if d.HasChange("promotion_tier") { - input.PromotionTier = aws.Int64(int64(d.Get("promotion_tier").(int))) + input.PromotionTier = aws.Int32(int32(d.Get("promotion_tier").(int))) } if d.HasChange(names.AttrPubliclyAccessible) { input.PubliclyAccessible = aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)) } - log.Printf("[DEBUG] Updating RDS Cluster Instance: %s", input) _, err := tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) { - return conn.ModifyDBInstanceWithContext(ctx, input) + return conn.ModifyDBInstance(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) } @@ -521,7 +524,7 @@ func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData, func resourceClusterInstanceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RDSConn(ctx) + conn := meta.(*conns.AWSClient).RDSClient(ctx) input := &rds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(d.Id()), @@ -534,17 +537,17 @@ func resourceClusterInstanceDelete(ctx context.Context, d *schema.ResourceData, } log.Printf("[DEBUG] Deleting RDS Cluster Instance: %s", d.Id()) - _, err := tfresource.RetryWhenAWSErrMessageContains(ctx, d.Timeout(schema.TimeoutDelete), + _, err := tfresource.RetryWhenIsAErrorMessageContains[*types.InvalidDBClusterStateFault](ctx, d.Timeout(schema.TimeoutDelete), func() (interface{}, error) { - return conn.DeleteDBInstanceWithContext(ctx, input) + return conn.DeleteDBInstance(ctx, input) }, - rds.ErrCodeInvalidDBClusterStateFault, "Delete the replica cluster before deleting") + "Delete the replica cluster before deleting") - if tfawserr.ErrCodeEquals(err, rds.ErrCodeDBInstanceNotFoundFault) { + if errs.IsA[*types.DBInstanceNotFoundFault](err) { return diags } - if err != nil && !tfawserr.ErrMessageContains(err, rds.ErrCodeInvalidDBInstanceStateFault, "is already being deleted") { + if err != nil && !errs.IsAErrorMessageContains[*types.InvalidDBInstanceStateFault](err, "is already being deleted") { return sdkdiag.AppendErrorf(diags, "deleting RDS Cluster Instance (%s): %s", d.Id(), err) } @@ -555,7 +558,7 @@ func resourceClusterInstanceDelete(ctx context.Context, d *schema.ResourceData, return diags } -func waitDBClusterInstanceCreated(ctx context.Context, conn *rds.RDS, id string, timeout time.Duration) (*rds.DBInstance, error) { +func waitDBClusterInstanceCreated(ctx context.Context, conn *rds.Client, id string, timeout time.Duration) (*types.DBInstance, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ InstanceStatusBackingUp, @@ -573,7 +576,7 @@ func waitDBClusterInstanceCreated(ctx context.Context, conn *rds.RDS, id string, InstanceStatusUpgrading, }, Target: []string{InstanceStatusAvailable}, - Refresh: statusDBInstanceSDKv1(ctx, conn, id), + Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, MinTimeout: 10 * time.Second, Delay: 30 * time.Second, @@ -581,14 +584,14 @@ func waitDBClusterInstanceCreated(ctx context.Context, conn *rds.RDS, id string, outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*rds.DBInstance); ok { + if output, ok := outputRaw.(*types.DBInstance); ok { return output, err } return nil, err } -func waitDBClusterInstanceUpdated(ctx context.Context, conn *rds.RDS, id string, timeout time.Duration) (*rds.DBInstance, error) { +func waitDBClusterInstanceUpdated(ctx context.Context, conn *rds.Client, id string, timeout time.Duration) (*types.DBInstance, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ InstanceStatusBackingUp, @@ -606,7 +609,7 @@ func waitDBClusterInstanceUpdated(ctx context.Context, conn *rds.RDS, id string, InstanceStatusUpgrading, }, Target: []string{InstanceStatusAvailable}, - Refresh: statusDBInstanceSDKv1(ctx, conn, id), + Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, MinTimeout: 10 * time.Second, Delay: 30 * time.Second, @@ -614,14 +617,14 @@ func waitDBClusterInstanceUpdated(ctx context.Context, conn *rds.RDS, id string, outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*rds.DBInstance); ok { + if output, ok := outputRaw.(*types.DBInstance); ok { return output, err } return nil, err } -func waitDBClusterInstanceDeleted(ctx context.Context, conn *rds.RDS, id string, timeout time.Duration) (*rds.DBInstance, error) { +func waitDBClusterInstanceDeleted(ctx context.Context, conn *rds.Client, id string, timeout time.Duration) (*types.DBInstance, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ InstanceStatusConfiguringLogExports, @@ -630,7 +633,7 @@ func waitDBClusterInstanceDeleted(ctx context.Context, conn *rds.RDS, id string, InstanceStatusModifying, }, Target: []string{}, - Refresh: statusDBInstanceSDKv1(ctx, conn, id), + Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, MinTimeout: 10 * time.Second, Delay: 30 * time.Second, @@ -638,87 +641,19 @@ func waitDBClusterInstanceDeleted(ctx context.Context, conn *rds.RDS, id string, outputRaw, err := stateConf.WaitForStateContext(ctx) - if output, ok := outputRaw.(*rds.DBInstance); ok { + if output, ok := outputRaw.(*types.DBInstance); ok { return output, err } return nil, err } -func clusterSetResourceDataEngineVersionFromClusterInstance(d *schema.ResourceData, c *rds.DBInstance) { +func clusterSetResourceDataEngineVersionFromClusterInstance(d *schema.ResourceData, c *types.DBInstance) { oldVersion := d.Get(names.AttrEngineVersion).(string) - newVersion := aws.StringValue(c.EngineVersion) + newVersion := aws.ToString(c.EngineVersion) var pendingVersion string if c.PendingModifiedValues != nil && c.PendingModifiedValues.EngineVersion != nil { - pendingVersion = aws.StringValue(c.PendingModifiedValues.EngineVersion) + pendingVersion = aws.ToString(c.PendingModifiedValues.EngineVersion) } compareActualEngineVersion(d, oldVersion, newVersion, pendingVersion) } - -// TODO Remove once migrate to AWS SDK for Go v2. -func findDBClusterByIDV1(ctx context.Context, conn *rds.RDS, id string) (*rds.DBCluster, error) { - input := &rds.DescribeDBClustersInput{ - DBClusterIdentifier: aws.String(id), - } - output, err := findDBClusterV1(ctx, conn, input, tfslices.PredicateTrue[*rds.DBCluster]()) - - if err != nil { - return nil, err - } - - // Eventual consistency check. - if arn.IsARN(id) { - if aws.StringValue(output.DBClusterArn) != id { - return nil, &retry.NotFoundError{ - LastRequest: input, - } - } - } else if aws.StringValue(output.DBClusterIdentifier) != id { - return nil, &retry.NotFoundError{ - LastRequest: input, - } - } - - return output, nil -} - -func findDBClusterV1(ctx context.Context, conn *rds.RDS, input *rds.DescribeDBClustersInput, filter tfslices.Predicate[*rds.DBCluster]) (*rds.DBCluster, error) { - output, err := findDBClustersV1(ctx, conn, input, filter) - - if err != nil { - return nil, err - } - - return tfresource.AssertSinglePtrResult(output) -} - -func findDBClustersV1(ctx context.Context, conn *rds.RDS, input *rds.DescribeDBClustersInput, filter tfslices.Predicate[*rds.DBCluster]) ([]*rds.DBCluster, error) { - var output []*rds.DBCluster - - err := conn.DescribeDBClustersPagesWithContext(ctx, input, func(page *rds.DescribeDBClustersOutput, lastPage bool) bool { - if page == nil { - return !lastPage - } - - for _, v := range page.DBClusters { - if v != nil && filter(v) { - output = append(output, v) - } - } - - return !lastPage - }) - - if tfawserr.ErrCodeEquals(err, rds.ErrCodeDBClusterNotFoundFault) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, - } - } - - if err != nil { - return nil, err - } - - return output, nil -} diff --git a/internal/service/rds/cluster_instance_test.go b/internal/service/rds/cluster_instance_test.go index 405c0bffcc1..7e48a9d92bb 100644 --- a/internal/service/rds/cluster_instance_test.go +++ b/internal/service/rds/cluster_instance_test.go @@ -9,9 +9,10 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/rds" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rds" + "github.com/aws/aws-sdk-go-v2/service/rds/types" + "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -28,7 +29,7 @@ func TestAccRDSClusterInstance_basic(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -83,7 +84,7 @@ func TestAccRDSClusterInstance_disappears(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -111,7 +112,7 @@ func TestAccRDSClusterInstance_identifierGenerated(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -147,7 +148,7 @@ func TestAccRDSClusterInstance_identifierPrefix(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -183,7 +184,7 @@ func TestAccRDSClusterInstance_tags(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -236,7 +237,7 @@ func TestAccRDSClusterInstance_isAlreadyBeingDeleted(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -255,12 +256,12 @@ func TestAccRDSClusterInstance_isAlreadyBeingDeleted(t *testing.T) { { PreConfig: func() { // Get Database Instance into deleting state - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) input := &rds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(rName), SkipFinalSnapshot: aws.Bool(true), } - _, err := conn.DeleteDBInstanceWithContext(ctx, input) + _, err := conn.DeleteDBInstance(ctx, input) if err != nil { t.Fatalf("error deleting Database Instance: %s", err) } @@ -278,7 +279,7 @@ func TestAccRDSClusterInstance_az(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" availabilityZonesDataSourceName := "data.aws_availability_zones.available" @@ -314,7 +315,7 @@ func TestAccRDSClusterInstance_kmsKey(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) kmsKeyResourceName := "aws_kms_key.test" resourceName := "aws_rds_cluster_instance.test" @@ -350,7 +351,7 @@ func TestAccRDSClusterInstance_publiclyAccessible(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -407,7 +408,7 @@ func TestAccRDSClusterInstance_copyTagsToSnapshot(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" @@ -449,7 +450,7 @@ func TestAccRDSClusterInstance_caCertificateIdentifier(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rds_cluster_instance.test" certificateDataSourceName := "data.aws_rds_certificate.latest" @@ -485,7 +486,7 @@ func TestAccRDSClusterInstance_monitoringInterval(t *testing.T) { t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -541,7 +542,7 @@ func TestAccRDSClusterInstance_MonitoringRoleARN_enabledToDisabled(t *testing.T) t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance iamRoleResourceName := "aws_iam_role.test" resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -584,7 +585,7 @@ func TestAccRDSClusterInstance_MonitoringRoleARN_enabledToRemoved(t *testing.T) t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance iamRoleResourceName := "aws_iam_role.test" resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -626,7 +627,7 @@ func TestAccRDSClusterInstance_MonitoringRoleARN_removedToEnabled(t *testing.T) t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance iamRoleResourceName := "aws_iam_role.test" resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -668,7 +669,7 @@ func TestAccRDSClusterInstance_PerformanceInsightsEnabled_auroraMySQL1(t *testin t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) engine := "aurora-mysql" @@ -704,7 +705,7 @@ func TestAccRDSClusterInstance_PerformanceInsightsEnabled_auroraPostgresql(t *te t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) engine := "aurora-postgresql" @@ -740,7 +741,7 @@ func TestAccRDSClusterInstance_PerformanceInsightsKMSKeyID_auroraMySQL1(t *testi t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance kmsKeyResourceName := "aws_kms_key.test" resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -778,7 +779,7 @@ func TestAccRDSClusterInstance_PerformanceInsightsKMSKeyIDAuroraMySQL1_defaultKe t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) engine := "aurora-mysql" @@ -818,7 +819,7 @@ func TestAccRDSClusterInstance_performanceInsightsRetentionPeriod(t *testing.T) t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -873,7 +874,7 @@ func TestAccRDSClusterInstance_PerformanceInsightsKMSKeyID_auroraPostgresql(t *t t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance kmsKeyResourceName := "aws_kms_key.test" resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -911,7 +912,7 @@ func TestAccRDSClusterInstance_PerformanceInsightsKMSKeyIDAuroraPostgresql_defau t.Skip("skipping long-running test in short mode") } - var v rds.DBInstance + var v types.DBInstance resourceName := "aws_rds_cluster_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) engine := "aurora-postgresql" @@ -946,14 +947,14 @@ func TestAccRDSClusterInstance_PerformanceInsightsKMSKeyIDAuroraPostgresql_defau } func testAccPerformanceInsightsDefaultVersionPreCheck(ctx context.Context, t *testing.T, engine string) { - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) input := &rds.DescribeDBEngineVersionsInput{ DefaultOnly: aws.Bool(true), Engine: aws.String(engine), } - result, err := conn.DescribeDBEngineVersionsWithContext(ctx, input) + result, err := conn.DescribeDBEngineVersions(ctx, input) if err != nil { t.Fatalf("unexpected PreCheck error: %s", err) } @@ -962,11 +963,11 @@ func testAccPerformanceInsightsDefaultVersionPreCheck(ctx context.Context, t *te t.Fatalf("unexpected PreCheck error, no default version for engine: %s", engine) } - testAccPerformanceInsightsPreCheck(ctx, t, engine, aws.StringValue(result.DBEngineVersions[0].EngineVersion)) + testAccPerformanceInsightsPreCheck(ctx, t, engine, aws.ToString(result.DBEngineVersions[0].EngineVersion)) } func testAccPerformanceInsightsPreCheck(ctx context.Context, t *testing.T, engine string, engineVersion string) { - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) input := &rds.DescribeOrderableDBInstanceOptionsInput{ Engine: aws.String(engine), @@ -974,26 +975,25 @@ func testAccPerformanceInsightsPreCheck(ctx context.Context, t *testing.T, engin } supportsPerformanceInsights := false - err := conn.DescribeOrderableDBInstanceOptionsPagesWithContext(ctx, input, func(resp *rds.DescribeOrderableDBInstanceOptionsOutput, lastPage bool) bool { - for _, instanceOption := range resp.OrderableDBInstanceOptions { - if instanceOption == nil { - continue - } + pages := rds.NewDescribeOrderableDBInstanceOptionsPaginator(conn, input) +Pages: + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) - if aws.BoolValue(instanceOption.SupportsPerformanceInsights) { - supportsPerformanceInsights = true - return false // stop processing pages - } + if tfawserr.ErrCodeEquals(err, "InvalidParameterCombination") { + t.Skipf("RDS Performance Insights not supported, skipping acceptance test") } - return !lastPage - }) - if tfawserr.ErrCodeEquals(err, "InvalidParameterCombination") { - t.Skipf("RDS Performance Insights not supported, skipping acceptance test") - } + if err != nil { + t.Fatalf("unexpected PreCheck error: %s", err) + } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) + for _, instanceOption := range page.OrderableDBInstanceOptions { + if aws.ToBool(instanceOption.SupportsPerformanceInsights) { + supportsPerformanceInsights = true + break Pages + } + } } if !supportsPerformanceInsights { @@ -1001,18 +1001,14 @@ func testAccPerformanceInsightsPreCheck(ctx context.Context, t *testing.T, engin } } -func testAccCheckClusterInstanceExists(ctx context.Context, n string, v *rds.DBInstance) resource.TestCheckFunc { +func testAccCheckClusterInstanceExists(ctx context.Context, n string, v *types.DBInstance) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { return fmt.Errorf("Not found: %s", n) } - if rs.Primary.ID == "" { - return fmt.Errorf("No RDS Cluster Instance ID is set") - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) output, err := tfrds.FindDBInstanceByID(ctx, conn, rs.Primary.ID) if err != nil { @@ -1027,7 +1023,7 @@ func testAccCheckClusterInstanceExists(ctx context.Context, n string, v *rds.DBI func testAccCheckClusterInstanceDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_rds_cluster_instance" { diff --git a/internal/service/rds/exports_test.go b/internal/service/rds/exports_test.go index cd4b732467a..77b3515dbf6 100644 --- a/internal/service/rds/exports_test.go +++ b/internal/service/rds/exports_test.go @@ -9,6 +9,7 @@ var ( ResourceCluster = resourceCluster ResourceClusterActivityStream = resourceClusterActivityStream ResourceClusterEndpoint = resourceClusterEndpoint + ResourceClusterInstance = resourceClusterInstance ResourceClusterParameterGroup = resourceClusterParameterGroup ResourceClusterRoleAssociation = resourceClusterRoleAssociation ResourceClusterSnapshot = resourceClusterSnapshot diff --git a/internal/service/rds/service_package_gen.go b/internal/service/rds/service_package_gen.go index 15246c50bab..56a9c352e80 100644 --- a/internal/service/rds/service_package_gen.go +++ b/internal/service/rds/service_package_gen.go @@ -250,7 +250,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka }, }, { - Factory: ResourceClusterInstance, + Factory: resourceClusterInstance, TypeName: "aws_rds_cluster_instance", Name: "Cluster Instance", Tags: &types.ServicePackageResourceTags{ From 3760461d78976cf0ac631e5df67929384dbc7167 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:04:59 -0400 Subject: [PATCH 08/15] rds: Fix sweeper build error. --- internal/service/rds/sweep.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/rds/sweep.go b/internal/service/rds/sweep.go index 222da60afdc..2b2ff4ffac8 100644 --- a/internal/service/rds/sweep.go +++ b/internal/service/rds/sweep.go @@ -374,7 +374,7 @@ func sweepInstances(region string) error { } for _, v := range page.DBInstances { - r := ResourceInstance() + r := resourceInstance() d := r.Data(nil) d.SetId(aws.ToString(v.DbiResourceId)) d.Set(names.AttrApplyImmediately, true) From 6173756c3770a7bd33220c922c2ce55755ccd683 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:14:03 -0400 Subject: [PATCH 09/15] rds: Remove some AWS SDK for Go v1 dependencies. --- internal/service/rds/export_task_test.go | 11 +- internal/service/rds/instance.go | 4 +- internal/service/rds/instance_migrate.go | 213 +++++------------- internal/service/rds/instance_migrate_test.go | 126 ----------- 4 files changed, 64 insertions(+), 290 deletions(-) delete mode 100644 internal/service/rds/instance_migrate_test.go diff --git a/internal/service/rds/export_task_test.go b/internal/service/rds/export_task_test.go index d8463f2ea42..157c0aa0cca 100644 --- a/internal/service/rds/export_task_test.go +++ b/internal/service/rds/export_task_test.go @@ -11,7 +11,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/rds/types" - rdsv1 "github.com/aws/aws-sdk-go/service/rds" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -30,10 +29,7 @@ func TestAccRDSExportTask_basic(t *testing.T) { resourceName := "aws_rds_export_task.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionHasService(t, rdsv1.EndpointsID) - }, + PreCheck: func() { acctest.PreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckExportTaskDestroy(ctx), @@ -67,10 +63,7 @@ func TestAccRDSExportTask_optional(t *testing.T) { s3Prefix := "test_prefix/test-export" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionHasService(t, rdsv1.EndpointsID) - }, + PreCheck: func() { acctest.PreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckExportTaskDestroy(ctx), diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index fe031b25094..6245e2a6ca1 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -68,12 +68,12 @@ func resourceInstance() *schema.Resource { StateUpgraders: []schema.StateUpgrader{ { Type: resourceInstanceResourceV0().CoreConfigSchema().ImpliedType(), - Upgrade: InstanceStateUpgradeV0, + Upgrade: instanceStateUpgradeV0, Version: 0, }, { Type: resourceInstanceResourceV1().CoreConfigSchema().ImpliedType(), - Upgrade: InstanceStateUpgradeV1, + Upgrade: instanceStateUpgradeV1, Version: 1, }, }, diff --git a/internal/service/rds/instance_migrate.go b/internal/service/rds/instance_migrate.go index 7937ae880a8..20cc0d0bef8 100644 --- a/internal/service/rds/instance_migrate.go +++ b/internal/service/rds/instance_migrate.go @@ -5,16 +5,9 @@ package rds import ( "context" - "fmt" - "strconv" - "strings" - "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/service/rds" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -96,11 +89,10 @@ func resourceInstanceResourceV0() *schema.Resource { }, names.AttrIdentifier: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ConflictsWith: []string{"identifier_prefix"}, + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, }, "identifier_prefix": { Type: schema.TypeString, @@ -178,14 +170,12 @@ func resourceInstanceResourceV0() *schema.Resource { Optional: true, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, }, "security_group_names": { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, }, names.AttrFinalSnapshotIdentifier: { @@ -197,10 +187,6 @@ func resourceInstanceResourceV0() *schema.Resource { Type: schema.TypeList, Optional: true, MaxItems: 1, - ConflictsWith: []string{ - "snapshot_identifier", - "replicate_source_db", - }, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ names.AttrBucketName: { @@ -391,7 +377,7 @@ func resourceInstanceResourceV0() *schema.Resource { } } -func InstanceStateUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { +func instanceStateUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { if rawState == nil { return nil, nil } @@ -412,27 +398,6 @@ func resourceInstanceResourceV1() *schema.Resource { Type: schema.TypeInt, Optional: true, Computed: true, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - mas := d.Get("max_allocated_storage").(int) - - newInt, err := strconv.Atoi(new) - if err != nil { - return false - } - - oldInt, err := strconv.Atoi(old) - if err != nil { - return false - } - - // Allocated is higher than the configuration - // and autoscaling is enabled - if oldInt > newInt && mas > newInt { - return true - } - - return false - }, }, names.AttrAllowMajorVersionUpgrade: { Type: schema.TypeBool, @@ -462,16 +427,14 @@ func resourceInstanceResourceV1() *schema.Resource { ForceNew: true, }, "backup_retention_period": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - ValidateFunc: validation.IntBetween(0, 35), + Type: schema.TypeInt, + Optional: true, + Computed: true, }, "backup_window": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidOnceADayWindowFormat, + Type: schema.TypeString, + Optional: true, + Computed: true, }, "blue_green_update": { Type: schema.TypeList, @@ -503,10 +466,9 @@ func resourceInstanceResourceV1() *schema.Resource { Default: false, }, "custom_iam_instance_profile": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^AWSRDSCustom.*$`), "must begin with AWSRDSCustom"), + Type: schema.TypeString, + Optional: true, + ForceNew: true, }, "customer_owned_ip_enabled": { Type: schema.TypeBool, @@ -517,9 +479,6 @@ func resourceInstanceResourceV1() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ConflictsWith: []string{ - "replicate_source_db", - }, }, "db_subnet_group_name": { Type: schema.TypeString, @@ -547,8 +506,7 @@ func resourceInstanceResourceV1() *schema.Resource { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringInSlice(InstanceExportableLogType_Values(), false), + Type: schema.TypeString, }, }, names.AttrEndpoint: { @@ -560,10 +518,6 @@ func resourceInstanceResourceV1() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - StateFunc: func(v interface{}) string { - value := v.(string) - return strings.ToLower(value) - }, }, names.AttrEngineVersion: { Type: schema.TypeString, @@ -577,12 +531,6 @@ func resourceInstanceResourceV1() *schema.Resource { names.AttrFinalSnapshotIdentifier: { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must only contain alphanumeric characters and hyphens"), - validation.StringDoesNotMatch(regexache.MustCompile(`--`), "cannot contain two consecutive hyphens"), - validation.StringDoesNotMatch(regexache.MustCompile(`-$`), "cannot end in a hyphen"), - ), }, names.AttrHostedZoneID: { Type: schema.TypeString, @@ -593,18 +541,14 @@ func resourceInstanceResourceV1() *schema.Resource { Optional: true, }, names.AttrIdentifier: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ConflictsWith: []string{"identifier_prefix"}, - ValidateFunc: validIdentifier, + Type: schema.TypeString, + Optional: true, + Computed: true, }, "identifier_prefix": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ConflictsWith: []string{names.AttrIdentifier}, - ValidateFunc: validIdentifierPrefix, + Type: schema.TypeString, + Optional: true, + Computed: true, }, "instance_class": { Type: schema.TypeString, @@ -616,11 +560,10 @@ func resourceInstanceResourceV1() *schema.Resource { Computed: true, }, names.AttrKMSKeyID: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidARN, + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, }, "latest_restorable_time": { Type: schema.TypeString, @@ -655,19 +598,10 @@ func resourceInstanceResourceV1() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - StateFunc: func(v interface{}) string { - if v != nil { - value := v.(string) - return strings.ToLower(value) - } - return "" - }, - ValidateFunc: verify.ValidOnceAWeekWindowFormat, }, "manage_master_user_password": { - Type: schema.TypeBool, - Optional: true, - ConflictsWith: []string{names.AttrPassword}, + Type: schema.TypeBool, + Optional: true, }, "master_user_secret": { Type: schema.TypeList, @@ -690,32 +624,23 @@ func resourceInstanceResourceV1() *schema.Resource { }, }, "master_user_secret_kms_key_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidKMSKeyID, + Type: schema.TypeString, + Optional: true, + Computed: true, }, "max_allocated_storage": { Type: schema.TypeInt, Optional: true, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - if old == "0" && new == fmt.Sprintf("%d", d.Get(names.AttrAllocatedStorage).(int)) { - return true - } - return false - }, }, "monitoring_interval": { - Type: schema.TypeInt, - Optional: true, - Default: 0, - ValidateFunc: validation.IntInSlice([]int{0, 1, 5, 10, 15, 30, 60}), + Type: schema.TypeInt, + Optional: true, + Default: 0, }, "monitoring_role_arn": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidARN, + Type: schema.TypeString, + Optional: true, + Computed: true, }, "multi_az": { Type: schema.TypeBool, @@ -729,10 +654,9 @@ func resourceInstanceResourceV1() *schema.Resource { ForceNew: true, }, "network_type": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: validation.StringInSlice(networkType_Values(), false), + Type: schema.TypeString, + Optional: true, + Computed: true, }, "option_group_name": { Type: schema.TypeString, @@ -745,10 +669,9 @@ func resourceInstanceResourceV1() *schema.Resource { Computed: true, }, names.AttrPassword: { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - ConflictsWith: []string{"manage_master_user_password"}, + Type: schema.TypeString, + Optional: true, + Sensitive: true, }, "performance_insights_enabled": { Type: schema.TypeBool, @@ -756,10 +679,9 @@ func resourceInstanceResourceV1() *schema.Resource { Default: false, }, "performance_insights_kms_key_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidARN, + Type: schema.TypeString, + Optional: true, + Computed: true, }, "performance_insights_retention_period": { Type: schema.TypeInt, @@ -777,10 +699,9 @@ func resourceInstanceResourceV1() *schema.Resource { Default: false, }, "replica_mode": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: validation.StringInSlice(rds.ReplicaMode_Values(), false), + Type: schema.TypeString, + Optional: true, + Computed: true, }, "replicas": { Type: schema.TypeList, @@ -800,18 +721,11 @@ func resourceInstanceResourceV1() *schema.Resource { Optional: true, MaxItems: 1, ForceNew: true, - ConflictsWith: []string{ - "s3_import", - "snapshot_identifier", - "replicate_source_db", - }, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "restore_time": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidUTCTimestamp, - ConflictsWith: []string{"restore_to_point_in_time.0.use_latest_restorable_time"}, + Type: schema.TypeString, + Optional: true, }, "source_db_instance_automated_backups_arn": { Type: schema.TypeString, @@ -826,9 +740,8 @@ func resourceInstanceResourceV1() *schema.Resource { Optional: true, }, "use_latest_restorable_time": { - Type: schema.TypeBool, - Optional: true, - ConflictsWith: []string{"restore_to_point_in_time.0.restore_time"}, + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -837,10 +750,6 @@ func resourceInstanceResourceV1() *schema.Resource { Type: schema.TypeList, Optional: true, MaxItems: 1, - ConflictsWith: []string{ - "snapshot_identifier", - "replicate_source_db", - }, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ names.AttrBucketName: { @@ -897,10 +806,9 @@ func resourceInstanceResourceV1() *schema.Resource { Computed: true, }, names.AttrStorageType: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: validation.StringInSlice(storageType_Values(), false), + Type: schema.TypeString, + Optional: true, + Computed: true, }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), @@ -911,11 +819,10 @@ func resourceInstanceResourceV1() *schema.Resource { ForceNew: true, }, names.AttrUsername: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ConflictsWith: []string{"replicate_source_db"}, + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, }, names.AttrVPCSecurityGroupIDs: { Type: schema.TypeSet, @@ -927,7 +834,7 @@ func resourceInstanceResourceV1() *schema.Resource { } } -func InstanceStateUpgradeV1(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { +func instanceStateUpgradeV1(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { if rawState == nil { return nil, nil } diff --git a/internal/service/rds/instance_migrate_test.go b/internal/service/rds/instance_migrate_test.go deleted file mode 100644 index 2af4f284890..00000000000 --- a/internal/service/rds/instance_migrate_test.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package rds_test - -import ( - "reflect" - "testing" - - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - tfrds "github.com/hashicorp/terraform-provider-aws/internal/service/rds" - "github.com/hashicorp/terraform-provider-aws/names" -) - -func TestInstanceStateUpgradeV0(t *testing.T) { - ctx := acctest.Context(t) - t.Parallel() - - testCases := []struct { - Description string - InputState map[string]interface{} - ExpectedState map[string]interface{} - }{ - { - Description: "missing state", - InputState: nil, - ExpectedState: nil, - }, - { - Description: "adds delete_automated_backups", - InputState: map[string]interface{}{ - names.AttrAllocatedStorage: 10, - names.AttrEngine: "mariadb", - names.AttrIdentifier: "my-test-instance", - "instance_class": "db.t2.micro", - names.AttrPassword: "avoid-plaintext-passwords", - names.AttrUsername: "tfacctest", - names.AttrTags: map[string]interface{}{acctest.CtKey1: acctest.CtValue1}, - }, - ExpectedState: map[string]interface{}{ - names.AttrAllocatedStorage: 10, - "delete_automated_backups": true, - names.AttrEngine: "mariadb", - names.AttrIdentifier: "my-test-instance", - "instance_class": "db.t2.micro", - names.AttrPassword: "avoid-plaintext-passwords", - names.AttrUsername: "tfacctest", - names.AttrTags: map[string]interface{}{acctest.CtKey1: acctest.CtValue1}, - }, - }, - } - - for _, testCase := range testCases { - testCase := testCase - t.Run(testCase.Description, func(t *testing.T) { - t.Parallel() - - got, err := tfrds.InstanceStateUpgradeV0(ctx, testCase.InputState, nil) - if err != nil { - t.Fatalf("error migrating state: %s", err) - } - - if !reflect.DeepEqual(testCase.ExpectedState, got) { - t.Fatalf("\n\nexpected:\n\n%#v\n\ngot:\n\n%#v\n\n", testCase.ExpectedState, got) - } - }) - } -} - -func TestInstanceStateUpgradeV1(t *testing.T) { - ctx := acctest.Context(t) - t.Parallel() - - testCases := []struct { - Description string - InputState map[string]interface{} - ExpectedState map[string]interface{} - }{ - { - Description: "missing state", - InputState: nil, - ExpectedState: nil, - }, - { - Description: "change id to resource id", - InputState: map[string]interface{}{ - names.AttrAllocatedStorage: 10, - names.AttrEngine: "mariadb", - names.AttrID: "my-test-instance", - names.AttrIdentifier: "my-test-instance", - "instance_class": "db.t2.micro", - names.AttrPassword: "avoid-plaintext-passwords", - names.AttrResourceID: "db-cnuap2ilnbmok4eunzklfvwjca", - names.AttrTags: map[string]interface{}{acctest.CtKey1: acctest.CtValue1}, - names.AttrUsername: "tfacctest", - }, - ExpectedState: map[string]interface{}{ - names.AttrAllocatedStorage: 10, - names.AttrEngine: "mariadb", - names.AttrID: "db-cnuap2ilnbmok4eunzklfvwjca", - names.AttrIdentifier: "my-test-instance", - "instance_class": "db.t2.micro", - names.AttrPassword: "avoid-plaintext-passwords", - names.AttrResourceID: "db-cnuap2ilnbmok4eunzklfvwjca", - names.AttrTags: map[string]interface{}{acctest.CtKey1: acctest.CtValue1}, - names.AttrUsername: "tfacctest", - }, - }, - } - - for _, testCase := range testCases { - testCase := testCase - t.Run(testCase.Description, func(t *testing.T) { - t.Parallel() - - got, err := tfrds.InstanceStateUpgradeV1(ctx, testCase.InputState, nil) - if err != nil { - t.Fatalf("error migrating state: %s", err) - } - - if !reflect.DeepEqual(testCase.ExpectedState, got) { - t.Fatalf("\n\nexpected:\n\n%#v\n\ngot:\n\n%#v\n\n", testCase.ExpectedState, got) - } - }) - } -} From 7c4f218f3c33b1bf9510884572da151bc62038eb Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:20:55 -0400 Subject: [PATCH 10/15] namevaluesfilters/v1: Remove RDS. --- .../generate/namevaluesfilters/v1/main.go | 1 - .../v1/service_filters_gen.go | 23 ------------------- 2 files changed, 24 deletions(-) diff --git a/internal/generate/namevaluesfilters/v1/main.go b/internal/generate/namevaluesfilters/v1/main.go index 95bf178f7a5..bf13a942439 100644 --- a/internal/generate/namevaluesfilters/v1/main.go +++ b/internal/generate/namevaluesfilters/v1/main.go @@ -31,7 +31,6 @@ func main() { // Representing types such as []*fsx.Filter, []*rds.Filter, ... sliceServiceNames := []string{ "imagebuilder", - "rds", } // Always sort to reduce any potential generation churn sort.Strings(sliceServiceNames) diff --git a/internal/namevaluesfilters/v1/service_filters_gen.go b/internal/namevaluesfilters/v1/service_filters_gen.go index 35b01eebd05..545b6585356 100644 --- a/internal/namevaluesfilters/v1/service_filters_gen.go +++ b/internal/namevaluesfilters/v1/service_filters_gen.go @@ -5,7 +5,6 @@ package v1 import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/imagebuilder" - "github.com/aws/aws-sdk-go/service/rds" ) // []*SERVICE.Filter handling @@ -31,25 +30,3 @@ func (filters NameValuesFilters) ImageBuilderFilters() []*imagebuilder.Filter { return result } - -// RDSFilters returns rds service filters. -func (filters NameValuesFilters) RDSFilters() []*rds.Filter { - m := filters.Map() - - if len(m) == 0 { - return nil - } - - result := make([]*rds.Filter, 0, len(m)) - - for k, v := range m { - filter := &rds.Filter{ - Name: aws.String(k), - Values: aws.StringSlice(v), - } - - result = append(result, filter) - } - - return result -} From 262fd6d81ef4c42ef558d17a62fe0b77db0c58b1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:24:12 -0400 Subject: [PATCH 11/15] Fixup 'TestAccMetaService_*'. --- internal/service/meta/service_data_source_test.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/service/meta/service_data_source_test.go b/internal/service/meta/service_data_source_test.go index a8bf18243cd..0c5443e5a03 100644 --- a/internal/service/meta/service_data_source_test.go +++ b/internal/service/meta/service_data_source_test.go @@ -7,8 +7,6 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/service/rds" - "github.com/aws/aws-sdk-go/service/s3" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" tfmeta "github.com/hashicorp/terraform-provider-aws/internal/service/meta" @@ -53,9 +51,9 @@ func TestAccMetaService_byReverseDNSName(t *testing.T) { Config: testAccServiceDataSourceConfig_byReverseDNSName(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, names.CNNorth1RegionID), - resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "cn.com.amazonaws", names.CNNorth1RegionID, s3.EndpointsID)), + resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "cn.com.amazonaws", names.CNNorth1RegionID, names.S3)), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "cn.com.amazonaws"), - resource.TestCheckResourceAttr(dataSourceName, "service_id", s3.EndpointsID), + resource.TestCheckResourceAttr(dataSourceName, "service_id", names.S3), resource.TestCheckResourceAttr(dataSourceName, "supported", acctest.CtTrue), ), }, @@ -76,9 +74,9 @@ func TestAccMetaService_byDNSName(t *testing.T) { Config: testAccServiceDataSourceConfig_byDNSName(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, names.USEast1RegionID), - resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", names.USEast1RegionID, rds.EndpointsID)), + resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", names.USEast1RegionID, names.RDS)), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "com.amazonaws"), - resource.TestCheckResourceAttr(dataSourceName, "service_id", rds.EndpointsID), + resource.TestCheckResourceAttr(dataSourceName, "service_id", names.RDS), resource.TestCheckResourceAttr(dataSourceName, "supported", acctest.CtTrue), ), }, @@ -98,8 +96,8 @@ func TestAccMetaService_byParts(t *testing.T) { { Config: testAccServiceDataSourceConfig_byPart(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", s3.EndpointsID, acctest.Region(), "amazonaws.com")), - resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", acctest.Region(), s3.EndpointsID)), + resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", names.S3, acctest.Region(), "amazonaws.com")), + resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", acctest.Region(), names.S3)), resource.TestCheckResourceAttr(dataSourceName, "supported", acctest.CtTrue), ), }, From b7648de39b1ebf1382295fb49fb4cf7a33ec383a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:28:31 -0400 Subject: [PATCH 12/15] Acceptance test output: % make testacc TESTARGS='-run=TestAccMetaService_' PKG=meta make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.22.6 test ./internal/service/meta/... -v -count 1 -parallel 20 -run=TestAccMetaService_ -timeout 360m === RUN TestAccMetaService_basic === PAUSE TestAccMetaService_basic === RUN TestAccMetaService_byReverseDNSName === PAUSE TestAccMetaService_byReverseDNSName === RUN TestAccMetaService_byDNSName === PAUSE TestAccMetaService_byDNSName === RUN TestAccMetaService_byParts === PAUSE TestAccMetaService_byParts === RUN TestAccMetaService_unsupported === PAUSE TestAccMetaService_unsupported === CONT TestAccMetaService_basic === CONT TestAccMetaService_byDNSName === CONT TestAccMetaService_byParts === CONT TestAccMetaService_unsupported === CONT TestAccMetaService_byReverseDNSName --- PASS: TestAccMetaService_basic (12.25s) --- PASS: TestAccMetaService_byReverseDNSName (12.25s) --- PASS: TestAccMetaService_byDNSName (12.32s) --- PASS: TestAccMetaService_unsupported (12.32s) --- PASS: TestAccMetaService_byParts (12.41s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/meta 17.668s From 512556ba35f03b24f1619e2b7d50256fa8269ca3 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 12:35:53 -0400 Subject: [PATCH 13/15] rds: Use AWS SDK for Go v2 exclusively. --- internal/conns/awsclient.go | 11 ---- internal/conns/awsclient_gen.go | 5 -- internal/service/rds/cluster.go | 10 +-- internal/service/rds/cluster_data_source.go | 2 +- internal/service/rds/cluster_endpoint.go | 2 +- internal/service/rds/cluster_instance.go | 4 +- .../service/rds/cluster_parameter_group.go | 2 +- internal/service/rds/cluster_snapshot.go | 4 +- .../rds/cluster_snapshot_data_source.go | 6 +- .../service/rds/custom_db_engine_version.go | 4 +- internal/service/rds/event_subscription.go | 2 +- internal/service/rds/generate.go | 3 +- internal/service/rds/instance.go | 12 ++-- internal/service/rds/instance_data_source.go | 4 +- internal/service/rds/instance_test.go | 11 ++-- internal/service/rds/instances_data_source.go | 2 +- internal/service/rds/integration.go | 4 +- internal/service/rds/option_group.go | 2 +- internal/service/rds/parameter_group.go | 2 +- internal/service/rds/proxy.go | 2 +- internal/service/rds/proxy_endpoint.go | 2 +- internal/service/rds/reserved_instance.go | 2 +- .../rds/service_endpoint_resolver_gen.go | 64 ------------------- .../service/rds/service_endpoints_gen_test.go | 43 ++----------- internal/service/rds/service_package_gen.go | 22 ------- internal/service/rds/snapshot.go | 4 +- internal/service/rds/snapshot_copy.go | 2 +- internal/service/rds/snapshot_data_source.go | 6 +- internal/service/rds/subnet_group.go | 2 +- internal/service/rds/tags_gen.go | 36 +++++------ internal/service/rds/tagsv2_gen.go | 59 ----------------- names/data/names_data.hcl | 2 +- 32 files changed, 73 insertions(+), 265 deletions(-) delete mode 100644 internal/service/rds/tagsv2_gen.go diff --git a/internal/conns/awsclient.go b/internal/conns/awsclient.go index 976b936ef7f..f2a8e401828 100644 --- a/internal/conns/awsclient.go +++ b/internal/conns/awsclient.go @@ -19,7 +19,6 @@ import ( aws_sdkv1 "github.com/aws/aws-sdk-go/aws" session_sdkv1 "github.com/aws/aws-sdk-go/aws/session" opsworks_sdkv1 "github.com/aws/aws-sdk-go/service/opsworks" - rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds" baselogging "github.com/hashicorp/aws-sdk-go-base/v2/logging" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/errs" @@ -86,16 +85,6 @@ func (c *AWSClient) RegionalHostname(ctx context.Context, prefix string) string return fmt.Sprintf("%s.%s.%s", prefix, c.Region, c.DNSSuffix(ctx)) } -// RDSConnForRegion returns an AWS SDK For Go v1 RDS API client for the specified AWS Region. -// If the specified region is not the default a new "simple" client is created. -// This new client does not use any configured endpoint override. -func (c *AWSClient) RDSConnForRegion(ctx context.Context, region string) *rds_sdkv1.RDS { - if region == c.Region { - return c.RDSConn(ctx) - } - return rds_sdkv1.New(c.session, aws_sdkv1.NewConfig().WithRegion(region)) -} - // S3ExpressClient returns an AWS SDK for Go v2 S3 API client suitable for use with S3 Express (directory buckets). // This client differs from the standard S3 API client only in us-east-1 if the global S3 endpoint is used. // In that case the returned client uses the regional S3 endpoint. diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index 968d123e6fd..0e33df47fac 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -242,7 +242,6 @@ import ( opsworks_sdkv1 "github.com/aws/aws-sdk-go/service/opsworks" outposts_sdkv1 "github.com/aws/aws-sdk-go/service/outposts" quicksight_sdkv1 "github.com/aws/aws-sdk-go/service/quicksight" - rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds" redshift_sdkv1 "github.com/aws/aws-sdk-go/service/redshift" redshiftserverless_sdkv1 "github.com/aws/aws-sdk-go/service/redshiftserverless" sagemaker_sdkv1 "github.com/aws/aws-sdk-go/service/sagemaker" @@ -964,10 +963,6 @@ func (c *AWSClient) RBinClient(ctx context.Context) *rbin_sdkv2.Client { return errs.Must(client[*rbin_sdkv2.Client](ctx, c, names.RBin, make(map[string]any))) } -func (c *AWSClient) RDSConn(ctx context.Context) *rds_sdkv1.RDS { - return errs.Must(conn[*rds_sdkv1.RDS](ctx, c, names.RDS, make(map[string]any))) -} - func (c *AWSClient) RDSClient(ctx context.Context) *rds_sdkv2.Client { return errs.Must(client[*rds_sdkv2.Client](ctx, c, names.RDS, make(map[string]any))) } diff --git a/internal/service/rds/cluster.go b/internal/service/rds/cluster.go index a3685ed4ae9..736dc9c18d1 100644 --- a/internal/service/rds/cluster.go +++ b/internal/service/rds/cluster.go @@ -657,7 +657,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int Engine: aws.String(d.Get(names.AttrEngine).(string)), EngineMode: aws.String(d.Get("engine_mode").(string)), SnapshotIdentifier: aws.String(v.(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZones); ok && v.(*schema.Set).Len() > 0 { @@ -788,7 +788,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int S3Prefix: aws.String(tfMap[names.AttrBucketPrefix].(string)), SourceEngine: aws.String(tfMap["source_engine"].(string)), SourceEngineVersion: aws.String(tfMap["source_engine_version"].(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZones); ok && v.(*schema.Set).Len() > 0 { @@ -911,7 +911,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), DBClusterIdentifier: aws.String(identifier), DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk("backtrack_window"); ok { @@ -1035,7 +1035,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), Engine: aws.String(d.Get(names.AttrEngine).(string)), EngineMode: aws.String(d.Get("engine_mode").(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOkExists(names.AttrAllocatedStorage); ok { @@ -1375,7 +1375,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter } } - setTagsOutV2(ctx, dbc.TagList) + setTagsOut(ctx, dbc.TagList) return diags } diff --git a/internal/service/rds/cluster_data_source.go b/internal/service/rds/cluster_data_source.go index 0db67df4380..2a3eb011f58 100644 --- a/internal/service/rds/cluster_data_source.go +++ b/internal/service/rds/cluster_data_source.go @@ -235,7 +235,7 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int return aws.ToString(v.VpcSecurityGroupId) })) - setTagsOutV2(ctx, dbc.TagList) + setTagsOut(ctx, dbc.TagList) return diags } diff --git a/internal/service/rds/cluster_endpoint.go b/internal/service/rds/cluster_endpoint.go index 205f5a18e17..5a3dcb487a4 100644 --- a/internal/service/rds/cluster_endpoint.go +++ b/internal/service/rds/cluster_endpoint.go @@ -97,7 +97,7 @@ func resourceClusterEndpointCreate(ctx context.Context, d *schema.ResourceData, DBClusterEndpointIdentifier: aws.String(endpointID), DBClusterIdentifier: aws.String(d.Get(names.AttrClusterIdentifier).(string)), EndpointType: aws.String(d.Get("custom_endpoint_type").(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk("excluded_members"); ok && v.(*schema.Set).Len() > 0 { diff --git a/internal/service/rds/cluster_instance.go b/internal/service/rds/cluster_instance.go index 359028633fb..a3468cd5bb6 100644 --- a/internal/service/rds/cluster_instance.go +++ b/internal/service/rds/cluster_instance.go @@ -259,7 +259,7 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, Engine: aws.String(d.Get(names.AttrEngine).(string)), PromotionTier: aws.Int32(int32(d.Get("promotion_tier").(int))), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZone); ok { @@ -434,7 +434,7 @@ func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, me clusterSetResourceDataEngineVersionFromClusterInstance(d, db) - setTagsOutV2(ctx, db.TagList) + setTagsOut(ctx, db.TagList) return diags } diff --git a/internal/service/rds/cluster_parameter_group.go b/internal/service/rds/cluster_parameter_group.go index 4cdc5534b82..ccfdc6bfcdc 100644 --- a/internal/service/rds/cluster_parameter_group.go +++ b/internal/service/rds/cluster_parameter_group.go @@ -114,7 +114,7 @@ func resourceClusterParameterGroupCreate(ctx context.Context, d *schema.Resource DBClusterParameterGroupName: aws.String(name), DBParameterGroupFamily: aws.String(d.Get(names.AttrFamily).(string)), Description: aws.String(d.Get(names.AttrDescription).(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } output, err := conn.CreateDBClusterParameterGroup(ctx, input) diff --git a/internal/service/rds/cluster_snapshot.go b/internal/service/rds/cluster_snapshot.go index 7523909ad0d..f6c25230ad1 100644 --- a/internal/service/rds/cluster_snapshot.go +++ b/internal/service/rds/cluster_snapshot.go @@ -137,7 +137,7 @@ func resourceClusterSnapshotCreate(ctx context.Context, d *schema.ResourceData, input := &rds.CreateDBClusterSnapshotInput{ DBClusterIdentifier: aws.String(d.Get("db_cluster_identifier").(string)), DBClusterSnapshotIdentifier: aws.String(id), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } const ( @@ -215,7 +215,7 @@ func resourceClusterSnapshotRead(ctx context.Context, d *schema.ResourceData, me return sdkdiag.AppendErrorf(diags, "reading RDS DB Cluster Snapshot (%s) attribute: %s", d.Id(), err) } - setTagsOutV2(ctx, snapshot.TagList) + setTagsOut(ctx, snapshot.TagList) return diags } diff --git a/internal/service/rds/cluster_snapshot_data_source.go b/internal/service/rds/cluster_snapshot_data_source.go index 92b463c6a9e..521847f2914 100644 --- a/internal/service/rds/cluster_snapshot_data_source.go +++ b/internal/service/rds/cluster_snapshot_data_source.go @@ -135,9 +135,9 @@ func dataSourceClusterSnapshotRead(ctx context.Context, d *schema.ResourceData, } f := tfslices.PredicateTrue[*types.DBClusterSnapshot]() - if tags := getTagsInV2(ctx); len(tags) > 0 { + if tags := getTagsIn(ctx); len(tags) > 0 { f = func(v *types.DBClusterSnapshot) bool { - return keyValueTagsV2(ctx, v.TagList).ContainsAll(keyValueTagsV2(ctx, tags)) + return KeyValueTags(ctx, v.TagList).ContainsAll(KeyValueTags(ctx, tags)) } } @@ -182,7 +182,7 @@ func dataSourceClusterSnapshotRead(ctx context.Context, d *schema.ResourceData, d.Set(names.AttrStorageEncrypted, snapshot.StorageEncrypted) d.Set(names.AttrVPCID, snapshot.VpcId) - setTagsOutV2(ctx, snapshot.TagList) + setTagsOut(ctx, snapshot.TagList) return diags } diff --git a/internal/service/rds/custom_db_engine_version.go b/internal/service/rds/custom_db_engine_version.go index 67614f9b075..6cdaf7dd139 100644 --- a/internal/service/rds/custom_db_engine_version.go +++ b/internal/service/rds/custom_db_engine_version.go @@ -174,7 +174,7 @@ func resourceCustomDBEngineVersionCreate(ctx context.Context, d *schema.Resource input := &rds.CreateCustomDBEngineVersionInput{ Engine: aws.String(d.Get(names.AttrEngine).(string)), EngineVersion: aws.String(d.Get(names.AttrEngineVersion).(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk("database_installation_files_s3_bucket_name"); ok { @@ -285,7 +285,7 @@ func resourceCustomDBEngineVersionRead(ctx context.Context, d *schema.ResourceDa d.Set("manifest_computed", out.CustomDBEngineVersionManifest) d.Set(names.AttrStatus, out.Status) - setTagsOutV2(ctx, out.TagList) + setTagsOut(ctx, out.TagList) return diags } diff --git a/internal/service/rds/event_subscription.go b/internal/service/rds/event_subscription.go index 98eeebaf415..6876f1dc685 100644 --- a/internal/service/rds/event_subscription.go +++ b/internal/service/rds/event_subscription.go @@ -114,7 +114,7 @@ func resourceEventSubscriptionCreate(ctx context.Context, d *schema.ResourceData Enabled: aws.Bool(d.Get(names.AttrEnabled).(bool)), SnsTopicArn: aws.String(d.Get("sns_topic").(string)), SubscriptionName: aws.String(name), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk("event_categories"); ok && v.(*schema.Set).Len() > 0 { diff --git a/internal/service/rds/generate.go b/internal/service/rds/generate.go index 7922bfcb4b6..b75be3bb341 100644 --- a/internal/service/rds/generate.go +++ b/internal/service/rds/generate.go @@ -1,8 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsInIDElem=ResourceName -ListTagsOutTagsElem=TagList -ServiceTagsSlice -TagOp=AddTagsToResource -TagInIDElem=ResourceName -UntagOp=RemoveTagsFromResource -UpdateTags -//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ServiceTagsSlice -TagsFunc=TagsV2 -KeyValueTagsFunc=keyValueTagsV2 -GetTagsInFunc=getTagsInV2 -SetTagsOutFunc=setTagsOutV2 -SkipAWSServiceImp -- tagsv2_gen.go +//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ListTagsInIDElem=ResourceName -ListTagsOutTagsElem=TagList -ServiceTagsSlice -TagOp=AddTagsToResource -TagInIDElem=ResourceName -UntagOp=RemoveTagsFromResource -UpdateTags //go:generate go run ../../generate/servicepackage/main.go //go:generate go run ../../generate/tagstests/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index 6245e2a6ca1..b3bd3c2fe89 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -763,7 +763,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), SourceDBInstanceIdentifier: aws.String(sourceDBInstanceID), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if _, ok := d.GetOk(names.AttrAllocatedStorage); ok { @@ -994,7 +994,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in SourceEngine: aws.String(tfMap["source_engine"].(string)), SourceEngineVersion: aws.String(tfMap["source_engine_version"].(string)), StorageEncrypted: aws.Bool(d.Get(names.AttrStorageEncrypted).(bool)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZone); ok { @@ -1140,7 +1140,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DBSnapshotIdentifier: aws.String(v.(string)), DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } engine := strings.ToLower(d.Get(names.AttrEngine).(string)) @@ -1399,7 +1399,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DBInstanceClass: aws.String(d.Get("instance_class").(string)), DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), TargetDBInstanceIdentifier: aws.String(identifier), } @@ -1611,7 +1611,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in MasterUsername: aws.String(d.Get(names.AttrUsername).(string)), PubliclyAccessible: aws.Bool(d.Get(names.AttrPubliclyAccessible).(bool)), StorageEncrypted: aws.Bool(d.Get(names.AttrStorageEncrypted).(bool)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.GetOk(names.AttrAvailabilityZone); ok { @@ -1999,7 +1999,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte dbSetResourceDataEngineVersionFromInstance(d, v) - setTagsOutV2(ctx, v.TagList) + setTagsOut(ctx, v.TagList) return diags } diff --git a/internal/service/rds/instance_data_source.go b/internal/service/rds/instance_data_source.go index 83fe2cdfdd5..e64d0c40a1c 100644 --- a/internal/service/rds/instance_data_source.go +++ b/internal/service/rds/instance_data_source.go @@ -225,7 +225,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in filter := tfslices.PredicateTrue[*types.DBInstance]() if tags := getTagsIn(ctx); len(tags) > 0 { filter = func(v *types.DBInstance) bool { - return keyValueTagsV2(ctx, v.TagList).ContainsAll(KeyValueTags(ctx, tags)) + return KeyValueTags(ctx, v.TagList).ContainsAll(KeyValueTags(ctx, tags)) } } @@ -319,7 +319,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrPort, nil) } - setTagsOutV2(ctx, instance.TagList) + setTagsOut(ctx, instance.TagList) return diags } diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index 541657fcb2f..79a6bb080fd 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -6517,8 +6517,7 @@ func testAccCheckInstanceReplicaAttributes(source, replica *types.DBInstance) re // The snapshot is deleted. func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn1 := acctest.Provider.Meta().(*conns.AWSClient).RDSConn(ctx) - conn2 := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RDSClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_db_instance" { @@ -6526,12 +6525,12 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. } finalSnapshotID := rs.Primary.Attributes[names.AttrFinalSnapshotIdentifier] - output, err := tfrds.FindDBSnapshotByID(ctx, conn2, finalSnapshotID) + output, err := tfrds.FindDBSnapshotByID(ctx, conn, finalSnapshotID) if err != nil { return err } - tags, err := tfrds.ListTags(ctx, conn1, aws.ToString(output.DBSnapshotArn)) + tags, err := tfrds.ListTags(ctx, conn, aws.ToString(output.DBSnapshotArn)) if err != nil { return err } @@ -6540,7 +6539,7 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. return fmt.Errorf("Name tag not found") } - _, err = conn2.DeleteDBSnapshot(ctx, &rds.DeleteDBSnapshotInput{ + _, err = conn.DeleteDBSnapshot(ctx, &rds.DeleteDBSnapshotInput{ DBSnapshotIdentifier: aws.String(finalSnapshotID), }) @@ -6548,7 +6547,7 @@ func testAccCheckInstanceDestroyWithFinalSnapshot(ctx context.Context) resource. return err } - _, err = tfrds.FindDBInstanceByID(ctx, conn2, rs.Primary.Attributes[names.AttrIdentifier]) + _, err = tfrds.FindDBInstanceByID(ctx, conn, rs.Primary.Attributes[names.AttrIdentifier]) if tfresource.NotFound(err) { continue diff --git a/internal/service/rds/instances_data_source.go b/internal/service/rds/instances_data_source.go index d92f266bbf9..b45e1b53555 100644 --- a/internal/service/rds/instances_data_source.go +++ b/internal/service/rds/instances_data_source.go @@ -55,7 +55,7 @@ func dataSourceInstancesRead(ctx context.Context, d *schema.ResourceData, meta i filter := tfslices.PredicateTrue[*types.DBInstance]() if v, ok := d.GetOk(names.AttrTags); ok { filter = func(x *types.DBInstance) bool { - return keyValueTagsV2(ctx, x.TagList).ContainsAll(tftags.New(ctx, v.(map[string]interface{}))) + return KeyValueTags(ctx, x.TagList).ContainsAll(tftags.New(ctx, v.(map[string]interface{}))) } } diff --git a/internal/service/rds/integration.go b/internal/service/rds/integration.go index 11d794634af..882d6c8ce9e 100644 --- a/internal/service/rds/integration.go +++ b/internal/service/rds/integration.go @@ -135,7 +135,7 @@ func (r *integrationResource) Create(ctx context.Context, request resource.Creat } // Additional fields. - input.Tags = getTagsInV2(ctx) + input.Tags = getTagsIn(ctx) output, err := conn.CreateIntegration(ctx, input) @@ -207,7 +207,7 @@ func (r *integrationResource) Read(ctx context.Context, request resource.ReadReq data.AdditionalEncryptionContext = prevAdditionalEncryptionContext } - setTagsOutV2(ctx, output.Tags) + setTagsOut(ctx, output.Tags) response.Diagnostics.Append(response.State.Set(ctx, &data)...) } diff --git a/internal/service/rds/option_group.go b/internal/service/rds/option_group.go index 1cadaf1754e..d19358fa76e 100644 --- a/internal/service/rds/option_group.go +++ b/internal/service/rds/option_group.go @@ -152,7 +152,7 @@ func resourceOptionGroupCreate(ctx context.Context, d *schema.ResourceData, meta MajorEngineVersion: aws.String(d.Get("major_engine_version").(string)), OptionGroupDescription: aws.String(d.Get("option_group_description").(string)), OptionGroupName: aws.String(name), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } _, err := conn.CreateOptionGroup(ctx, input) diff --git a/internal/service/rds/parameter_group.go b/internal/service/rds/parameter_group.go index 7f88932b6f4..8c49d1133c2 100644 --- a/internal/service/rds/parameter_group.go +++ b/internal/service/rds/parameter_group.go @@ -121,7 +121,7 @@ func resourceParameterGroupCreate(ctx context.Context, d *schema.ResourceData, m DBParameterGroupFamily: aws.String(d.Get(names.AttrFamily).(string)), DBParameterGroupName: aws.String(name), Description: aws.String(d.Get(names.AttrDescription).(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } output, err := conn.CreateDBParameterGroup(ctx, input) diff --git a/internal/service/rds/proxy.go b/internal/service/rds/proxy.go index 93b0f2a4d61..008ebc180ff 100644 --- a/internal/service/rds/proxy.go +++ b/internal/service/rds/proxy.go @@ -153,7 +153,7 @@ func resourceProxyCreate(ctx context.Context, d *schema.ResourceData, meta inter DBProxyName: aws.String(name), EngineFamily: types.EngineFamily(d.Get("engine_family").(string)), RoleArn: aws.String(d.Get(names.AttrRoleARN).(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), VpcSubnetIds: flex.ExpandStringValueSet(d.Get("vpc_subnet_ids").(*schema.Set)), } diff --git a/internal/service/rds/proxy_endpoint.go b/internal/service/rds/proxy_endpoint.go index 88a540f36ef..79de10c9c47 100644 --- a/internal/service/rds/proxy_endpoint.go +++ b/internal/service/rds/proxy_endpoint.go @@ -113,7 +113,7 @@ func resourceProxyEndpointCreate(ctx context.Context, d *schema.ResourceData, me input := &rds.CreateDBProxyEndpointInput{ DBProxyName: aws.String(dbProxyName), DBProxyEndpointName: aws.String(dbProxyEndpointName), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), TargetRole: types.DBProxyEndpointTargetRole(d.Get("target_role").(string)), VpcSubnetIds: flex.ExpandStringValueSet(d.Get("vpc_subnet_ids").(*schema.Set)), } diff --git a/internal/service/rds/reserved_instance.go b/internal/service/rds/reserved_instance.go index 89014e845ef..d97b0097800 100644 --- a/internal/service/rds/reserved_instance.go +++ b/internal/service/rds/reserved_instance.go @@ -139,7 +139,7 @@ func resourceReservedInstanceCreate(ctx context.Context, d *schema.ResourceData, input := &rds.PurchaseReservedDBInstancesOfferingInput{ ReservedDBInstancesOfferingId: aws.String(d.Get("offering_id").(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } if v, ok := d.Get(names.AttrInstanceCount).(int); ok && v > 0 { diff --git a/internal/service/rds/service_endpoint_resolver_gen.go b/internal/service/rds/service_endpoint_resolver_gen.go index 423d25fb15b..ffa5506c1da 100644 --- a/internal/service/rds/service_endpoint_resolver_gen.go +++ b/internal/service/rds/service_endpoint_resolver_gen.go @@ -6,78 +6,14 @@ import ( "context" "fmt" "net" - "net/url" aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" - endpoints_sdkv1 "github.com/aws/aws-sdk-go/aws/endpoints" smithyendpoints "github.com/aws/smithy-go/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/errs" ) -var _ endpoints_sdkv1.Resolver = resolverSDKv1{} - -type resolverSDKv1 struct { - ctx context.Context -} - -func newEndpointResolverSDKv1(ctx context.Context) resolverSDKv1 { - return resolverSDKv1{ - ctx: ctx, - } -} - -func (r resolverSDKv1) EndpointFor(service, region string, opts ...func(*endpoints_sdkv1.Options)) (endpoint endpoints_sdkv1.ResolvedEndpoint, err error) { - ctx := r.ctx - - var opt endpoints_sdkv1.Options - opt.Set(opts...) - - useFIPS := opt.UseFIPSEndpoint == endpoints_sdkv1.FIPSEndpointStateEnabled - - defaultResolver := endpoints_sdkv1.DefaultResolver() - - if useFIPS { - ctx = tflog.SetField(ctx, "tf_aws.use_fips", useFIPS) - - endpoint, err = defaultResolver.EndpointFor(service, region, opts...) - if err != nil { - return endpoint, err - } - - tflog.Debug(ctx, "endpoint resolved", map[string]any{ - "tf_aws.endpoint": endpoint.URL, - }) - - var endpointURL *url.URL - endpointURL, err = url.Parse(endpoint.URL) - if err != nil { - return endpoint, err - } - - hostname := endpointURL.Hostname() - _, err = net.LookupHost(hostname) - if err != nil { - if dnsErr, ok := errs.As[*net.DNSError](err); ok && dnsErr.IsNotFound { - tflog.Debug(ctx, "default endpoint host not found, disabling FIPS", map[string]any{ - "tf_aws.hostname": hostname, - }) - opts = append(opts, func(o *endpoints_sdkv1.Options) { - o.UseFIPSEndpoint = endpoints_sdkv1.FIPSEndpointStateDisabled - }) - } else { - err = fmt.Errorf("looking up accessanalyzer endpoint %q: %s", hostname, err) - return - } - } else { - return endpoint, err - } - } - - return defaultResolver.EndpointFor(service, region, opts...) -} - var _ rds_sdkv2.EndpointResolverV2 = resolverSDKv2{} type resolverSDKv2 struct { diff --git a/internal/service/rds/service_endpoints_gen_test.go b/internal/service/rds/service_endpoints_gen_test.go index 3c640b715c8..6543f92d5e4 100644 --- a/internal/service/rds/service_endpoints_gen_test.go +++ b/internal/service/rds/service_endpoints_gen_test.go @@ -18,8 +18,6 @@ import ( aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds" "github.com/aws/smithy-go/middleware" smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" @@ -236,25 +234,13 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S }, } - t.Run("v1", func(t *testing.T) { - for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv - testcase := testcase + for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv + testcase := testcase - t.Run(name, func(t *testing.T) { - testEndpointCase(t, providerRegion, testcase, callServiceV1) - }) - } - }) - - t.Run("v2", func(t *testing.T) { - for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv - testcase := testcase - - t.Run(name, func(t *testing.T) { - testEndpointCase(t, providerRegion, testcase, callServiceV2) - }) - } - }) + t.Run(name, func(t *testing.T) { + testEndpointCase(t, providerRegion, testcase, callService) + }) + } } func defaultEndpoint(region string) (url.URL, error) { @@ -292,7 +278,7 @@ func defaultFIPSEndpoint(region string) (url.URL, error) { return ep.URI, nil } -func callServiceV2(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { +func callService(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { t.Helper() client := meta.RDSClient(ctx) @@ -317,21 +303,6 @@ func callServiceV2(ctx context.Context, t *testing.T, meta *conns.AWSClient) api return result } -func callServiceV1(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { - t.Helper() - - client := meta.RDSConn(ctx) - - req, _ := client.DescribeDBInstancesRequest(&rds_sdkv1.DescribeDBInstancesInput{}) - - req.HTTPRequest.URL.Path = "/" - - return apiCallParams{ - endpoint: req.HTTPRequest.URL.String(), - region: aws_sdkv1.StringValue(client.Config.Region), - } -} - func withNoConfig(_ *caseSetup) { // no-op } diff --git a/internal/service/rds/service_package_gen.go b/internal/service/rds/service_package_gen.go index 56a9c352e80..d03891944e1 100644 --- a/internal/service/rds/service_package_gen.go +++ b/internal/service/rds/service_package_gen.go @@ -7,10 +7,6 @@ import ( aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" rds_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rds" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - session_sdkv1 "github.com/aws/aws-sdk-go/aws/session" - rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds" - "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/types" "github.com/hashicorp/terraform-provider-aws/names" @@ -298,24 +294,6 @@ func (p *servicePackage) ServicePackageName() string { return names.RDS } -// NewConn returns a new AWS SDK for Go v1 client for this service package's AWS API. -func (p *servicePackage) NewConn(ctx context.Context, config map[string]any) (*rds_sdkv1.RDS, error) { - sess := config[names.AttrSession].(*session_sdkv1.Session) - - cfg := aws_sdkv1.Config{} - - if endpoint := config[names.AttrEndpoint].(string); endpoint != "" { - tflog.Debug(ctx, "setting endpoint", map[string]any{ - "tf_aws.endpoint": endpoint, - }) - cfg.Endpoint = aws_sdkv1.String(endpoint) - } else { - cfg.EndpointResolver = newEndpointResolverSDKv1(ctx) - } - - return rds_sdkv1.New(sess.Copy(&cfg)), nil -} - // NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API. func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*rds_sdkv2.Client, error) { cfg := *(config["aws_sdkv2_config"].(*aws_sdkv2.Config)) diff --git a/internal/service/rds/snapshot.go b/internal/service/rds/snapshot.go index 782c7be4995..b0da96b19bf 100644 --- a/internal/service/rds/snapshot.go +++ b/internal/service/rds/snapshot.go @@ -144,7 +144,7 @@ func resourceSnapshotCreate(ctx context.Context, d *schema.ResourceData, meta in input := &rds.CreateDBSnapshotInput{ DBInstanceIdentifier: aws.String(d.Get("db_instance_identifier").(string)), DBSnapshotIdentifier: aws.String(dbSnapshotID), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } output, err := conn.CreateDBSnapshot(ctx, input) @@ -221,7 +221,7 @@ func resourceSnapshotRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "reading RDS DB Snapshot (%s) attribute: %s", d.Id(), err) } - setTagsOutV2(ctx, snapshot.TagList) + setTagsOut(ctx, snapshot.TagList) return diags } diff --git a/internal/service/rds/snapshot_copy.go b/internal/service/rds/snapshot_copy.go index 2684948ed2a..649121e4af8 100644 --- a/internal/service/rds/snapshot_copy.go +++ b/internal/service/rds/snapshot_copy.go @@ -161,7 +161,7 @@ func resourceSnapshotCopyCreate(ctx context.Context, d *schema.ResourceData, met targetDBSnapshotID := d.Get("target_db_snapshot_identifier").(string) input := &rds.CopyDBSnapshotInput{ SourceDBSnapshotIdentifier: aws.String(d.Get("source_db_snapshot_identifier").(string)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), TargetDBSnapshotIdentifier: aws.String(targetDBSnapshotID), } diff --git a/internal/service/rds/snapshot_data_source.go b/internal/service/rds/snapshot_data_source.go index 40e0820367a..9fae90b18cc 100644 --- a/internal/service/rds/snapshot_data_source.go +++ b/internal/service/rds/snapshot_data_source.go @@ -154,9 +154,9 @@ func dataSourceSnapshotRead(ctx context.Context, d *schema.ResourceData, meta in } f := tfslices.PredicateTrue[*types.DBSnapshot]() - if tags := getTagsInV2(ctx); len(tags) > 0 { + if tags := getTagsIn(ctx); len(tags) > 0 { f = func(v *types.DBSnapshot) bool { - return keyValueTagsV2(ctx, v.TagList).ContainsAll(keyValueTagsV2(ctx, tags)) + return KeyValueTags(ctx, v.TagList).ContainsAll(KeyValueTags(ctx, tags)) } } @@ -208,7 +208,7 @@ func dataSourceSnapshotRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrStorageType, snapshot.StorageType) d.Set(names.AttrVPCID, snapshot.VpcId) - setTagsOutV2(ctx, snapshot.TagList) + setTagsOut(ctx, snapshot.TagList) return diags } diff --git a/internal/service/rds/subnet_group.go b/internal/service/rds/subnet_group.go index c29b2a0f741..646add5ad81 100644 --- a/internal/service/rds/subnet_group.go +++ b/internal/service/rds/subnet_group.go @@ -97,7 +97,7 @@ func resourceSubnetGroupCreate(ctx context.Context, d *schema.ResourceData, meta DBSubnetGroupDescription: aws.String(d.Get(names.AttrDescription).(string)), DBSubnetGroupName: aws.String(name), SubnetIds: flex.ExpandStringValueSet(d.Get(names.AttrSubnetIDs).(*schema.Set)), - Tags: getTagsInV2(ctx), + Tags: getTagsIn(ctx), } output, err := conn.CreateDBSubnetGroup(ctx, input) diff --git a/internal/service/rds/tags_gen.go b/internal/service/rds/tags_gen.go index 9fb5dde2fa2..aac138a0aa0 100644 --- a/internal/service/rds/tags_gen.go +++ b/internal/service/rds/tags_gen.go @@ -5,9 +5,9 @@ import ( "context" "fmt" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/rds" - "github.com/aws/aws-sdk-go/service/rds/rdsiface" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rds" + awstypes "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/logging" @@ -19,12 +19,12 @@ import ( // listTags lists rds service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. -func listTags(ctx context.Context, conn rdsiface.RDSAPI, identifier string) (tftags.KeyValueTags, error) { +func listTags(ctx context.Context, conn *rds.Client, identifier string, optFns ...func(*rds.Options)) (tftags.KeyValueTags, error) { input := &rds.ListTagsForResourceInput{ ResourceName: aws.String(identifier), } - output, err := conn.ListTagsForResourceWithContext(ctx, input) + output, err := conn.ListTagsForResource(ctx, input, optFns...) if err != nil { return tftags.New(ctx, nil), err @@ -36,7 +36,7 @@ func listTags(ctx context.Context, conn rdsiface.RDSAPI, identifier string) (tft // ListTags lists rds service tags and set them in Context. // It is called from outside this package. func (p *servicePackage) ListTags(ctx context.Context, meta any, identifier string) error { - tags, err := listTags(ctx, meta.(*conns.AWSClient).RDSConn(ctx), identifier) + tags, err := listTags(ctx, meta.(*conns.AWSClient).RDSClient(ctx), identifier) if err != nil { return err @@ -52,11 +52,11 @@ func (p *servicePackage) ListTags(ctx context.Context, meta any, identifier stri // []*SERVICE.Tag handling // Tags returns rds service tags. -func Tags(tags tftags.KeyValueTags) []*rds.Tag { - result := make([]*rds.Tag, 0, len(tags)) +func Tags(tags tftags.KeyValueTags) []awstypes.Tag { + result := make([]awstypes.Tag, 0, len(tags)) for k, v := range tags.Map() { - tag := &rds.Tag{ + tag := awstypes.Tag{ Key: aws.String(k), Value: aws.String(v), } @@ -68,11 +68,11 @@ func Tags(tags tftags.KeyValueTags) []*rds.Tag { } // KeyValueTags creates tftags.KeyValueTags from rds service tags. -func KeyValueTags(ctx context.Context, tags []*rds.Tag) tftags.KeyValueTags { +func KeyValueTags(ctx context.Context, tags []awstypes.Tag) tftags.KeyValueTags { m := make(map[string]*string, len(tags)) for _, tag := range tags { - m[aws.StringValue(tag.Key)] = tag.Value + m[aws.ToString(tag.Key)] = tag.Value } return tftags.New(ctx, m) @@ -80,7 +80,7 @@ func KeyValueTags(ctx context.Context, tags []*rds.Tag) tftags.KeyValueTags { // getTagsIn returns rds service tags from Context. // nil is returned if there are no input tags. -func getTagsIn(ctx context.Context) []*rds.Tag { +func getTagsIn(ctx context.Context) []awstypes.Tag { if inContext, ok := tftags.FromContext(ctx); ok { if tags := Tags(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { return tags @@ -91,7 +91,7 @@ func getTagsIn(ctx context.Context) []*rds.Tag { } // setTagsOut sets rds service tags in Context. -func setTagsOut(ctx context.Context, tags []*rds.Tag) { +func setTagsOut(ctx context.Context, tags []awstypes.Tag) { if inContext, ok := tftags.FromContext(ctx); ok { inContext.TagsOut = option.Some(KeyValueTags(ctx, tags)) } @@ -100,7 +100,7 @@ func setTagsOut(ctx context.Context, tags []*rds.Tag) { // updateTags updates rds service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. -func updateTags(ctx context.Context, conn rdsiface.RDSAPI, identifier string, oldTagsMap, newTagsMap any) error { +func updateTags(ctx context.Context, conn *rds.Client, identifier string, oldTagsMap, newTagsMap any, optFns ...func(*rds.Options)) error { oldTags := tftags.New(ctx, oldTagsMap) newTags := tftags.New(ctx, newTagsMap) @@ -111,10 +111,10 @@ func updateTags(ctx context.Context, conn rdsiface.RDSAPI, identifier string, ol if len(removedTags) > 0 { input := &rds.RemoveTagsFromResourceInput{ ResourceName: aws.String(identifier), - TagKeys: aws.StringSlice(removedTags.Keys()), + TagKeys: removedTags.Keys(), } - _, err := conn.RemoveTagsFromResourceWithContext(ctx, input) + _, err := conn.RemoveTagsFromResource(ctx, input, optFns...) if err != nil { return fmt.Errorf("untagging resource (%s): %w", identifier, err) @@ -129,7 +129,7 @@ func updateTags(ctx context.Context, conn rdsiface.RDSAPI, identifier string, ol Tags: Tags(updatedTags), } - _, err := conn.AddTagsToResourceWithContext(ctx, input) + _, err := conn.AddTagsToResource(ctx, input, optFns...) if err != nil { return fmt.Errorf("tagging resource (%s): %w", identifier, err) @@ -142,5 +142,5 @@ func updateTags(ctx context.Context, conn rdsiface.RDSAPI, identifier string, ol // UpdateTags updates rds service tags. // It is called from outside this package. func (p *servicePackage) UpdateTags(ctx context.Context, meta any, identifier string, oldTags, newTags any) error { - return updateTags(ctx, meta.(*conns.AWSClient).RDSConn(ctx), identifier, oldTags, newTags) + return updateTags(ctx, meta.(*conns.AWSClient).RDSClient(ctx), identifier, oldTags, newTags) } diff --git a/internal/service/rds/tagsv2_gen.go b/internal/service/rds/tagsv2_gen.go deleted file mode 100644 index f4ef758c4f8..00000000000 --- a/internal/service/rds/tagsv2_gen.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by internal/generate/tags/main.go; DO NOT EDIT. -package rds - -import ( - "context" - - "github.com/aws/aws-sdk-go-v2/aws" - awstypes "github.com/aws/aws-sdk-go-v2/service/rds/types" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "github.com/hashicorp/terraform-provider-aws/internal/types/option" -) - -// []*SERVICE.Tag handling - -// TagsV2 returns rds service tags. -func TagsV2(tags tftags.KeyValueTags) []awstypes.Tag { - result := make([]awstypes.Tag, 0, len(tags)) - - for k, v := range tags.Map() { - tag := awstypes.Tag{ - Key: aws.String(k), - Value: aws.String(v), - } - - result = append(result, tag) - } - - return result -} - -// keyValueTagsV2 creates tftags.KeyValueTags from rds service tags. -func keyValueTagsV2(ctx context.Context, tags []awstypes.Tag) tftags.KeyValueTags { - m := make(map[string]*string, len(tags)) - - for _, tag := range tags { - m[aws.ToString(tag.Key)] = tag.Value - } - - return tftags.New(ctx, m) -} - -// getTagsInV2 returns rds service tags from Context. -// nil is returned if there are no input tags. -func getTagsInV2(ctx context.Context) []awstypes.Tag { - if inContext, ok := tftags.FromContext(ctx); ok { - if tags := TagsV2(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { - return tags - } - } - - return nil -} - -// setTagsOutV2 sets rds service tags in Context. -func setTagsOutV2(ctx context.Context, tags []awstypes.Tag) { - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some(keyValueTagsV2(ctx, tags)) - } -} diff --git a/names/data/names_data.hcl b/names/data/names_data.hcl index 49da2911b1c..b6cf5909ccc 100644 --- a/names/data/names_data.hcl +++ b/names/data/names_data.hcl @@ -7264,7 +7264,7 @@ service "rds" { sdk { id = "RDS" - client_version = [1, 2] + client_version = [2] } names { From e18d470b5e5b846a5960212236cb76a04541682d Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 13 Aug 2024 13:38:56 -0400 Subject: [PATCH 14/15] Fix golangi-lint 'unused'. --- internal/service/rds/cluster.go | 2 +- internal/service/rds/cluster_instance.go | 64 +++++----- internal/service/rds/consts.go | 145 ++++++++++------------- internal/service/rds/instance.go | 62 +++++----- 4 files changed, 129 insertions(+), 144 deletions(-) diff --git a/internal/service/rds/cluster.go b/internal/service/rds/cluster.go index 736dc9c18d1..36a8d3af6d1 100644 --- a/internal/service/rds/cluster.go +++ b/internal/service/rds/cluster.go @@ -215,7 +215,7 @@ func resourceCluster() *schema.Resource { Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringInSlice(ClusterExportableLogType_Values(), false), + ValidateFunc: validation.StringInSlice(clusterExportableLogType_Values(), false), }, }, names.AttrEndpoint: { diff --git a/internal/service/rds/cluster_instance.go b/internal/service/rds/cluster_instance.go index a3468cd5bb6..8cf64f4931f 100644 --- a/internal/service/rds/cluster_instance.go +++ b/internal/service/rds/cluster_instance.go @@ -561,21 +561,21 @@ func resourceClusterInstanceDelete(ctx context.Context, d *schema.ResourceData, func waitDBClusterInstanceCreated(ctx context.Context, conn *rds.Client, id string, timeout time.Duration) (*types.DBInstance, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ - InstanceStatusBackingUp, - InstanceStatusConfiguringEnhancedMonitoring, - InstanceStatusConfiguringIAMDatabaseAuth, - InstanceStatusConfiguringLogExports, - InstanceStatusCreating, - InstanceStatusMaintenance, - InstanceStatusModifying, - InstanceStatusRebooting, - InstanceStatusRenaming, - InstanceStatusResettingMasterCredentials, - InstanceStatusStarting, - InstanceStatusStorageOptimization, - InstanceStatusUpgrading, + instanceStatusBackingUp, + instanceStatusConfiguringEnhancedMonitoring, + instanceStatusConfiguringIAMDatabaseAuth, + instanceStatusConfiguringLogExports, + instanceStatusCreating, + instanceStatusMaintenance, + instanceStatusModifying, + instanceStatusRebooting, + instanceStatusRenaming, + instanceStatusResettingMasterCredentials, + instanceStatusStarting, + instanceStatusStorageOptimization, + instanceStatusUpgrading, }, - Target: []string{InstanceStatusAvailable}, + Target: []string{instanceStatusAvailable}, Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, MinTimeout: 10 * time.Second, @@ -594,21 +594,21 @@ func waitDBClusterInstanceCreated(ctx context.Context, conn *rds.Client, id stri func waitDBClusterInstanceUpdated(ctx context.Context, conn *rds.Client, id string, timeout time.Duration) (*types.DBInstance, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ - InstanceStatusBackingUp, - InstanceStatusConfiguringEnhancedMonitoring, - InstanceStatusConfiguringIAMDatabaseAuth, - InstanceStatusConfiguringLogExports, - InstanceStatusCreating, - InstanceStatusMaintenance, - InstanceStatusModifying, - InstanceStatusRebooting, - InstanceStatusRenaming, - InstanceStatusResettingMasterCredentials, - InstanceStatusStarting, - InstanceStatusStorageOptimization, - InstanceStatusUpgrading, + instanceStatusBackingUp, + instanceStatusConfiguringEnhancedMonitoring, + instanceStatusConfiguringIAMDatabaseAuth, + instanceStatusConfiguringLogExports, + instanceStatusCreating, + instanceStatusMaintenance, + instanceStatusModifying, + instanceStatusRebooting, + instanceStatusRenaming, + instanceStatusResettingMasterCredentials, + instanceStatusStarting, + instanceStatusStorageOptimization, + instanceStatusUpgrading, }, - Target: []string{InstanceStatusAvailable}, + Target: []string{instanceStatusAvailable}, Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, MinTimeout: 10 * time.Second, @@ -627,10 +627,10 @@ func waitDBClusterInstanceUpdated(ctx context.Context, conn *rds.Client, id stri func waitDBClusterInstanceDeleted(ctx context.Context, conn *rds.Client, id string, timeout time.Duration) (*types.DBInstance, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ - InstanceStatusConfiguringLogExports, - InstanceStatusDeletePreCheck, - InstanceStatusDeleting, - InstanceStatusModifying, + instanceStatusConfiguringLogExports, + instanceStatusDeletePreCheck, + instanceStatusDeleting, + instanceStatusModifying, }, Target: []string{}, Refresh: statusDBInstance(ctx, conn, id), diff --git a/internal/service/rds/consts.go b/internal/service/rds/consts.go index f334769e935..d34aabeca54 100644 --- a/internal/service/rds/consts.go +++ b/internal/service/rds/consts.go @@ -60,17 +60,6 @@ const ( storageTypeAuroraIOPT1 = "aurora-iopt1" ) -func storageType_Values() []string { - return []string{ - storageTypeStandard, - storageTypeGP2, - storageTypeGP3, - storageTypeIO1, - storageTypeIO2, - storageTypeAuroraIOPT1, - } -} - const ( InstanceEngineAuroraMySQL = "aurora-mysql" InstanceEngineAuroraPostgreSQL = "aurora-postgresql" @@ -92,37 +81,37 @@ const ( // https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/accessing-monitoring.html#Overview.DBInstance.Status. const ( - InstanceStatusAvailable = "available" - InstanceStatusBackingUp = "backing-up" - InstanceStatusConfiguringEnhancedMonitoring = "configuring-enhanced-monitoring" - InstanceStatusConfiguringIAMDatabaseAuth = "configuring-iam-database-auth" - InstanceStatusConfiguringLogExports = "configuring-log-exports" - InstanceStatusConvertingToVPC = "converting-to-vpc" - InstanceStatusCreating = "creating" - InstanceStatusDeletePreCheck = "delete-precheck" - InstanceStatusDeleting = "deleting" - InstanceStatusFailed = "failed" - InstanceStatusInaccessibleEncryptionCredentials = "inaccessible-encryption-credentials" - InstanceStatusInaccessibleEncryptionCredentialsRecoverable = "inaccessible-encryption-credentials-recoverable" - InstanceStatusIncompatiblCreate = "incompatible-create" - InstanceStatusIncompatibleNetwork = "incompatible-network" - InstanceStatusIncompatibleOptionGroup = "incompatible-option-group" - InstanceStatusIncompatibleParameters = "incompatible-parameters" - InstanceStatusIncompatibleRestore = "incompatible-restore" - InstanceStatusInsufficentCapacity = "insufficient-capacity" - InstanceStatusMaintenance = "maintenance" - InstanceStatusModifying = "modifying" - InstanceStatusMovingToVPC = "moving-to-vpc" - InstanceStatusRebooting = "rebooting" - InstanceStatusResettingMasterCredentials = "resetting-master-credentials" - InstanceStatusRenaming = "renaming" - InstanceStatusRestoreError = "restore-error" - InstanceStatusStarting = "starting" - InstanceStatusStopped = "stopped" - InstanceStatusStopping = "stopping" - InstanceStatusStorageFull = "storage-full" - InstanceStatusStorageOptimization = "storage-optimization" - InstanceStatusUpgrading = "upgrading" + instanceStatusAvailable = "available" + instanceStatusBackingUp = "backing-up" + instanceStatusConfiguringEnhancedMonitoring = "configuring-enhanced-monitoring" + instanceStatusConfiguringIAMDatabaseAuth = "configuring-iam-database-auth" + instanceStatusConfiguringLogExports = "configuring-log-exports" + instanceStatusConvertingToVPC = "converting-to-vpc" + instanceStatusCreating = "creating" + instanceStatusDeletePreCheck = "delete-precheck" + instanceStatusDeleting = "deleting" + instanceStatusFailed = "failed" + instanceStatusInaccessibleEncryptionCredentials = "inaccessible-encryption-credentials" + instanceStatusInaccessibleEncryptionCredentialsRecoverable = "inaccessible-encryption-credentials-recoverable" + instanceStatusIncompatiblCreate = "incompatible-create" + instanceStatusIncompatibleNetwork = "incompatible-network" + instanceStatusIncompatibleOptionGroup = "incompatible-option-group" + instanceStatusIncompatibleParameters = "incompatible-parameters" + instanceStatusIncompatibleRestore = "incompatible-restore" + instanceStatusInsufficentCapacity = "insufficient-capacity" + instanceStatusMaintenance = "maintenance" + instanceStatusModifying = "modifying" + instanceStatusMovingToVPC = "moving-to-vpc" + instanceStatusRebooting = "rebooting" + instanceStatusResettingMasterCredentials = "resetting-master-credentials" + instanceStatusRenaming = "renaming" + instanceStatusRestoreError = "restore-error" + instanceStatusStarting = "starting" + instanceStatusStopped = "stopped" + instanceStatusStopping = "stopping" + instanceStatusStorageFull = "storage-full" + instanceStatusStorageOptimization = "storage-optimization" + instanceStatusUpgrading = "upgrading" ) const ( @@ -220,47 +209,47 @@ func engineLifecycleSupport_Values() []string { } const ( - ExportableLogTypeAgent = "agent" - ExportableLogTypeAlert = "alert" - ExportableLogTypeAudit = "audit" - ExportableLogTypeDiagLog = "diag.log" - ExportableLogTypeError = "error" - ExportableLogTypeGeneral = "general" - ExportableLogTypeListener = "listener" - ExportableLogTypeNotifyLog = "notify.log" - ExportableLogTypeOEMAgent = "oemagent" - ExportableLogTypePostgreSQL = "postgresql" - ExportableLogTypeSlowQuery = "slowquery" - ExportableLogTypeTrace = "trace" - ExportableLogTypeUpgrade = "upgrade" + exportableLogTypeAgent = "agent" + exportableLogTypeAlert = "alert" + exportableLogTypeAudit = "audit" + exportableLogTypeDiagLog = "diag.log" + exportableLogTypeError = "error" + exportableLogTypeGeneral = "general" + exportableLogTypeListener = "listener" + exportableLogTypeNotifyLog = "notify.log" + exportableLogTypeOEMAgent = "oemagent" + exportableLogTypePostgreSQL = "postgresql" + exportableLogTypeSlowQuery = "slowquery" + exportableLogTypeTrace = "trace" + exportableLogTypeUpgrade = "upgrade" ) -func ClusterExportableLogType_Values() []string { +func clusterExportableLogType_Values() []string { return []string{ - ExportableLogTypeAudit, - ExportableLogTypeError, - ExportableLogTypeGeneral, - ExportableLogTypePostgreSQL, - ExportableLogTypeSlowQuery, - ExportableLogTypeUpgrade, + exportableLogTypeAudit, + exportableLogTypeError, + exportableLogTypeGeneral, + exportableLogTypePostgreSQL, + exportableLogTypeSlowQuery, + exportableLogTypeUpgrade, } } -func InstanceExportableLogType_Values() []string { +func instanceExportableLogType_Values() []string { return []string{ - ExportableLogTypeAgent, - ExportableLogTypeAlert, - ExportableLogTypeAudit, - ExportableLogTypeDiagLog, - ExportableLogTypeError, - ExportableLogTypeGeneral, - ExportableLogTypeListener, - ExportableLogTypeNotifyLog, - ExportableLogTypeOEMAgent, - ExportableLogTypePostgreSQL, - ExportableLogTypeSlowQuery, - ExportableLogTypeTrace, - ExportableLogTypeUpgrade, + exportableLogTypeAgent, + exportableLogTypeAlert, + exportableLogTypeAudit, + exportableLogTypeDiagLog, + exportableLogTypeError, + exportableLogTypeGeneral, + exportableLogTypeListener, + exportableLogTypeNotifyLog, + exportableLogTypeOEMAgent, + exportableLogTypePostgreSQL, + exportableLogTypeSlowQuery, + exportableLogTypeTrace, + exportableLogTypeUpgrade, } } @@ -316,10 +305,6 @@ const ( propagationTimeout = 2 * time.Minute ) -const ( - ResNameTags = "Tags" -) - const ( reservedInstanceStateActive = "active" reservedInstanceStateRetired = "retired" diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index b3bd3c2fe89..695fb78bed9 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -290,7 +290,7 @@ func resourceInstance() *schema.Resource { Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringInSlice(InstanceExportableLogType_Values(), false), + ValidateFunc: validation.StringInSlice(instanceExportableLogType_Values(), false), }, }, names.AttrEndpoint: { @@ -2766,23 +2766,23 @@ func waitDBInstanceAvailable(ctx context.Context, conn *rds.Client, id string, t stateConf := &retry.StateChangeConf{ Pending: []string{ - InstanceStatusBackingUp, - InstanceStatusConfiguringEnhancedMonitoring, - InstanceStatusConfiguringIAMDatabaseAuth, - InstanceStatusConfiguringLogExports, - InstanceStatusCreating, - InstanceStatusMaintenance, - InstanceStatusModifying, - InstanceStatusMovingToVPC, - InstanceStatusRebooting, - InstanceStatusRenaming, - InstanceStatusResettingMasterCredentials, - InstanceStatusStarting, - InstanceStatusStopping, - InstanceStatusStorageFull, - InstanceStatusUpgrading, + instanceStatusBackingUp, + instanceStatusConfiguringEnhancedMonitoring, + instanceStatusConfiguringIAMDatabaseAuth, + instanceStatusConfiguringLogExports, + instanceStatusCreating, + instanceStatusMaintenance, + instanceStatusModifying, + instanceStatusMovingToVPC, + instanceStatusRebooting, + instanceStatusRenaming, + instanceStatusResettingMasterCredentials, + instanceStatusStarting, + instanceStatusStopping, + instanceStatusStorageFull, + instanceStatusUpgrading, }, - Target: []string{InstanceStatusAvailable, InstanceStatusStorageOptimization}, + Target: []string{instanceStatusAvailable, instanceStatusStorageOptimization}, Refresh: statusDBInstance(ctx, conn, id), Timeout: timeout, } @@ -2809,20 +2809,20 @@ func waitDBInstanceDeleted(ctx context.Context, conn *rds.Client, id string, tim stateConf := &retry.StateChangeConf{ Pending: []string{ - InstanceStatusAvailable, - InstanceStatusBackingUp, - InstanceStatusConfiguringEnhancedMonitoring, - InstanceStatusConfiguringLogExports, - InstanceStatusCreating, - InstanceStatusDeletePreCheck, - InstanceStatusDeleting, - InstanceStatusIncompatibleParameters, - InstanceStatusIncompatibleRestore, - InstanceStatusModifying, - InstanceStatusStarting, - InstanceStatusStopping, - InstanceStatusStorageFull, - InstanceStatusStorageOptimization, + instanceStatusAvailable, + instanceStatusBackingUp, + instanceStatusConfiguringEnhancedMonitoring, + instanceStatusConfiguringLogExports, + instanceStatusCreating, + instanceStatusDeletePreCheck, + instanceStatusDeleting, + instanceStatusIncompatibleParameters, + instanceStatusIncompatibleRestore, + instanceStatusModifying, + instanceStatusStarting, + instanceStatusStopping, + instanceStatusStorageFull, + instanceStatusStorageOptimization, }, Target: []string{}, Refresh: statusDBInstance(ctx, conn, id), From 011b745895bd6a9371e55a0b4b501a07a618d9bc Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 14 Aug 2024 16:19:43 -0400 Subject: [PATCH 15/15] Fix 'TestAccRDSInstance_MySQL_snapshotRestoreWithEngineVersion'. --- internal/service/rds/instance_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index 79a6bb080fd..c780335622c 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -4039,7 +4039,7 @@ func TestAccRDSInstance_MySQL_snapshotRestoreWithEngineVersion(t *testing.T) { testAccCheckDBInstanceExists(ctx, restoreResourceName, &vRestoredInstance), testAccCheckDBInstanceExists(ctx, resourceName, &v), // Hardcoded older version. Will need to update when no longer compatible to upgrade from this to the default version. - resource.TestCheckResourceAttr(resourceName, names.AttrEngineVersion, "8.0.31"), + resource.TestCheckResourceAttr(resourceName, names.AttrEngineVersion, "8.0.32"), resource.TestCheckResourceAttrPair(restoreResourceName, names.AttrEngineVersion, "data.aws_rds_engine_version.default", names.AttrVersion), ), }, @@ -8159,7 +8159,7 @@ func testAccInstanceConfig_mySQLSnapshotRestoreEngineVersion(rName string) strin resource "aws_db_instance" "test" { allocated_storage = 20 engine = data.aws_rds_engine_version.default.engine - engine_version = "8.0.31" # test is from older to newer version, update when restore from this to current default version is incompatible + engine_version = "8.0.32" # test is from older to newer version, update when restore from this to current default version is incompatible identifier = %[1]q instance_class = data.aws_rds_orderable_db_instance.test.instance_class skip_final_snapshot = true