Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/45017.txt
Original file line number Diff line number Diff line change
@@ -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
```
10 changes: 3 additions & 7 deletions internal/service/elasticache/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1021,15 +1017,15 @@ 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")
}

// 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 {
Expand Down
31 changes: 31 additions & 0 deletions internal/service/elasticache/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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" {
Expand Down
8 changes: 4 additions & 4 deletions website/docs/r/elasticache_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
Loading