-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
103 lines (92 loc) · 2.43 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
resource "aws_vpc" "Vpc" {
cidr_block = local.VpcCidrBlock
instance_tenancy = local.VpcInstanceTenancy
enable_dns_support = local.VpcEnableDnsSupport
enable_dns_hostnames = local.VpcEnableDnsHostnames
tags = {
Name = local.VpcName
Owner = local.UserEmailTag
Project = local.UserProjectTag
}
}
resource "aws_subnet" "PublicSubnet" {
availability_zone = local.PublicSubnetAvailabilityZone
cidr_block = local.PublicSubnetCidrBlock
vpc_id = aws_vpc.Vpc.id
tags = {
Name = local.PublicSubnetName
Owner = local.UserEmailTag
Project = local.UserProjectTag
}
}
resource "aws_security_group" "PublicSecurityGroup" {
name = local.PublicSecurityGroupName
description = local.PublicSecurityGroupName
vpc_id = aws_vpc.Vpc.id
tags = {
Name = local.PublicSecurityGroupName
Owner = local.UserEmailTag
Project = local.UserProjectTag
}
}
resource "aws_security_group_rule" "PublicIngress1" {
type = "ingress"
security_group_id = aws_security_group.PublicSecurityGroup.id
protocol = "-1"
from_port = 0
to_port = 0
source_security_group_id = aws_security_group.PublicSecurityGroup.id
}
resource "aws_security_group_rule" "PublicIngress443" {
type = "ingress"
security_group_id = aws_security_group.PublicSecurityGroup.id
protocol = "tcp"
from_port = 443
to_port = 443
cidr_blocks = local.InboundIPv4CidrBlocks
}
resource "aws_security_group_rule" "PublicEgress1" {
type = "egress"
security_group_id = aws_security_group.PublicSecurityGroup.id
protocol = "-1"
to_port = 0
from_port = 0
cidr_blocks = [ "0.0.0.0/0" ]
}
resource "aws_default_security_group" "DefaultEgress1" {
vpc_id = aws_vpc.Vpc.id
egress {
protocol = -1
self = true
from_port = 0
to_port = 0
}
}
resource "aws_internet_gateway" "InternetGw" {
vpc_id = aws_vpc.Vpc.id
tags = {
Name = local.InternetGwName
Owner = local.UserEmailTag
Project = local.UserProjectTag
}
}
resource "aws_route" "PublicRoute" {
destination_cidr_block = "0.0.0.0/0"
route_table_id = aws_route_table.PublicRouteTable.id
gateway_id = aws_internet_gateway.InternetGw.id
depends_on = [
aws_internet_gateway.InternetGw
]
}
resource "aws_route_table" "PublicRouteTable" {
vpc_id = aws_vpc.Vpc.id
tags = {
Name = local.PublicRouteTableName
Owner = local.UserEmailTag
Project = local.UserProjectTag
}
}
resource "aws_route_table_association" "PublicSubnetRouteTableAssociation" {
route_table_id = aws_route_table.PublicRouteTable.id
subnet_id = aws_subnet.PublicSubnet.id
}