Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for engineValkey in the ValidateFunc #39972

Closed
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
2 changes: 1 addition & 1 deletion 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}, false),
ValidateFunc: validation.StringInSlice([]string{engineMemcached, engineRedis, engineValkey}, false),
},
names.AttrEngineVersion: {
Type: schema.TypeString,
Expand Down
55 changes: 55 additions & 0 deletions internal/service/elasticache/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,50 @@ func TestAccElastiCacheCluster_Engine_redis(t *testing.T) {
})
}

func TestAccElastiCacheCluster_Engine_valkey(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

var ec awstypes.CacheCluster
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_elasticache_cluster.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.ElastiCacheServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckClusterDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccClusterConfig_engineValkey(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckClusterExists(ctx, resourceName, &ec),
resource.TestCheckResourceAttr(resourceName, names.AttrAutoMinorVersionUpgrade, acctest.CtTrue),
resource.TestCheckResourceAttr(resourceName, "cache_nodes.#", "1"),
resource.TestCheckResourceAttr(resourceName, "cache_nodes.0.id", "0001"),
resource.TestCheckResourceAttr(resourceName, "cache_nodes.0.outpost_arn", ""),
resource.TestCheckResourceAttr(resourceName, names.AttrEngine, "valkey"),
resource.TestMatchResourceAttr(resourceName, "engine_version_actual", regexache.MustCompile(`^7\.[[:digit:]]+\.[[:digit:]]+$`)),
resource.TestCheckResourceAttr(resourceName, "ip_discovery", "ipv4"),
resource.TestCheckResourceAttr(resourceName, "network_type", "ipv4"),
resource.TestCheckNoResourceAttr(resourceName, "outpost_mode"),
resource.TestCheckResourceAttr(resourceName, "preferred_outpost_arn", ""),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
names.AttrApplyImmediately,
},
},
},
})
}

func TestAccElastiCacheCluster_disappears(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
Expand Down Expand Up @@ -1561,6 +1605,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_engineRedis(rName string) string {
return fmt.Sprintf(`
resource "aws_elasticache_cluster" "test" {
Expand Down
Loading