AWS ElastiCache Subnet Group

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

aws_elasticache_subnet_group (Terraform)

The Subnet Group in ElastiCache can be configured in Terraform with the resource name aws_elasticache_subnet_group. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L13
resource "aws_elasticache_subnet_group" "redis-subnets" {
  name       = "redis-subnets"
  subnet_ids = var.subnet_ids
}

resource "aws_elasticache_cluster" "elasticache-memcached" {
main.tf#L13
resource "aws_elasticache_subnet_group" "redis-subnets" {
  name       = "redis-subnets"
  subnet_ids = var.subnet_ids
}

resource "aws_elasticache_cluster" "elasticache-memcached" {

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Provides an ElastiCache Subnet Group resource.

NOTE: ElastiCache Subnet Groups are only for use when working with an ElastiCache cluster inside of a VPC. If you are on EC2 Classic, see the ElastiCache Security Group resource.

Tips: Best Practices for The Other AWS ElastiCache Resources

In addition to the aws_elasticache_cluster, AWS ElastiCache has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

aws_elasticache_cluster

Ensure to enable backup retention of Elasitcache

It's better to take snapshots of Redis clusters to improve data availability.

risk-label

aws_elasticache_replication_group

Ensure to enable in-transit encryption of ElastiCache

It's better to enable in-transit encryption of ElastiCahe. If the ElastiCache replication group uses unencrypted traffic, it is vulnerable to meet-in-the-middle (MITM) attacks.

Review your AWS ElastiCache settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

AWS::ElastiCache::SubnetGroup (CloudFormation)

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

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

Explanation in CloudFormation Registry

Creates a cache subnet group. For more information about cache subnet groups, go to Cache Subnet Groups in the Amazon ElastiCache User Guide or go to CreateCacheSubnetGroup in the Amazon ElastiCache API Reference Guide.

Frequently asked questions

What is AWS ElastiCache Subnet Group?

AWS ElastiCache Subnet Group 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 Subnet Group?

For Terraform, the chidrup/terraform_aws and anupdubbewar/terraform-aws source code examples are useful. See the Terraform Example section for further details.