-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsecurity_group.tf
41 lines (35 loc) · 1.02 KB
/
security_group.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
resource "aws_security_group" "bastion" {
name = "Bastion host of ${local.project}"
description = "Allow SSH access to bastion host and outbound internet access"
vpc_id = local.vpc_id
lifecycle {
create_before_destroy = true
}
tags = {
Project = local.project
}
}
resource "aws_security_group_rule" "ssh" {
protocol = "TCP"
from_port = 22
to_port = 22
type = "ingress"
cidr_blocks = var.allowed_hosts
security_group_id = aws_security_group.bastion.id
}
resource "aws_security_group_rule" "internet" {
protocol = "-1"
from_port = 0
to_port = 0
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = aws_security_group.bastion.id
}
resource "aws_security_group_rule" "intranet" {
protocol = "-1"
from_port = 0
to_port = 0
type = "egress"
cidr_blocks = var.internal_networks
security_group_id = aws_security_group.bastion.id
}