aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

[AWS::ElastiCache::ServerlessCache] - [BUG] - cannot unset CacheUsageLimits.DataStorage properties once set

Open
#2,424 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::ElastiCache::ServerlessCache

### Resource Name

_No response_

### Issue Description

After creating a ValKey serverless cache and setting the `CacheUsageLimits.DataStorage.Minimum` property to any value, as in the example:

```
ValKey:
Type: AWS::ElastiCache::ServerlessCache
Properties:
CacheUsageLimits:
DataStorage:
Maximum: 10
Minimum: 1
Unit: GB
DailySnapshotTime: "03:00"
Description: !Ref "AWS::StackName"
Engine: Valkey
KmsKeyId: !Ref KmsKey
MajorEngineVersion: 8
SecurityGroupIds:
- !Ref SecurityGroup
ServerlessCacheName: !Ref CacheName
SnapshotRetentionLimit: 35
SubnetIds: !Ref Subnets
UserGroupId: !Ref UserGroup
```

Trying to update the stack to remove the property fails with
```
Resource handler returned message: "null" (RequestToken: xxx, HandlerErrorCode: InternalFailure)
```
That happens when the property is not present or set to `!Ref "AWS::NoValue"`. The property is marked as non-required in the documentation, so it should be possible to remove it.

To reset (remove) the value from configuration through CloudFormation in this situation, it needs to be set to `0` (zero), as follows:
```
Properties:
CacheUsageLimits:
DataStorage:
Maximum: 10
Minimum: 0
Unit: GB
```

This is confusing because:
1. The console suggests the minimal allowed value is `1` (one) and does not allow 0. It does allow the value to be empty. Which is exact opposite to how cloudformation behaves.
2. The Elasticache api follows the behaviour of the console - that is, the value can be empty (not set) or non-zero, it cannot be zero. See example output of when the value is not set:
```
"CacheUsageLimits": {
"DataStorage": {
"Maximum": 10,
"Unit": "GB"
}
},
```

I haven't tested it, but I'm assuming this likely affects other properties in `CacheUsageLimits` as well.

### Expected Behavior

It should be possible to remove any of the non-required properties even if they were initially set.

### Observed Behavior

Removing the property or setting it to `!Ref "AWS::NoValue"`, fails with
```
Resource handler returned message: "null" (RequestToken: xxx, HandlerErrorCode: InternalFailure)
```

Property needs to be set to `0` (zero) to unset it's value which is the opposite of how AWS API and Console behave.

### Test Cases

1. Create a Cache with the property set:
```
ValKey:
Type: AWS::ElastiCache::ServerlessCache
Properties:
CacheUsageLimits:
DataStorage:
Maximum: 10
Minimum: 1
Unit: GB
DailySnapshotTime: "03:00"
Description: !Ref "AWS::StackName"
Engine: Valkey
KmsKeyId: !Ref KmsKey
MajorEngineVersion: 8
SecurityGroupIds:
- !Ref SecurityGroup
ServerlessCacheName: !Ref CacheName
SnapshotRetentionLimit: 35
SubnetIds: !Ref Subnets
UserGroupId: !Ref UserGroup
```
2. Remove the property:

```
ValKey:
Type: AWS::ElastiCache::ServerlessCache
Properties:
CacheUsageLimits:
DataStorage:
Maximum: 10
Unit: GB
DailySnapshotTime: "03:00"
Description: !Ref "AWS::StackName"
Engine: Valkey
KmsKeyId: !Ref KmsKey
MajorEngineVersion: 8
SecurityGroupIds:
- !Ref SecurityGroup
ServerlessCacheName: !Ref CacheName
SnapshotRetentionLimit: 35
SubnetIds: !Ref Subnets
UserGroupId: !Ref UserGroup
```
3. See error.

4. Set the property to zero:
```
ValKey:
Type: AWS::ElastiCache::ServerlessCache
Properties:
CacheUsageLimits:
DataStorage:
Maximum: 10
Minimum: 0
Unit: GB
DailySnapshotTime: "03:00"
Description: !Ref "AWS::StackName"
Engine: Valkey
KmsKeyId: !Ref KmsKey
MajorEngineVersion: 8
SecurityGroupIds:
- !Ref SecurityGroup
ServerlessCacheName: !Ref CacheName
SnapshotRetentionLimit: 35
SubnetIds: !Ref Subnets
UserGroupId: !Ref UserGroup
```
5. Run `aws elasticache describe-serverless-caches` and see the property is not set:
```
{
"ServerlessCacheName": "xxx",
"Description": "x",
"CreateTime": "2025-11-04T17:11:29.318000+00:00",
"Status": "available",
"Engine": "valkey",
"MajorEngineVersion": "8",
"FullEngineVersion": "8.1",
"CacheUsageLimits": {
"DataStorage": {
"Maximum": 10,
"Unit": "GB"
}
},
(...)
```

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the update with the provided AWS::ElastiCache::ServerlessCache CloudFormation templates, removing CacheUsageLimits.DataStorage.Minimum and then setting it to 0. Compare the results with `aws elasticache describe-serverless-caches`. Done means removing a previously set non-required limit succeeds without an InternalFailure and matches the AWS API and console behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.