-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.tf
More file actions
116 lines (108 loc) · 3.52 KB
/
main.tf
File metadata and controls
116 lines (108 loc) · 3.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
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
##############################################################################
# Resource Group
##############################################################################
module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.6"
# if an existing resource group is not set (null) create a new one using prefix
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
existing_resource_group_name = var.resource_group
}
#############################################################################
# Provision VPC
#############################################################################
module "hub_vpc" {
source = "../../"
resource_group_id = module.resource_group.resource_group_id
region = var.region
name = "hub"
prefix = "${var.prefix}-hub"
tags = var.resource_tags
enable_hub = true
subnets = {
zone-1 = [
{
name = "subnet-a"
cidr = "10.10.10.0/24"
public_gateway = true
acl_name = "vpc-acl"
}
],
zone-2 = [
{
name = "subnet-b"
cidr = "10.20.10.0/24"
public_gateway = false
acl_name = "vpc-acl"
}
],
zone-3 = [
{
name = "subnet-c"
cidr = "10.30.10.0/24"
public_gateway = false
acl_name = "vpc-acl"
}
]
}
}
data "ibm_iam_account_settings" "iam_account_settings" {}
module "spoke_vpc" {
source = "../../"
resource_group_id = module.resource_group.resource_group_id
region = var.region
name = "spoke"
prefix = "${var.prefix}-spoke"
tags = var.resource_tags
hub_account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
hub_vpc_crn = module.hub_vpc.vpc_crn
enable_hub_vpc_crn = true
update_delegated_resolver = false
resolver_type = "manual"
# Point to the custom resolver in the hub VPC
manual_servers = [for location in module.hub_vpc.custom_resolver_hub.locations :
{
address = location.dns_server_ip
}
]
subnets = {
zone-1 = [
{
name = "subnet-a"
cidr = "10.40.10.0/24"
public_gateway = true
acl_name = "vpc-acl"
}
],
zone-2 = [
{
name = "subnet-b"
cidr = "10.50.10.0/24"
public_gateway = false
acl_name = "vpc-acl"
}
],
zone-3 = [
{
name = "subnet-c"
cidr = "10.60.10.0/24"
public_gateway = false
acl_name = "vpc-acl"
}
]
}
}
##############################################################################
# Transit Gateway connects the 2 VPCs
##############################################################################
module "tg_gateway_connection" {
source = "terraform-ibm-modules/transit-gateway/ibm"
version = "2.5.0"
transit_gateway_name = "${var.prefix}-tg"
region = var.region
global_routing = false
resource_tags = var.resource_tags
resource_group_id = module.resource_group.resource_group_id
vpc_connections = [module.hub_vpc.vpc_crn, module.spoke_vpc.vpc_crn]
classic_connections_count = 0
}