generated from rhythmictech/terraform-terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
groups.tf
58 lines (50 loc) · 1.84 KB
/
groups.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
resource "aws_security_group" "this" {
name_prefix = var.name
description = "Attached to all Bitbucket instances"
vpc_id = var.vpc_id
tags = merge(var.tags,
{ "Name" : var.name }
)
lifecycle {
create_before_destroy = true
}
}
resource "aws_security_group_rule" "allow_all" {
count = var.asg_allow_outbound_egress ? 1 : 0
cidr_blocks = ["0.0.0.0/0"] #tfsec:ignore:AWS007
description = "Allow outbound egress"
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.this.id
to_port = 0
type = "egress"
}
resource "aws_security_group_rule" "allow_inbound_http_from_lb" {
description = "Allow HTTPS traffic from the load balancer"
from_port = 7990
protocol = "tcp"
security_group_id = aws_security_group.this.id
source_security_group_id = try(aws_security_group.alb_https[0].id, aws_security_group.elb[0].id)
to_port = 7990
type = "ingress"
}
resource "aws_security_group_rule" "allow_inbound_http_from_lb_ssh" {
count = var.create_alb ? 0 : 1
description = "Allow SSH traffic from the load balancer"
from_port = 7999
protocol = "tcp"
security_group_id = aws_security_group.this.id
source_security_group_id = aws_security_group.elb[0].id
to_port = 7999
type = "ingress"
}
resource "aws_security_group_rule" "allow_inbound_from_lb_ssh" {
count = var.create_alb ? 1 : 0
cidr_blocks = var.alb_allowed_ssh_cidr_blocks
description = "Allow SSH traffic - NLBs do not support SGs"
from_port = 7999
protocol = "tcp"
security_group_id = aws_security_group.this.id
to_port = 7999
type = "ingress"
}