Skip to content

Standard PBS TF Elasticache Redis Standalone (Cluster Mode Disabled) Module

License

Notifications You must be signed in to change notification settings

pbs/terraform-aws-elasticache-redis-standalone-module

Repository files navigation

PBS TF ElastiCache Redis Standalone Module

Installation

Using the Repo Source

Use this URL for the source of the module. See the usage examples below for more details.

github.com/pbs/terraform-aws-elasticache-redis-standalone-module?ref=2.0.1

Alternative Installation Methods

More information can be found on these install methods and more in the documentation here.

Usage

Provisions an Elasticache Redis (or Valkey) cluster (with Cluster Mode Disabled).

ℹ️ Note the confusing terminology around Cluster Mode. The Cluster Mode setting is a Redis feature that allows data to be sharded among nodes in a cluster, and requires some additional configuration to connect with it correctly. A Redis cluster that does not have Cluster Mode enabled is a set of standalone Redis nodes that have a single primary node for reading and writing and replica nodes for reading.

By default, it will provision one writer and one reader node, but that can be adjusted by setting the nodes variable to a different value.

This module also assumes that connections are established through a private DNS record created in Route53. This makes it so that replacement of the ElastiCache cluster can be made in a fashion that is transparent to application configurations. This can be adjusted by setting create_dns to false.

Integrate this module like so:

module "redis" {
  source = "github.com/pbs/terraform-aws-elasticache-redis-standalone-module?ref=2.0.1"

  # Tagging Parameters
  organization = var.organization
  environment  = var.environment
  product      = var.product
  repo         = var.repo

  # Optional Parameters
}

Adding This Version of the Module

If this repo is added as a subtree, then the version of the module should be close to the version shown here:

2.0.1

Note, however that subtrees can be altered as desired within repositories.

Further documentation on usage can be found here.

Below is automatically generated documentation on this Terraform module using terraform-docs


Requirements

Name Version
terraform >= 1.3.2
aws >= 4.5.0

Providers

Name Version
aws 5.24.0

Modules

No modules.

Resources

Name Type
aws_elasticache_replication_group.replication_group resource
aws_elasticache_subnet_group.subnet_group resource
aws_route53_record.primary_endpoint resource
aws_route53_record.reader_endpoint resource
aws_security_group.sg resource
aws_security_group_rule.egress resource
aws_default_tags.common_tags data source
aws_route53_zone.private_hosted_zone data source
aws_subnets.private_subnets data source
aws_vpc.vpc data source

Inputs

Name Description Type Default Required
environment Environment (sharedtools, dev, staging, qa, prod) string n/a yes
organization Organization using this module. Used to prefix tags so that they are easily identified as being from your organization string n/a yes
product Tag used to group resources according to product string n/a yes
repo Tag used to point to the repo using this module string n/a yes
apply_immediately Whether any database modifications are applied immediately, or during the next maintenance window. bool false no
at_rest_encryption_enabled Whether to enable encryption at rest. Because there is a performance hit to enabling this feature, the default is false. Consider setting to true if your application can tolerate it. bool false no
auth_token Password used to access a password protected server. Can be specified only if transit_encryption_enabled = true. string null no
auto_minor_version_upgrade Specifies whether minor version engine upgrades will be applied automatically to the underlying nodes during the maintenance window. Only supported for engine type "redis" and if the engine version is 6 or higher. bool true no
automatic_failover_enabled Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. If null, will be enabled if nodes > 1. If true, nodes must be greater than 1. bool null no
cname The value to use for the CNAME record if create_dns is true. The primary endpoint will be .<private_hosted_zone>, and the reader endpoint will be -ro.<private_hosted_zone>. If null, the name variable will be used instead. string null no
create_dns Whether to create DNS records for the primary and reader endpoints. bool true no
data_tiering_enabled Enables data tiering. Data tiering is only supported for replication groups using the r6gd node type. This parameter must be set to true when using r6gd nodes. bool false no
dns_ttl TTL for DNS records. number 300 no
egress_cidr_blocks List of CIDR blocks to assign to the egress rule of the security group. If null, egress_security_group_ids must be used. list(string)
[
"10.0.0.0/8"
]
no
egress_source_sg_id List of security group ID to assign to the egress rule of the security group. If null, egress_cidr_blocks must be used. string null no
engine The engine to use ('valkey' or 'redis') string "redis" no
engine_version Version number of the cache engine to be used. If not set, defaults to the latest version. See Describe Cache Engine Versions in the AWS Documentation for supported versions. When engine is redis and the version is 6 or higher, the major and minor version can be set, e.g., 6.2, or the minor version can be unspecified which will use the latest version at creation time, e.g., 6.x. Otherwise, specify the full version desired, e.g., 5.0.6. string null no
final_snapshot_identifier Name of your final cluster snapshot. If omitted, no final snapshot will be made. string null no
global_replication_group_id The ID of the global replication group to which this replication group should belong. If this parameter is specified, the replication group is added to the specified global replication group as a secondary replication group; otherwise, the replication group is not part of any global replication group. If global_replication_group_id is set, the num_node_groups parameter cannot be set. string null no
kms_key_id The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if at_rest_encryption_enabled = true. string null no
log_delivery_configurations List of log delivery configurations. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster#log-delivery-configuration
list(object({
destination = string
destination_type = string
log_format = string
log_type = string
}))
[] no
maintenance_window Specifies the weekly time range for when maintenance on the cluster is performed. The format is ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). The minimum maintenance window is a 60 minute period. Example: sun:05:00-sun:09:00. string "mon:07:00-mon:08:00" no
multi_az_enabled Whether to enable Multi-AZ. If Multi-AZ is enabled, the value of nodes must be at least 2. bool false no
name Name of the ElastiCache Redis instance. If null, will default to product. string null no
node_type ElastiCache node type string "cache.t3.micro" no
nodes Number of nodes (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications. Conflicts with num_node_groups, the deprecatednumber_cache_clusters, or the deprecated cluster_mode. number 2 no
notification_topic_arn ARN of an SNS topic to send ElastiCache notifications to. Example: arn:aws:sns:us-east-1:012345678999:my_sns_topic. string null no
parameter_group_name Name of the parameter group to be created. string null no
port The port number on which each of the cache nodes will accept connections. Cannot be provided with replication_group_id. Changing this value will re-create the resource. number 6379 no
preferred_cache_cluster_azs List of availability zones in which to create cluster. list(string) null no
private_hosted_zone Private hosted zone to create DNS records in. If null, create_dns must be set to false. string null no
replication_group_description Description of the replication group to be created. If null, one will be generated using the name of the nodes. string null no
replication_group_id Replication group identifier. This parameter is stored as a lowercase string. If null, the name of the nodes will be used. string null no
security_group_ids One or more VPC security groups associated with the nodes. If null, use the one provided by this module. list(string) null no
sg_name Name of the security group to be created. If null, will use the name of the nodes. string null no
snapshot_arns Single-element string list containing an Amazon Resource Name (ARN) of a Redis RDB snapshot file stored in Amazon S3. The object name cannot contain any commas. Changing snapshot_arns forces a new resource. list(string) null no
snapshot_retention_limit Number of days for which ElastiCache will retain automatic cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot_retention_limit is not supported on cache.t1.micro cache nodes. number null no
snapshot_window Daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your nodes. Example: 05:00-09:00 string null no
subnet_data_lookup_filters Values of the filter blocks in the aws_subnets data source used in this module. If null, one will be guessed using the resolved VPC and a Name filter of *-private-*. Ignored if subnets is populated. map(any) null no
subnet_group_name Name of the subnet group to be used for the cluster. Changing this value will re-create the resource. If null, will use the subnet group created by this module. string null no
subnets List of subnet IDs to create cluster nodes in. If null, a list will be generated by looking up subnets in the resolved VPC. list(string) null no
tags Extra tags map(string) {} no
transit_encryption_enabled Whether to enable encryption at rest. Because there is a performance hit to enabling this feature, the default is false. Consider setting to true if your application can tolerate it. bool false no
use_prefix Whether to use prefixes in the resource names. If false, will use a fully specified name for resources. bool true no
user_group_ids 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. list(string) null no
vpc_data_lookup_tags Value of the tags parameter in the aws_vpc data source used in this module. If null, a dynamic lookup based on environment will be used. Ignored if vpc_id is populated. map(string) null no
vpc_id VPC ID to create the nodes in. If null, one will be guessed based on vpc_data_lookup_tags. string null no

Outputs

Name Description
arn The ARN of the ElastiCache replication group
engine_version_actual Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine.
member_clusters Identifiers of all the nodes that are part of this replication group.
name The name of the ElastiCache replication group
primary_endpoint_address Address of the endpoint for the primary node in the replication group.
reader_endpoint_address Address of the endpoint for the reader node in the replication group.
sg_ids The security group ids
tags The tags

About

Standard PBS TF Elasticache Redis Standalone (Cluster Mode Disabled) Module

Resources

License

Stars

Watchers

Forks

Packages

No packages published