Skip to content

opszero/terraform-aws-elasticache

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

77 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Terraform-aws-elasticache

Terraform AWS Cloud elasticache Module

Table of Contents

Introduction

This Terraform module creates an AWS elasticache along with additional configuration options.

Usage

To use this module, you can include it in your Terraform configuration. Here's an example of how to use it:

Examples:

Example: memcached

module "memcached" {
  source                     = "git::https://github.com/opszero/terraform-aws-elasticache.git?ref=v1.0.1"
  name                       = "memcached"
  engine                     = "memcached"
  engine_version             = "1.6.17"
  node_type                  = "cache.t2.micro"
  num_cache_nodes            = 2
  subnet_ids                 = module.subnets.public_subnet_id
  automatic_failover_enabled = false
  security_group_ids         = []
  security_group_names       = null
}

Example: redis

module "redis" {
  source                        = "git::https://github.com/opszero/terraform-aws-elasticache.git?ref=v1.0.1"
  name                          = "redis"
  engine                        = "redis"
  engine_version                = "7.0"
  port                          = 6379
  node_type                     = "cache.r6g.large"
  subnet_ids                    = module.subnets.public_subnet_id
  automatic_failover_enabled    = false
  multi_az_enabled              = false
  num_cache_clusters            = 1
  retention_in_days             = 0
  snapshot_retention_limit      = 7
  replication_group_description = "opszero"

  log_delivery_configuration = [
    {
      destination_type = "cloudwatch-logs"
      log_format       = "json"
      log_type         = "slow-log"
    },
    {
      destination_type = "cloudwatch-logs"
      log_format       = "json"
      log_type         = "engine-log"
    }
  ]
}

Example: redis-cluster

module "redis-cluster" {
  source                        = "git::https://github.com/opszero/terraform-aws-elasticache.git?ref=v1.0.1"
  name                          = "redis-cluster"
  engine                        = "redis"
  engine_version                = "7.0"
  port                          = 6379
  node_type                     = "cache.t2.micro"
  subnet_ids                    = module.subnets.public_subnet_id
  num_cache_nodes               = 1
  snapshot_retention_limit      = 7
  automatic_failover_enabled    = false
  replication_group_description = "opszero"

  log_delivery_configuration = [
    {
      destination_type = "cloudwatch-logs"
      log_format       = "json"
      log_type         = "slow-log"
    },
    {
      destination_type = "cloudwatch-logs"
      log_format       = "json"
      log_type         = "engine-log"
    }
  ]
}

Examples

For detailed examples on how to use this module, please refer to the Examples directory within this repository.

Author

Your Name Replace MIT and opszero with the appropriate license and your information. Feel free to expand this README with additional details or usage instructions as needed for your specific use case.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Providers

Name Version
aws >= 6.14.0
random 3.7.2

Inputs

Name Description Type Default Required
apply_immediately Specifies whether any modifications are applied immediately, or during the next maintenance window. Default is false. bool false no
auth_token The password used to access a password protected server. Can be specified only if transit_encryption_enabled = true. string null no
auth_token_enabled Flag to specify whether to create auth token (password) protected cluster. Can be specified only if transit_encryption_enabled = true. bool true no
auto_minor_version_upgrade Specifies whether a minor engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Defaults to true. 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 true, Multi-AZ is enabled for this replication group. If false, Multi-AZ is disabled for this replication group. Must be enabled for Redis (cluster mode enabled) replication groups. Defaults to false. bool true no
availability_zone Availability Zone for the cache cluster. If you want to create cache nodes in multi-az, use preferred_availability_zones instead string null no
az_mode Whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. Valid values for this parameter are single-az or cross-az, default is single-az string null no
create_replication_group Determines whether an ElastiCache replication group will be created or not bool true no
deletion_window_in_days Duration in days after which the key is deleted after destruction of the resource. number 7 no
description Description for the cache subnet group. Defaults to Managed by Terraform. string "The Description of the ElastiCache Subnet Group." no
engine ElastiCache engine type to use. Valid values: 'redis', 'valkey', or 'memcached'. string "" no
engine_version The version number of the cache engine to be used for the cache clusters in this replication group. string "7.1" no
final_snapshot_identifier (Redis only) Name of your final cluster snapshot. If omitted, no final snapshot will be made string null no
ip_discovery The IP version to advertise in the discovery protocol. Valid values are ipv4 or ipv6 string null no
length ##------------------------------- random_password---------------------------- number 25 no
log_delivery_configuration (Redis OSS or Valkey) Specifies the destination and format of Redis OSS/Valkey SLOWLOG or Redis OSS/Valkey Engine Log any
{
"slow-log": {
"destination_type": "cloudwatch-logs",
"log_format": "json"
}
}
no
maintenance_window Maintenance window. string "sun:05:00-sun:06:00" no
multi_az_enabled Specifies whether to enable Multi-AZ Support for the replication group. If true, automatic_failover_enabled must also be enabled. Defaults to false. bool false no
name Name (e.g. app or cluster). string "" no
network_type The IP versions for cache cluster connections. Valid values are ipv4, ipv6 or dual_stack string null no
node_type The compute and memory capacity of the nodes in the node group. string "cache.t3.small" no
notification_topic_arn An Amazon Resource Name (ARN) of an SNS topic to send ElastiCache notifications to. string "" no
num_cache_clusters (Required for Cluster Mode Disabled) 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. Updates will occur before other modifications. number 1 no
num_cache_nodes (Required unless replication_group_id is provided) The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcache, this value must be between 1 and 20. If this number is reduced on subsequent runs, the highest numbered nodes will be removed. number 1 no
outpost_mode Specify the outpost mode that will apply to the cache cluster creation. Valid values are single-outpost and cross-outpost, however AWS currently only supports single-outpost mode string null no
parameter_group_family The engine version that the parameter group can be used with string "redis7" no
parameter_group_parameters A list of parameter maps to apply list(map(string)) [] no
port The port number on which the cache engine accepts connections. Default is 11211 for Memcached and 6379 for Redis. number 11211 no
preferred_availability_zones List of the Availability Zones in which cache nodes are created list(string) [] no
preferred_outpost_arn (Required if outpost_mode is specified) The outpost ARN in which the cache cluster will be created string null no
replication_group_description Desc of either the resource. string null no
replication_group_id Replication group identifier. When create_replication_group is set to true, this is the ID assigned to the replication group created. When create_replication_group is set to false, this is the ID of an externally created replication group string null no
retention_in_days Specifies the number of days you want to retain log events in the specified log group. number 0 no
security_group_ids of the security group id. list(any) [] no
security_group_names A list of cache security group names to associate with this replication group. list(string) null no
snapshot_arns A single-element string list containing an Amazon Resource Name (ARN) of a Redis RDB snapshot file stored in Amazon S3. list(string) null no
snapshot_name The name of a snapshot from which to restore data into the new node group. Changing the snapshot_name forces a new resource. string "" no
snapshot_retention_limit (Redis only) The number of days for which ElastiCache will retain automatic cache 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 or cache.t2.* cache nodes. string "0" no
snapshot_window (Redis only) 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 null no
special n/a bool false no
subnet_ids List of VPC Subnet IDs for the cache subnet group. list(any) [] no
tags Additional tags (e.g. map(BusinessUnit,XYZ). map(string) {} no
timeouts Define maximum timeout for creating, updating, and deleting cluster resource map(string) {} no
transit_encryption_enabled Specifies whether to enable encryption in transit. bool false no

Resources

Name Type
aws_cloudwatch_log_group.default resource
aws_elasticache_cluster.this resource
aws_elasticache_parameter_group.default resource
aws_elasticache_replication_group.cluster resource
aws_elasticache_subnet_group.default resource
aws_kms_key.cloudwatch resource
random_password.auth_token resource

Outputs

Name Description
id Redis cluster id.
redis_arn n/a
redis_endpoint Redis endpoint address.

๐Ÿš€ Built by opsZero!

Since 2016 opsZero has been providing Kubernetes expertise to companies of all sizes on any Cloud. With a focus on AI and Compliance we can say we seen it all whether SOC2, HIPAA, PCI-DSS, ITAR, FedRAMP, CMMC we have you and your customers covered.

We provide support to organizations in the following ways:

We do this with a high-touch support model where you:

  • Get access to us on Slack, Microsoft Teams or Email
  • Get 24/7 coverage of your infrastructure
  • Get an accelerated migration to Kubernetes

Please schedule a call if you need support.



About

Provision AWS ElastiCache Redis or Memcached clusters with secure defaults

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • HCL 100.0%