Skip to content

Commit

Permalink
removed duplicate security group
Browse files Browse the repository at this point in the history
  • Loading branch information
tkjwa committed Nov 15, 2023
1 parent ff3b0e0 commit 5af96d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "instances_security_group_id" {
value = aws_security_group.beanstalk_instances_security_group.id
value = module.beanstalk.instances_security_group_id
}

output "instance_role" {
Expand Down
25 changes: 2 additions & 23 deletions security-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,19 @@ resource "aws_security_group_rule" "allow_all_outbound_traffic_from_lb" {
to_port = 80
protocol = "TCP"
security_group_id = aws_security_group.load_balancer_security_group.id
source_security_group_id = aws_security_group.beanstalk_instances_security_group.id
source_security_group_id = module.beanstalk.instances_security_group_id
}

########################################################################################################################
#### BEANSTALK INSTANCES
########################################################################################################################

resource "aws_security_group" "beanstalk_instances_security_group" {
name = "${var.beanstalk_env_name}-beanstalk-instances"
description = "${var.beanstalk_env_name} ec2 beanstalk instances security group"
vpc_id = var.vpc_id

tags = {
Name = "${var.beanstalk_env_name}-beanstalk-instances"
}
}

resource "aws_security_group_rule" "allow_traffic_from_lb_to_beanstalk_instances" {
description = "Allow inbound traffic to ${var.beanstalk_env_name} beanstalk instances on port 80 from the load balancer"
protocol = "TCP"
type = "ingress"
security_group_id = aws_security_group.beanstalk_instances_security_group.id
security_group_id = module.beanstalk.instances_security_group_id
to_port = 80
source_security_group_id = aws_security_group.load_balancer_security_group.id
from_port = 80
}

resource "aws_security_group_rule" "allow_all_outbound_traffic_from_beanstalk_instances" {
description = "Allow all outbound traffic from ${var.beanstalk_env_name} beanstalk instances"
protocol = "-1"
type = "egress"
security_group_id = aws_security_group.beanstalk_instances_security_group.id
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
from_port = 0
}

0 comments on commit 5af96d8

Please sign in to comment.