-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.tf
74 lines (74 loc) · 2.09 KB
/
vpc.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
# Define public subnet
resource "aws_vpc" "Cmosetick" {
cidr_block = "192.168.0.0/24"
enable_dns_support = "True"
enable_dns_hostnames = "True"
tags {
Name = "Cmosetick"
}
}
# Define Internet Gateway for vpc
resource "aws_internet_gateway" "Cmosetick-IG" {
vpc_id = "${aws_vpc.Cmosetick.id}"
tags {
Name = "Cmosetick-IG"
}
}
# Define route table for public access
resource "aws_route_table" "Public-Route" {
vpc_id = "${aws_vpc.Cmosetick.id}"
route = {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.Cmosetick-IG.id}"
}
tags {
Name = "Public-Route"
}
}
# Define route table association
resource "aws_route_table_association" "Public-Route" {
subnet_id = "${aws_subnet.Cmosetick-Public.id}"
route_table_id = "${aws_route_table.Public-Route.id}"
}
# Public subnet
resource "aws_subnet" "Cmosetick-Public" {
vpc_id = "${aws_vpc.Cmosetick.id}"
availability_zone = "${var.my_availability_zone}"
cidr_block = "192.168.0.0/24"
tags {
Name = "Cmosetick-Public"
}
}
# Public access security group
resource "aws_security_group" "Cmosetick-Public" {
name = "Cmosetick-Public"
vpc_id = "${aws_vpc.Cmosetick.id}"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# Allow all outbound traffic
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "Cmosetick-Public"
}
}