-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathterraform_modules
More file actions
89 lines (70 loc) · 1.52 KB
/
terraform_modules
File metadata and controls
89 lines (70 loc) · 1.52 KB
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
provider "aws" {
region = var.aws_region
}
#variable declartion
variables "aws_region"{
description="allow the aws region"
default="us-east_1"
}
variable "cidr_block"{
descrpition="allow CIDR block"
default ="10.0.0.0/16"
}
#vcp
resource "aws_vpc" "main_vcp" {
cidr_block = var.cidr_block
tags = {
Name = "main_vcp"
}
}
# Subnets
resource "aws_subnet" "public_1a" {
vpc_id = aws_vpc.main_vcp.id
cidr_block = "var.cidr_block"
availability_zone = "var.aws_region"
tags = {
Name = "public-subnet-1a"
}
}
resource "aws_subnet" "public_1b" {
vpc_id = aws_vpc.main_vcp.id
cidr_block = "var.cidr_block"
availability_zone = "us-east-1b"
tags = {
Name = "public-subnet-1b"
}
}
resource "aws_subnet" "private_2a" {
vpc_id = aws_vpc.main_vcp.id
cidr_block = "var.cidr_block"
availability_zone = "us-east-1b"
tags = {
Name = "private-subnet-2a"
}
}
resource "aws_subnet" "private_2b" {
vpc_id = aws_vpc.main_vcp.id
cidr_block = "var.cidr_block"
availability_zone = "us-east-1b"
tags = {
Name = "private-subnet-2b"
}
}
#internet_gateway
resource "aws_internet_gateway" "ig" {
vpc_id = aws_vpc.main_vcp.id
tags = {
Name = "internet-gateway"
}
}
#nat_gateway
resource "aws_eip" "nat_eip" {
vpc = true
}
resource "aws_nat_gateway" "ng" {
allocation_id = aws_eip.nat_eip.id
subnet_id = aws_subnet.public_1a.id
tags = {
Name = "nat-gateway"
}
}