-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis.tf
38 lines (34 loc) · 1.21 KB
/
redis.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
resource "aws_security_group" "redis_service" {
name = "${var.namespace}-redis-service"
vpc_id = module.vpc.vpc_id
}
resource "aws_security_group_rule" "redis_egress" {
security_group_id = aws_security_group.redis_service.id
type = "egress"
from_port = "0"
to_port = "0"
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
resource "aws_security_group_rule" "redis_ingress" {
security_group_id = aws_security_group.redis_service.id
type = "ingress"
from_port = "6379"
to_port = "6379"
protocol = "tcp"
cidr_blocks = [module.vpc.vpc_cidr_block]
}
resource "aws_elasticache_subnet_group" "redis" {
name = "${var.namespace}-redis"
subnet_ids = module.vpc.private_subnets
}
resource "aws_elasticache_cluster" "redis" {
for_each = toset(["dev", "pg", "stable"])
cluster_id = "${var.namespace}-${each.key}-redis"
engine = "redis"
node_type = "cache.t3.micro"
num_cache_nodes = 1
engine_version = "7.0"
security_group_ids = [aws_security_group.redis_service.id]
subnet_group_name = aws_elasticache_subnet_group.redis.name
}