-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
62 lines (51 loc) · 1.56 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
terraform {
required_providers {
metal = {
source = "equinix/metal"
version = ">= 3"
}
equinix = {
source = "equinix/equinix"
}
}
}
provider "metal" {
auth_token = var.auth_token
}
resource "metal_vlan" "vlan1" {
metro = var.metro
project_id = var.project_id
description = var.metal_vlan_description
vxlan = var.metal_vxlan
}
#Deploy Metal Intance
resource "metal_device" "node" {
count = var.metal_node_count
hostname = var.hostname
plan = var.plan
metro = var.metro
operating_system = var.operating_system
billing_cycle = var.billing_cycle
project_id = var.project_id
user_data = templatefile("${path.module}/templates/user_data.sh.tpl", {
LAST_OCTET = count.index + 5
METAL_VXLAN = var.metal_vxlan
})
}
#Set Metal instance to Hybrid Bonded network mode
resource "metal_device_network_type" "node" {
count = var.metal_node_count
device_id = metal_device.node[count.index].id
type = var.metal_network_mode
}
#attach instance to Metal VLAN1
resource "metal_port_vlan_attachment" "router_vlan_attach" {
count = var.metal_node_count
device_id = metal_device.node[count.index].id
port_name = var.port_name
vlan_vnid = metal_vlan.vlan1.vxlan
}
#associate Metal VLAN1 to Primary Port of the shared Connection to Fabric Edge L2
#right now works only for dedicated ports
# "https://registry.terraform.io/providers/equinix/metal/latest/docs/resources/virtual_circuit"
# FR open: "https://github.com/equinix/terraform-provider-metal/issues/150"