aws / aws/aws-cdk

(RDS): CDK overwrites DatabaseInstance AllocatedStorage back to default (100) on every deploy

Open
#12,916 9 comments 5 reactions 0 assignees View on GitHub
@aws-cdk/aws-rds bug needs-cfn p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

The default behaviour of an RDS service update (specifically DatabaseInstance) is to maintain the existing AllocatedStorage if no value is specified by the user. Users often use RDS storage autoscaling, while setting only MaxAllocatedStorage.
The CFN definition for AllocatedStorage is optional hence expected behaviour at the time of the deploy is to retain the existing AllocatedStorage.

However when you leave AllocatedStorage out of the DatabaseInstance construct in CDK it instead sets it to 100.
This tries to overrides whatever the current AllocatedStorage is, which, as mentioned, already increased by the storage autoscaling which raises an error.

### Reproduction Steps

1. Deploy RDS DatabaseInstance with MaxAllocatedStorage set to 500 (without setting AllocatedStorage)
2. Letting the autoscale get into action to increase allocated storage to > 500
3. Deploy the stack again with some minor change, i.e increase the MaxAllocatedStorage to 1000

### What did you expect to happen?

Deploy should not assign default value (100) for AllocatedStorage, instead ket the CF use current value.

### What actually happened?

```
1/3 | 12:27:21 PM | UPDATE_FAILED | AWS::RDS::DBInstance | SpansDatabaseInstance (SpansDatabaseInstance76A399EE) Invalid storage size for engine name postgres and storage type gp2: 100 (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 33851626-63a7-4b91-9451-374ae492aa57; Proxy: null)
new DatabaseInstance (/private/var/folders/_l/mhjrnwdj54ld1fb77tlsw6bw0000gn/T/jsii-kernel-5b0Vtn/node_modules/@aws-cdk/aws-rds/lib/instance.js:352:26)
\_ GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:3589:49
\_ Kernel._wrapSandboxCode (GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:4073:16)
\_ Kernel._create (GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:3589:26)
\_ Kernel.create (GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:3324:21)
\_ KernelHost.processRequest (GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:13191:28)
\_ KernelHost.run (GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:13129:14)
\_ Immediate._onImmediate (GitProjects/epsagon-backend/venv/lib/python3.6/site-packages/jsii/_embedded/jsii/jsii-runtime.js:13132:37)
\_ processImmediate (internal/timers.js:456:21)
```

### Workaround

To set the the CDK AllocatedStorage to the real current value taken from the RDS console.

### Environment

- **CDK CLI Version :** 1.87.0
- **Framework Version:** 1.87.0
- **Node.js Version:** 12.18.2
- **Language (Version):** Python 3.6.5

---

This is :bug: Bug Report

Contributor guide

Open the contributing guide

Research direction

Start at the DatabaseInstance construct and inspect how omitted AllocatedStorage is translated into the CloudFormation RDS definition. Reproduce the update with MaxAllocatedStorage and autoscaled storage, then verify that a deploy without AllocatedStorage preserves the current value instead of sending 100.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, postgresql, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.