ElastiCache is a fully managed in-memory data store and cache service. This component creates an elasticache cluster with encryption enabled. Read more
It creates:
- Elasticache replication group: Redis with Elasticache Cluster Mode Enabled.
- High Availability elasticache cluster with automatic failover and auto minor version upgrade
- Automatic backup and maintenance
- Encryption enabled at rest and transit by default
- Required version of Terraform is mentioned in
versions.tf
. - Go through
variables.tf
for understanding each terraform variable before running this component.
- VPC with Private Subnets
Needs the following accounts:
- Any AWS Account where Elasticache needs to be deployed
IMPORTANT: We periodically release versions for the components. Since, master branch may have on-going changes, best practice would be to use a released version in form of a tag (e.g. ?ref=x.y.z)
module "elasticache_cluster" {
source = "git::https://<YOUR_VCS_URL>/components/terraform-aws-elasticache.git?ref=v4.0.0"
base_name = "${var.base_name}--redis-"
vpc_config = {
vpc_id = module.vpc.vpc_id
private_subnets = [module.vpc.private_subnet_ids]
}
redis_cluster_config = {
instance_type = var.elasticache["instance_type"]
node_count = var.elasticache["node_count"]
engine_version = "5.0.6"
}
auth_token = var.elasticache["redis_auth_token"]
multi_az_enabled = var.multi_az_enabled
}
Name | Version |
---|---|
terraform | >= 1.0.0 |
aws | >= 5.0.0, < 6.0.0 |
Name | Version |
---|---|
aws | >= 5.0.0, < 6.0.0 |
null | n/a |
Name | Source | Version |
---|---|---|
custom_elasticache_alarms | oozou/cloudwatch-alarm/aws | 2.0.1 |
Name | Type |
---|---|
aws_cloudwatch_metric_alarm.redis_cpu_alarm | resource |
aws_cloudwatch_metric_alarm.redis_memory_alarm | resource |
aws_elasticache_replication_group.elasticache | resource |
aws_elasticache_serverless_cache.elasticache | resource |
aws_elasticache_subnet_group.elasticache | resource |
aws_security_group.client | resource |
aws_security_group.elasticache | resource |
aws_security_group_rule.additional_cluster_ingress | resource |
aws_security_group_rule.egress | resource |
aws_security_group_rule.ingress | resource |
null_resource.validate_config | resource |
aws_subnet.subnets | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
additional_cluster_security_group_ingress_rules | Additional ingress rule for cluster security group. | list(object({ |
[] |
no |
auth_token | Auth token for the Elasticache redis/valkey auth. Reference: https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/auth.html | string |
null |
no |
cache_type | Type of cache to create. Valid values: redis, valkey, redis-serverless, valkey-serverless | string |
"redis" |
no |
custom_elasticache_alarms_configure | custom_elasticache_alarms_configure = { cpu_utilization_too_high = { metric_name = "EngineCPUUtilization" statistic = "Average" comparison_operator = ">=" threshold = "85" period = "300" evaluation_periods = "1" alarm_actions = [sns_topic_arn] ok_actions = [sns_topic_arn] } } |
any |
{} |
no |
default_alarm_actions | The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN). | list(string) |
[] |
no |
default_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 Name (ARN). | list(string) |
[] |
no |
environment | Environment Variable used as a prefix | string |
n/a | yes |
is_enable_default_alarms | if enable the default alarms | bool |
false |
no |
maintenance_window | Snapshot Retention Limit | string |
"mon:00:00-mon:03:00" |
no |
multi_az_enabled | Specifies whether to enable Multi-AZ Support for the replication group (traditional clusters only) | bool |
false |
no |
name | Name of the ElastiCache cluster to create | string |
n/a | yes |
prefix | The prefix name of customer to be displayed in AWS console and resource | string |
n/a | yes |
redis_cluster_config | Configuration for traditional redis/valkey cluster (not used for serverless) | object({ |
null |
no |
serverless_config | Configuration for serverless cache | object({ |
null |
no |
serverless_security_group_ids | List of security group IDs for serverless cache (required for serverless caches) | list(string) |
[] |
no |
snapshot_config | (optional) Snapshot config to retain and create backup | object({ |
{ |
no |
tags | Custom tags which can be passed on to the AWS resources. They should be key value pairs having distinct keys. | map(string) |
{} |
no |
vpc_config | VPC ID and private subnets for ElastiCache cluster | object({ |
n/a | yes |
Name | Description |
---|---|
cache_engine | Cache engine (redis or valkey). |
cache_host | Hostname of the cache endpoint (traditional cluster primary endpoint or serverless endpoint). |
cache_port | Port of the cache endpoint. |
cache_type | Type of cache created (redis, valkey, redis-serverless, valkey-serverless). |
client_security_group_id | Security group id for the elasticache clients. |
is_serverless | Whether the cache is serverless. |
redis_host | Hostname of the redis/valkey host in the replication group (traditional clusters only). |
replication_group_id | ID of the ElastiCache replication group (traditional clusters only). |
security_group_id | Security group id for the elasticache. |
serverless_cache_arn | ARN of the serverless cache (serverless caches only). |
serverless_cache_name | Name of the serverless cache (serverless caches only). |