elasticache
Creates an ElastiCache Redis replication group or Memcached cluster with at-rest and in-transit encryption.
Provisions either a Redis replication group (with Multi-AZ, automatic failover, TLS, AUTH token, KMS encryption, and snapshot retention) or a Memcached cluster, with a custom parameter group and subnet group. Redis is the default engine.
Usage
module "redis" {
source = "hcassc.jfrog.io/iac-terraform-modules-virtual/database/elasticache/aws"
version = "0.1.0"
cluster_id = "prod-redis"
subnet_ids = module.vpc.isolated_subnet_id_list
security_group_ids = [module.security_groups.ids["redis"]]
kms_key_id = module.kms.key_arn
auth_token = random_password.redis_auth.result
}
Requirements
| Name | Version |
|---|---|
| terraform | ~> 1.5 |
| aws | ~> 6.50 |
Providers
| Name | Version |
|---|---|
| aws | 6.50.0 |
Resources
| Name | Type |
|---|---|
| aws_elasticache_cluster.memcached | resource |
| aws_elasticache_parameter_group.this | resource |
| aws_elasticache_replication_group.this | resource |
| aws_elasticache_subnet_group.this | resource |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| cluster_id | Replication group ID | string |
n/a | yes |
| security_group_ids | Security group IDs | list(string) |
n/a | yes |
| at_rest_encryption_enabled | Enable at-rest encryption | bool |
true |
no |
| auth_token | Redis AUTH token (required when transit_encryption_enabled = true) | string |
null |
no |
| automatic_failover_enabled | Enable Redis automatic failover (requires num_cache_clusters >= 2) | bool |
true |
no |
| engine | Cache engine — redis or memcached | string |
"redis" |
no |
| engine_version | Cache engine version | string |
"7.1" |
no |
| kms_key_id | KMS key ARN for at-rest encryption | string |
null |
no |
| maintenance_window | Weekly maintenance window | string |
"sun:05:00-sun:06:00" |
no |
| multi_az_enabled | Enable Multi-AZ for the replication group | bool |
true |
no |
| node_type | ElastiCache node type | string |
"cache.t3.medium" |
no |
| num_cache_clusters | Number of Redis replica clusters | number |
2 |
no |
| num_cache_nodes | Number of cache nodes (Memcached) or number of node groups (Redis cluster mode disabled = 1) | number |
1 |
no |
| parameters | Map of cache parameter names to values | map(string) |
{} |
no |
| snapshot_retention_limit | Days to retain Redis snapshots (0 disables) | number |
7 |
no |
| snapshot_window | Daily snapshot window (UTC) | string |
"03:00-04:00" |
no |
| subnet_group_name | ElastiCache subnet group name (created when subnet_ids is non-empty) | string |
null |
no |
| subnet_ids | Subnet IDs for the subnet group | list(string) |
[] |
no |
| tags | Resource tags to apply to all resources | map(string) |
{} |
no |
| transit_encryption_enabled | Enable in-transit TLS encryption | bool |
true |
no |
Outputs
| Name | Description |
|---|---|
| memcached_configuration_endpoint | Memcached configuration endpoint |
| memcached_id | Memcached cluster ID (null for Redis) |
| redis_arn | Redis replication group ARN |
| redis_id | Redis replication group ID (null for Memcached) |
| redis_primary_endpoint | Redis primary endpoint address |
| redis_reader_endpoint | Redis reader endpoint address |