-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsg.tf
More file actions
33 lines (29 loc) · 1016 Bytes
/
sg.tf
File metadata and controls
33 lines (29 loc) · 1016 Bytes
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
data "aws_subnet" "selected_subnet" {
id = var.subnet_id
}
data "aws_vpc" "selected" {
id = data.aws_subnet.selected_subnet.vpc_id
}
resource "aws_security_group" "dsf_agent_sg" {
description = "${var.friendly_name} - Basic security group"
vpc_id = data.aws_subnet.selected_subnet.vpc_id
tags = var.tags
}
resource "aws_security_group_rule" "all_out" {
description = "${var.friendly_name} - Allow all out"
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = aws_security_group.dsf_agent_sg.id
}
resource "aws_security_group_rule" "sg_cidr_ingress" {
description = "${var.friendly_name} - Allow ssh local"
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = concat([data.aws_vpc.selected.cidr_block], var.allowed_ssh_cidrs)
security_group_id = aws_security_group.dsf_agent_sg.id
}