Skip to content

Commit 9bdbf14

Browse files
fix(cdk): enable Point-in-Time Recovery on UserConcurrencyTable (#205) (#206)
Aligns the last remaining DynamoDB table with the project-wide default of PITR enabled. Adds opt-out prop for consistency with other table constructs. Co-authored-by: bgagent <345885+scottschreckengaust@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 629882e commit 9bdbf14

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

cdk/src/constructs/user-concurrency-table.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export interface UserConcurrencyTableProps {
3636
* @default RemovalPolicy.DESTROY
3737
*/
3838
readonly removalPolicy?: RemovalPolicy;
39+
40+
/**
41+
* Whether to enable point-in-time recovery.
42+
* @default true
43+
*/
44+
readonly pointInTimeRecovery?: boolean;
3945
}
4046

4147
/**
@@ -44,9 +50,6 @@ export interface UserConcurrencyTableProps {
4450
* Schema: user_id (PK). Each item holds an atomic counter (active_count)
4551
* representing the number of currently running tasks for the user.
4652
* The application layer uses conditional updates for increment/decrement.
47-
*
48-
* No point-in-time recovery: this is transient counter data that can be
49-
* reconstructed from the Tasks table by a reconciliation process.
5053
*/
5154
export class UserConcurrencyTable extends Construct {
5255
/**
@@ -64,6 +67,9 @@ export class UserConcurrencyTable extends Construct {
6467
type: dynamodb.AttributeType.STRING,
6568
},
6669
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
70+
pointInTimeRecoverySpecification: {
71+
pointInTimeRecoveryEnabled: props.pointInTimeRecovery ?? true,
72+
},
6773
removalPolicy: props.removalPolicy ?? RemovalPolicy.DESTROY,
6874
});
6975
}

cdk/test/constructs/user-concurrency-table.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ describe('UserConcurrencyTable', () => {
4545
});
4646
});
4747

48-
test('does not enable point-in-time recovery', () => {
48+
test('enables point-in-time recovery by default', () => {
4949
template.hasResourceProperties('AWS::DynamoDB::Table', {
50-
PointInTimeRecoverySpecification: Match.absent(),
50+
PointInTimeRecoverySpecification: {
51+
PointInTimeRecoveryEnabled: true,
52+
},
5153
});
5254
});
5355

@@ -96,4 +98,17 @@ describe('UserConcurrencyTable with custom props', () => {
9698
UpdateReplacePolicy: 'Retain',
9799
});
98100
});
101+
102+
test('allows disabling point-in-time recovery', () => {
103+
const app = new App();
104+
const stack = new Stack(app, 'TestStack');
105+
new UserConcurrencyTable(stack, 'UserConcurrencyTable', { pointInTimeRecovery: false });
106+
const template = Template.fromStack(stack);
107+
108+
template.hasResourceProperties('AWS::DynamoDB::Table', {
109+
PointInTimeRecoverySpecification: {
110+
PointInTimeRecoveryEnabled: false,
111+
},
112+
});
113+
});
99114
});

0 commit comments

Comments
 (0)