Skip to content

How do you convert an ElastiCache ReplicationGroup from Redis to Valkey in CloudFormation?

0

I'm trying to convert a ElastiCache ReplicationGroup from a Redis to a Valkey engine in CloudFormation but I'm getting an error. CFN is complaining that the Redis parameter group is not applicable to the Valkey engine. While this is true, my CFN template doesn't specify a parameter group for either engine. I even tried specifying a Valkey parameter group (default.valkey8) but that didn't work either.

This seems like a race condition; you can't change the engine without changing the parameter group, but you can't change the parameter group without changing the engine.

CFN Error:

redis parameter group is not applicable to engine valkey (Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterCombination;
1 Answer
2
Accepted Answer

Hello.

I tried changing from ElastiCache Redis to Valkey below.

  ElastiCacheSubnetGroup:
    Type: AWS::ElastiCache::SubnetGroup
    Properties:
      CacheSubnetGroupName: test-cache-subunet
      Description: Redis Subnet Group
      SubnetIds:
        - !Ref PublicSubnet01
        - !Ref PublicSubnet02

  ElastiCacheCluster:
    Type: AWS::ElastiCache::ReplicationGroup
    Properties: 
      CacheNodeType: !Ref ElastiCacheNodeType
      CacheSubnetGroupName: !Ref ElastiCacheSubnetGroup
      Engine: Redis
      EngineVersion: 7.1
      MultiAZEnabled: true
      NumCacheClusters: 2
      Port: 6379
      ReplicationGroupDescription: Redis Cluster
      ReplicationGroupId: test-elasticache-redis
      SecurityGroupIds: 
        - !Ref ElasticacheSG
      Tags: 
        - Key: Name
          Value: test-elasticache-redis

The template used to change to Valkey is as follows.
Please check whether the engine version of the parameter group and "EngineVersion" specified in AWS::ElastiCache::ReplicationGroup match.

  ElastiCacheSubnetGroup:
    Type: AWS::ElastiCache::SubnetGroup
    Properties:
      CacheSubnetGroupName: test-cache-subunet
      Description: Redis Subnet Group
      SubnetIds:
        - !Ref PublicSubnet01
        - !Ref PublicSubnet02

  ElastiCacheCluster:
    Type: AWS::ElastiCache::ReplicationGroup
    Properties: 
      CacheNodeType: !Ref ElastiCacheNodeType
      CacheParameterGroupName: "default.valkey7" # Edit
      CacheSubnetGroupName: !Ref ElastiCacheSubnetGroup
      Engine: valkey # Edit
      EngineVersion: 7.2 # Edit
      MultiAZEnabled: true
      NumCacheClusters: 2
      Port: 6379
      ReplicationGroupDescription: Redis Cluster
      ReplicationGroupId: test-elasticache-redis
      SecurityGroupIds: 
        - !Ref ElasticacheSG
      Tags: 
        - Key: Name
          Value: test-elasticache-redis
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Hmmm.... I'm not specifying the engine version. Maybe that's important. :thinking:

  • Since Valkey is from version 7.2, I think that even if it was not specified originally, an error would occur if it was not specified when upgrading.

  • Yes, adding the "EngineVersion" parameter allowed CFN to update the engine itself. Thanks for the help!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.