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
resource "aws_elasticache_subnet_group" "redis-subnets" {
name = "redis-subnets"
subnet_ids = var.subnet_ids
}
resource "aws_elasticache_cluster" "elasticache-memcached" {
resource "aws_elasticache_subnet_group" "redis-subnets" {
name = "redis-subnets"
subnet_ids = var.subnet_ids
}
resource "aws_elasticache_cluster" "elasticache-memcached" {
Parameters
-
description
optional - string -
id
optional computed - string -
name
required - string -
subnet_ids
required - set of string
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.
aws_elasticache_cluster
Ensure to enable backup retention of Elasitcache
It's better to take snapshots of Redis clusters to improve data availability.
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.
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
-
CacheSubnetGroupName
optional - String -
Description
required - String -
SubnetIds
required - List -
Tags
optional - List of Tag
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.