Review ElastiCache default ports and access controls

Check permitted clients, authentication, and encryption rather than relying on the port number.

Description

Redis OSS defaults to port 6379 and Memcached to 11211. The port number alone tells you little about who can reach the cache.

Potential impact

An overly broad network rule lets clients that do not need the cache attempt connections.

Remediation

Restrict the subnets and security groups to required clients and use authentication supported by the engine. For TLS on node-based Redis OSS, configure a supported replication group and TLS clients. If you need another port, choose a supported value. Review the Terraform plan for the resulting cluster replacement and coordinate the data, client and firewall changes.

Examples

The examples change the Redis OSS port from 6379 to 6380. Supply the referenced parameter group and the network configuration separately.

Before

hcl
resource "aws_elasticache_cluster" "example" {
  cluster_id           = "cluster"
  engine               = "redis"
  node_type            = "cache.m5.large"
  num_cache_nodes      = 1
  parameter_group_name = aws_elasticache_parameter_group.default.id
  port                 = 6379
}

After

hcl
resource "aws_elasticache_cluster" "example" {
  cluster_id           = "cluster"
  engine               = "redis"
  node_type            = "cache.m5.large"
  num_cache_nodes      = 1
  parameter_group_name = aws_elasticache_parameter_group.default.id
  port                 = 6380
}

References