Skip to content

Commit 8e9df27

Browse files
committed
updates
1 parent ce820cc commit 8e9df27

File tree

4 files changed

+324
-100
lines changed

4 files changed

+324
-100
lines changed

examples/multi-region/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Multi Region cluster
2+
3+
Configuration in this directory creates:
4+
5+
- AWS Multi-Regional MemoryDB cluster
6+
- AWS MemoryDB cluster
7+
- AWS MemoryDB users
8+
- AWS MemoryDB ACL
9+
- AWS MemoryDB subnet group
10+
- AWS MemoryDB parameter group
11+
12+
<!-- BEGIN_TF_DOCS -->
13+
## Requirements
14+
15+
| Name | Version |
16+
|------|---------|
17+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
18+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.82 |
19+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
20+
21+
## Providers
22+
23+
| Name | Version |
24+
|------|---------|
25+
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0 |
26+
27+
## Modules
28+
29+
| Name | Source | Version |
30+
|------|--------|---------|
31+
| <a name="module_memory_db"></a> [memory\_db](#module\_memory\_db) | ../.. | n/a |
32+
| <a name="module_memory_db_disabled"></a> [memory\_db\_disabled](#module\_memory\_db\_disabled) | ../.. | n/a |
33+
| <a name="module_multi_region_cluster"></a> [multi\_region\_cluster](#module\_multi\_region\_cluster) | ../../modules/multi-region-cluster | n/a |
34+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
35+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
36+
37+
## Resources
38+
39+
| Name | Type |
40+
|------|------|
41+
| [random_password.password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
42+
43+
## Inputs
44+
45+
No inputs.
46+
47+
## Outputs
48+
49+
| Name | Description |
50+
|------|-------------|
51+
| <a name="output_acl_arn"></a> [acl\_arn](#output\_acl\_arn) | The ARN of the ACL |
52+
| <a name="output_acl_id"></a> [acl\_id](#output\_acl\_id) | Name of the ACL |
53+
| <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 |
54+
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the cluster |
55+
| <a name="output_cluster_endpoint_address"></a> [cluster\_endpoint\_address](#output\_cluster\_endpoint\_address) | DNS hostname of the cluster configuration endpoint |
56+
| <a name="output_cluster_endpoint_port"></a> [cluster\_endpoint\_port](#output\_cluster\_endpoint\_port) | Port number that the cluster configuration endpoint is listening on |
57+
| <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 |
58+
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Cluster name |
59+
| <a name="output_cluster_shards"></a> [cluster\_shards](#output\_cluster\_shards) | Set of shards in this cluster |
60+
| <a name="output_multi_region_cluster_arn"></a> [multi\_region\_cluster\_arn](#output\_multi\_region\_cluster\_arn) | The ARN of the multi-region cluster |
61+
| <a name="output_multi_region_cluster_name"></a> [multi\_region\_cluster\_name](#output\_multi\_region\_cluster\_name) | The name of the multi-region cluster |
62+
| <a name="output_parameter_group_arn"></a> [parameter\_group\_arn](#output\_parameter\_group\_arn) | The ARN of the parameter group |
63+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | Name of the parameter group |
64+
| <a name="output_subnet_group_arn"></a> [subnet\_group\_arn](#output\_subnet\_group\_arn) | ARN of the subnet group |
65+
| <a name="output_subnet_group_id"></a> [subnet\_group\_id](#output\_subnet\_group\_id) | Name of the subnet group |
66+
| <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 |
67+
| <a name="output_users"></a> [users](#output\_users) | Map of attributes for the users created |
68+
<!-- END_TF_DOCS -->

examples/multi-region/main.tf

Lines changed: 98 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ provider "aws" {
22
region = local.region
33
}
44

5-
provider "aws" {
6-
region = "us-west-2"
7-
alias = "us-west-2"
8-
}
9-
105
locals {
116
region = "us-east-1"
127
name = "memorydb-ex-${replace(basename(path.cwd), "_", "-")}"
@@ -51,14 +46,11 @@ module "memory_db" {
5146
# This makes it part of the multi region cluster
5247
multi_region_cluster_name = module.multi_region_cluster.multi_region_cluster_name
5348

54-
# engine = "valkey"
55-
# engine_version = "7.3"
5649
auto_minor_version_upgrade = true
5750
node_type = "db.r7g.xlarge"
5851
num_shards = 2
5952
num_replicas_per_shard = 2
6053

61-
# tls_enabled = true
6254
security_group_ids = [module.security_group.security_group_id]
6355
maintenance_window = "sun:23:00-mon:01:30"
6456
snapshot_retention_limit = 7
@@ -81,7 +73,7 @@ module "memory_db" {
8173
}
8274

8375
# ACL
84-
create_acl = false
76+
create_acl = true
8577
acl_name = "${local.name}-acl"
8678
acl_tags = { acl = "custom" }
8779

@@ -99,51 +91,57 @@ module "memory_db" {
9991
tags = local.tags
10092
}
10193

102-
module "secondary_memory_db" {
103-
source = "../.."
104-
105-
# Cluster
106-
name = "${local.name}-secondary"
107-
description = "Example MemoryDB cluster"
108-
109-
# This makes it part of the multi region cluster
110-
multi_region_cluster_name = module.multi_region_cluster.multi_region_cluster_name
111-
112-
# engine = "valkey"
113-
# engine_version = "7.3"
114-
auto_minor_version_upgrade = true
115-
node_type = "db.r7g.xlarge"
116-
num_shards = 2
117-
num_replicas_per_shard = 2
118-
119-
# tls_enabled = true
120-
security_group_ids = [module.secondary_security_group.security_group_id]
121-
maintenance_window = "sun:23:00-mon:01:30"
122-
snapshot_retention_limit = 7
123-
snapshot_window = "05:00-09:00"
124-
125-
# ACL
126-
create_acl = false
127-
acl_name = "${local.name}-acl"
128-
acl_tags = { acl = "custom" }
129-
130-
# Parameter group
131-
create_parameter_group = false
132-
133-
# Subnet group
134-
subnet_group_name = "${local.name}-subnet-group"
135-
subnet_group_description = "Example MemoryDB subnet group"
136-
subnet_ids = module.secondary_vpc.database_subnets
137-
subnet_group_tags = {
138-
subnet_group = "custom"
139-
}
140-
141-
tags = local.tags
142-
143-
providers = {
144-
aws = aws.us-west-2
145-
}
146-
}
94+
# Provides example of an additional region cluster that is part of the multi-region cluster
95+
# Note: Deleting a cluster with existing clusters in other regions can take several hours
96+
# it places the multi-region cluster into an updating state which is not valid for deletion
97+
98+
#provider "aws" {
99+
# region = "us-west-2"
100+
# alias = "us-west-2"
101+
#}
102+
103+
#module "secondary_memory_db" {
104+
# source = "../.."
105+
#
106+
# # Cluster
107+
# name = "${local.name}-secondary"
108+
# description = "Example MemoryDB cluster"
109+
#
110+
# # This makes it part of the multi region cluster
111+
# multi_region_cluster_name = module.multi_region_cluster.multi_region_cluster_name
112+
#
113+
# auto_minor_version_upgrade = true
114+
# node_type = "db.r7g.xlarge"
115+
# num_shards = 2
116+
# num_replicas_per_shard = 2
117+
#
118+
# security_group_ids = [module.secondary_security_group.security_group_id]
119+
# maintenance_window = "sun:23:00-mon:01:30"
120+
# snapshot_retention_limit = 7
121+
# snapshot_window = "05:00-09:00"
122+
#
123+
# # ACL
124+
# create_acl = true
125+
# acl_name = "${local.name}-acl"
126+
# acl_tags = { acl = "custom" }
127+
#
128+
# # Parameter group
129+
# create_parameter_group = false
130+
#
131+
# # Subnet group
132+
# subnet_group_name = "${local.name}-subnet-group"
133+
# subnet_group_description = "Example MemoryDB subnet group"
134+
# subnet_ids = module.secondary_vpc.database_subnets
135+
# subnet_group_tags = {
136+
# subnet_group = "custom"
137+
# }
138+
#
139+
# tags = local.tags
140+
#
141+
# providers = {
142+
# aws = aws.us-west-2
143+
# }
144+
#}
147145

148146
################################################################################
149147
# Supporting Resources
@@ -170,31 +168,6 @@ module "vpc" {
170168
tags = local.tags
171169
}
172170

173-
module "secondary_vpc" {
174-
source = "terraform-aws-modules/vpc/aws"
175-
version = "~> 5.0"
176-
177-
name = local.name
178-
cidr = "10.99.0.0/18"
179-
180-
azs = ["us-west-2a", "us-west-2b", "us-west-2d"] # Caution: check which zones are available
181-
private_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"]
182-
database_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
183-
184-
create_database_subnet_group = true
185-
enable_nat_gateway = false
186-
187-
manage_default_security_group = true
188-
default_security_group_ingress = []
189-
default_security_group_egress = []
190-
191-
tags = local.tags
192-
193-
providers = {
194-
aws = aws.us-west-2
195-
}
196-
}
197-
198171
module "security_group" {
199172
source = "terraform-aws-modules/security-group/aws"
200173
version = "~> 4.0"
@@ -212,29 +185,54 @@ module "security_group" {
212185
tags = local.tags
213186
}
214187

215-
module "secondary_security_group" {
216-
source = "terraform-aws-modules/security-group/aws"
217-
version = "~> 4.0"
218-
219-
name = local.name
220-
description = "Security group for ${local.name}"
221-
vpc_id = module.secondary_vpc.vpc_id
222-
223-
ingress_cidr_blocks = module.secondary_vpc.private_subnets_cidr_blocks
224-
ingress_rules = ["redis-tcp"]
225-
226-
egress_cidr_blocks = [module.secondary_vpc.vpc_cidr_block]
227-
egress_rules = ["all-all"]
228-
229-
tags = local.tags
230-
231-
providers = {
232-
aws = aws.us-west-2
233-
}
234-
}
235-
236188
resource "random_password" "password" {
237189
length = 16
238190
special = true
239191
override_special = "_%@"
240192
}
193+
194+
#module "secondary_vpc" {
195+
# source = "terraform-aws-modules/vpc/aws"
196+
# version = "~> 5.0"
197+
#
198+
# name = local.name
199+
# cidr = "10.99.0.0/18"
200+
#
201+
# azs = ["us-west-2a", "us-west-2b", "us-west-2d"] # Caution: check which zones are available
202+
# private_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"]
203+
# database_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
204+
#
205+
# create_database_subnet_group = true
206+
# enable_nat_gateway = false
207+
#
208+
# manage_default_security_group = true
209+
# default_security_group_ingress = []
210+
# default_security_group_egress = []
211+
#
212+
# tags = local.tags
213+
#
214+
# providers = {
215+
# aws = aws.us-west-2
216+
# }
217+
#}
218+
#
219+
#module "secondary_security_group" {
220+
# source = "terraform-aws-modules/security-group/aws"
221+
# version = "~> 4.0"
222+
#
223+
# name = local.name
224+
# description = "Security group for ${local.name}"
225+
# vpc_id = module.secondary_vpc.vpc_id
226+
#
227+
# ingress_cidr_blocks = module.secondary_vpc.private_subnets_cidr_blocks
228+
# ingress_rules = ["redis-tcp"]
229+
#
230+
# egress_cidr_blocks = [module.secondary_vpc.vpc_cidr_block]
231+
# egress_rules = ["all-all"]
232+
#
233+
# tags = local.tags
234+
#
235+
# providers = {
236+
# aws = aws.us-west-2
237+
# }
238+
#}

0 commit comments

Comments
 (0)