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 = [aws_security_group.aws_security_group_public.name]
}
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 = [aws_security_group.aws_security_group_public.name]
}
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 = var.name
description = var.description
security_group_names = var.security_group_names
Parameters
-
description
optional - string -
id
optional computed - string -
name
required - string -
security_group_names
required - set of string
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.
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::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.
Parameters
-
Description
required - String -
Tags
optional - List of Tag
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.