Skip to content

Commit ca89223

Browse files
authored
feat: Support engine argument and valkey (#10)
1 parent c8540d6 commit ca89223

File tree

11 files changed

+353
-8
lines changed

11 files changed

+353
-8
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,21 @@ module "memory_db" {
111111
Examples codified under the [`examples`](https://github.com/terraform-aws-modules/terraform-aws-memory-db/tree/master/examples) are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module. If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you!
112112

113113
- [Complete](https://github.com/terraform-aws-modules/terraform-aws-memory-db/tree/master/examples/complete)
114+
- [Valkey](https://github.com/terraform-aws-modules/terraform-aws-memory-db/tree/master/examples/valkey)
114115

115116
<!-- BEGIN_TF_DOCS -->
116117
## Requirements
117118

118119
| Name | Version |
119120
|------|---------|
120121
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
121-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.47 |
122+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.78 |
122123

123124
## Providers
124125

125126
| Name | Version |
126127
|------|---------|
127-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.47 |
128+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.78 |
128129

129130
## Modules
130131

@@ -156,7 +157,8 @@ No modules.
156157
| <a name="input_create_users"></a> [create\_users](#input\_create\_users) | Determines whether to create users specified | `bool` | `true` | no |
157158
| <a name="input_data_tiering"></a> [data\_tiering](#input\_data\_tiering) | Must be set to `true` when using a data tiering node type | `bool` | `null` | no |
158159
| <a name="input_description"></a> [description](#input\_description) | Description for the cluster. Defaults to `Managed by Terraform` | `string` | `null` | no |
159-
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Version number of the Redis engine to be used for the cluster. Downgrades are not supported | `string` | `null` | no |
160+
| <a name="input_engine"></a> [engine](#input\_engine) | The engine that will run on your nodes. Supported values are redis and valkey | `string` | `null` | no |
161+
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Version number of the engine to be used for the cluster. Downgrades are not supported | `string` | `null` | no |
160162
| <a name="input_final_snapshot_name"></a> [final\_snapshot\_name](#input\_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 | `string` | `null` | no |
161163
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | ARN of the KMS key used to encrypt the cluster at rest | `string` | `null` | no |
162164
| <a name="input_maintenance_window"></a> [maintenance\_window](#input\_maintenance\_window) | Specifies the weekly time range during which maintenance on the cluster is performed. It is specified as a range in the format `ddd:hh24:mi-ddd:hh24:mi` | `string` | `null` | no |

examples/complete/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ Note that this example may create resources which will incur monetary charges on
2626
| Name | Version |
2727
|------|---------|
2828
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
29-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.47 |
29+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.78 |
3030
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
3131

3232
## Providers
3333

3434
| Name | Version |
3535
|------|---------|
36-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.47 |
36+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.78 |
3737
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0 |
3838

3939
## Modules

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.47"
7+
version = ">= 5.78"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/valkey/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Valkey AWS MemoryDB Example
2+
3+
Configuration in this directory creates:
4+
5+
- AWS MemoryDB cluster
6+
- AWS MemoryDB users
7+
- AWS MemoryDB ACL
8+
- AWS MemoryDB subnet group
9+
- AWS MemoryDB parameter group
10+
11+
## Usage
12+
13+
To run this example you need to execute:
14+
15+
```bash
16+
$ terraform init
17+
$ terraform plan
18+
$ terraform apply
19+
```
20+
21+
Note that this example may create resources which will incur monetary charges on your AWS bill. Run `terraform destroy` when you no longer need these resources.
22+
23+
<!-- BEGIN_TF_DOCS -->
24+
## Requirements
25+
26+
| Name | Version |
27+
|------|---------|
28+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
29+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.78 |
30+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
31+
32+
## Providers
33+
34+
| Name | Version |
35+
|------|---------|
36+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.78 |
37+
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0 |
38+
39+
## Modules
40+
41+
| Name | Source | Version |
42+
|------|--------|---------|
43+
| <a name="module_memory_db"></a> [memory\_db](#module\_memory\_db) | ../.. | n/a |
44+
| <a name="module_memory_db_disabled"></a> [memory\_db\_disabled](#module\_memory\_db\_disabled) | ../.. | n/a |
45+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
46+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
47+
48+
## Resources
49+
50+
| Name | Type |
51+
|------|------|
52+
| [aws_sns_topic.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
53+
| [random_password.password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
54+
55+
## Inputs
56+
57+
No inputs.
58+
59+
## Outputs
60+
61+
| Name | Description |
62+
|------|-------------|
63+
| <a name="output_acl_arn"></a> [acl\_arn](#output\_acl\_arn) | The ARN of the ACL |
64+
| <a name="output_acl_id"></a> [acl\_id](#output\_acl\_id) | Name of the ACL |
65+
| <a name="output_acl_minimum_engine_version"></a> [acl\_minimum\_engine\_version](#output\_acl\_minimum\_engine\_version) | The minimum engine version supported by the ACL |
66+
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the cluster |
67+
| <a name="output_cluster_endpoint_address"></a> [cluster\_endpoint\_address](#output\_cluster\_endpoint\_address) | DNS hostname of the cluster configuration endpoint |
68+
| <a name="output_cluster_endpoint_port"></a> [cluster\_endpoint\_port](#output\_cluster\_endpoint\_port) | Port number that the cluster configuration endpoint is listening on |
69+
| <a name="output_cluster_engine_patch_version"></a> [cluster\_engine\_patch\_version](#output\_cluster\_engine\_patch\_version) | Patch version number of the Redis engine used by the cluster |
70+
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Cluster name |
71+
| <a name="output_cluster_shards"></a> [cluster\_shards](#output\_cluster\_shards) | Set of shards in this cluster |
72+
| <a name="output_parameter_group_arn"></a> [parameter\_group\_arn](#output\_parameter\_group\_arn) | The ARN of the parameter group |
73+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | Name of the parameter group |
74+
| <a name="output_subnet_group_arn"></a> [subnet\_group\_arn](#output\_subnet\_group\_arn) | ARN of the subnet group |
75+
| <a name="output_subnet_group_id"></a> [subnet\_group\_id](#output\_subnet\_group\_id) | Name of the subnet group |
76+
| <a name="output_subnet_group_vpc_id"></a> [subnet\_group\_vpc\_id](#output\_subnet\_group\_vpc\_id) | The VPC in which the subnet group exists |
77+
| <a name="output_users"></a> [users](#output\_users) | Map of attributes for the users created |
78+
<!-- END_TF_DOCS -->
79+
80+
Apache-2.0 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-memory-db/blob/master/LICENSE).

examples/valkey/main.tf

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
provider "aws" {
2+
region = local.region
3+
}
4+
5+
locals {
6+
region = "us-east-1"
7+
name = "memorydb-ex-${replace(basename(path.cwd), "_", "-")}"
8+
9+
tags = {
10+
Example = local.name
11+
Environment = "dev"
12+
}
13+
}
14+
15+
################################################################################
16+
# MemoryDB Module
17+
################################################################################
18+
19+
module "memory_db_disabled" {
20+
source = "../.."
21+
22+
name = "${local.name}-disabled"
23+
create = false
24+
}
25+
26+
module "memory_db" {
27+
source = "../.."
28+
29+
# Cluster
30+
name = local.name
31+
description = "Example MemoryDB cluster"
32+
33+
engine = "valkey"
34+
engine_version = "7.2"
35+
auto_minor_version_upgrade = true
36+
node_type = "db.r6gd.xlarge"
37+
num_shards = 2
38+
num_replicas_per_shard = 2
39+
data_tiering = true
40+
41+
tls_enabled = true
42+
security_group_ids = [module.security_group.security_group_id]
43+
maintenance_window = "sun:23:00-mon:01:30"
44+
sns_topic_arn = aws_sns_topic.example.arn
45+
snapshot_retention_limit = 7
46+
snapshot_window = "05:00-09:00"
47+
48+
# Users
49+
users = {
50+
admin = {
51+
user_name = "admin-user"
52+
access_string = "on ~* &* +@all"
53+
type = "iam"
54+
tags = { user = "admin" }
55+
}
56+
readonly = {
57+
user_name = "readonly-user"
58+
access_string = "on ~* &* -@all +@read"
59+
passwords = [random_password.password.result]
60+
tags = { user = "readonly" }
61+
}
62+
}
63+
64+
# ACL
65+
acl_name = "${local.name}-acl"
66+
acl_tags = { acl = "custom" }
67+
68+
# Parameter group
69+
parameter_group_name = "${local.name}-param-group"
70+
parameter_group_description = "Example Valkey MemoryDB parameter group"
71+
parameter_group_family = "memorydb_valkey7"
72+
parameter_group_parameters = [
73+
{
74+
name = "activedefrag"
75+
value = "yes"
76+
}
77+
]
78+
parameter_group_tags = {
79+
parameter_group = "custom"
80+
}
81+
82+
# Subnet group
83+
subnet_group_name = "${local.name}-subnet-group"
84+
subnet_group_description = "Example Valkey MemoryDB subnet group"
85+
subnet_ids = module.vpc.database_subnets
86+
subnet_group_tags = {
87+
subnet_group = "custom"
88+
}
89+
90+
tags = local.tags
91+
}
92+
93+
################################################################################
94+
# Supporting Resources
95+
################################################################################
96+
97+
module "vpc" {
98+
source = "terraform-aws-modules/vpc/aws"
99+
version = "~> 5.0"
100+
101+
name = local.name
102+
cidr = "10.98.0.0/18"
103+
104+
azs = ["${local.region}a", "${local.region}b", "${local.region}d"] # Caution: check which zones are available
105+
private_subnets = ["10.98.0.0/24", "10.98.1.0/24", "10.98.2.0/24"]
106+
database_subnets = ["10.98.3.0/24", "10.98.4.0/24", "10.98.5.0/24"]
107+
108+
create_database_subnet_group = true
109+
enable_nat_gateway = false
110+
111+
manage_default_security_group = true
112+
default_security_group_ingress = []
113+
default_security_group_egress = []
114+
115+
tags = local.tags
116+
}
117+
118+
module "security_group" {
119+
source = "terraform-aws-modules/security-group/aws"
120+
version = "~> 4.0"
121+
122+
name = local.name
123+
description = "Security group for ${local.name}"
124+
vpc_id = module.vpc.vpc_id
125+
126+
ingress_cidr_blocks = module.vpc.private_subnets_cidr_blocks
127+
ingress_rules = ["redis-tcp"]
128+
129+
egress_cidr_blocks = [module.vpc.vpc_cidr_block]
130+
egress_rules = ["all-all"]
131+
132+
tags = local.tags
133+
}
134+
135+
resource "aws_sns_topic" "example" {
136+
name = local.name
137+
kms_master_key_id = "alias/aws/sns"
138+
139+
tags = local.tags
140+
}
141+
142+
resource "random_password" "password" {
143+
length = 16
144+
special = true
145+
override_special = "_%@"
146+
}

examples/valkey/outputs.tf

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
################################################################################
2+
# Cluster
3+
################################################################################
4+
5+
output "cluster_id" {
6+
description = "Cluster name"
7+
value = module.memory_db.cluster_id
8+
}
9+
10+
output "cluster_arn" {
11+
description = "The ARN of the cluster"
12+
value = module.memory_db.cluster_arn
13+
}
14+
15+
output "cluster_endpoint_address" {
16+
description = "DNS hostname of the cluster configuration endpoint"
17+
value = module.memory_db.cluster_endpoint_address
18+
}
19+
20+
output "cluster_endpoint_port" {
21+
description = "Port number that the cluster configuration endpoint is listening on"
22+
value = module.memory_db.cluster_endpoint_port
23+
}
24+
25+
output "cluster_engine_patch_version" {
26+
description = "Patch version number of the Redis engine used by the cluster"
27+
value = module.memory_db.cluster_engine_patch_version
28+
}
29+
30+
output "cluster_shards" {
31+
description = "Set of shards in this cluster"
32+
value = module.memory_db.cluster_shards
33+
}
34+
35+
################################################################################
36+
# User(s)
37+
################################################################################
38+
39+
output "users" {
40+
description = "Map of attributes for the users created"
41+
value = module.memory_db.users
42+
sensitive = true
43+
}
44+
45+
################################################################################
46+
# ACL
47+
################################################################################
48+
49+
output "acl_id" {
50+
description = "Name of the ACL"
51+
value = module.memory_db.acl_id
52+
}
53+
54+
output "acl_arn" {
55+
description = "The ARN of the ACL"
56+
value = module.memory_db.acl_arn
57+
}
58+
59+
output "acl_minimum_engine_version" {
60+
description = "The minimum engine version supported by the ACL"
61+
value = module.memory_db.acl_minimum_engine_version
62+
}
63+
64+
################################################################################
65+
# Parameter Group
66+
################################################################################
67+
68+
output "parameter_group_id" {
69+
description = "Name of the parameter group"
70+
value = module.memory_db.parameter_group_id
71+
}
72+
73+
output "parameter_group_arn" {
74+
description = "The ARN of the parameter group"
75+
value = module.memory_db.parameter_group_arn
76+
}
77+
78+
################################################################################
79+
# Subnet Group
80+
################################################################################
81+
82+
output "subnet_group_id" {
83+
description = "Name of the subnet group"
84+
value = module.memory_db.subnet_group_id
85+
}
86+
87+
output "subnet_group_arn" {
88+
description = "ARN of the subnet group"
89+
value = module.memory_db.subnet_group_arn
90+
}
91+
92+
output "subnet_group_vpc_id" {
93+
description = "The VPC in which the subnet group exists"
94+
value = module.memory_db.subnet_group_vpc_id
95+
}

examples/valkey/variables.tf

Whitespace-only changes.

examples/valkey/versions.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.78"
8+
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = ">= 3.0"
12+
}
13+
14+
}
15+
}

0 commit comments

Comments
 (0)