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 Valkey engine support for memorydb resources #39939

Closed
wants to merge 5 commits into from
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
11 changes: 11 additions & 0 deletions .changelog/39939.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:enhancement
resource/memorydb_cluster: Add `engine` attribute.
```

```release-note:enhancement
resource/memorydb_snapshot: Add `engine` attribute in `cluster_configuration` attribute.
```

```release-note:enhancement
data-source/memorydb_cluster: Add `engine` attribute.
```
15 changes: 12 additions & 3 deletions internal/service/memorydb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,17 @@ func resourceCluster() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
names.AttrEngine: {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"redis",
"valkey",
}, false),
},
names.AttrEngineVersion: {
Type: schema.TypeString,
Optional: true,
Computed: true,
Required: true,
},
"final_snapshot_name": {
Type: schema.TypeString,
Expand Down Expand Up @@ -282,6 +289,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int
ACLName: aws.String(d.Get("acl_name").(string)),
AutoMinorVersionUpgrade: aws.Bool(d.Get(names.AttrAutoMinorVersionUpgrade).(bool)),
ClusterName: aws.String(name),
Engine: aws.String(d.Get(names.AttrEngine).(string)),
NodeType: aws.String(d.Get("node_type").(string)),
NumReplicasPerShard: aws.Int32(int32(d.Get("num_replicas_per_shard").(int))),
NumShards: aws.Int32(int32(d.Get("num_shards").(int))),
Expand Down Expand Up @@ -375,6 +383,7 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int

input := &memorydb.UpdateClusterInput{
ClusterName: aws.String(d.Id()),
Engine: aws.String(d.Get(names.AttrEngine).(string)),
}

if d.HasChange("acl_name") {
Expand Down Expand Up @@ -448,7 +457,6 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int
input.SnsTopicStatus = aws.String(ClusterSNSTopicStatusActive)
}
}

log.Printf("[DEBUG] Updating MemoryDB Cluster (%s)", d.Id())

_, err := conn.UpdateCluster(ctx, input)
Expand Down Expand Up @@ -513,6 +521,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter

d.Set(names.AttrDescription, cluster.Description)
d.Set("engine_patch_version", cluster.EnginePatchVersion)
d.Set(names.AttrEngine, cluster.Engine)
d.Set(names.AttrEngineVersion, cluster.EngineVersion)
d.Set(names.AttrKMSKeyARN, cluster.KmsKeyId) // KmsKeyId is actually an ARN here.
d.Set("maintenance_window", cluster.MaintenanceWindow)
Expand Down
5 changes: 5 additions & 0 deletions internal/service/memorydb/cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func dataSourceCluster() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
names.AttrEngine: {
Type: schema.TypeString,
Computed: true,
},
names.AttrEngineVersion: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -200,6 +204,7 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int

d.Set(names.AttrDescription, cluster.Description)
d.Set("engine_patch_version", cluster.EnginePatchVersion)
d.Set(names.AttrEngine, cluster.Engine)
d.Set(names.AttrEngineVersion, cluster.EngineVersion)
d.Set(names.AttrKMSKeyARN, cluster.KmsKeyId) // KmsKeyId is actually an ARN here.
d.Set("maintenance_window", cluster.MaintenanceWindow)
Expand Down
2 changes: 2 additions & 0 deletions internal/service/memorydb/cluster_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAccMemoryDBClusterDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(dataSourceName, "data_tiering", resourceName, "data_tiering"),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDescription, resourceName, names.AttrDescription),
resource.TestCheckResourceAttrPair(dataSourceName, "engine_patch_version", resourceName, "engine_patch_version"),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrEngine, resourceName, names.AttrEngine),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrEngineVersion, resourceName, names.AttrEngineVersion),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrKMSKeyARN, resourceName, names.AttrKMSKeyARN),
resource.TestCheckResourceAttrPair(dataSourceName, "maintenance_window", resourceName, "maintenance_window"),
Expand Down Expand Up @@ -87,6 +88,7 @@ resource "aws_memorydb_cluster" "test" {
auto_minor_version_upgrade = false
kms_key_arn = aws_kms_key.test.arn
name = %[1]q
engine = "valkey"
node_type = "db.t4g.small"
num_shards = 2
security_group_ids = [aws_security_group.test.id]
Expand Down
226 changes: 152 additions & 74 deletions internal/service/memorydb/cluster_test.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions internal/service/memorydb/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func resourceSnapshot() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
names.AttrEngine: {
Type: schema.TypeString,
Computed: true,
},
names.AttrEngineVersion: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -248,6 +252,7 @@ func flattenClusterConfiguration(v *awstypes.ClusterConfiguration) []interface{}

m := map[string]interface{}{
names.AttrDescription: aws.ToString(v.Description),
names.AttrEngine: aws.ToString(v.Engine),
names.AttrEngineVersion: aws.ToString(v.EngineVersion),
"maintenance_window": aws.ToString(v.MaintenanceWindow),
names.AttrName: aws.ToString(v.Name),
Expand Down
2 changes: 2 additions & 0 deletions internal/service/memorydb/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAccMemoryDBSnapshot_basic(t *testing.T) {
testAccCheckSnapshotExists(ctx, resourceName),
acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "memorydb", "snapshot/"+rName),
resource.TestCheckTypeSetElemAttrPair(resourceName, "cluster_configuration.0.description", "aws_memorydb_cluster.test", names.AttrDescription),
resource.TestCheckTypeSetElemAttrPair(resourceName, "cluster_configuration.0.engine", "aws_memorydb_cluster.test", names.AttrEngine),
resource.TestCheckTypeSetElemAttrPair(resourceName, "cluster_configuration.0.engine_version", "aws_memorydb_cluster.test", names.AttrEngineVersion),
resource.TestCheckTypeSetElemAttrPair(resourceName, "cluster_configuration.0.maintenance_window", "aws_memorydb_cluster.test", "maintenance_window"),
resource.TestCheckTypeSetElemAttrPair(resourceName, "cluster_configuration.0.name", "aws_memorydb_cluster.test", names.AttrName),
Expand Down Expand Up @@ -295,6 +296,7 @@ resource "aws_memorydb_cluster" "test" {
acl_name = "open-access"
name = %[1]q
node_type = "db.t4g.small"
engine = "redis"
num_replicas_per_shard = 0
num_shards = 1
security_group_ids = [aws_security_group.test.id]
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/memorydb_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This data source exports the following attributes in addition to the arguments a
* `data_tiering` - True when data tiering is enabled.
* `description` - Description for the cluster.
* `engine_patch_version` - Patch version number of the Redis engine used by the cluster.
* `engine` - Engine that will run on cluster nodes.
* `engine_version` - Version number of the Redis engine used by the cluster.
* `final_snapshot_name` - Name of the final cluster snapshot to be created when this resource is deleted. If omitted, no final snapshot will be made.
* `kms_key_arn` - ARN of the KMS key used to encrypt the cluster at rest.
Expand Down
5 changes: 4 additions & 1 deletion website/docs/r/memorydb_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ resource "aws_memorydb_cluster" "example" {
acl_name = "open-access"
name = "my-cluster"
node_type = "db.t4g.small"
engine = "redis"
engine_version = "7.1"
num_shards = 2
security_group_ids = [aws_security_group.example.id]
snapshot_retention_limit = 7
Expand All @@ -31,14 +33,15 @@ resource "aws_memorydb_cluster" "example" {
The following arguments are required:

* `acl_name` - (Required) The name of the Access Control List to associate with the cluster.
* `engine` - (Required) The engine that will run on your nodes. Supported values are `redis` and `valkey`.
* `engine_version` - (Required) Version number of the Redis engine to be used for the cluster. Downgrades are not supported.
* `node_type` - (Required) The compute and memory capacity of the nodes in the cluster. See AWS documentation on [supported node types](https://docs.aws.amazon.com/memorydb/latest/devguide/nodes.supportedtypes.html) as well as [vertical scaling](https://docs.aws.amazon.com/memorydb/latest/devguide/cluster-vertical-scaling.html).

The following arguments are optional:

* `auto_minor_version_upgrade` - (Optional, Forces new resource) When set to `true`, the cluster will automatically receive minor engine version upgrades after launch. Defaults to `true`.
* `data_tiering` - (Optional, Forces new resource) Enables data tiering. This option is not supported by all instance types. For more information, see [Data tiering](https://docs.aws.amazon.com/memorydb/latest/devguide/data-tiering.html).
* `description` - (Optional) Description for the cluster. Defaults to `"Managed by Terraform"`.
* `engine_version` - (Optional) Version number of the Redis engine to be used for the cluster. Downgrades are not supported.
* `final_snapshot_name` - (Optional) Name of the final cluster snapshot to be created when this resource is deleted. If omitted, no final snapshot will be made.
* `kms_key_arn` - (Optional, Forces new resource) ARN of the KMS key used to encrypt the cluster at rest.
* `maintenance_window` - (Optional) Specifies the weekly time range during which maintenance on the cluster is performed. Specify as a range in the format `ddd:hh24:mi-ddd:hh24:mi` (24H Clock UTC). The minimum maintenance window is a 60 minute period. Example: `sun:23:00-mon:01:30`.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/memorydb_snapshot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This resource exports the following attributes in addition to the arguments abov
* `arn` - The ARN of the snapshot.
* `cluster_configuration` - The configuration of the cluster from which the snapshot was taken.
* `description` - Description for the cluster.
* `engine` - The engine that will run on cluster nodes.
* `engine_version` - Version number of the Redis engine used by the cluster.
* `maintenance_window` - The weekly time range during which maintenance on the cluster is performed.
* `name` - Name of the cluster.
Expand Down
Loading