-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.tf
127 lines (115 loc) · 5.48 KB
/
config.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
##############################################################################
# Get Config For Subnets, Public Gateways, and VPN Gateways
##############################################################################
module "subnet_config" {
for_each = toset(var.vpc_names)
source = "./config_modules/subnet_config"
prefix = var.prefix
vpc_name = each.key
vpc_names = var.vpc_names
zones = var.zones
vpc_subnet_tiers = var.vpc_subnet_tiers
vpc_subnet_tiers_add_public_gateway = var.vpc_subnet_tiers_add_public_gateway
vpcs_add_vpn_subnet = var.vpcs_add_vpn_subnet
}
##############################################################################
##############################################################################
# Create Network ACLs Config
##############################################################################
module "network_acls" {
for_each = toset(var.vpc_names)
source = "./config_modules/acl_config"
prefix = var.prefix
vpc_name = each.key
vpc_names = var.vpc_names
vpc_subnet_tiers = var.vpc_subnet_tiers
add_cluster_rules = var.add_cluster_rules
global_inbound_allow_list = var.global_inbound_allow_list
global_outbound_allow_list = var.global_outbound_allow_list
global_inbound_deny_list = var.global_inbound_deny_list
global_outbound_deny_list = var.global_outbound_deny_list
vpcs_add_vpn_subnet = var.vpcs_add_vpn_subnet
}
##############################################################################
##############################################################################
# Dynamic VPC Network Configuration
##############################################################################
locals {
##############################################################################
# VPC Config
##############################################################################
vpcs = [
for network in var.vpc_names :
{
prefix = network
resource_group = ibm_resource_group.resource_group[network].id
default_security_group_rules = []
address_prefixes = {
zone-1 = []
zone-2 = []
zone-3 = []
}
subnets = module.subnet_config[network].subnets
use_public_gateways = module.subnet_config[network].use_public_gateways
vpn_gateway = module.subnet_config[network].vpn_gateway
network_acls = module.network_acls[network].network_acls
flow_logs_bucket_name = "${network}-flow-logs-bucket"
}
]
##############################################################################
# Shortcut for management resource group
management_rg = ibm_resource_group.resource_group[var.vpc_names[0]].id
##############################################################################
# Config
##############################################################################
config = {
vpcs = local.vpcs
##############################################################################
# Key Management
##############################################################################
key_management = {
name = var.existing_hs_crypto_name == null ? "kms" : var.existing_hs_crypto_name
use_hs_crypto = var.existing_hs_crypto_name == null ? false : true
use_data = var.existing_hs_crypto_name == null ? false : true
resource_group_name = var.existing_hs_crypto_resource_group == null ? local.management_rg : var.existing_hs_crypto_resource_group
authorize_vpc_reader_role = true
}
##############################################################################
##############################################################################
# Atracker
##############################################################################
atracker = {
receive_global_events = true
add_route = var.add_atracker_route
collector_bucket_name = "atracker-bucket"
}
enable_atracker = var.enable_atracker
##############################################################################
##############################################################################
# Cloud Object Storage
##############################################################################
cos = [
{
name = "cos"
resource_group_name = local.management_rg
random_suffix = var.cos_use_random_suffix
plan = "standard"
use_data = false
buckets = [
# Create a flow log bucket for each vpc and a bucket for atracker
for network in concat(var.vpc_names, var.enable_atracker == true ? ["atracker"] : []) :
{
name = network == "atracker" ? "atracker-bucket" : "${network}-flow-logs-bucket"
endpoint_type = "public"
force_delete = true
storage_class = "standard"
kms_key = "bucket-key"
}
]
keys = []
}
]
##############################################################################
}
}
##############################################################################