Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful

| Name | Type |
|------|------|
| [aws_cloudwatch_metric_alarm.cache_connections](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_cloudwatch_metric_alarm.cache_cpu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_cloudwatch_metric_alarm.cache_evictions](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_cloudwatch_metric_alarm.cache_hits](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_cloudwatch_metric_alarm.cache_memory](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_cloudwatch_metric_alarm.cache_misses](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_cloudwatch_metric_alarm.cache_replication_lag](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_elasticache_cluster.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
| [aws_elasticache_parameter_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
| [aws_elasticache_replication_group.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group) | resource |
| [aws_elasticache_subnet_group.elasticache](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource |
Expand All @@ -125,12 +131,17 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_alarm_actions"></a> [alarm\_actions](#input\_alarm\_actions) | Alarm action list | `list(string)` | `[]` | no |
| <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 |
| <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 |
| <a name="input_alarm_connections_threshold"></a> [alarm\_connections\_threshold](#input\_alarm\_connections\_threshold) | Connections threshold alarm level | `number` | `100` | no |
| <a name="input_alarm_cpu_threshold_percent"></a> [alarm\_cpu\_threshold\_percent](#input\_alarm\_cpu\_threshold\_percent) | CPU threshold alarm level | `number` | `75` | no |
| <a name="input_alarm_eviction_threshold"></a> [alarm\_eviction\_threshold](#input\_alarm\_eviction\_threshold) | Eviction threshold alarm level | `number` | `20` | no |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_automatic_failover_enabled"></a> [automatic\_failover\_enabled](#input\_automatic\_failover\_enabled) | Enable automatic failover | `bool` | `true` | no |
| <a name="input_automatic_failover_enabled"></a> [automatic\_failover\_enabled](#input\_automatic\_failover\_enabled) | Enable automatic failover | `bool` | `false` | no |
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | The no. of AZs | `list(string)` | `[]` | no |
| <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 |
| <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 |
Expand All @@ -150,9 +161,9 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
| <a name="input_name"></a> [name](#input\_name) | The name of the redis cluster | `string` | `""` | no |
| <a name="input_node_type"></a> [node\_type](#input\_node\_type) | The instance size of the redis cluster | `string` | `"cache.t3.micro"` | no |
| <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 |
| <a name="input_num_cache_nodes"></a> [num\_cache\_nodes](#input\_num\_cache\_nodes) | The number of cache nodes | `number` | `1` | no |
| <a name="input_num_cache_nodes"></a> [num\_cache\_nodes](#input\_num\_cache\_nodes) | The number of cache nodes | `number` | n/a | yes |
| <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 |
| <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 |
| <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 |
| <a name="input_parameter_group_description"></a> [parameter\_group\_description](#input\_parameter\_group\_description) | Parameter group | `string` | `null` | no |
| <a name="input_port"></a> [port](#input\_port) | The redis port | `number` | `6379` | no |
| <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 |
Expand All @@ -167,15 +178,21 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
| <a name="input_snapshot_retention_limit"></a> [snapshot\_retention\_limit](#input\_snapshot\_retention\_limit) | The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot\_retention\_limit is not supported on cache.t1.micro or cache.t2.* cache nodes | `number` | `7` | no |
| <a name="input_snapshot_window"></a> [snapshot\_window](#input\_snapshot\_window) | The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum maintenance window is a 60 minute period. Example: 05:00-09:00 | `string` | `"03:00-05:00"` | no |
| <a name="input_subnets"></a> [subnets](#input\_subnets) | The subnets where the redis cluster is deployed | `list(string)` | `[]` | no |
| <a name="input_transit_encryption_enabled"></a> [transit\_encryption\_enabled](#input\_transit\_encryption\_enabled) | (Optional) Whether to enable encryption in transit | `bool` | `true` | no |
| <a name="input_transit_encryption_enabled"></a> [transit\_encryption\_enabled](#input\_transit\_encryption\_enabled) | (Optional) Whether to enable encryption in transit | `bool` | `false` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The vpc where we will put the redis cluster | `string` | `""` | no |

## Outputs

| Name | Description |
|------|-------------|
| <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) |
| <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) |
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | (Memcached only) DNS name of the cache cluster without the port appended |
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | The ARN of the ElastiCache Cluster |
| <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` |
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery |
| <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 |
| <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 |
| <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 |
| <a name="output_elastic_cache_redis_port"></a> [elastic\_cache\_redis\_port](#output\_elastic\_cache\_redis\_port) | Port number of Redis |
| <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 |
| <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 |
Expand Down
3 changes: 2 additions & 1 deletion examples/complete-cluster-mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This example will be very useful for users who are new to a module and want to q
| Name | Source | Version |
|------|--------|---------|
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | n/a |
| <a name="module_redis"></a> [redis](#module\_redis) | squareops/elasticache-redis/aws | n/a |
| <a name="module_redis"></a> [redis](#module\_redis) | ../../ | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | squareops/vpc/aws | 3.3.1 |

## Resources
Expand All @@ -51,5 +51,6 @@ No inputs.
| <a name="output_id_of_redis_cluster"></a> [id\_of\_redis\_cluster](#output\_id\_of\_redis\_cluster) | ID of the elasticache-redis cluster |
| <a name="output_port_no"></a> [port\_no](#output\_port\_no) | Port number of Redis |
| <a name="output_primary_endpoint_address"></a> [primary\_endpoint\_address](#output\_primary\_endpoint\_address) | Primary endpoint address of redis |
| <a name="output_redis_member_clusters"></a> [redis\_member\_clusters](#output\_redis\_member\_clusters) | Subnet group name of the elasticache-redis cluster |
| <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 |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9 changes: 8 additions & 1 deletion examples/complete-cluster-mode/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,27 @@ module "redis" {
environment = local.environment
engine_version = local.redis_engine_version
cluster_mode_enabled = local.cluster_mode_enabled
num_cache_nodes = 0
cluster_mode_num_node_groups = 1
cluster_mode_replicas_per_node_group = 2
vpc_id = module.vpc.vpc_id
subnets = module.vpc.database_subnets
kms_key_arn = module.kms.key_arn
multi_az_enabled = true
transit_encryption_enabled = true
availability_zones = local.availability_zones
snapshot_window = "07:00-08:00"
maintenance_window = "sun:09:00-sun:10:00"
allowed_security_groups = local.allowed_security_groups
cloudwatch_metric_alarms_enabled = true
alarm_cpu_threshold_percent = 70
alarm_memory_threshold_bytes = "10000000" # in bytes
slack_notification_enabled = true
alarm_eviction_threshold = 1000
alarm_connections_threshold = 100
alarm_replication_lag_threshold = 10
alarm_cache_hits_threshold = 1000
alarm_cache_misses_threshold = 50
slack_notification_enabled = false
slack_username = ""
slack_channel = ""
slack_webhook_url = ""
Expand Down
3 changes: 2 additions & 1 deletion examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This example will be very useful for users who are new to a module and want to q
| Name | Source | Version |
|------|--------|---------|
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | n/a |
| <a name="module_redis"></a> [redis](#module\_redis) | squareops/elasticache-redis/aws | n/a |
| <a name="module_redis"></a> [redis](#module\_redis) | ../../ | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | squareops/vpc/aws | 3.3.1 |

## Resources
Expand All @@ -51,5 +51,6 @@ No inputs.
| <a name="output_id_of_redis_cluster"></a> [id\_of\_redis\_cluster](#output\_id\_of\_redis\_cluster) | ID of the elasticache-redis cluster |
| <a name="output_port_no"></a> [port\_no](#output\_port\_no) | Port number of Redis |
| <a name="output_primary_endpoint_address"></a> [primary\_endpoint\_address](#output\_primary\_endpoint\_address) | Primary endpoint address of redis |
| <a name="output_redis_member_clusters"></a> [redis\_member\_clusters](#output\_redis\_member\_clusters) | Subnet group name of the elasticache-redis cluster |
| <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 |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
8 changes: 7 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
name = "redis"
region = "us-west-2"
region = "us-east-1"
family = "redis6.x"
node_type = "cache.t3.small"
vpc_cidr = "10.0.0.0/16"
Expand Down Expand Up @@ -107,13 +107,19 @@ module "redis" {
subnets = module.vpc.database_subnets
kms_key_arn = module.kms.key_arn
multi_az_enabled = true
transit_encryption_enabled = true
availability_zones = local.availability_zones
snapshot_window = "07:00-08:00"
maintenance_window = "sun:09:00-sun:10:00"
allowed_security_groups = local.allowed_security_groups
cloudwatch_metric_alarms_enabled = true
alarm_cpu_threshold_percent = 70
alarm_memory_threshold_bytes = "10000000" # in bytes
alarm_eviction_threshold = 1000
alarm_connections_threshold = 100
alarm_replication_lag_threshold = 10
alarm_cache_hits_threshold = 1000
alarm_cache_misses_threshold = 50
slack_notification_enabled = false
slack_username = ""
slack_channel = ""
Expand Down
9 changes: 9 additions & 0 deletions examples/standalone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Redis Example With Standalone Redis
![squareops_avatar]

[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png

### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
<br>

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 -->
63 changes: 63 additions & 0 deletions examples/standalone/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
locals {
name = "redis"
region = "us-east-1"
family = "redis6.x"
node_type = "cache.t3.small"
vpc_cidr = "10.0.0.0/16"
allowed_security_groups = ["sg-0412fe49"]
environment = "prod"
redis_engine_version = "6.0"
additional_tags = {
Owner = "Organization_Name"
Expires = "Never"
Department = "Engineering"
}
current_identity = data.aws_caller_identity.current.arn
availability_zones = slice(data.aws_availability_zones.primary.names, 0, 3)
}

data "aws_availability_zones" "primary" {}
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

module "vpc" {
source = "squareops/vpc/aws"
version = "3.3.1"
name = local.name
vpc_cidr = local.vpc_cidr
environment = local.environment
availability_zones = local.availability_zones
public_subnet_enabled = true
auto_assign_public_ip = true
intra_subnet_enabled = false
private_subnet_enabled = true
one_nat_gateway_per_az = false
database_subnet_enabled = true
}

module "redis" {
source = "squareops/elasticache-redis/aws"
num_cache_nodes = 1 #keep it 1 for To create only master node and 0 replica node.
name = local.name
family = local.family
node_type = local.node_type
environment = local.environment
engine_version = local.redis_engine_version
vpc_id = module.vpc.vpc_id
subnets = module.vpc.database_subnets
snapshot_window = "07:00-08:00"
maintenance_window = "sun:09:00-sun:10:00"
allowed_security_groups = local.allowed_security_groups
cloudwatch_metric_alarms_enabled = true
alarm_cpu_threshold_percent = 70
alarm_memory_threshold_bytes = "10000000" # in bytes
alarm_eviction_threshold = 1000
alarm_connections_threshold = 100
alarm_replication_lag_threshold = 10
alarm_cache_hits_threshold = 1000
alarm_cache_misses_threshold = 50
slack_notification_enabled = false
slack_username = ""
slack_channel = ""
slack_webhook_url = ""
}
Loading