AWS MemoryDB Terraform module
Terraform module which creates AWS MemoryDB resources.
Usage
See examples directory for working examples to reference:
module "memory_db" {
source = "terraform-aws-modules/memory-db/aws"
# Cluster
name = "example"
description = "Example MemoryDB cluster"
engine = "valkey"
engine_version = "7.3"
auto_minor_version_upgrade = true
node_type = "db.t4g.small"
num_shards = 2
num_replicas_per_shard = 2
tls_enabled = true
security_group_ids = ["sg-12345678"]
maintenance_window = "sun:23:00-mon:01:30"
sns_topic_arn = "arn:aws:sns:us-east-1:012345678910:example-topic"
snapshot_retention_limit = 7
snapshot_window = "05:00-09:00"
# Users
users = {
admin = {
user_name = "admin-user"
access_string = "on ~* &* +@all"
passwords = ["YouShouldPickAStrongSecurePassword987!"]
tags = { User = "admin" }
}
readonly = {
user_name = "readonly-user"
access_string = "on ~* &* -@all +@read"
passwords = ["YouShouldPickAStrongSecurePassword123!"]
tags = { User = "readonly" }
}
}
# ACL
acl_name = "example-acl"
acl_tags = { Acl = "custom" }
# Parameter group
parameter_group_name = "example-param-group"
parameter_group_description = "Example MemoryDB parameter group"
parameter_group_family = "memorydb_redis6"
parameter_group_parameters = [
{
name = "activedefrag"
value = "yes"
}
]
parameter_group_tags = {
ParameterGroup = "custom"
}
# Subnet group
subnet_group_name = "example-subnet-group"
subnet_group_description = "Example MemoryDB subnet group"
subnet_ids = ["subnet-1fe3d837", "subnet-129d66ab", "subnet-1211eef5"]
subnet_group_tags = {
SubnetGroup = "custom"
}
tags = {
Terraform = "true"
Environment = "dev"
}
}
Conditional Creation
The following values are provided to toggle on/off creation of the associated resources as desired:
module "memory_db" {
source = "terraform-aws-modules/memory-db/aws"
# Disable creation of cluster and all resources
create = false
# Disable creation of users
create_users = false
# Disable creation of ACL - an ACL will need to be provided
create_acl = false
acl_name = "existing_acl"
# Disable creation of parameter group - a parameter group will need to be provided
create_parameter_group = false
parameter_group_name = "existing_parameter_group"
# Disable creation of subnet group - a subnet group will need to be provided
create_subnet_group = false
subnet_group_name = "existing_subnet_group"
# ... omitted
}
Examples
Examples codified under the examples are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module. If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you!
License
Apache-2.0 Licensed. See LICENSE.