Skip to content

Commit b824543

Browse files
authored
add TableReplica field (#125)
Description of changes: Adding `TableReplica` Support as part of the minor release instead of a patch that was done and reverted. [Original Changes] This PR implements support for managing DynamoDB table replicas through the tableReplicas field. This enhancement allows users to manage multi-region table replicas that automatically remain in sync. This is complemented by a replicaDescription field in the Table status for tracking replica states. Changes Overview - Added tableReplicas field to Table spec for defining replica configurations across regions - Added controller logic for replica lifecycle management (creation, updates, deletion) - Implemented validation rules: - DynamoDB Streams must be enabled with NEW_AND_OLD_IMAGES - Terminal error conditions for invalid configurations - E2E tests By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 5f9432a commit b824543

File tree

7 files changed

+979
-20
lines changed

7 files changed

+979
-20
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ack_generate_info:
2-
build_date: "2025-03-27T16:23:51Z"
2+
build_date: "2025-03-28T01:43:12Z"
33
build_hash: 980cb1e4734f673d16101cf55206b84ca639ec01
44
go_version: go1.24.1
55
version: v0.44.0

pkg/resource/table/hooks.go

+20-19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package table
1515

1616
import (
1717
"context"
18+
"errors"
1819
"fmt"
1920
"strings"
2021
"time"
@@ -232,17 +233,17 @@ func (rm *resourceManager) customUpdateTable(
232233
}
233234
return nil, err
234235
}
235-
// case delta.DifferentAt("Spec.TableReplicas"):
236-
// // Enabling replicas required streams enabled and StreamViewType to be NEW_AND_OLD_IMAGES
237-
// // Version 2019.11.21 TableUpdate API requirement
238-
// if !hasStreamSpecificationWithNewAndOldImages(desired) {
239-
// msg := "table must have DynamoDB Streams enabled with StreamViewType set to NEW_AND_OLD_IMAGES for replica updates"
240-
// rlog.Debug(msg)
241-
// return nil, ackerr.NewTerminalError(errors.New(msg))
242-
// }
243-
// if err := rm.syncReplicas(ctx, latest, desired); err != nil {
244-
// return nil, err
245-
// }
236+
case delta.DifferentAt("Spec.TableReplicas"):
237+
// Enabling replicas required streams enabled and StreamViewType to be NEW_AND_OLD_IMAGES
238+
// Version 2019.11.21 TableUpdate API requirement
239+
if !hasStreamSpecificationWithNewAndOldImages(desired) {
240+
msg := "table must have DynamoDB Streams enabled with StreamViewType set to NEW_AND_OLD_IMAGES for replica updates"
241+
rlog.Debug(msg)
242+
return nil, ackerr.NewTerminalError(errors.New(msg))
243+
}
244+
if err := rm.syncReplicas(ctx, latest, desired); err != nil {
245+
return nil, err
246+
}
246247
}
247248
}
248249

@@ -577,14 +578,14 @@ func customPreCompare(
577578
}
578579
}
579580

580-
// // Handle ReplicaUpdates API comparison
581-
// if len(a.ko.Spec.TableReplicas) != len(b.ko.Spec.TableReplicas) {
582-
// delta.Add("Spec.TableReplicas", a.ko.Spec.TableReplicas, b.ko.Spec.TableReplicas)
583-
// } else if a.ko.Spec.TableReplicas != nil && b.ko.Spec.TableReplicas != nil {
584-
// if !equalReplicaArrays(a.ko.Spec.TableReplicas, b.ko.Spec.TableReplicas) {
585-
// delta.Add("Spec.TableReplicas", a.ko.Spec.TableReplicas, b.ko.Spec.TableReplicas)
586-
// }
587-
// }
581+
// Handle ReplicaUpdates API comparison
582+
if len(a.ko.Spec.TableReplicas) != len(b.ko.Spec.TableReplicas) {
583+
delta.Add("Spec.TableReplicas", a.ko.Spec.TableReplicas, b.ko.Spec.TableReplicas)
584+
} else if a.ko.Spec.TableReplicas != nil && b.ko.Spec.TableReplicas != nil {
585+
if !equalReplicaArrays(a.ko.Spec.TableReplicas, b.ko.Spec.TableReplicas) {
586+
delta.Add("Spec.TableReplicas", a.ko.Spec.TableReplicas, b.ko.Spec.TableReplicas)
587+
}
588+
}
588589

589590
if a.ko.Spec.DeletionProtectionEnabled == nil {
590591
a.ko.Spec.DeletionProtectionEnabled = aws.Bool(false)

0 commit comments

Comments
 (0)