Skip to content

Commit

Permalink
separated out sg rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kunduso committed Nov 19, 2024
1 parent a08c516 commit 5b02323
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions security_group.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.this.id
}
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
resource "aws_security_group" "elasticache" {
name = "app-4-elasticache-sg"
name = "${var.name}-elasticache-sg"
description = "Allow inbound to and outbound access from the Amazon ElastiCache cluster."
ingress {
from_port = 6379
to_port = 6379
protocol = "tcp"
cidr_blocks = [var.vpc_cidr]
description = "Enable communication to the Amazon ElastiCache for Redis cluster. "
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
description = "Enable access to the ElastiCache cluster."
}
vpc_id = aws_vpc.this.id
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."
}

0 comments on commit 5b02323

Please sign in to comment.