-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
99 lines (79 loc) · 1.99 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
provider "aws"{
shared_config_files = ["~/.aws/config"]
shared_credentials_files = ["~/.aws/credentials"]
}
resource "aws_vpc" "fis_vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public_subnet" {
cidr_block = "10.0.1.0/24"
vpc_id = aws_vpc.fis_vpc.id
}
resource "aws_subnet" "private_subnet" {
cidr_block = "10.0.2.0/24"
vpc_id = aws_vpc.fis_vpc.id
}
resource "aws_internet_gateway" "fis_public_internet_gateway" {
vpc_id = aws_vpc.fis_vpc.id
}
resource "aws_route_table" "fis_public_subnet_route_table" {
vpc_id = aws_vpc.fis_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.fis_public_internet_gateway.id
}
route {
ipv6_cidr_block = "::/0"
gateway_id = aws_internet_gateway.fis_public_internet_gateway.id
}
}
resource "aws_route_table_association" "fis_public_association" {
route_table_id = aws_route_table.fis_public_subnet_route_table.id
subnet_id = aws_subnet.public_subnet.id
}
resource "aws_security_group" "web_server_sg" {
vpc_id = aws_vpc.fis_vpc.id
ingress{
description = "Allow HTTP traffic form internet"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress{
description = "Allow HTTPS traffic form internet"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
description = "Allow all trafic"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "aeis security group"
}
}
//Data
data "aws_ami" "ubuntu" {
most_recent = "true"
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "ubuntu_aeis_instance" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
subnet_id = aws_subnet.public_subnet.id
}