hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.2k forks source link

[Bug]: aws_elasticache_cluster resource does not support Valkey as an engine #39905

Open kevinsantiago-mnltechnology opened 3 weeks ago

kevinsantiago-mnltechnology commented 3 weeks ago

Terraform Core Version

1.9.8

AWS Provider Version

5.73.0

Affected Resource(s)

aws_elasticache_cluster

Expected Behavior

should accept valkey as an engine per 5.73.0 release

Actual Behavior

Error: expected engine to be one of ["memcached" "redis"], got valkey

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_elasticache_cluster" "valkey-cluster" {
  cluster_id           = "valkey-cluster"
  engine               = "valkey"
  engine_version       = "7.2"
  node_type            = "cache.t2.micro"
  num_cache_nodes      = 1
  parameter_group_name = "default.valkey7"
  port                 = 6379
  subnet_group_name    = data.aws_elasticache_subnet_group.redis-subnet-group.name
  security_group_ids   = [data.aws_security_group.redis-sg.id]
}

Steps to Reproduce

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.73.0"
    }
  }
}

resource "aws_elasticache_cluster" "valkey-cluster" {
  cluster_id           = "valkey-cluster"
  engine               = "valkey"
  engine_version       = "7.2"
  node_type            = "cache.t2.micro"
  num_cache_nodes      = 1
  parameter_group_name = "default.valkey7"
  port                 = 6379
  subnet_group_name    = data.aws_elasticache_subnet_group.redis-subnet-group.name
  security_group_ids   = [data.aws_security_group.redis-sg.id]
}

Debug Output

No response

Panic Output

No response

Important Factoids

i tried engine "valkey" in aws_elasticache_replication_group it is working.

References

Relates https://github.com/hashicorp/terraform-provider-aws/issues/39641.

Would you like to implement a fix?

None

github-actions[bot] commented 3 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

xpertkn commented 3 weeks ago

Same here. Already installed provider 5.73.0 and here is my code:

resource "aws_elasticache_cluster" "this" {
  cluster_id           = "lab-valkey1"
  engine               = "valkey"
  node_type            = "cache.t4g.micro"
  num_cache_nodes      = 1
  parameter_group_name = "default.valkey7"
  engine_version       = "7.2"
}

terraform {
  required_version = ">= 1.3.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.73.0"
    }
  }
}

When I run terraform plan, it says valkey engine is not supported

❯ terraform plan
╷
│ Error: expected engine to be one of ["memcached" "redis"], got valkey
│ 
│   with aws_elasticache_cluster.this,
│   on main.tf line 3, in resource "aws_elasticache_cluster" "this":
│    3:   engine               = "valkey"
│ 
╵
beezly commented 3 weeks ago

This looks wrong:

https://github.com/hashicorp/terraform-provider-aws/blame/1977363a134f59ecfe3ebbd90c97dd8fad94336d/internal/service/elasticache/cluster.go#L144

            names.AttrEngine: {
                Type:         schema.TypeString,
                Optional:     true,
                Computed:     true,
                ForceNew:     true,
                ExactlyOneOf: []string{names.AttrEngine, "replication_group_id"},
                ValidateFunc: validation.StringInSlice([]string{engineMemcached, engineRedis}, false),
            },

engineValkey exists in consts.go so I suspect the fix is:

                ValidateFunc: validation.StringInSlice([]string{engineMemcached, engineRedis, engineValkey}, false),
schematis commented 1 week ago

Experiencing this in 5.75 still.

jar-b commented 1 week ago

This enhancement is blocked until the upstream API adds support for this engine type. See https://github.com/hashicorp/terraform-provider-aws/pull/39972#issuecomment-2474848288.

schroedermatthias-iu commented 1 week ago

This enhancement is blocked until the upstream API adds support for this engine type. See #39972 (comment).

But you can use the aws_elasticache_replication_group with existing valkey support instead 🙂