AWS ElastiCache Cluster

This page shows how to write Terraform and CloudFormation for ElastiCache Cluster and write them securely.

aws_elasticache_cluster (Terraform)

The Cluster in ElastiCache can be configured in Terraform with the resource name aws_elasticache_cluster. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

github-iconstorebot/pr_demo_flat
resource "aws_elasticache_cluster" "noMemcachedInElastiCache" {
  cluster_id           = "cluster-example"
  engine               = "memcached"
  node_type            = "cache.m4.large"
  num_cache_nodes      = 2
  parameter_group_name = "default.memcached1.4"
github-iconmelscoop-test/check
resource "aws_elasticache_cluster" "enabled" {
  cluster_id           = "cluster"
  engine               = "redis"
  node_type            = "cache.m5.large"
  num_cache_nodes      = 1
  parameter_group_name = "default.redis6.x"
github-icongilyas/infracost
resource "aws_elasticache_cluster" "memcached" {
  cluster_id           = "cluster-example"
  engine               = "memcached"
  node_type            = "cache.m4.large"
  num_cache_nodes      = 2
  parameter_group_name = "default.redis3.2"
github-iconSnidermanIndustries/checkov-fork
resource "aws_elasticache_cluster" "enabled" {
  cluster_id           = "cluster"
  engine               = "redis"
  node_type            = "cache.m5.large"
  num_cache_nodes      = 1
  parameter_group_name = "default.redis6.x"
github-iconbridgecrewio/checkov
resource "aws_elasticache_cluster" "enabled" {
  cluster_id           = "cluster"
  engine               = "redis"
  node_type            = "cache.m5.large"
  num_cache_nodes      = 1
  parameter_group_name = "default.redis6.x"

Parameters

Explanation in Terraform Registry

Provides an ElastiCache Cluster resource, which manages either a Memcached cluster, a single-node Redis instance, or a [read replica in a Redis (Cluster Mode Enabled) replication group]. For working with Redis (Cluster Mode Enabled) replication groups, see the aws_elasticache_replication_group resource.

Note: When you change an attribute, such as num_cache_nodes, by default it is applied in the next maintenance window. Because of this, Terraform may report a difference in its planning phase because the actual modification has not yet taken place. You can use the apply_immediately flag to instruct the service to apply the change immediately. Using apply_immediately can result in a brief downtime as the server reboots. See the AWS Documentation on Modifying an ElastiCache Cache Cluster for ElastiCache for Memcached or ElastiCache for Redis for more information. Note: Any attribute changes that re-create the resource will be applied immediately, regardless of the value of apply_immediately.

AWS::ElastiCache::CacheCluster (CloudFormation)

The CacheCluster in ElastiCache can be configured in CloudFormation with the resource name AWS::ElastiCache::CacheCluster. The following sections describe how to use the resource and its parameters.

Parameters

Explanation in CloudFormation Registry

The AWS::ElastiCache::CacheCluster type creates an Amazon ElastiCache cache cluster.

Frequently asked questions

What is AWS ElastiCache Cluster?

AWS ElastiCache Cluster is a resource for ElastiCache of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS ElastiCache Cluster?

For Terraform, the storebot/pr_demo_flat, melscoop-test/check and gilyas/infracost source code examples are useful. See the Terraform Example section for further details.