Skip to content

Commit 9614ef6

Browse files
committed
Updated module
1 parent 92a9cc1 commit 9614ef6

File tree

12 files changed

+234
-38
lines changed

12 files changed

+234
-38
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,14 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
103103

104104
| Name | Type |
105105
|------|------|
106+
| [aws_cloudwatch_metric_alarm.cache_connections](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
106107
| [aws_cloudwatch_metric_alarm.cache_cpu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
108+
| [aws_cloudwatch_metric_alarm.cache_evictions](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
109+
| [aws_cloudwatch_metric_alarm.cache_hits](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
107110
| [aws_cloudwatch_metric_alarm.cache_memory](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
111+
| [aws_cloudwatch_metric_alarm.cache_misses](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
112+
| [aws_cloudwatch_metric_alarm.cache_replication_lag](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
113+
| [aws_elasticache_cluster.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
108114
| [aws_elasticache_parameter_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
109115
| [aws_elasticache_replication_group.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group) | resource |
110116
| [aws_elasticache_subnet_group.elasticache](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource |
@@ -125,12 +131,17 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
125131
| Name | Description | Type | Default | Required |
126132
|------|-------------|------|---------|:--------:|
127133
| <a name="input_alarm_actions"></a> [alarm\_actions](#input\_alarm\_actions) | Alarm action list | `list(string)` | `[]` | no |
134+
| <a name="input_alarm_cache_hits_threshold"></a> [alarm\_cache\_hits\_threshold](#input\_alarm\_cache\_hits\_threshold) | Cache hits threshold alarm level | `number` | `1000` | no |
135+
| <a name="input_alarm_cache_misses_threshold"></a> [alarm\_cache\_misses\_threshold](#input\_alarm\_cache\_misses\_threshold) | Cache misses threshold alarm level | `number` | `50` | no |
136+
| <a name="input_alarm_connections_threshold"></a> [alarm\_connections\_threshold](#input\_alarm\_connections\_threshold) | Connections threshold alarm level | `number` | `100` | no |
128137
| <a name="input_alarm_cpu_threshold_percent"></a> [alarm\_cpu\_threshold\_percent](#input\_alarm\_cpu\_threshold\_percent) | CPU threshold alarm level | `number` | `75` | no |
138+
| <a name="input_alarm_eviction_threshold"></a> [alarm\_eviction\_threshold](#input\_alarm\_eviction\_threshold) | Eviction threshold alarm level | `number` | `20` | no |
129139
| <a name="input_alarm_memory_threshold_bytes"></a> [alarm\_memory\_threshold\_bytes](#input\_alarm\_memory\_threshold\_bytes) | Ram threshold alarm level in bytes | `number` | `10000000` | no |
140+
| <a name="input_alarm_replication_lag_threshold"></a> [alarm\_replication\_lag\_threshold](#input\_alarm\_replication\_lag\_threshold) | Replication lag threshold alarm level | `number` | `10` | no |
130141
| <a name="input_allowed_cidr_blocks"></a> [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | A list of CIDR blocks which are allowed to access the database | `list(any)` | `[]` | no |
131142
| <a name="input_allowed_security_groups"></a> [allowed\_security\_groups](#input\_allowed\_security\_groups) | A list of Security Group ID's to allow access to | `list(any)` | `[]` | no |
132143
| <a name="input_at_rest_encryption_enabled"></a> [at\_rest\_encryption\_enabled](#input\_at\_rest\_encryption\_enabled) | (Optional) Whether to enable encryption at rest | `bool` | `true` | no |
133-
| <a name="input_automatic_failover_enabled"></a> [automatic\_failover\_enabled](#input\_automatic\_failover\_enabled) | Enable automatic failover | `bool` | `true` | no |
144+
| <a name="input_automatic_failover_enabled"></a> [automatic\_failover\_enabled](#input\_automatic\_failover\_enabled) | Enable automatic failover | `bool` | `false` | no |
134145
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | The no. of AZs | `list(string)` | `[]` | no |
135146
| <a name="input_cloudwatch_metric_alarms_enabled"></a> [cloudwatch\_metric\_alarms\_enabled](#input\_cloudwatch\_metric\_alarms\_enabled) | Boolean flag to enable/disable CloudWatch metrics alarms | `bool` | `false` | no |
136147
| <a name="input_cluster_mode_enabled"></a> [cluster\_mode\_enabled](#input\_cluster\_mode\_enabled) | Whether to enable/disable creation of a native redis cluster. | `bool` | `false` | no |
@@ -152,7 +163,7 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
152163
| <a name="input_notification_topic_arn"></a> [notification\_topic\_arn](#input\_notification\_topic\_arn) | (Optional) ARN of an SNS topic to send ElastiCache notifications | `string` | `null` | no |
153164
| <a name="input_num_cache_nodes"></a> [num\_cache\_nodes](#input\_num\_cache\_nodes) | The number of cache nodes | `number` | `1` | no |
154165
| <a name="input_ok_actions"></a> [ok\_actions](#input\_ok\_actions) | The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN) | `list(string)` | `[]` | no |
155-
| <a name="input_parameter"></a> [parameter](#input\_parameter) | A list of Redis parameters to apply. It can be different based on mode slection. | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
166+
| <a name="input_parameter"></a> [parameter](#input\_parameter) | A list of Redis parameters to apply. It can be different based on mode slection. | <pre>list(object({<br/> name = string<br/> value = string<br/> }))</pre> | `[]` | no |
156167
| <a name="input_parameter_group_description"></a> [parameter\_group\_description](#input\_parameter\_group\_description) | Parameter group | `string` | `null` | no |
157168
| <a name="input_port"></a> [port](#input\_port) | The redis port | `number` | `6379` | no |
158169
| <a name="input_recovery_window_aws_secret"></a> [recovery\_window\_aws\_secret](#input\_recovery\_window\_aws\_secret) | Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be 0 to force deletion without recovery or range from 7 to 30 days. | `number` | `0` | no |
@@ -174,8 +185,14 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
174185

175186
| Name | Description |
176187
|------|-------------|
177-
| <a name="output_auth_token_password"></a> [auth\_token\_password](#output\_auth\_token\_password) | Elasticache-redis auth token password(this password may be old, because Terraform doesn't track it after initial creation) |
188+
| <a name="output_auth_token_password"></a> [auth\_token\_password](#output\_auth\_token\_password) | Elasticache-redis auth token password(redis password may be old, because Terraform doesn't track it after initial creation) |
189+
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | (Memcached only) DNS name of the cache cluster without the port appended |
190+
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the ElastiCache Cluster |
191+
| <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` |
192+
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery |
193+
| <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 |
178194
| <a name="output_elastic_cache_redis_cluster_id"></a> [elastic\_cache\_redis\_cluster\_id](#output\_elastic\_cache\_redis\_cluster\_id) | ID of the elasticache-redis cluster |
195+
| <a name="output_elastic_cache_redis_member_clusters"></a> [elastic\_cache\_redis\_member\_clusters](#output\_elastic\_cache\_redis\_member\_clusters) | ID of the elasticache-redis cluster |
179196
| <a name="output_elastic_cache_redis_port"></a> [elastic\_cache\_redis\_port](#output\_elastic\_cache\_redis\_port) | Port number of Redis |
180197
| <a name="output_elastic_cache_redis_primary_endpoint_address"></a> [elastic\_cache\_redis\_primary\_endpoint\_address](#output\_elastic\_cache\_redis\_primary\_endpoint\_address) | Primary endpoint address of redis |
181198
| <a name="output_elastic_cache_redis_security_group"></a> [elastic\_cache\_redis\_security\_group](#output\_elastic\_cache\_redis\_security\_group) | The security group ID of the cluster |

examples/complete-cluster-mode/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ No inputs.
5151
| <a name="output_id_of_redis_cluster"></a> [id\_of\_redis\_cluster](#output\_id\_of\_redis\_cluster) | ID of the elasticache-redis cluster |
5252
| <a name="output_port_no"></a> [port\_no](#output\_port\_no) | Port number of Redis |
5353
| <a name="output_primary_endpoint_address"></a> [primary\_endpoint\_address](#output\_primary\_endpoint\_address) | Primary endpoint address of redis |
54+
| <a name="output_redis_member_clusters"></a> [redis\_member\_clusters](#output\_redis\_member\_clusters) | Subnet group name of the elasticache-redis cluster |
5455
| <a name="output_redis_subnet_group_name"></a> [redis\_subnet\_group\_name](#output\_redis\_subnet\_group\_name) | Subnet group name of the elasticache-redis cluster |
5556
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/complete/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This example will be very useful for users who are new to a module and want to q
2626
| Name | Source | Version |
2727
|------|--------|---------|
2828
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | n/a |
29-
| <a name="module_redis"></a> [redis](#module\_redis) | squareops/elasticache-redis/aws | n/a |
29+
| <a name="module_redis"></a> [redis](#module\_redis) | ../../ | n/a |
3030
| <a name="module_vpc"></a> [vpc](#module\_vpc) | squareops/vpc/aws | 3.3.1 |
3131

3232
## Resources
@@ -51,5 +51,6 @@ No inputs.
5151
| <a name="output_id_of_redis_cluster"></a> [id\_of\_redis\_cluster](#output\_id\_of\_redis\_cluster) | ID of the elasticache-redis cluster |
5252
| <a name="output_port_no"></a> [port\_no](#output\_port\_no) | Port number of Redis |
5353
| <a name="output_primary_endpoint_address"></a> [primary\_endpoint\_address](#output\_primary\_endpoint\_address) | Primary endpoint address of redis |
54+
| <a name="output_redis_member_clusters"></a> [redis\_member\_clusters](#output\_redis\_member\_clusters) | Subnet group name of the elasticache-redis cluster |
5455
| <a name="output_redis_subnet_group_name"></a> [redis\_subnet\_group\_name](#output\_redis\_subnet\_group\_name) | Subnet group name of the elasticache-redis cluster |
5556
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/complete/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ module "vpc" {
9696
}
9797

9898
module "redis" {
99-
source = "squareops/elasticache-redis/aws"
99+
source = "../../"
100100
name = local.name
101101
family = local.family
102102
node_type = local.node_type
103103
environment = local.environment
104104
engine_version = local.redis_engine_version
105-
num_cache_nodes = 2 # Set count 1 for standalone mode
105+
num_cache_nodes = 2
106106
vpc_id = module.vpc.vpc_id
107107
subnets = module.vpc.database_subnets
108108
kms_key_arn = module.kms.key_arn

examples/standalone/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## Redis Example With Standalone Redis
2+
![squareops_avatar]
3+
4+
[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png
5+
6+
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
7+
<br>
8+
9+
This example will be very useful for users who are new to a module and want to quickly learn how to use it. By reviewing the examples, users can gain a better understanding of how the module works, what features it supports, and how to customize it to their specific needs.<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
10+
## Requirements
11+
12+
| Name | Version |
13+
|------|---------|
14+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
15+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.63 |
16+
17+
## Providers
18+
19+
| Name | Version |
20+
|------|---------|
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.63 |
22+
23+
## Modules
24+
25+
| Name | Source | Version |
26+
|------|--------|---------|
27+
| <a name="module_redis"></a> [redis](#module\_redis) | ../../ | n/a |
28+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | squareops/vpc/aws | 3.3.1 |
29+
30+
## Resources
31+
32+
| Name | Type |
33+
|------|------|
34+
| [aws_availability_zones.primary](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
35+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
36+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
37+
38+
## Inputs
39+
40+
No inputs.
41+
42+
## Outputs
43+
44+
| Name | Description |
45+
|------|-------------|
46+
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | (Memcached only) DNS name of the cache cluster without the port appended |
47+
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the ElastiCache Cluster |
48+
| <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` |
49+
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery |
50+
| <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 |
51+
<!-- END_TF_DOCS -->

examples/standalone/main.tf

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
locals {
2+
name = "redis"
3+
region = "us-east-1"
4+
family = "redis6.x"
5+
node_type = "cache.t3.small"
6+
vpc_cidr = "10.0.0.0/16"
7+
allowed_security_groups = ["sg-0412fe49"]
8+
environment = "prod"
9+
redis_engine_version = "6.0"
10+
additional_tags = {
11+
Owner = "Organization_Name"
12+
Expires = "Never"
13+
Department = "Engineering"
14+
}
15+
current_identity = data.aws_caller_identity.current.arn
16+
availability_zones = slice(data.aws_availability_zones.primary.names, 0, 3)
17+
}
18+
19+
data "aws_availability_zones" "primary" {}
20+
data "aws_caller_identity" "current" {}
21+
data "aws_region" "current" {}
22+
23+
module "vpc" {
24+
source = "squareops/vpc/aws"
25+
version = "3.3.1"
26+
name = local.name
27+
vpc_cidr = local.vpc_cidr
28+
environment = local.environment
29+
availability_zones = local.availability_zones
30+
public_subnet_enabled = true
31+
auto_assign_public_ip = true
32+
intra_subnet_enabled = false
33+
private_subnet_enabled = true
34+
one_nat_gateway_per_az = false
35+
database_subnet_enabled = true
36+
}
37+
38+
module "redis" {
39+
source = "../../"
40+
num_cache_nodes = 1 #keep it 1 for To create only master node and 0 replica node.
41+
name = local.name
42+
family = local.family
43+
node_type = local.node_type
44+
environment = local.environment
45+
engine_version = local.redis_engine_version
46+
vpc_id = module.vpc.vpc_id
47+
subnets = module.vpc.database_subnets
48+
snapshot_window = "07:00-08:00"
49+
maintenance_window = "sun:09:00-sun:10:00"
50+
allowed_security_groups = local.allowed_security_groups
51+
cloudwatch_metric_alarms_enabled = true
52+
alarm_cpu_threshold_percent = 70
53+
alarm_memory_threshold_bytes = "10000000" # in bytes
54+
alarm_eviction_threshold = 1000
55+
alarm_connections_threshold = 100
56+
alarm_replication_lag_threshold = 10
57+
alarm_cache_hits_threshold = 1000
58+
alarm_cache_misses_threshold = 50
59+
slack_notification_enabled = false
60+
slack_username = ""
61+
slack_channel = ""
62+
slack_webhook_url = ""
63+
}

examples/standalone/outputs.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ################################################################################
2+
# # Cluster
3+
# ################################################################################
4+
5+
output "cluster_arn" {
6+
description = "The ARN of the ElastiCache Cluster"
7+
value = module.redis.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.redis.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.redis.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.redis.cluster_address
23+
}
24+
25+
output "cluster_configuration_endpoint" {
26+
description = "(Memcached only) Configuration endpoint to allow host discovery"
27+
value = module.redis.cluster_configuration_endpoint
28+
}

examples/standalone/provider.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
provider "aws" {
2+
region = local.region
3+
default_tags {
4+
tags = local.additional_tags
5+
}
6+
}

examples/standalone/versions.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
version = ">= 3.63"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)