-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
57 lines (42 loc) · 1.37 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
terraform {
required_version = ">= 1.2"
required_providers {
vcd = {
source = "vmware/vcd"
version = ">= 3.8.2"
}
}
}
# Create the Datacenter Group data source
data "vcd_vdc_group" "dcgroup" {
org = var.vdc_org_name
name = var.vdc_group_name
}
# Create the NSX-T Edge Gateway data source
data "vcd_nsxt_edgegateway" "t1" {
org = var.vdc_org_name
owner_id = data.vcd_vdc_group.dcgroup.id
name = var.vdc_edge_name
}
data "vcd_network_routed_v2" "network" {
for_each = var.segments
org = var.vdc_org_name
name = each.key
edge_gateway_id = data.vcd_nsxt_edgegateway.t1.id
}
resource "vcd_nsxt_network_dhcp" "dhcp" {
for_each = var.segments
org = var.vdc_org_name
org_network_id = data.vcd_network_routed_v2.network[each.key].id
mode = each.value.dhcp_mode
listener_ip_address = each.value.dhcp_mode == "NETWORK" ? each.value.listener_ip_address : null
lease_time = each.value.lease_time
dns_servers = each.value.dhcp_mode == "RELAY" ? null : each.value.dns_servers
dynamic "pool" {
for_each = each.value.dhcp_mode == "RELAY" ? [] : each.value.pool_ranges
content {
start_address = pool.value.start_address
end_address = pool.value.end_address
}
}
}