-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.tf
68 lines (60 loc) · 2.01 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
# AWS VPC
terraform {
required_version = ">= 0.12.0"
}
# AWS VPC Resources
resource "aws_vpc" "vpc" {
cidr_block = var.cidr
tags = {
Name = "${var.cluster_prefix}-${var.cluster_environment}"
Environment = var.cluster_environment
}
}
# AWS VPC Internet Gateway
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.vpc.id
tags = {
Name = "${var.cluster_prefix}-${var.cluster_environment}"
Environment = var.cluster_environment
}
}
# AWS VPC Subnets Module - Public Subnet
module "public_subnet" {
source = "./modules/subnets"
vpc_id = aws_vpc.vpc.id
aws_internet_gateway_id = aws_internet_gateway.igw.id
subnet_bits = var.subnet_bits
cidr = var.cidr
cluster_prefix = var.cluster_prefix
cluster_environment = var.cluster_environment
subnet_type = ["public"]
cluster_architecture = var.cluster_architecture
}
# AWS NAT Gateway Module
module "nat_gateway" {
source = "./modules/nat-gateways"
cluster_prefix = var.cluster_prefix
cluster_environment = var.cluster_environment
public_subnet_ids = module.public_subnet.public_subnet_ids
cluster_architecture = var.cluster_architecture
}
# AWS VPC Subnets Module - Private Subnet
module "private_subnet" {
source = "./modules/subnets"
vpc_id = aws_vpc.vpc.id
aws_nat_gateway_id = module.nat_gateway.nat_gateway_ids
cidr = var.cidr
cluster_prefix = var.cluster_prefix
cluster_environment = var.cluster_environment
subnet_bits = var.subnet_bits
subnet_type = ["private", "storage"]
cluster_architecture = var.cluster_architecture
}
# AWS VPC Security Groups Module
module "security_group" {
source = "./modules/security-groups"
vpc_id = aws_vpc.vpc.id
cluster_prefix = var.cluster_prefix
cluster_environment = var.cluster_environment
cluster_architecture = var.cluster_architecture
}