Skip to content

oozou/terraform-aws-elasticache

Repository files navigation

AWS Elasticache Cluster

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

Architecture

Arch

Run-Book

Pre-requisites

IMPORTANT NOTE

  1. Required version of Terraform is mentioned in versions.tf.
  2. Go through variables.tf for understanding each terraform variable before running this component.

Resources needed before deploying this component

  1. VPC with Private Subnets

AWS Accounts

Needs the following accounts:

  1. Any AWS Account where Elasticache needs to be deployed

Getting Started

How to use this component in a blueprint

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
}

Requirements

Name Version
terraform >= 1.0.0
aws >= 5.0.0

Providers

Name Version
aws 5.1.0

Modules

Name Source Version
custom_elasticache_alarms oozou/cloudwatch-alarm/aws 2.0.1

Resources

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_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
aws_subnet.subnets data source

Inputs

Name Description Type Default Required
additional_cluster_security_group_ingress_rules Additional ingress rule for cluster security group.
list(object({
from_port = number
to_port = number
protocol = string
cidr_blocks = list(string)
source_security_group_id = string
description = string
}))
[] no
auth_token Auth token for the Elasticache redis auth. Reference: https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/auth.html string n/a yes
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 bool n/a yes
name Name of the ECS 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 redis cluster
object({
port = number
instance_type = string
engine_version = string
node_count = number
})
n/a yes
snapshot_config (optional) Snapshot config to retain and create backup
object({
snapshot_window = string
snapshot_retention_limit = number
})
{
"snapshot_retention_limit": 3,
"snapshot_window": "03:00-05:00"
}
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({
vpc_id = string
private_subnets = list(string)
})
n/a yes

Outputs

Name Description
client_security_group_id Security group id for the elasticache clients.
redis_host Hostname of the redis host in the replication group.
security_group_id Security group id for the elasticache.