diff --git a/.changelog/37570.txt b/.changelog/37570.txt new file mode 100644 index 00000000000..e2a6da5e108 --- /dev/null +++ b/.changelog/37570.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_dynamodb_table_replica: Correctly set `kms_key_arn` on Read +``` diff --git a/internal/service/dynamodb/table_replica.go b/internal/service/dynamodb/table_replica.go index 92e8fa3b90a..6ca59eacfec 100644 --- a/internal/service/dynamodb/table_replica.go +++ b/internal/service/dynamodb/table_replica.go @@ -75,8 +75,8 @@ func resourceTableReplica() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ValidateFunc: verify.ValidARN, ForceNew: true, + ValidateFunc: verify.ValidARN, }, "point_in_time_recovery": { // direct to replica Type: schema.TypeBool, @@ -297,6 +297,10 @@ func resourceTableReplicaReadReplica(ctx context.Context, d *schema.ResourceData return create.AppendDiagError(diags, names.DynamoDB, create.ErrActionReading, resNameTableReplica, d.Id(), fmt.Errorf("continuous backups: %w", err)) } + if table.SSEDescription != nil && table.SSEDescription.KMSMasterKeyArn != nil { + d.Set(names.AttrKMSKeyARN, table.SSEDescription.KMSMasterKeyArn) + } + if pitrOut != nil && pitrOut.ContinuousBackupsDescription != nil && pitrOut.ContinuousBackupsDescription.PointInTimeRecoveryDescription != nil { d.Set("point_in_time_recovery", pitrOut.ContinuousBackupsDescription.PointInTimeRecoveryDescription.PointInTimeRecoveryStatus == awstypes.PointInTimeRecoveryStatusEnabled) } else { diff --git a/internal/service/dynamodb/table_replica_test.go b/internal/service/dynamodb/table_replica_test.go index abb809d04e0..e47f5ec1b9e 100644 --- a/internal/service/dynamodb/table_replica_test.go +++ b/internal/service/dynamodb/table_replica_test.go @@ -176,7 +176,7 @@ func TestAccDynamoDBTableReplica_pitrDefault(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckTableReplicaExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "point_in_time_recovery", "false"), - resource.TestCheckResourceAttr(resourceName, names.AttrKMSKeyARN, ""), + resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyARN), ), }, { @@ -184,7 +184,7 @@ func TestAccDynamoDBTableReplica_pitrDefault(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckTableReplicaExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "point_in_time_recovery", "true"), - resource.TestCheckResourceAttr(resourceName, names.AttrKMSKeyARN, ""), + resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyARN), ), }, { @@ -192,7 +192,7 @@ func TestAccDynamoDBTableReplica_pitrDefault(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckTableReplicaExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "point_in_time_recovery", "false"), - resource.TestCheckResourceAttr(resourceName, names.AttrKMSKeyARN, ""), + resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyARN), ), }, {