Use this module
module "memory_db" {
source = "registry.compliance.tf/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"
}
}The example from the module's README, with this page's source.
Key inputs
Required inputs first, then the inputs the README example sets.
- namestring, default ""
Cluster name - also default name used on all resources if more specific resource names are not provided
- descriptionstring, default null
Description for the cluster. Defaults to
Managed by Terraform - enginestring, default null
The engine that will run on your nodes. Supported values are
redisandvalkey - engine_versionstring, default null
Version number of the engine to be used for the cluster. Downgrades are not supported
- auto_minor_version_upgradebool, default null
When set to
true, the cluster will automatically receive minor engine version upgrades after launch. Defaults totrue - node_typestring, default null
The compute and memory capacity of the nodes in the cluster. See AWS documentation on [supported node types](https://docs.aws.amazon.com/memorydb/latest/devguide/nodes.supportedtypes.html) as well as [vertical scaling](https://docs.aws.amazon.com/memorydb/latest/devguide/cluster-vertical-scaling.html)
- num_shardsnumber, default null
The number of shards in the cluster. Defaults to
1 - num_replicas_per_shardnumber, default null
The number of replicas to apply to each shard, up to a maximum of 5. Defaults to
1(i.e. 2 nodes per shard) - tls_enabledbool, default null
A flag to enable in-transit encryption on the cluster. When set to
false, theacl_namemust beopen-access. Defaults totrue - security_group_idslist(string), default null
Set of VPC Security Group ID-s to associate with this cluster