-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
72 lines (53 loc) · 1.48 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
# =====================================================
# Fetching Az Names
# =====================================================
data "aws_availability_zones" "az" {
state = "available"
}
# =====================================================
# vpc Creation
# =====================================================
resource "aws_vpc" "vpc" {
cidr_block = var.vpc_cidr
instance_tenancy = "default"
enable_dns_support = true
enable_dns_hostnames = true
lifecycle {
create_before_destroy = true
}
tags = {
Name = "${var.project}-vpc"
project = var.project
}
}
# =====================================================
# Attaching Internet gateWay
# =====================================================
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.vpc.id
tags = {
Name = "${var.project}-igw"
project = var.project
}
}
# =====================================================
# Elatic Ip Allocation
# =====================================================
resource "aws_eip" "eip" {
vpc = true
tags = {
Name = "${var.project}-nat-eip"
project = var.project
}
}
# =====================================================
# Creating Nat GateWay
# =====================================================
resource "aws_nat_gateway" "nat" {
allocation_id = aws_eip.eip.id
subnet_id = aws_subnet.Public2.id
tags = {
Name = "${var.project}-nat-eip"
project = var.project
}
}