aws / aws/aws-cdk

DynamoDB GSI Autoscaling doesn't require a scaling policy, leading to invalid infrastructure configuration

Open
#7,464 3 comments 3 reactions 0 assignees View on GitHub
@aws-cdk/aws-dynamodb bug ddb-legacy-table effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### DynamoDB GSI Autoscaling doesn't require a scaling policy, leading to invalid infrastructure configuration

#### Background

When using GSI Autoscaling, it's possible to add autoscaling targets without adding an associated scaling policy.

```
table.addGlobalSecondaryIndex({
indexName: props.indexName,
partitionKey: props.partitionKey,
sortKey: props.sortKey,
});
table.autoScaleGlobalSecondaryIndexReadCapacity(props.indexName, {
minCapacity: props.minReadCapacity,
maxCapacity: props.maxReadCapacity,
});
table.autoScaleGlobalSecondaryIndexWriteCapacity(props.indexName, {
minCapacity: props.minWriteCapacity,
maxCapacity: props.maxWriteCapacity,
});
```

When you do that, CDK (nor the underlying CloudFormation) error on the invalid configuration.

#### What's the impact
The end result is that DynamoDB results in failing to autoscale the GSI, resulting in the GSI only using the default levels, with the only notification to the customer being an "ERROR" field when looking at the GSI.

Currently, nothing prevents the customer from ending up with an invalid autoscaling configuration, that'll only get caught when they need autoscaling the most.

#### What should CDK do
In my opinion, CDK should fail the build because of the invalid autoscaling configuration on the GSI.

I imagine it'd be possible to detect whether no scaling policy was added for the GSI (either through the helpers, or manually through lower-level cloudformation resources)

#### Potential "gotchas" with the implementation
* A customer could add the underlying scaling policy using the low-level resource types themselves.

Contributor guide

Open the contributing guide

Research direction

Trace the GSI autoscaling helper methods and the underlying low-level CloudFormation resources they create. Check how an autoscaling target without a scaling policy is represented, including policies added through low-level resources; done means the invalid configuration is rejected without incorrectly rejecting a valid manually configured policy.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.