Skip to content

Commit 277e8cd

Browse files
committed
feat: Update Redis replication group example
1 parent 59c8bc7 commit 277e8cd

File tree

10 files changed

+252
-117
lines changed

10 files changed

+252
-117
lines changed

examples/complete-redis-replication-group/README.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

examples/complete-redis-replication-group/main.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/complete-redis-replication-group/outputs.tf

Whitespace-only changes.

examples/complete-redis-replication-group/replication_group.tf

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/redis-cluster/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Note that this example may create resources which will incur monetary charges on
3232

3333
| Name | Source | Version |
3434
|------|--------|---------|
35-
| <a name="module_elasticache"></a> [elasticache](#module\_elasticache) | ../.. | n/a |
35+
| <a name="module_elasticache"></a> [elasticache](#module\_elasticache) | ../../ | n/a |
3636
| <a name="module_elasticache_disabled"></a> [elasticache\_disabled](#module\_elasticache\_disabled) | ../.. | n/a |
3737
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
3838

@@ -48,7 +48,23 @@ No inputs.
4848

4949
## Outputs
5050

51-
No outputs.
51+
| Name | Description |
52+
|------|-------------|
53+
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | (Memcached only) DNS name of the cache cluster without the port appended |
54+
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the ElastiCache Cluster |
55+
| <a name="output_cluster_cache_nodes"></a> [cluster\_cache\_nodes](#output\_cluster\_cache\_nodes) | List of node objects including `id`, `address`, `port` and `availability_zone` |
56+
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery |
57+
| <a name="output_cluster_engine_version_actual"></a> [cluster\_engine\_version\_actual](#output\_cluster\_engine\_version\_actual) | Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine |
58+
| <a name="output_parameter_group_arn"></a> [parameter\_group\_arn](#output\_parameter\_group\_arn) | The AWS ARN associated with the parameter group |
59+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group name |
60+
| <a name="output_rep_group_arn"></a> [rep\_group\_arn](#output\_rep\_group\_arn) | ARN of the created ElastiCache Replication Group |
61+
| <a name="output_rep_group_coniguration_endpoint_address"></a> [rep\_group\_coniguration\_endpoint\_address](#output\_rep\_group\_coniguration\_endpoint\_address) | Address of the replication group configuration endpoint when cluster mode is enabled |
62+
| <a name="output_rep_group_engine_version_actual"></a> [rep\_group\_engine\_version\_actual](#output\_rep\_group\_engine\_version\_actual) | Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine |
63+
| <a name="output_rep_group_id"></a> [rep\_group\_id](#output\_rep\_group\_id) | ID of the ElastiCache Replication Group |
64+
| <a name="output_rep_group_member_clusters"></a> [rep\_group\_member\_clusters](#output\_rep\_group\_member\_clusters) | Identifiers of all the nodes that are part of this replication group |
65+
| <a name="output_rep_group_primary_endpoint_address"></a> [rep\_group\_primary\_endpoint\_address](#output\_rep\_group\_primary\_endpoint\_address) | Address of the endpoint for the primary node in the replication group, if the cluster mode is disabled |
66+
| <a name="output_rep_group_reader_endpoint_address"></a> [rep\_group\_reader\_endpoint\_address](#output\_rep\_group\_reader\_endpoint\_address) | Address of the endpoint for the reader node in the replication group, if the cluster mode is disabled |
67+
| <a name="output_subnet_group_name"></a> [subnet\_group\_name](#output\_subnet\_group\_name) | The ElastiCache subnet group name |
5268
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5369

5470
Apache-2.0 Licensed. See [LICENSE](https://github.com/clowdhaus/terraform-aws-elasticache/blob/main/LICENSE).
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ElastiCache example for Redis replication group
2+
3+
Configuration in this directory creates set of ElastiCaChe resources including replication group, subnet group and parameter group.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```bash
10+
$ terraform init
11+
$ terraform plan
12+
$ terraform apply
13+
```
14+
15+
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.
16+
17+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
18+
## Requirements
19+
20+
| Name | Version |
21+
|------|---------|
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.23 |
24+
25+
## Providers
26+
27+
| Name | Version |
28+
|------|---------|
29+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.23 |
30+
31+
## Modules
32+
33+
| Name | Source | Version |
34+
|------|--------|---------|
35+
| <a name="module_elasticache"></a> [elasticache](#module\_elasticache) | ../.. | n/a |
36+
| <a name="module_elasticache_disabled"></a> [elasticache\_disabled](#module\_elasticache\_disabled) | ../.. | n/a |
37+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
38+
39+
## Resources
40+
41+
| Name | Type |
42+
|------|------|
43+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
44+
45+
## Inputs
46+
47+
No inputs.
48+
49+
## Outputs
50+
51+
No outputs.
52+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
53+
54+
Apache-2.0 Licensed. See [LICENSE](https://github.com/clowdhaus/terraform-aws-elasticache/blob/main/LICENSE).
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
provider "aws" {
2+
region = local.region
3+
}
4+
5+
data "aws_availability_zones" "available" {}
6+
7+
locals {
8+
region = "us-east-1"
9+
name = "ex-${basename(path.cwd)}"
10+
11+
vpc_cidr = "10.0.0.0/16"
12+
azs = slice(data.aws_availability_zones.available.names, 0, 3)
13+
14+
tags = {
15+
Name = local.name
16+
Example = local.name
17+
Repository = "https://github.com/clowdhaus/terraform-aws-elasticache"
18+
}
19+
}
20+
21+
################################################################################
22+
# ElastiCache Module
23+
################################################################################
24+
25+
module "elasticache" {
26+
source = "../../"
27+
28+
create_replication_group = true
29+
replication_group_id = local.name
30+
31+
engine_version = "7.1"
32+
node_type = "cache.t4g.small"
33+
34+
# cluster_mode = [{
35+
# replicas_per_node_group = 1
36+
# num_node_groups = 3
37+
# }]
38+
39+
# snapshot_retention_limit = 1
40+
# snapshot_window = "20:00-23:00"
41+
42+
transit_encryption_enabled = true
43+
auth_token = "PickSomethingMoreSecure123!"
44+
45+
security_group_ids = []
46+
47+
# subnet group
48+
subnet_group_name = local.name
49+
subnet_group_description = "${title(local.name)} subnet group"
50+
subnet_ids = module.vpc.private_subnets
51+
52+
maintenance_window = "sun:05:00-sun:09:00"
53+
apply_immediately = true
54+
55+
# parameter group
56+
create_parameter_group = true
57+
parameter_group_name = local.name
58+
parameter_group_family = "redis7.1"
59+
parameter_group_description = "${title(local.name)} parameter group"
60+
parameters = [
61+
{
62+
name = "activerehashing"
63+
value = "yes"
64+
},
65+
{
66+
name = "min-slaves-to-write"
67+
value = "2"
68+
}
69+
]
70+
71+
tags = local.tags
72+
}
73+
74+
################################################################################
75+
# Supporting Resources
76+
################################################################################
77+
78+
module "vpc" {
79+
source = "terraform-aws-modules/vpc/aws"
80+
version = "~> 5.0"
81+
82+
name = local.name
83+
cidr = local.vpc_cidr
84+
85+
azs = local.azs
86+
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
87+
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)]
88+
89+
tags = local.tags
90+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
################################################################################
2+
# Cluster
3+
################################################################################
4+
5+
output "cluster_arn" {
6+
description = "The ARN of the ElastiCache Cluster"
7+
value = module.elasticache.cluster_arn
8+
}
9+
10+
output "cluster_engine_version_actual" {
11+
description = "Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine"
12+
value = module.elasticache.cluster_engine_version_actual
13+
}
14+
15+
output "cluster_cache_nodes" {
16+
description = "List of node objects including `id`, `address`, `port` and `availability_zone`"
17+
value = module.elasticache.cluster_cache_nodes
18+
}
19+
20+
output "cluster_address" {
21+
description = "(Memcached only) DNS name of the cache cluster without the port appended"
22+
value = module.elasticache.cluster_address
23+
}
24+
25+
output "cluster_configuration_endpoint" {
26+
description = "(Memcached only) Configuration endpoint to allow host discovery"
27+
value = module.elasticache.cluster_configuration_endpoint
28+
}
29+
30+
################################################################################
31+
# Replication Group
32+
################################################################################
33+
34+
output "rep_group_arn" {
35+
description = "ARN of the created ElastiCache Replication Group"
36+
value = module.elasticache.rep_group_arn
37+
}
38+
39+
output "rep_group_engine_version_actual" {
40+
description = "Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine"
41+
value = module.elasticache.rep_group_engine_version_actual
42+
}
43+
44+
output "rep_group_coniguration_endpoint_address" {
45+
description = "Address of the replication group configuration endpoint when cluster mode is enabled"
46+
value = module.elasticache.rep_group_coniguration_endpoint_address
47+
}
48+
49+
output "rep_group_id" {
50+
description = "ID of the ElastiCache Replication Group"
51+
value = module.elasticache.rep_group_id
52+
}
53+
54+
output "rep_group_member_clusters" {
55+
description = "Identifiers of all the nodes that are part of this replication group"
56+
value = module.elasticache.rep_group_member_clusters
57+
}
58+
59+
output "rep_group_primary_endpoint_address" {
60+
description = "Address of the endpoint for the primary node in the replication group, if the cluster mode is disabled"
61+
value = module.elasticache.rep_group_primary_endpoint_address
62+
}
63+
64+
output "rep_group_reader_endpoint_address" {
65+
description = "Address of the endpoint for the reader node in the replication group, if the cluster mode is disabled"
66+
value = module.elasticache.rep_group_reader_endpoint_address
67+
}
68+
69+
################################################################################
70+
# Parameter Group
71+
################################################################################
72+
73+
output "parameter_group_arn" {
74+
description = "The AWS ARN associated with the parameter group"
75+
value = module.elasticache.parameter_group_arn
76+
}
77+
78+
output "parameter_group_id" {
79+
description = "The ElastiCache parameter group name"
80+
value = module.elasticache.parameter_group_id
81+
}
82+
83+
################################################################################
84+
# Subnet Group
85+
################################################################################
86+
87+
output "subnet_group_name" {
88+
description = "The ElastiCache subnet group name"
89+
value = module.elasticache.subnet_group_name
90+
}

0 commit comments

Comments
 (0)