cache:
redis:
- name: namexyz
environment_name: dev
ecs_cluster_names:
- "dev-apps"
node_type: cache.t2.micro
parameter_group_name: default.redis6.x
engine_version: 6.x
transit_encryption_enabled: false
enabled: true
resource "aws_kms_key" "redis_key" {}
resource "aws_kms_alias" "redis_alias" {
name = "alias/redis-${local.workspace.environment_name}"
target_key_id = aws_kms_key.redis_key.key_id
}
module "cache_redis" {
source = "git::https://github.com/DNXLabs/terraform-aws-redis.git"
for_each = { for redis in local.workspace.cache.redis : redis.name => redis }
name = "redis-${each.value.environment_name}"
environment_name = each.value.environment_name
automatic_failover_enabled = try(each.value.automatic_failover_enabled, false)
at_rest_encryption_enabled = try(each.value.at_rest_encryption_enabled, false)
transit_encryption_enabled = try(each.value.transit_encryption_enabled, false)
multi_az_enabled = try(each.value.multi_az_enabled, false)
engine = try(each.value.engine, "redis")
engine_version = each.value.engine_version
kms_key_id = try(each.value.at_rest_encryption_enabled, false ) ? aws_kms_key.redis_key.arn : ""
maintenance_window = try(each.value.maintenance_window, "sun:05:00-sun:07:00")
node_type = each.value.node_type
notification_topic_arn = try(each.value.notification_topic_arn, "")
number_cache_clusters = try(each.value.number_cache_clusters, 1)
port = try(each.value.port, 6379)
snapshot_retention_limit = try(each.value.snapshot_retention_limit, 0)
snapshot_window = try(each.value.snapshot_window, "03:00-04:00")
parameter_group_name = each.value.parameter_group_name
create_subnet_group = try(each.value.create_subnet_group, true)
subnet_group_name = "${each.value.environment_name}-cachesubnet"
allow_security_group_ids = concat(
[for cluster_name in try(each.value.ecs_cluster_names, []) : module.ecs_cluster[cluster_name].ecs_nodes_secgrp_id], []
)
allow_cidrs = try(each.value.allow_cidrs, [local.common.vpn_cidr])
subnet_ids = data.aws_subnet_ids.secure.ids
vpc_id = data.aws_vpc.selected.id
}
Name | Version |
---|---|
terraform | >= 0.13.0 |
Name | Version |
---|---|
aws | n/a |
random | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
allow_cidrs | List of CIDRs to allow connection to this DB | list(string) |
[] |
no |
allow_security_group_ids | List of Security Group IDs to allow connection to this Redis | list(string) |
[] |
no |
at_rest_encryption_enabled | n/a | bool |
true |
no |
automatic_failover_enabled | n/a | bool |
false |
no |
create_subnet_group | Create a subnet group | bool |
false |
no |
engine | n/a | string |
n/a | yes |
engine_version | n/a | string |
n/a | yes |
environment_name | Environment name to use as a prefix to this Redis | string |
n/a | yes |
kms_key_id | KMS Key ARN to use a CMK instead of default shared key | any |
null |
no |
maintenance_window | Specifies the weekly time range for when maintenance on the cache cluster is performed | string |
"sun:05:00-sun:07:00" |
no |
multi_az_enabled | n/a | bool |
false |
no |
name | Name of this Redis | string |
n/a | yes |
node_type | The instance class to be used | string |
n/a | yes |
notification_topic_arn | n/a | string |
"" |
no |
num_cache_clusters | The number of cache clusters (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2 | number |
1 |
no |
parameter_group_name | The name of the parameter group to associate with this replication group | string |
null |
no |
port | Port number for this Redis | number |
6379 |
no |
snapshot_retention_limit | The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them | number |
0 |
no |
snapshot_window | The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum snapshot window is a 60 minute period | string |
"03:00-04:00" |
no |
subnet_group_name | The name of the cache subnet group to be used for the replication group | string |
n/a | yes |
subnet_ids | List of Subnet IDs for the RDS Subnet Group | list(any) |
[] |
no |
transit_encryption_enabled | n/a | bool |
false |
no |
user_group_ids | (Optional) User Group ID to associate with the replication group. Only a maximum of one (1) user group ID is valid. NOTE: This argument is a set because the AWS specification allows for multiple IDs. However, in practice, AWS only allows a maximum size of one. | set(string) |
null |
no |
vpc_id | n/a | string |
n/a | yes |
Name | Description |
---|---|
id | n/a |
redis_endpoint | n/a |
redis_sg | n/a |
Module managed by DNX Solutions.
Apache 2 Licensed. See LICENSE for full details.