Skip to content

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

@pbudzon

Description

@pbudzon

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
  1. 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
  1. See error.

  2. 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
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions