By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Can't create valkey cluster through cloudformation

0

I edited my working cloudformation template for creating a redis cluster to create a valkey cluster instead, by changing the Engine parameter from redis to valkey. Creation fails with "This API doesn't support Valkey engine. Please use CreateReplicationGroup API for Valkey cluster creation. (Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterValue". The documentation says "valkey" is a valid Engine value. Is this a cloudformation bug, or do I need to change something else in my template for valkey?

ElastiCacheCluster: Type: AWS::ElastiCache::CacheCluster Properties: AutoMinorVersionUpgrade: Ref: AutoMinorVersionUpgrade Engine: valkey CacheNodeType: Ref: CacheNodeType ClusterName: Ref: ClusterName NumCacheNodes: 1 CacheSubnetGroupName: Ref: SubnetGroup VpcSecurityGroupIds: - Fn::ImportValue: Fn::Sub: ${ECSResourcesStackName}:InternalSecurityGroup - Fn::ImportValue: Fn::Sub: ${LambdaResourcesStackName}:InternalSecurityGroup

1 Answer
1
Accepted Answer

The error you're encountering is not due to a CloudFormation bug, but rather due to the way Valkey clusters need to be created in Amazon ElastiCache. Unlike Redis, Valkey clusters cannot be created using the CacheCluster resource type in CloudFormation.

For Valkey, you need to use the ReplicationGroup resource type instead of CacheCluster. This is because Valkey clusters are always created as replication groups, even if you're only creating a single-node cluster.

To create a Valkey cluster using CloudFormation, you should modify your template to use AWS::ElastiCache::ReplicationGroup instead of AWS::ElastiCache::CacheCluster. Here's an example of how you might modify your template:

ElastiCacheCluster: Type: AWS::ElastiCache::ReplicationGroup Properties: AutoMinorVersionUpgrade: Ref: AutoMinorVersionUpgrade Engine: valkey CacheNodeType: Ref: CacheNodeType ReplicationGroupId: Ref: ClusterName NumCacheClusters: 1 CacheSubnetGroupName: Ref: SubnetGroup SecurityGroupIds: - Fn::ImportValue: Fn::Sub: ${ECSResourcesStackName}:InternalSecurityGroup - Fn::ImportValue: Fn::Sub: ${LambdaResourcesStackName}:InternalSecurityGroup

Note the changes:

  1. The Type is now AWS::ElastiCache::ReplicationGroup
  2. ClusterName is replaced with ReplicationGroupId
  3. NumCacheNodes is replaced with NumCacheClusters
  4. VpcSecurityGroupIds is replaced with SecurityGroupIds

These changes should allow you to create a Valkey cluster using CloudFormation. Remember that Valkey clusters are always created as replication groups, which is why the API and resource type are different from what you might use for a single-node Redis cluster.
Sources
Creating a Valkey or Redis OSS replication group - Amazon ElastiCache
Creating a cluster for Valkey or Redis OSS - Amazon ElastiCache

profile picture
answered a month ago
profile picture
EXPERT
reviewed a month ago

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.

Guidelines for Answering Questions