-
Notifications
You must be signed in to change notification settings - Fork 2
/
security_group.tf
26 lines (26 loc) · 1.16 KB
/
security_group.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
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
resource "aws_security_group" "elasticache" {
name = "${var.name}-elasticache-sg"
description = "Allow inbound to and outbound access from the Amazon ElastiCache cluster."
vpc_id = module.vpc.vpc.id
}
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule
resource "aws_security_group_rule" "elasticache_ingress" {
type = "ingress"
security_group_id = aws_security_group.elasticache.id
from_port = 6379
to_port = 6379
protocol = "tcp"
cidr_blocks = [var.vpc_cidr]
description = "Enable communication to the Amazon ElastiCache for Redis cluster."
}
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule
resource "aws_security_group_rule" "elasticache_egress" {
type = "egress"
security_group_id = aws_security_group.elasticache.id
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
description = "Enable access to the ElastiCache cluster."
}