Skip to content

Commit 97bc4b5

Browse files
authored
fix: Argument replication_group_id conflicts with engine and log_delivery_configuration (#10)
1 parent 077f7c7 commit 97bc4b5

File tree

6 files changed

+388
-2
lines changed

6 files changed

+388
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# ElastiCache example for Redis replication group with cluster replica
2+
3+
Configuration in this directory creates a replication group with a cluster replica both in a single module and separate modules as well to show adding a cluster replica to an existing replication 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.47 |
24+
25+
## Providers
26+
27+
| Name | Version |
28+
|------|---------|
29+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.47 |
30+
31+
## Modules
32+
33+
| Name | Source | Version |
34+
|------|--------|---------|
35+
| <a name="module_cluster_replica"></a> [cluster\_replica](#module\_cluster\_replica) | ../../ | n/a |
36+
| <a name="module_replication_group"></a> [replication\_group](#module\_replication\_group) | ../../ | n/a |
37+
| <a name="module_replication_group_with_cluster_replica"></a> [replication\_group\_with\_cluster\_replica](#module\_replication\_group\_with\_cluster\_replica) | ../../ | n/a |
38+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
39+
40+
## Resources
41+
42+
| Name | Type |
43+
|------|------|
44+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
45+
46+
## Inputs
47+
48+
No inputs.
49+
50+
## Outputs
51+
52+
| Name | Description |
53+
|------|-------------|
54+
| <a name="output_cloudwatch_log_group_arn"></a> [cloudwatch\_log\_group\_arn](#output\_cloudwatch\_log\_group\_arn) | Arn of cloudwatch log group created |
55+
| <a name="output_cloudwatch_log_group_name"></a> [cloudwatch\_log\_group\_name](#output\_cloudwatch\_log\_group\_name) | Name of cloudwatch log group created |
56+
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | (Memcached only) DNS name of the cache cluster without the port appended |
57+
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the ElastiCache Cluster |
58+
| <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` |
59+
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery |
60+
| <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 |
61+
| <a name="output_global_replication_group_arn"></a> [global\_replication\_group\_arn](#output\_global\_replication\_group\_arn) | ARN of the created ElastiCache Global Replication Group |
62+
| <a name="output_global_replication_group_engine_version_actual"></a> [global\_replication\_group\_engine\_version\_actual](#output\_global\_replication\_group\_engine\_version\_actual) | The full version number of the cache engine running on the members of this global replication group |
63+
| <a name="output_global_replication_group_id"></a> [global\_replication\_group\_id](#output\_global\_replication\_group\_id) | ID of the ElastiCache Global Replication Group |
64+
| <a name="output_global_replication_group_node_groups"></a> [global\_replication\_group\_node\_groups](#output\_global\_replication\_group\_node\_groups) | Set of node groups (shards) on the global replication group |
65+
| <a name="output_parameter_group_arn"></a> [parameter\_group\_arn](#output\_parameter\_group\_arn) | The AWS ARN associated with the parameter group |
66+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group name |
67+
| <a name="output_replication_group_arn"></a> [replication\_group\_arn](#output\_replication\_group\_arn) | ARN of the created ElastiCache Replication Group |
68+
| <a name="output_replication_group_coniguration_endpoint_address"></a> [replication\_group\_coniguration\_endpoint\_address](#output\_replication\_group\_coniguration\_endpoint\_address) | Address of the replication group configuration endpoint when cluster mode is enabled |
69+
| <a name="output_replication_group_engine_version_actual"></a> [replication\_group\_engine\_version\_actual](#output\_replication\_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 |
70+
| <a name="output_replication_group_id"></a> [replication\_group\_id](#output\_replication\_group\_id) | ID of the ElastiCache Replication Group |
71+
| <a name="output_replication_group_member_clusters"></a> [replication\_group\_member\_clusters](#output\_replication\_group\_member\_clusters) | Identifiers of all the nodes that are part of this replication group |
72+
| <a name="output_replication_group_primary_endpoint_address"></a> [replication\_group\_primary\_endpoint\_address](#output\_replication\_group\_primary\_endpoint\_address) | Address of the endpoint for the primary node in the replication group, if the cluster mode is disabled |
73+
| <a name="output_replication_group_reader_endpoint_address"></a> [replication\_group\_reader\_endpoint\_address](#output\_replication\_group\_reader\_endpoint\_address) | Address of the endpoint for the reader node in the replication group, if the cluster mode is disabled |
74+
| <a name="output_security_group_arn"></a> [security\_group\_arn](#output\_security\_group\_arn) | Amazon Resource Name (ARN) of the security group |
75+
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | ID of the security group |
76+
| <a name="output_subnet_group_name"></a> [subnet\_group\_name](#output\_subnet\_group\_name) | The ElastiCache subnet group name |
77+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
78+
79+
Apache-2.0 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/LICENSE).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
provider "aws" {
2+
region = local.region
3+
}
4+
5+
data "aws_availability_zones" "available" {}
6+
7+
locals {
8+
region = "eu-west-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/terraform-aws-modules/terraform-aws-elasticache"
18+
}
19+
}
20+
21+
################################################################################
22+
# Replication Group with Cluster Replica (single module)
23+
################################################################################
24+
module "replication_group_with_cluster_replica" {
25+
source = "../../"
26+
27+
cluster_id = "cluster"
28+
create_cluster = true
29+
create_replication_group = true
30+
replication_group_id = "repl-grp-with-cluster-replica"
31+
32+
log_delivery_configuration = {
33+
slow-log = {
34+
cloudwatch_log_group_name = "repl-grp-with-cluster-replica"
35+
destination_type = "cloudwatch-logs"
36+
log_format = "json"
37+
}
38+
}
39+
40+
engine_version = "7.1"
41+
node_type = "cache.t4g.small"
42+
43+
maintenance_window = "sun:05:00-sun:09:00"
44+
apply_immediately = true
45+
46+
# Security Group
47+
vpc_id = module.vpc.vpc_id
48+
security_group_rules = {
49+
ingress_vpc = {
50+
# Default type is `ingress`
51+
# Default port is based on the default engine port
52+
description = "VPC traffic"
53+
cidr_ipv4 = module.vpc.vpc_cidr_block
54+
}
55+
}
56+
57+
# Subnet Group
58+
subnet_group_name = "repl-grp-with-cluster-replica"
59+
subnet_group_description = "repl-grp-with-cluster-replica subnet group"
60+
subnet_ids = module.vpc.private_subnets
61+
62+
# Parameter Group
63+
create_parameter_group = true
64+
parameter_group_name = "repl-grp-with-cluster-replica"
65+
parameter_group_family = "redis7"
66+
parameter_group_description = "repl-grp-with-cluster-replica parameter group"
67+
parameters = [
68+
{
69+
name = "latency-tracking"
70+
value = "yes"
71+
}
72+
]
73+
74+
tags = local.tags
75+
}
76+
77+
################################################################################
78+
# Add Cluster Replica to Existing Replication Group (separate modules)
79+
################################################################################
80+
module "replication_group" {
81+
source = "../../"
82+
83+
replication_group_id = "ex-replication-group"
84+
85+
engine_version = "7.1"
86+
node_type = "cache.t4g.small"
87+
88+
transit_encryption_enabled = true
89+
auth_token = "PickSomethingMoreSecure123!"
90+
maintenance_window = "sun:05:00-sun:09:00"
91+
apply_immediately = true
92+
93+
# Security Group
94+
vpc_id = module.vpc.vpc_id
95+
security_group_rules = {
96+
ingress_vpc = {
97+
# Default type is `ingress`
98+
# Default port is based on the default engine port
99+
description = "VPC traffic"
100+
cidr_ipv4 = module.vpc.vpc_cidr_block
101+
}
102+
}
103+
104+
# Subnet Group
105+
subnet_group_name = "ex-replication-group"
106+
subnet_group_description = "${title(local.name)} subnet group"
107+
subnet_ids = module.vpc.private_subnets
108+
109+
# Parameter Group
110+
create_parameter_group = true
111+
parameter_group_name = "ex-replication-group"
112+
parameter_group_family = "redis7"
113+
parameter_group_description = "${title(local.name)} parameter group"
114+
parameters = [
115+
{
116+
name = "latency-tracking"
117+
value = "yes"
118+
}
119+
]
120+
121+
tags = local.tags
122+
}
123+
124+
module "cluster_replica" {
125+
source = "../../"
126+
127+
cluster_id = "ex-cluster-replica"
128+
create_cluster = true
129+
cluster_mode_enabled = false
130+
replication_group_id = module.replication_group.replication_group_id
131+
create_replication_group = false
132+
create_subnet_group = false
133+
134+
log_delivery_configuration = {
135+
create_cloudwatch_log_group = false
136+
}
137+
}
138+
139+
################################################################################
140+
# Supporting Resources
141+
################################################################################
142+
143+
module "vpc" {
144+
source = "terraform-aws-modules/vpc/aws"
145+
version = "~> 5.0"
146+
147+
name = local.name
148+
cidr = local.vpc_cidr
149+
150+
azs = local.azs
151+
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
152+
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)]
153+
154+
tags = local.tags
155+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
################################################################################
2+
# Cluster
3+
################################################################################
4+
5+
output "cluster_arn" {
6+
description = "The ARN of the ElastiCache Cluster"
7+
value = module.replication_group_with_cluster_replica.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.replication_group_with_cluster_replica.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.replication_group_with_cluster_replica.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.replication_group_with_cluster_replica.cluster_address
23+
}
24+
25+
output "cluster_configuration_endpoint" {
26+
description = "(Memcached only) Configuration endpoint to allow host discovery"
27+
value = module.replication_group_with_cluster_replica.cluster_configuration_endpoint
28+
}
29+
30+
################################################################################
31+
# Replication Group
32+
################################################################################
33+
34+
output "replication_group_arn" {
35+
description = "ARN of the created ElastiCache Replication Group"
36+
value = module.replication_group_with_cluster_replica.replication_group_arn
37+
}
38+
39+
output "replication_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.replication_group_with_cluster_replica.replication_group_engine_version_actual
42+
}
43+
44+
output "replication_group_coniguration_endpoint_address" {
45+
description = "Address of the replication group configuration endpoint when cluster mode is enabled"
46+
value = module.replication_group_with_cluster_replica.replication_group_coniguration_endpoint_address
47+
}
48+
49+
output "replication_group_id" {
50+
description = "ID of the ElastiCache Replication Group"
51+
value = module.replication_group_with_cluster_replica.replication_group_id
52+
}
53+
54+
output "replication_group_member_clusters" {
55+
description = "Identifiers of all the nodes that are part of this replication group"
56+
value = module.replication_group_with_cluster_replica.replication_group_member_clusters
57+
}
58+
59+
output "replication_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.replication_group_with_cluster_replica.replication_group_primary_endpoint_address
62+
}
63+
64+
output "replication_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.replication_group_with_cluster_replica.replication_group_reader_endpoint_address
67+
}
68+
69+
################################################################################
70+
# Global Replication Group
71+
################################################################################
72+
73+
output "global_replication_group_id" {
74+
description = "ID of the ElastiCache Global Replication Group"
75+
value = module.replication_group_with_cluster_replica.global_replication_group_id
76+
}
77+
78+
output "global_replication_group_arn" {
79+
description = "ARN of the created ElastiCache Global Replication Group"
80+
value = module.replication_group_with_cluster_replica.global_replication_group_arn
81+
}
82+
83+
output "global_replication_group_engine_version_actual" {
84+
description = "The full version number of the cache engine running on the members of this global replication group"
85+
value = module.replication_group_with_cluster_replica.global_replication_group_engine_version_actual
86+
}
87+
88+
output "global_replication_group_node_groups" {
89+
description = "Set of node groups (shards) on the global replication group"
90+
value = module.replication_group_with_cluster_replica.global_replication_group_node_groups
91+
}
92+
93+
################################################################################
94+
# CloudWatch Log Group
95+
################################################################################
96+
97+
output "cloudwatch_log_group_name" {
98+
description = "Name of cloudwatch log group created"
99+
value = module.replication_group_with_cluster_replica.cloudwatch_log_group_name
100+
}
101+
102+
output "cloudwatch_log_group_arn" {
103+
description = "Arn of cloudwatch log group created"
104+
value = module.replication_group_with_cluster_replica.cloudwatch_log_group_arn
105+
}
106+
107+
################################################################################
108+
# Parameter Group
109+
################################################################################
110+
111+
output "parameter_group_arn" {
112+
description = "The AWS ARN associated with the parameter group"
113+
value = module.replication_group_with_cluster_replica.parameter_group_arn
114+
}
115+
116+
output "parameter_group_id" {
117+
description = "The ElastiCache parameter group name"
118+
value = module.replication_group_with_cluster_replica.parameter_group_id
119+
}
120+
121+
################################################################################
122+
# Subnet Group
123+
################################################################################
124+
125+
output "subnet_group_name" {
126+
description = "The ElastiCache subnet group name"
127+
value = module.replication_group_with_cluster_replica.subnet_group_name
128+
}
129+
130+
################################################################################
131+
# Security Group
132+
################################################################################
133+
134+
output "security_group_arn" {
135+
description = "Amazon Resource Name (ARN) of the security group"
136+
value = module.replication_group_with_cluster_replica.security_group_arn
137+
}
138+
139+
output "security_group_id" {
140+
description = "ID of the security group"
141+
value = module.replication_group_with_cluster_replica.security_group_id
142+
}

examples/redis-replication-group-with-cluster-replica/variables.tf

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.47"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)