Skip to content

Commit ad46653

Browse files
committed
test(dynamodb): fence the local-replica-only GSI read-capacity derivation (#1452)
A live CloudFormation probe (stack Cdkd1452ProbeXRegionRead, us-east-1 + us-west-2, 2026-08-10) disproved the CapacityAutoScalingSettings doc sentence that motivated the issue. A GlobalTable whose local replica GSI carried SeedCapacity 10 (MinCapacity 1) and whose remote replica GSI carried a fixed ReadCapacityUnits 20 came up with ReadCapacityUnits 1 in us-east-1 and a ProvisionedThroughputOverride of 20 on the us-west-2 replica -- no cross-region max, and the remote value scoped to the remote replica. So deriving read capacity from the LOCAL replica alone is CORRECT and cdkd needs no source change. This adds the probe shape as a regression fence so a future reader who finds the same doc sentence cannot turn it into a cross-region max, with the transcript inlined in the test comment. The same run independently re-confirmed issue #1435's MinCapacity-on-create finding on a new template shape.
1 parent d4d0280 commit ad46653

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

tests/unit/provisioning/dynamodb-globaltable-provider-gsi-throughput.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,81 @@ describe('DynamoDBGlobalTable GSI throughput translation (issue #1387)', () => {
361361
expect(gsi!.OnDemandThroughput).toBeUndefined();
362362
});
363363

364+
// Issue #1452 FENCE. The CFn docs for CapacityAutoScalingSettings claim a
365+
// CROSS-REGION max: "if your global secondary index myGSI has a
366+
// SeedCapacity of 10 in us-east-1 and a fixed ReadCapacityUnits of 20 in
367+
// eu-west-1, CloudFormation will initially set the read capacity for myGSI
368+
// to 20." A live probe DISPROVED that sentence, so deriving read capacity
369+
// from the LOCAL replica alone is CORRECT and must stay that way.
370+
//
371+
// Probe (stack Cdkd1452ProbeXRegionRead, us-east-1 + us-west-2, 2026-08-10):
372+
// an AWS::DynamoDB::GlobalTable whose local (us-east-1) replica GSI carried
373+
// ReadCapacityAutoScalingSettings{MinCapacity 1, MaxCapacity 100,
374+
// SeedCapacity 10} and whose remote (us-west-2) replica GSI carried a fixed
375+
// ReadCapacityUnits 20 reached CREATE_COMPLETE with:
376+
// us-east-1 myGSI ProvisionedThroughput.ReadCapacityUnits = 1
377+
// us-west-2 myGSI ProvisionedThroughputOverride.ReadCapacityUnits = 20
378+
// So CloudFormation took the LOCAL replica's MinCapacity (1) and applied
379+
// the remote's 20 only as that replica's own override. It took neither the
380+
// remote's higher value NOR the local SeedCapacity — the latter
381+
// independently re-confirming issue #1435's 'min'-on-create finding.
382+
//
383+
// Taking a max across replicas here would OVER-provision every such table
384+
// and diverge from CloudFormation. This is the same failure mode as #1427,
385+
// whose doc-derived premise the same probe family also disproved.
386+
it('does NOT raise the local read capacity to a higher REMOTE replica value (issue #1452)', () => {
387+
const [gsi] = toSdkGlobalSecondaryIndexes(
388+
{
389+
BillingMode: 'PROVISIONED',
390+
GlobalSecondaryIndexes: [
391+
{
392+
IndexName: 'myGSI',
393+
KeySchema: [{ AttributeName: 'gsipk', KeyType: 'HASH' }],
394+
Projection: { ProjectionType: 'KEYS_ONLY' },
395+
WriteProvisionedThroughputSettings: {
396+
WriteCapacityAutoScalingSettings: { MinCapacity: 1, MaxCapacity: 10 },
397+
},
398+
},
399+
],
400+
Replicas: [
401+
{
402+
Region: 'us-east-1',
403+
GlobalSecondaryIndexes: [
404+
{
405+
IndexName: 'myGSI',
406+
ReadProvisionedThroughputSettings: {
407+
ReadCapacityAutoScalingSettings: {
408+
MinCapacity: 1,
409+
MaxCapacity: 100,
410+
SeedCapacity: 10,
411+
},
412+
},
413+
},
414+
],
415+
},
416+
{
417+
Region: 'us-west-2',
418+
GlobalSecondaryIndexes: [
419+
{
420+
IndexName: 'myGSI',
421+
ReadProvisionedThroughputSettings: { ReadCapacityUnits: 20 },
422+
},
423+
],
424+
},
425+
],
426+
},
427+
'us-east-1',
428+
'PROVISIONED'
429+
);
430+
// 1 = the LOCAL replica's MinCapacity. NOT 20 (the remote replica's
431+
// fixed value) and NOT 10 (the local SeedCapacity) — both were rejected
432+
// by the live probe above.
433+
expect(gsi!.ProvisionedThroughput).toEqual({
434+
ReadCapacityUnits: 1,
435+
WriteCapacityUnits: 1,
436+
});
437+
});
438+
364439
it('maps the on-demand CDK shape to SDK OnDemandThroughput (both directions)', () => {
365440
const [gsi] = toSdkGlobalSecondaryIndexes(
366441
ON_DEMAND_TABLE_PROPS,

0 commit comments

Comments
 (0)