Skip to content

Can't Create or import valkey elasticache with cluster mode enabled with single node from terraform #43233

@hussein-mimi

Description

@hussein-mimi

Terraform and AWS Provider Version

Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.100.0

Affected Resource(s) or Data Source(s)

aws_elasticache_replication_group

Expected Behavior

The expected behaviour to import or create this resource when num_cache_clusters is set to 1, and cluster_mode = "enabled"

Actual Behavior

resource can't be created using terraform when num_cache_clusters is set to 1, but i can create it, when num_chache_clusters is set to 2.

Note: i created with these configs using AWS console

Relevant Error/Panic Output

│ Error: "num_cache_clusters": must be at least 2 if automatic_failover_enabled is true

│   with module.clusters.module.elasticache["my-elasticache-cluster"].aws_elasticache_replication_group.this,
│   on .terraform/modules/clusters.elasticache/resources.tf line 2, in resource "aws_elasticache_replication_group" "this":
│    2: resource "aws_elasticache_replication_group" "this" {

Sample Terraform Configuration

We used custome and private module

  engine               = "valkey"
  engine_version       = "8.0"
  replication_group_id = "my-elasticache-cluster"
  cluster_mode         = "enabled"
  node_type            = "cache.t4g.micro"
  description          = " "
  maintenance_window   = "mon:03:00-mon:04:00"
  num_cache_clusters   = 2
  create_parameter_group      = true
  parameter_group_name        = "my-elasticache-cluster"
  parameter_group_description = "my-elasticache-cluster"
  parameter_group_family      = "valkey8"
  parameter_group_parameters = [{
    name  = "maxmemory-policy",
    value = "volatile-ttl"
  },
  {
    name  = "cluster-enabled",
    value = "yes"
  }
  ]
  snapshot_retention_limit   = 0
  snapshot_window            = "09:00-10:00"
  automatic_failover_enabled = true
  multi_az_enabled           = false
  global_enabled             = false
  security_group_ids         = ["sg-ID"]
  at_rest_encryption_enabled = true
  transit_encryption_enabled = true

Steps to Reproduce

  1. Create from AWS console valkey cluster with cluster mode enabled, single AZ and one replica
  2. try to import it to terraform or create it using terraform, it will fail with error num_cache_clusters must be 2 at least to enable failover, while these can be done using AWS console

Debug Logging

Click to expand log output

GenAI / LLM Assisted Development

n/a

Important Facts and References

No response

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.needs-triageWaiting for first response or review from a maintainer.service/elasticacheIssues and PRs that pertain to the elasticache service.waiting-responseMaintainers are waiting on response from community or contributor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions