-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
138 lines (116 loc) · 4.67 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* VPC MODULE DEFINITION
*
* Author : Joffrey DUPIRE <joffrey.dupire@ynov.com>
* Purpose : A fulfully modelable VPC
* Last updated : 15/06/2018
*
*/
data "aws_region" "current" {
name = var.region
}
data "aws_availability_zones" "availability_zones" {
}
resource "aws_vpc" "vpc" {
cidr_block = var.cidr_block
instance_tenancy = var.instance_tenancy
enable_classiclink = var.enable_classiclink
enable_classiclink_dns_support = var.enable_classiclink_dns_support
enable_dns_hostnames = var.enable_dns_hostnames
enable_dns_support = var.enable_dns_support
assign_generated_ipv6_cidr_block = var.assign_generated_ipv6_cidr_block
tags = {
Name = format(
"%s-%s (%s)",
title(var.plateform_name),
"VPC",
title(var.plateform_environment),
)
Environment = title(var.plateform_environment)
Delivered_Service = "Network"
AWS_Service = "VPC"
Version = var.module_version
}
}
module "subnets" {
source = "./modules/subnets"
#CONDITIONS TO DEPLOY
have_public_subnets = var.have_public_subnets
have_private_subnets = var.have_private_subnets
have_nat_gateways = var.have_nat_gateways
is_multi_az = var.is_multi_az
#VARS IF DEPLOY
## ENV VARS
plateform_name = title(var.plateform_name)
plateform_environment = title(var.plateform_environment)
module_version = var.module_version
## SUBMODULE VARS
vpc_id = aws_vpc.vpc.id
availability_zones = [data.aws_availability_zones.availability_zones.names]
cidr_block = aws_vpc.vpc.cidr_block
virtual_private_gateway_id = var.have_vpn_connections == true ? list(module.vpn.virtual_private_gateway_id) : [] # if have vpn true must be set
}
module "flowlogs" {
source = "./modules/flowlogs"
#CONDITIONS TO DEPLOY
have_flowlogs = var.have_flowlogs
have_kinesis_stream = var.have_kinesis_stream
have_logging_bucket = var.have_logging_bucket
#VARS IF DEPLOY
name = var.plateform_name
environment = var.plateform_environment
vpc_id = aws_vpc.vpc.id
cwl_retention_in_days = var.cwl_retention_in_days
s3_expiration_enabled = var.s3_expiration_enabled
logs_expiration_standard = var.logs_expiration_standard
logs_expiration_onezone = var.logs_expiration_onezone
logs_expiration_glacier = var.logs_expiration_glacier
logs_complete_expiration_days = var.logs_complete_expiration_days
region = var.region
}
module "vpc_peering" {
source = "./modules/vpc_peering"
#CONDITIONS TO DEPLOY
have_vpc_peering = var.have_vpc_peering
#VARS IF DEPLOY
plateform_name = title(var.plateform_name)
plateform_environment = title(var.plateform_environment)
module_version = var.module_version
peer_owner_ids = var.peer_owner_ids
peer_vpc_ids = var.peer_vpc_ids
peer_region = var.peer_region
peer_friendly_name = var.peer_friendly_name
vpc_id = aws_vpc.vpc.id
accepter_allow_remote_vpc_dns_resolution = var.requester_allow_remote_vpc_dns_resolution
accepter_allow_classic_link_to_remote_vpc = var.requester_allow_classic_link_to_remote_vpc
accepter_allow_vpc_to_remote_classic_link = var.requester_allow_vpc_to_remote_classic_link
requester_allow_remote_vpc_dns_resolution = var.requester_allow_remote_vpc_dns_resolution
requester_allow_classic_link_to_remote_vpc = var.requester_allow_classic_link_to_remote_vpc
requester_allow_vpc_to_remote_classic_link = var.requester_allow_vpc_to_remote_classic_link
}
module "vpn" {
source = "./modules/vpn"
#CONDITIONS TO DEPLOY
have_vpn_connections = var.have_vpn_connections
#VARS IF DEPLOY
plateform_name = title(var.plateform_name)
plateform_environment = title(var.plateform_environment)
module_version = var.module_version
client_name = var.vpn_client_name
client_vpn_endpoint = var.vpn_client_endpoint
static_routes_only = var.static_routes_only
amazon_side_asn = var.amazon_side_asn
bgp_asn = var.bgp_asn
vpc_id = aws_vpc.vpc.id
}
/*
module "nacl" {
source = "./modules/nacl"
#CONDITIONS TO DEPLOY
have_nacl = "${var.have_nacl}"
#VARS IF DEPLOY
Plateform_Name = "${title(var.plateform_name)}"
Plateform_Environment = "${title(var.plateform_environment)}"
Module_Version = "${var.module_version}"
}
*/