From b2fcf9599e4650f90e458968cae7cf72c8b16cd7 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:25:34 +0100 Subject: [PATCH 01/12] aws_docdb_cluster --- internal/service/docdb/cluster.go | 96 ++++++++++++++++++++++++++ internal/service/docdb/cluster_test.go | 79 +++++++++++++++++++++ internal/service/docdb/consts.go | 12 ++++ 3 files changed, 187 insertions(+) diff --git a/internal/service/docdb/cluster.go b/internal/service/docdb/cluster.go index d735d41c1ee6..73be98e7c27e 100644 --- a/internal/service/docdb/cluster.go +++ b/internal/service/docdb/cluster.go @@ -222,6 +222,43 @@ func ResourceCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "restore_to_point_in_time": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "restore_to_time": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidUTCTimestamp, + ConflictsWith: []string{"restore_to_point_in_time.0.use_latest_restorable_time"}, + }, + "restore_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(RestoreType_Values(), false), + }, + "source_cluster_identifier": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "use_latest_restorable_time": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + ConflictsWith: []string{"restore_to_point_in_time.0.restore_to_time"}, + }, + }, + }, + ConflictsWith: []string{ + "snapshot_identifier", + }, + }, "skip_final_snapshot": { Type: schema.TypeBool, Optional: true, @@ -235,6 +272,9 @@ func ResourceCluster() *schema.Resource { // allow snapshot_idenfitier to be removed without forcing re-creation return new == "" }, + ConflictsWith: []string{ + "restore_to_point_in_time", + }, }, names.AttrStorageEncrypted: { Type: schema.TypeBool, @@ -357,6 +397,62 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int if err != nil { return sdkdiag.AppendErrorf(diags, "creating DocumentDB Cluster (restore from snapshot) (%s): %s", identifier, err) } + } 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{}) + input := &docdb.RestoreDBClusterToPointInTimeInput{ + DBClusterIdentifier: aws.String(identifier), + SourceDBClusterIdentifier: aws.String(tfMap["source_cluster_identifier"].(string)), + DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)), + Tags: getTagsIn(ctx), + } + + if v, ok := tfMap["restore_to_time"].(string); ok && v != "" { + v, _ := time.Parse(time.RFC3339, v) + input.RestoreToTime = aws.Time(v) + } + + if v, ok := tfMap["use_latest_restorable_time"].(bool); ok && v { + input.UseLatestRestorableTime = aws.Bool(v) + } + + if input.RestoreToTime == nil && input.UseLatestRestorableTime == nil { + return sdkdiag.AppendErrorf(diags, `Either "restore_to_time" or "use_latest_restorable_time" must be set`) + } + + if v, ok := d.GetOk("db_subnet_group_name"); ok { + input.DBSubnetGroupName = aws.String(v.(string)) + } + + if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && len(v.([]interface{})) > 0 { + input.EnableCloudwatchLogsExports = flex.ExpandStringList(v.([]interface{})) + } + + if v, ok := tfMap["restore_type"].(string); ok { + input.RestoreType = aws.String(v) + } + + if v, ok := d.GetOk(names.AttrKMSKeyID); ok { + input.KmsKeyId = aws.String(v.(string)) + } + + if v, ok := d.GetOk(names.AttrPort); ok { + input.Port = aws.Int64(int64(v.(int))) + } + + if v, ok := d.GetOk(names.AttrStorageType); ok { + input.StorageType = aws.String(v.(string)) + } + + if v := d.Get(names.AttrVPCSecurityGroupIDs).(*schema.Set); v.Len() > 0 { + input.VpcSecurityGroupIds = flex.ExpandStringSet(v) + } + + _, err := tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) { + return conn.RestoreDBClusterToPointInTimeWithContext(ctx, input) + }, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") + if err != nil { + return sdkdiag.AppendErrorf(diags, "creating DocumentDB Cluster (restore to point-in-time) (%s): %s", identifier, err) + } } else { // Secondary DocDB clusters part of a global cluster will not supply the master_password if _, ok := d.GetOk("global_cluster_identifier"); !ok { diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index c34579116ed7..17fb96be4a91 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -463,6 +463,42 @@ func TestAccDocDBCluster_backupsUpdate(t *testing.T) { }) } +func TestAccDocDBCluster_pointInTimeRestore(t *testing.T) { + ctx := acctest.Context(t) + var dbCluster docdb.DBCluster + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + sourceResourceName := "aws_docdb_cluster.test" + resourceName := "aws_docdb_cluster.restore" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.DocDBServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckClusterDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccClusterConfig_pointInTimeRestoreSource(rName), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckClusterExists(ctx, sourceResourceName, &dbCluster), + testAccCheckClusterExists(ctx, resourceName, &dbCluster), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "allow_major_version_upgrade", + names.AttrApplyImmediately, + "final_snapshot_identifier", + "master_password", + "skip_final_snapshot", + }, + }, + }, + }) +} + func TestAccDocDBCluster_port(t *testing.T) { ctx := acctest.Context(t) var dbCluster1, dbCluster2 docdb.DBCluster @@ -1232,6 +1268,49 @@ resource "aws_docdb_cluster" "test" { `, rName, port)) } +func testAccClusterConfig_baseForPITR(rName string) string { + return acctest.ConfigCompose(acctest.ConfigAvailableAZsNoOptIn(), fmt.Sprintf(` +resource "aws_docdb_cluster" "test" { + cluster_identifier = %[1]q + + restore_to_point_in_time { + source_cluster_identifier = aws_rds_cluster.test.cluster_identifier + restore_type = "standard" + use_latest_restorable_time = true + } + + availability_zones = [ + data.aws_availability_zones.available.names[0], + data.aws_availability_zones.available.names[1], + data.aws_availability_zones.available.names[2] + ] + + master_password = "avoid-plaintext-passwords" + master_username = "tfacctest" + skip_final_snapshot = true + + enabled_cloudwatch_logs_exports = [ + "audit", + "profiler", + ] +} +`, rName)) +} + +func testAccClusterConfig_pointInTimeRestoreSource(rName string) string { + return acctest.ConfigCompose(acctest.ConfigAvailableAZsNoOptIn(), fmt.Sprintf(` +resource "aws_docdb_cluster" "restore" { + cluster_identifier = %[1]q + + restore_to_point_in_time { + source_cluster_identifier = aws_docdb_cluster.test.cluster_identifier + restore_type = "standard" + use_latest_restorable_time = true + } +} +`, rName)) +} + func testAccClusterConfig_deleteProtection(rName string, isProtected bool) string { return fmt.Sprintf(` resource "aws_docdb_cluster" "test" { diff --git a/internal/service/docdb/consts.go b/internal/service/docdb/consts.go index dadd4fa3bbd0..785c9385ba53 100644 --- a/internal/service/docdb/consts.go +++ b/internal/service/docdb/consts.go @@ -69,3 +69,15 @@ func storageType_Values() []string { storageTypeStandard, } } + +const ( + RestoreTypeStandard = "standard" + RestoreTypeIOpt1 = "iopt1" +) + +func RestoreType_Values() []string { + return []string{ + RestoreTypeStandard, + RestoreTypeIOpt1, + } +} From 3cd175ef92fd60b8cd02abdd3c900c0111547150 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:27:54 +0100 Subject: [PATCH 02/12] aws_docdb_cluster --- .changelog/37716.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/37716.txt diff --git a/.changelog/37716.txt b/.changelog/37716.txt new file mode 100644 index 000000000000..d1b78acd8272 --- /dev/null +++ b/.changelog/37716.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_docdb_cluster: Add `restore_to_point_in_time` argument +``` \ No newline at end of file From 7339d505e23119ec7cde9fc83cfac2eca8b40a65 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:29:46 +0100 Subject: [PATCH 03/12] aws_docdb_cluster --- internal/service/docdb/cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index 17fb96be4a91..85b57fddd1c3 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -1298,7 +1298,7 @@ resource "aws_docdb_cluster" "test" { } func testAccClusterConfig_pointInTimeRestoreSource(rName string) string { - return acctest.ConfigCompose(acctest.ConfigAvailableAZsNoOptIn(), fmt.Sprintf(` + return acctest.ConfigCompose(testAccClusterConfig_baseForPITR(rName), fmt.Sprintf(` resource "aws_docdb_cluster" "restore" { cluster_identifier = %[1]q From 7cc83e3d4bef7881612394810b8288e4f72f181e Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:43:16 +0100 Subject: [PATCH 04/12] aws_docdb_cluster --- internal/service/docdb/cluster_test.go | 6 ------ internal/service/docdb/consts.go | 10 +++++----- website/docs/r/docdb_cluster.html.markdown | 8 ++++++++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index 85b57fddd1c3..528c6e460b86 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -1273,12 +1273,6 @@ func testAccClusterConfig_baseForPITR(rName string) string { resource "aws_docdb_cluster" "test" { cluster_identifier = %[1]q - restore_to_point_in_time { - source_cluster_identifier = aws_rds_cluster.test.cluster_identifier - restore_type = "standard" - use_latest_restorable_time = true - } - availability_zones = [ data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1], diff --git a/internal/service/docdb/consts.go b/internal/service/docdb/consts.go index 785c9385ba53..734e5174cde9 100644 --- a/internal/service/docdb/consts.go +++ b/internal/service/docdb/consts.go @@ -71,13 +71,13 @@ func storageType_Values() []string { } const ( - RestoreTypeStandard = "standard" - RestoreTypeIOpt1 = "iopt1" + RestoreTypeCopyOnWrite = "copy-on-write" + RestoreTypeFullCopy = "full-copy" ) func RestoreType_Values() []string { return []string{ - RestoreTypeStandard, - RestoreTypeIOpt1, + RestoreTypeCopyOnWrite, + RestoreTypeFullCopy, } -} +} \ No newline at end of file diff --git a/website/docs/r/docdb_cluster.html.markdown b/website/docs/r/docdb_cluster.html.markdown index 9e309e20c8aa..abb924512efb 100644 --- a/website/docs/r/docdb_cluster.html.markdown +++ b/website/docs/r/docdb_cluster.html.markdown @@ -70,6 +70,7 @@ This argument supports the following arguments: * `preferred_backup_window` - (Optional) The daily time range during which automated backups are created if automated backups are enabled using the BackupRetentionPeriod parameter.Time in UTC Default: A 30-minute window selected at random from an 8-hour block of time per regionE.g., 04:00-09:00 * `preferred_maintenance_window` - (Optional) The weekly time range during which system maintenance can occur, in (UTC) e.g., wed:04:00-wed:04:30 +* `restore_to_point_in_time` - (Optional, Forces new resource) A configuration block for restoring a DB instance to an arbitrary point in time. Requires the `identifier` argument to be set with the name of the new DB instance to be created. See [Restore To Point In Time](#restore-to-point-in-time) below for details. * `skip_final_snapshot` - (Optional) Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from `final_snapshot_identifier`. Default is `false`. * `snapshot_identifier` - (Optional) Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot. Automated snapshots **should not** be used for this attribute, unless from a different cluster. Automated snapshots are deleted as part of cluster destruction when the resource is replaced. * `storage_encrypted` - (Optional) Specifies whether the DB cluster is encrypted. The default is `false`. @@ -78,6 +79,13 @@ Default: A 30-minute window selected at random from an 8-hour block of time per * `vpc_security_group_ids` - (Optional) List of VPC security groups to associate with the Cluster +The `restore_to_point_in_time` block supports the following arguments: + +* `restore_to_time` - (Optional) The date and time to restore from. Value must be a time in Universal Coordinated Time (UTC) format and must be before the latest restorable time for the DB instance. Cannot be specified with `use_latest_restorable_time`. +* `restore_type` - (Optional) The type of restore to be performed. Valid values are `full-copy`, `copy-on-write`. +* `source_cluster_identifier` - (Required) The identifier of the source DB cluster from which to restore. Must match the identifier of an existing DB cluster. +* `use_latest_restorable_time` - (Optional) A boolean value that indicates whether the DB cluster is restored from the latest backup time. Defaults to `false`. Cannot be specified with `restore_to_time`. + ## Attribute Reference This resource exports the following attributes in addition to the arguments above: From fab55db1281d7247dc221a471d3f1cf5c4a7beb2 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:44:33 +0100 Subject: [PATCH 05/12] aws_docdb_cluster --- internal/service/docdb/cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index 528c6e460b86..1027ccfd3e59 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -1294,7 +1294,7 @@ resource "aws_docdb_cluster" "test" { func testAccClusterConfig_pointInTimeRestoreSource(rName string) string { return acctest.ConfigCompose(testAccClusterConfig_baseForPITR(rName), fmt.Sprintf(` resource "aws_docdb_cluster" "restore" { - cluster_identifier = %[1]q + cluster_identifier = "%[1]s-restore" restore_to_point_in_time { source_cluster_identifier = aws_docdb_cluster.test.cluster_identifier From 62298715fadc0fdc71fd1dde1d1a87c475c5afa2 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:46:04 +0100 Subject: [PATCH 06/12] aws_docdb_cluster --- internal/service/docdb/consts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/docdb/consts.go b/internal/service/docdb/consts.go index 734e5174cde9..58d24ebcead2 100644 --- a/internal/service/docdb/consts.go +++ b/internal/service/docdb/consts.go @@ -80,4 +80,4 @@ func RestoreType_Values() []string { RestoreTypeCopyOnWrite, RestoreTypeFullCopy, } -} \ No newline at end of file +} From 39e2e5270c350a7487faddc8ddb9db048da84bf9 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 21:50:34 +0100 Subject: [PATCH 07/12] aws_docdb_cluster --- internal/service/docdb/cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index 1027ccfd3e59..da6cbd21a8e8 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -1298,7 +1298,7 @@ resource "aws_docdb_cluster" "restore" { restore_to_point_in_time { source_cluster_identifier = aws_docdb_cluster.test.cluster_identifier - restore_type = "standard" + restore_type = "full-copy" use_latest_restorable_time = true } } From 0daa53766acf491541e04da7b487df1e7a221670 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 22:09:29 +0100 Subject: [PATCH 08/12] aws_docdb_cluster --- internal/service/docdb/cluster_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index da6cbd21a8e8..846ad860da2f 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -492,6 +492,7 @@ func TestAccDocDBCluster_pointInTimeRestore(t *testing.T) { names.AttrApplyImmediately, "final_snapshot_identifier", "master_password", + "restore_to_point_in_time", "skip_final_snapshot", }, }, @@ -1301,6 +1302,8 @@ resource "aws_docdb_cluster" "restore" { restore_type = "full-copy" use_latest_restorable_time = true } + + skip_final_snapshot = true } `, rName)) } From 23ee9ae5fc146e2e1567c50c2cd42bcab8b908d3 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 26 May 2024 22:15:17 +0100 Subject: [PATCH 09/12] aws_docdb_cluster --- website/docs/r/docdb_cluster.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/r/docdb_cluster.html.markdown b/website/docs/r/docdb_cluster.html.markdown index abb924512efb..8309fd162280 100644 --- a/website/docs/r/docdb_cluster.html.markdown +++ b/website/docs/r/docdb_cluster.html.markdown @@ -79,6 +79,8 @@ Default: A 30-minute window selected at random from an 8-hour block of time per * `vpc_security_group_ids` - (Optional) List of VPC security groups to associate with the Cluster +### Restore To Point In Time + The `restore_to_point_in_time` block supports the following arguments: * `restore_to_time` - (Optional) The date and time to restore from. Value must be a time in Universal Coordinated Time (UTC) format and must be before the latest restorable time for the DB instance. Cannot be specified with `use_latest_restorable_time`. From 71cffc338ba8c382fef9b77b14b5829df8e1fcdc Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 14 Jun 2024 11:17:24 -0500 Subject: [PATCH 10/12] aws_docdb_cluster: tweaks to use AWS sdkv2 --- internal/service/docdb/cluster.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/docdb/cluster.go b/internal/service/docdb/cluster.go index 2d06af24dc43..d6257d1d0f03 100644 --- a/internal/service/docdb/cluster.go +++ b/internal/service/docdb/cluster.go @@ -410,8 +410,8 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int } if v, ok := tfMap["restore_to_time"].(string); ok && v != "" { - v, _ := time.Parse(time.RFC3339, v) - input.RestoreToTime = aws.Time(v) + t, _ := time.Parse(time.RFC3339, v) + input.RestoreToTime = aws.Time(t) } if v, ok := tfMap["use_latest_restorable_time"].(bool); ok && v { @@ -427,7 +427,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int } if v, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && len(v.([]interface{})) > 0 { - input.EnableCloudwatchLogsExports = flex.ExpandStringList(v.([]interface{})) + input.EnableCloudwatchLogsExports = flex.ExpandStringValueList(v.([]interface{})) } if v, ok := tfMap["restore_type"].(string); ok { @@ -439,7 +439,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta 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(names.AttrStorageType); ok { @@ -447,11 +447,11 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int } if v := d.Get(names.AttrVPCSecurityGroupIDs).(*schema.Set); v.Len() > 0 { - input.VpcSecurityGroupIds = flex.ExpandStringSet(v) + input.VpcSecurityGroupIds = flex.ExpandStringValueSet(v) } _, err := tfresource.RetryWhenAWSErrMessageContains(ctx, propagationTimeout, func() (interface{}, error) { - return conn.RestoreDBClusterToPointInTimeWithContext(ctx, input) + return conn.RestoreDBClusterToPointInTime(ctx, input) }, errCodeInvalidParameterValue, "IAM role ARN value is invalid or does not include the required permissions") if err != nil { return sdkdiag.AppendErrorf(diags, "creating DocumentDB Cluster (restore to point-in-time) (%s): %s", identifier, err) From d9378c7a71a66d1de620a5420d3780bea77584ce Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 14 Jun 2024 12:52:27 -0500 Subject: [PATCH 11/12] aws_docdb_cluster: tweaks test to use AWS sdkv2 --- internal/service/docdb/cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index b227813eb7d3..5ff29d4b470e 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -466,7 +466,7 @@ func TestAccDocDBCluster_backupsUpdate(t *testing.T) { func TestAccDocDBCluster_pointInTimeRestore(t *testing.T) { ctx := acctest.Context(t) - var dbCluster docdb.DBCluster + var dbCluster awstypes.DBCluster rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) sourceResourceName := "aws_docdb_cluster.test" resourceName := "aws_docdb_cluster.restore" From 9ce36edc6bc0c0b4efd9a25475fe914db1b8b66d Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 14 Jun 2024 13:07:37 -0500 Subject: [PATCH 12/12] chore: semgrep fix --- internal/service/docdb/cluster.go | 2 +- internal/service/docdb/cluster_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/docdb/cluster.go b/internal/service/docdb/cluster.go index d6257d1d0f03..271e35d842c8 100644 --- a/internal/service/docdb/cluster.go +++ b/internal/service/docdb/cluster.go @@ -405,7 +405,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int input := &docdb.RestoreDBClusterToPointInTimeInput{ DBClusterIdentifier: aws.String(identifier), SourceDBClusterIdentifier: aws.String(tfMap["source_cluster_identifier"].(string)), - DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)), + DeletionProtection: aws.Bool(d.Get(names.AttrDeletionProtection).(bool)), Tags: getTagsIn(ctx), } diff --git a/internal/service/docdb/cluster_test.go b/internal/service/docdb/cluster_test.go index 5ff29d4b470e..791541ea9536 100644 --- a/internal/service/docdb/cluster_test.go +++ b/internal/service/docdb/cluster_test.go @@ -489,9 +489,9 @@ func TestAccDocDBCluster_pointInTimeRestore(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "allow_major_version_upgrade", + names.AttrAllowMajorVersionUpgrade, names.AttrApplyImmediately, - "final_snapshot_identifier", + names.AttrFinalSnapshotIdentifier, "master_password", "restore_to_point_in_time", "skip_final_snapshot",