diff --git a/.changelog/45017.txt b/.changelog/45017.txt new file mode 100644 index 000000000000..38b45446d246 --- /dev/null +++ b/.changelog/45017.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_elasticache_cluster: Fixed by removing valkey as an engine option to keep an alignment with aws sdk CreateCacheCluster +``` diff --git a/internal/service/elasticache/cluster.go b/internal/service/elasticache/cluster.go index dfcc1227337a..8afff74b5e2c 100644 --- a/internal/service/elasticache/cluster.go +++ b/internal/service/elasticache/cluster.go @@ -142,7 +142,7 @@ func resourceCluster() *schema.Resource { Computed: true, ForceNew: true, ExactlyOneOf: []string{names.AttrEngine, "replication_group_id"}, - ValidateFunc: validation.StringInSlice([]string{engineMemcached, engineRedis, engineValkey}, false), + ValidateFunc: validation.StringInSlice([]string{engineMemcached, engineRedis}, false), }, names.AttrEngineVersion: { Type: schema.TypeString, @@ -964,10 +964,6 @@ func setFromCacheCluster(d *schema.ResourceData, c *awstypes.CacheCluster) error engine := aws.ToString(c.Engine) d.Set(names.AttrEngine, engine) switch engine { - case engineValkey: - if err := setEngineVersionValkey(d, c.EngineVersion); err != nil { - return err // nosemgrep:ci.bare-error-returns - } case engineRedis: if err := setEngineVersionRedis(d, c.EngineVersion); err != nil { return err // nosemgrep:ci.bare-error-returns @@ -1021,7 +1017,7 @@ func clusterForceNewOnMemcachedNodeTypeChange(_ context.Context, diff *schema.Re if diff.Id() == "" || !diff.HasChange("node_type") { return nil } - if v, ok := diff.GetOk(names.AttrEngine); !ok || v.(string) == engineRedis || v.(string) == engineValkey { + if v, ok := diff.GetOk(names.AttrEngine); !ok || v.(string) == engineRedis { return nil } return diff.ForceNew("node_type") @@ -1029,7 +1025,7 @@ func clusterForceNewOnMemcachedNodeTypeChange(_ context.Context, diff *schema.Re // clusterValidateMemcachedSnapshotIdentifier validates that `final_snapshot_identifier` is not set when `engine` is "memcached" func clusterValidateMemcachedSnapshotIdentifier(_ context.Context, diff *schema.ResourceDiff, v any) error { - if v, ok := diff.GetOk(names.AttrEngine); !ok || v.(string) == engineRedis || v.(string) == engineValkey { + if v, ok := diff.GetOk(names.AttrEngine); !ok || v.(string) == engineRedis { return nil } if _, ok := diff.GetOk(names.AttrFinalSnapshotIdentifier); !ok { diff --git a/internal/service/elasticache/cluster_test.go b/internal/service/elasticache/cluster_test.go index 61b30dba9265..8e992dfab08b 100644 --- a/internal/service/elasticache/cluster_test.go +++ b/internal/service/elasticache/cluster_test.go @@ -115,6 +115,26 @@ func TestAccElastiCacheCluster_Engine_redis(t *testing.T) { }) } +func TestAccElastiCacheCluster_Engine_valkey(t *testing.T) { + ctx := acctest.Context(t) + rName := acctest.RandomWithPrefix(t, acctest.ResourcePrefix) + + acctest.ParallelTest(ctx, t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.ElastiCacheServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckClusterDestroy(ctx, t), + Steps: []resource.TestStep{ + { + Config: testAccClusterConfig_engineValkey(rName), + // Verify "ExactlyOneOf" in the schema for "engine" + // throws a plan-time error when engine is valkey + ExpectError: regexache.MustCompile(`expected engine to be one of \["memcached" "redis"\], got valkey`), + }, + }, + }) +} + func TestAccElastiCacheCluster_disappears(t *testing.T) { ctx := acctest.Context(t) if testing.Short() { @@ -1570,6 +1590,17 @@ resource "aws_elasticache_cluster" "test" { `, rName) } +func testAccClusterConfig_engineValkey(rName string) string { + return fmt.Sprintf(` +resource "aws_elasticache_cluster" "test" { + cluster_id = %[1]q + engine = "valkey" + node_type = "cache.t3.small" + num_cache_nodes = 1 +} +`, rName) +} + func testAccClusterConfig_engineRedisV5(rName string) string { return fmt.Sprintf(` resource "aws_elasticache_cluster" "test" { diff --git a/website/docs/r/elasticache_cluster.html.markdown b/website/docs/r/elasticache_cluster.html.markdown index e41a7c89588d..879c1d622452 100644 --- a/website/docs/r/elasticache_cluster.html.markdown +++ b/website/docs/r/elasticache_cluster.html.markdown @@ -22,7 +22,7 @@ place. You can use the `apply_immediately` flag to instruct the service to apply change immediately. Using `apply_immediately` can result in a brief downtime as the server reboots. See the "Changes take effect" section of the "Details" column in the AWS Documentation on Engine specific parameters for [ElastiCache for Memcached](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ParameterGroups.Engine.html#ParameterGroups.Memcached) or -[ElastiCache for Valkey and Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ParameterGroups.Engine.html#ParameterGroups.Redis) +[ElastiCache for Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ParameterGroups.Engine.html#ParameterGroups.Redis) for more information. ~> **Note:** Any attribute changes that re-create the resource will be applied immediately, regardless of the value of `apply_immediately`. @@ -139,9 +139,9 @@ resource "aws_elasticache_cluster" "example" { This resource supports the following arguments: * `cluster_id` - (Required) Group identifier. ElastiCache converts this name to lowercase. Changing this value will re-create the resource. -* `engine` - (Optional, Required if `replication_group_id` is not specified) Name of the cache engine to be used for this cache cluster. Valid values are `memcached`, `redis` and `valkey`. +* `engine` - (Optional, Required if `replication_group_id` is not specified) Name of the cache engine to be used for this cache cluster. Valid values are `memcached`, `redis`. * `node_type` - (Required unless `replication_group_id` is provided) The instance class used. - See AWS documentation for information on [supported node types for Valkey or Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SupportedTypes.html#CacheNodes.CurrentGen) and [guidance on selecting node types for Valkey or Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SelectSize.html#CacheNodes.SelectSize.redis). + See AWS documentation for information on [supported node types for Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SupportedTypes.html#CacheNodes.CurrentGen) and [guidance on selecting node types for Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SelectSize.html#CacheNodes.SelectSize.redis). See AWS documentation for information on [supported node types for Memcached](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SupportedTypes.html#CacheNodes.CurrentGen-Memcached) and [guidance on selecting node types for Memcached](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SelectSize.html#CacheNodes.SelectSize.Mem). For Memcached, changing this value will re-create the resource. * `num_cache_nodes` - (Required unless `replication_group_id` is provided) The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcached, this value must be between 1 and 40. If this number is reduced on subsequent runs, the highest numbered nodes will be removed. @@ -181,7 +181,7 @@ The minimum maintenance window is a 60 minute period. Example: `sun:05:00-sun:09 * `snapshot_window` - (Optional, Redis only) Daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. Example: 05:00-09:00 * `subnet_group_name` - (Optional, VPC only) Name of the subnet group to be used for the cache cluster. Changing this value will re-create the resource. Cannot be provided with `replication_group_id.` * `tags` - (Optional) Map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. -* `transit_encryption_enabled` - (Optional) Enable encryption in-transit. Supported with Memcached versions `1.6.12` and later, Valkey `7.2` and later, Redis OSS versions `3.2.6`, `4.0.10` and later, running in a VPC. See the [ElastiCache in-transit encryption documentation](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/in-transit-encryption.html#in-transit-encryption-constraints) for more details. +* `transit_encryption_enabled` - (Optional) Enable encryption in-transit. Supported with Memcached versions `1.6.12` and later, Redis OSS versions `3.2.6`, `4.0.10` and later, running in a VPC. See the [ElastiCache in-transit encryption documentation](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/in-transit-encryption.html#in-transit-encryption-constraints) for more details. ### Log Delivery Configuration