@aws-blocks/bb-distributed-table 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +18 -1
- package/README.md +57 -1
- package/dist/index.aws.d.ts +3 -2
- package/dist/index.aws.d.ts.map +1 -1
- package/dist/index.aws.js +3 -0
- package/dist/index.cdk.d.ts +12 -2
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +137 -11
- package/dist/index.cdk.test.js +300 -1
- package/dist/index.mock.d.ts +3 -2
- package/dist/index.mock.d.ts.map +1 -1
- package/dist/index.mock.js +3 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/src/index.aws.ts +6 -0
- package/src/index.cdk.test.ts +327 -1
- package/src/index.cdk.ts +152 -13
- package/src/index.mock.ts +6 -0
- package/src/types.ts +85 -0
- package/src/version.ts +1 -1
package/src/types.ts
CHANGED
|
@@ -57,6 +57,80 @@ export interface DistributedTableOptions<
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
ttl?: keyof T & string;
|
|
60
|
+
/**
|
|
61
|
+
* DynamoDB Point-in-Time Recovery (continuous backups) — restore the table
|
|
62
|
+
* to any second within a retention window, protecting against accidental
|
|
63
|
+
* writes/deletes and logical corruption.
|
|
64
|
+
*
|
|
65
|
+
* A single knob, since the recovery window only means anything when PITR is
|
|
66
|
+
* on:
|
|
67
|
+
* - `true` — enable PITR with the default 35-day window.
|
|
68
|
+
* - `false` — disable PITR.
|
|
69
|
+
* - `{ retentionDays: n }` — enable PITR and keep `n` days of continuous
|
|
70
|
+
* backups (**1–35**). A shorter window reduces backup-storage cost at the
|
|
71
|
+
* expense of how far back you can restore.
|
|
72
|
+
*
|
|
73
|
+
* When omitted, the stack-wide default applies (`defaults.pointInTimeRecovery`
|
|
74
|
+
* from `BlocksPresets` — on under `production`, off under `sandbox`). A
|
|
75
|
+
* per-block value always wins.
|
|
76
|
+
*
|
|
77
|
+
* Note: PITR bills for continuous-backup storage (per GB-month of table
|
|
78
|
+
* size), so it is not free on large tables.
|
|
79
|
+
*/
|
|
80
|
+
pointInTimeRecovery?: boolean | { retentionDays: number };
|
|
81
|
+
/**
|
|
82
|
+
* How hard the table is to destroy — a single knob spanning DynamoDB
|
|
83
|
+
* deletion protection and the CloudFormation removal policy, which together
|
|
84
|
+
* answer one question: "can this table be destroyed?"
|
|
85
|
+
*
|
|
86
|
+
* - `'disposable'`: `RemovalPolicy.DESTROY`, deletion protection **off**.
|
|
87
|
+
* Deleting the stack deletes the table. The **sandbox default** — keeps
|
|
88
|
+
* `sandbox:destroy` a one-command teardown.
|
|
89
|
+
* - `'retained'`: `RemovalPolicy.RETAIN`, deletion protection **off**.
|
|
90
|
+
* Deleting the stack orphans (keeps) the table, but a direct
|
|
91
|
+
* `DeleteTable`/console delete still works. Use when you want the data to
|
|
92
|
+
* survive stack teardown without blocking intentional deletes.
|
|
93
|
+
* - `'locked'`: `RemovalPolicy.RETAIN` **and** deletion protection **on**.
|
|
94
|
+
* The table survives stack deletion and DynamoDB refuses a direct delete
|
|
95
|
+
* until protection is turned off. The **production default**.
|
|
96
|
+
*
|
|
97
|
+
* When omitted, removal policy and deletion protection follow the stack-wide
|
|
98
|
+
* `defaults` (`BlocksPresets.production` ≈ `'locked'`, `BlocksPresets.sandbox`
|
|
99
|
+
* ≈ `'disposable'`). A per-block value always wins.
|
|
100
|
+
*
|
|
101
|
+
* Replaces the separate `deletionProtection` + `removalPolicy` booleans:
|
|
102
|
+
* those two knobs could encode the contradictory `deletionProtection: true`
|
|
103
|
+
* + `removalPolicy: 'destroy'` state, which wedges stack deletion (CFN
|
|
104
|
+
* issues `DeleteTable`, DynamoDB refuses it, the stack lands in
|
|
105
|
+
* `DELETE_FAILED`). A single enum makes that state unrepresentable.
|
|
106
|
+
*/
|
|
107
|
+
protection?: 'disposable' | 'retained' | 'locked';
|
|
108
|
+
/**
|
|
109
|
+
* Server-side encryption at rest.
|
|
110
|
+
*
|
|
111
|
+
* - `'aws-managed'` (default): SSE with the AWS-managed `aws/dynamodb` KMS
|
|
112
|
+
* key. Auditable via CloudTrail with no per-key monthly charge.
|
|
113
|
+
* - `'customer-managed'`: provisions a **dedicated** customer-managed KMS
|
|
114
|
+
* key (CMK) for this table, giving you full control over rotation and key
|
|
115
|
+
* policy. Incurs standard KMS key + request charges — and note this mints
|
|
116
|
+
* a **separate key per table**, so a dozen tables means a dozen keys.
|
|
117
|
+
* - a {@link ExternalKmsKeyRef} from {@link DistributedTable.fromKmsKey}:
|
|
118
|
+
* uses an **existing** CMK you already own, so several tables can share one
|
|
119
|
+
* key (and one monthly charge) instead of each provisioning its own.
|
|
120
|
+
*
|
|
121
|
+
* DynamoDB is always encrypted at rest; this only selects the key.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* // Share one key across several tables
|
|
126
|
+
* const key = DistributedTable.fromKmsKey(
|
|
127
|
+
* 'arn:aws:kms:us-east-1:111122223333:key/abcd-1234',
|
|
128
|
+
* );
|
|
129
|
+
* new DistributedTable(scope, 'orders', { schema, key: { partitionKey: 'id' }, encryption: key });
|
|
130
|
+
* new DistributedTable(scope, 'events', { schema, key: { partitionKey: 'id' }, encryption: key });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
encryption?: 'aws-managed' | 'customer-managed' | ExternalKmsKeyRef;
|
|
60
134
|
/**
|
|
61
135
|
* How reads (`get`, `getBatch`, `query`, `scan`) reconcile a stored item with
|
|
62
136
|
* the configured `schema`. Writes (`put`/`putBatch`) always validate; this
|
|
@@ -109,6 +183,17 @@ export interface ExternalTableRef {
|
|
|
109
183
|
readonly tableName: string;
|
|
110
184
|
}
|
|
111
185
|
|
|
186
|
+
/**
|
|
187
|
+
* A reference to an existing customer-managed KMS key, produced by
|
|
188
|
+
* {@link DistributedTable.fromKmsKey}. Pass it as the `encryption` option to
|
|
189
|
+
* encrypt the table with a CMK you already own — letting several tables share
|
|
190
|
+
* one key instead of each provisioning its own dedicated key.
|
|
191
|
+
*/
|
|
192
|
+
export interface ExternalKmsKeyRef {
|
|
193
|
+
readonly __brand: 'ExternalKmsKeyRef';
|
|
194
|
+
readonly keyArn: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
112
197
|
// ── Key type for get/delete ─────────────────────────────────────────────────
|
|
113
198
|
|
|
114
199
|
/**
|
package/src/version.ts
CHANGED