-
Notifications
You must be signed in to change notification settings - Fork 62
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:
- 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. - 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
- 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
- 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
-
See error.
-
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
- Run
aws elasticache describe-serverless-cachesand 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