Project: KICS (Provisioning / Security & Compliance)
File: 54229498-850b-4f78-b3a7-218d24ef2c37.md

title: BOM - AWS Elasticache hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 54229498-850b-4f78-b3a7-218d24ef2c37 Query name: BOM - AWS Elasticache Platform: Terraform Severity: <span style="color:#CCCCCC">Trace</span> Category: Bill Of Materials URL: A list of Elasticache resources found. Amazon ElastiCache is a fully managed, in-memory caching service supporting flexible, real-time use cases. You can use ElastiCache for caching, which accelerates application and database performance, or as a primary data store for use cases that don't require durability like session stores, gaming leaderboards, streaming, and analytics. ElastiCache is compatible with Redis and Memcached.<br> ```tf title="Positive test num. 1 - tf file" hl_lines="1" resource "awselasticachecluster" "positive1" { cluster_id = "cluster-example" engine = "memcached" node_type = "cache.m4.large" numcachenodes = 2 parametergroupname = awselasticacheparametergroup.default1 port = 11211 } resource "awselasticacheparametergroup" "default1" { name = "cache-params" family = "memcached1.4" } ``` ```tf title="Positive test num. 2 - tf file" hl_lines="1" resource "awselasticachecluster" "positive2" { cluster_id = "cluster-example" engine = "redis" node_type = "cache.m4.large" numcachenodes = 1 parametergroupname = awselasticacheparametergroup.default2 engine_version = "3.2.10" port = 6379 } resource "awselasticacheparametergroup" "default2" { name = "cache-params" family = "redis3.2" } ``` ```tf title="Positive test num. 3 - tf file" hl_lines="33" resource "awssecuritygroup" "sg1" { name = "sg1" description = "sg1" ingress { from_port = 0 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } } resource "awssecuritygroup" "sg2" { name = "sg2" description = "positive3" ingress { from_port = 0 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } } resource "awselasticachesecurity_group" "positive3" { name = "positive3" securitygroupnames = [ awssecuritygroup.sg1.name, awssecuritygroup.sg2.name, ] } resource "awselasticachecluster" "positive3" { cluster_id = "test-cache" engine = "redis" node_type = "cache.m4.large" port = 6379 numcachenodes = 1 parametergroupname = awselasticacheparameter_group.default.id securitygroupnames = [awselasticachesecurity_group.positive3.name] } ``` <details><summary>Positive test num. 4 - tf file</summary> ```tf hl_lines="33" resource "awssecuritygroup" "sg11" { name = "sg1" description = "sg11" ingress { from_port = 0 to_port = 22 protocol = "tcp" cidr_blocks =

} } resource "awssecuritygroup" "sg22" { name = "sg22" description = "positive3" ingress { from_port = 0 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.2.0/0"] } } resource "awselasticachesecurity_group" "positive4" { name = "positive4" securitygroupnames = [ awssecuritygroup.sg11.name, awssecuritygroup.sg22.name, ] } resource "awselasticachecluster" "positive4" { cluster_id = "test-cache" engine = "redis" node_type = "cache.m4.large" port = 6379 numcachenodes = 1 parametergroupname = awselasticacheparameter_group.default.id securitygroupnames = [awselasticachesecurity_group.positive4.name] } ``` </details> <details><summary>Positive test num. 5 - tf file</summary> ```tf hl_lines="13" resource "awssecuritygroup" "sgg" { name = "sgg" description = "sgg" ingress { from_port = 0 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.2.0/0"] } } resource "awselasticachecluster" "positive5" { cluster_id = "test-cache" engine = "redis" node_type = "cache.m4.large" port = 6379 numcachenodes = 1 parametergroupname = awselasticacheparameter_group.default.id securitygroupnames = [awssecuritygroup.sgg.name] } ``` </details> <details><summary>Positive test num. 6 - tf file</summary> ```tf hl_lines="13" resource "awssecuritygroup" "sg6" { name = "sg6" description = "sg6" ingress { from_port = 0 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } } resource "awselasticachecluster" "positive6" { cluster_id = "test-cache" engine = "redis" node_type = "cache.m4.large" port = 6379 numcachenodes = 1 parametergroupname = awselasticacheparameter_group.default.id securitygroupids = [awssecuritygroup.sg6.id] } ``` </details> ```tf title="Negative test num. 1 - tf file" module "redis" { source = "cloudposse/elasticache-redis/aws" version = "0.40.1" availabilityzones = var.availabilityzones namespace = var.namespace stage = var.stage name = var.name zoneid = var.zoneid vpcid = module.vpc.vpcid subnets = module.subnets.privatesubnetids clustersize = var.clustersize instancetype = var.instancetype apply_immediately = true automaticfailoverenabled = false engineversion = var.engineversion family = var.family atrestencryptionenabled = var.atrestencryptionenabled transitencryptionenabled = var.transitencryptionenabled securitygrouprules = [ { type = "egress" from_port = 0 to_port = 65535 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] sourcesecuritygroup_id = null description = "Allow all outbound traffic" }, { type = "ingress" from_port = 0 to_port = 65535 protocol = "-1" cidr_blocks = [] sourcesecuritygroupid = module.vpc.vpcdefaultsecuritygroup_id description = "Allow all inbound traffic from trusted Security Groups" }, ] parameter = [ { name = "notify-keyspace-events" value = "lK" } ] } ```