Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with AWS not return KMS key for replica #37570

Merged
merged 8 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/37570.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_dynamodb_table_replica: Correctly set `kms_key_arn` on Read
```
6 changes: 5 additions & 1 deletion internal/service/dynamodb/table_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions internal/service/dynamodb/table_replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,23 @@ 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),
),
},
{
Config: testAccTableReplicaConfig_pitrDefault(rName, true),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableReplicaExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "point_in_time_recovery", "true"),
resource.TestCheckResourceAttr(resourceName, names.AttrKMSKeyARN, ""),
resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyARN),
),
},
{
Config: testAccTableReplicaConfig_pitrDefault(rName, false),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableReplicaExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "point_in_time_recovery", "false"),
resource.TestCheckResourceAttr(resourceName, names.AttrKMSKeyARN, ""),
resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyARN),
),
},
{
Expand Down
Loading