Skip to content

[Bug]: aws_elasticache_serverless_cache recreates if engine is changed from valkey 7 to redis 7 #45204

@sukumaar

Description

@sukumaar

Terraform and AWS Provider Version

Terraform Core Version
v1.5.7

AWS Provider Version
v6.20.0

Affected Resource(s) or Data Source(s)

aws_elasticache_serverless_cache

Expected Behavior

Terraform should allow in-place valkey 7 to redis 7 engine update as AWS console allows same behaviour. It should not destroy and recreate resource.

Actual Behavior

Terraform is recreating elasticache serverless.

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_elasticache_serverless_cache.test_redis_valkey must be replaced
-/+ resource "aws_elasticache_serverless_cache" "test_redis_valkey" {
      ~ arn                      = "arn:aws:elasticache:us-west-2:123456789:serverlesscache:test-redis" -> (known after apply)
      ~ create_time              = "2025-11-21T16:36:57Z" -> (known after apply)
      ~ daily_snapshot_time      = "11:30" -> (known after apply)
      ~ description              = " " -> (known after apply)
      ~ endpoint                 = [
          - {
              - address = "test-redis-qwerty.serverless.usw2.cache.amazonaws.com"
              - port    = 6379
            },
        ] -> (known after apply)
      ~ engine                   = "valkey" -> "redis" # forces replacement
      ~ full_engine_version      = "7.2" -> (known after apply)
      ~ id                       = "test-redis" -> (known after apply)
        name                     = "test-redis"
      ~ reader_endpoint          = [
          - {
              - address = "test-redis-qwerty.serverless.usw2.cache.amazonaws.com"
              - port    = 6380
            },
        ] -> (known after apply)
      ~ snapshot_retention_limit = 0 -> (known after apply)
      ~ status                   = "available" -> (known after apply)
        # (5 unchanged attributes hidden)
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Changes to Outputs:
  ~ elasticache_engine               = "valkey" -> "redis"
  ~ elasticache_primary_endpoint     = [
      - {
          - address = "test-redis-qwerty.serverless.usw2.cache.amazonaws.com"
          - port    = 6379
        },
    ] -> (known after apply)
  ~ elasticache_serverless_cache_id  = "test-redis" -> (known after apply)

Relevant Error/Panic Output

Sample Terraform Configuration

initial valkey 7
resource "aws_elasticache_serverless_cache" "test_redis_valkey" {
  name   = "test-redis"
  
  engine = "valkey"  
  
  major_engine_version = "7"

  subnet_ids = [
    aws_subnet.test_subnet_a.id,
    aws_subnet.test_subnet_b.id
  ]

  security_group_ids = [aws_security_group.elasticache_sg.id]
}
after redis 7
resource "aws_elasticache_serverless_cache" "test_redis_valkey" {
  name   = "test-redis"

  engine = "redis"
  
  major_engine_version = "7"

  subnet_ids = [
    aws_subnet.test_subnet_a.id,
    aws_subnet.test_subnet_b.id
  ]

  security_group_ids = [aws_security_group.elasticache_sg.id]
}

Steps to Reproduce

  1. create aws_elasticache_serverless_cache with engine valkey 7
  2. terraform plan & terraform apply
  3. update engine to redis 7
  4. terraform plan

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?

Yes

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions