AWS ElastiCache Security Group

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

aws_elasticache_security_group (Terraform)

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

Example Usage from GitHub
resource "aws_elasticache_security_group" "aws_elasticache_security_group_public" {
  name                 = "elasticache-security-group"
  security_group_names = []

resource "aws_elasticache_security_group" "aws_elasticache_security_group_private" {
resource "aws_elasticache_security_group" "security_group" {
  count                = length(var.security_group)
  name                 = lookup(var.security_group[count.index], "name")
  security_group_names = [var.security_group_names]
resource "aws_elasticache_security_group" "aws_elasticache_security_group_public" {
  name                 = "elasticache-security-group"
  security_group_names = []

resource "aws_elasticache_security_group" "aws_elasticache_security_group_private" {
resource "aws_elasticache_security_group" "bar" {
  name                 = "elastic-redis"
  security_group_names = ["elastic-redis"]
resource "aws_elasticache_security_group" "general" {
  name =
  description = var.description
  security_group_names = var.security_group_names

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).


Explanation in Terraform Registry

Provides an ElastiCache Security Group to control access to one or more cache clusters.

NOTE: ElastiCache Security Groups are for use only when working with an ElastiCache cluster outside of a VPC. If you are using a VPC, see the ElastiCache Subnet 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.



Ensure to enable backup retention of Elasitcache

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



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::SecurityGroup (CloudFormation)

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

Example Usage from GitHub

An example could not be found in GitHub.


Explanation in CloudFormation Registry

The AWS::ElastiCache::SecurityGroup resource creates a cache security group. For more information about cache security groups, go to CacheSecurityGroups in the Amazon ElastiCache User Guide or go to CreateCacheSecurityGroup in the Amazon ElastiCache API Reference Guide. For more information, see CreateCacheSubnetGroup.

Frequently asked questions

What is AWS ElastiCache Security Group?

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

For Terraform, the SnidermanIndustries/checkov-fork, mikamakusa/terraform and melscoop-test/check source code examples are useful. See the Terraform Example section for further details.