Skip to content

Commit 5b02323

Browse files
committed
separated out sg rules
1 parent a08c516 commit 5b02323

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

security_group.tf

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
resource "aws_default_security_group" "default" {
2-
vpc_id = aws_vpc.this.id
3-
}
1+
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
42
resource "aws_security_group" "elasticache" {
5-
name = "app-4-elasticache-sg"
3+
name = "${var.name}-elasticache-sg"
64
description = "Allow inbound to and outbound access from the Amazon ElastiCache cluster."
7-
ingress {
8-
from_port = 6379
9-
to_port = 6379
10-
protocol = "tcp"
11-
cidr_blocks = [var.vpc_cidr]
12-
description = "Enable communication to the Amazon ElastiCache for Redis cluster. "
13-
}
14-
egress {
15-
from_port = 0
16-
to_port = 0
17-
protocol = "-1"
18-
cidr_blocks = ["0.0.0.0/0"]
19-
description = "Enable access to the ElastiCache cluster."
20-
}
21-
vpc_id = aws_vpc.this.id
5+
vpc_id = module.vpc.vpc.id
6+
}
7+
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule
8+
resource "aws_security_group_rule" "elasticache_ingress" {
9+
type = "ingress"
10+
security_group_id = aws_security_group.elasticache.id
11+
from_port = 6379
12+
to_port = 6379
13+
protocol = "tcp"
14+
cidr_blocks = [var.vpc_cidr]
15+
description = "Enable communication to the Amazon ElastiCache for Redis cluster."
16+
}
17+
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule
18+
resource "aws_security_group_rule" "elasticache_egress" {
19+
type = "egress"
20+
security_group_id = aws_security_group.elasticache.id
21+
from_port = 0
22+
to_port = 0
23+
protocol = "-1"
24+
cidr_blocks = ["0.0.0.0/0"]
25+
description = "Enable access to the ElastiCache cluster."
2226
}

0 commit comments

Comments
 (0)