-
Notifications
You must be signed in to change notification settings - Fork 0
/
vce_instances.tf
102 lines (90 loc) · 3.42 KB
/
vce_instances.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
/**
* Copyright 2022 Takeoff Technologies Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
data "velocloud_profile" "hub_profile" {
name = var.velocloud_hub_profile
}
resource "google_compute_address" "lan_subnet_static_ip" {
for_each = { for region in var.network_regions : region.name => region }
name = "sdwan-${each.value.name}-lan-ip"
subnetwork = module.sdwan_vpc["lan"].subnets["${each.value.name}/${module.sdwan_vpc["lan"].network_name}-subnet-${each.value.name}"].self_link
address_type = "INTERNAL"
address = cidrhost(each.value.lan_subnet, 2)
region = each.value.name
project = var.project_id
}
resource "velocloud_edge" "gcp_vce" {
for_each = { for region in var.network_regions : region.name => region }
configurationid = data.velocloud_profile.hub_profile.id
modelnumber = "virtual"
name = "${var.project_id}.sdwan-${each.value.name}"
site {
name = var.project_id
}
}
resource "velocloud_device_settings" "gcp_vce" {
for_each = { for region in var.network_regions : region.name => region }
profile = velocloud_edge.gcp_vce[each.value.name].edgeprofileid
vlan {
cidr_ip = "192.168.100.1"
advertise = false
override = false
}
routed_interface {
name = "GE3"
cidr_ip = local.network_interfaces["lan"][each.value.name].network_ip
cidr_prefix = substr(each.value.lan_subnet, -2, -1)
gateway = cidrhost(each.value.lan_subnet, 1)
netmask = cidrnetmask(each.value.lan_subnet)
type = "STATIC"
}
}
resource "time_sleep" "wait_300_seconds" {
depends_on = [velocloud_edge.gcp_vce["*"]]
destroy_duration = "300s"
}
resource "google_compute_instance" "dm_gcp_vce" {
for_each = { for region in var.network_regions : region.name => region }
depends_on = [time_sleep.wait_300_seconds]
name = "sdwan-${each.value.name}"
machine_type = var.vce_machine_type
zone = "${each.value.name}-a"
project = var.project_id
can_ip_forward = true
boot_disk {
initialize_params {
image = "projects/vmware-sdwan-public/global/images/vce-342-102-r342-20200610-ga-3f5ad3b9e2"
}
}
dynamic "network_interface" {
for_each = local.all_vpcs
content {
network = local.network_interfaces[network_interface.value][each.value.name].network
subnetwork = local.network_interfaces[network_interface.value][each.value.name].subnetwork
network_ip = local.network_interfaces[network_interface.value][each.value.name].network_ip
dynamic "access_config" {
for_each = try(local.network_interfaces[network_interface.value][each.value.name].access_config, [])
content {
}
}
}
}
metadata = {
user-data = templatefile("${path.module}/vce.userdata.tpl", {
velocloud_vco = var.velocloud_vco
velocloud_activaction_code = velocloud_edge.gcp_vce[each.value.name].activationkey
})
}
}