In Terraform, the above could translate to stash project scoped state, for example, for IPAM data:
variable "ipam" {
description = "project scoped ipam (this is stored in the Metal Project API as customdata)"
default = {vlans:{"vlan1001" = { cidr = "192.168.1/24", hosts = 20, offset = 5 }}
}
}
resource "equinix_metal_project" "foo" {
customdata = jsonencode(var.ipam)
}
resource "equinix_metal_device" "foo" {
count = var.ipam.vlan1001.hosts
userdata = templatefile("foo.yaml", { ip = cidrhost(var.ipam.vlan1001.cidr, count.index + var.ipam.vlan1001.offset) })
}
// equinix_metal_vlan to create vlan1001
// equinix_metal_port to attach each device to vlan1001
This is contrived, there are certainly other approaches that may be more effective. Alternatives could include SSH provisioners templated similarly to userdata above, triggered on node count changes.
Nonetheless, the API exposes a project customdata field and Terraform does not offer access to this field potentially keeping users from creative solutioning.
Metal projects offer a
customdata
field which can be used to store arbitrary JSON.In Terraform, the above could translate to stash project scoped state, for example, for IPAM data:
This is contrived, there are certainly other approaches that may be more effective. Alternatives could include SSH provisioners templated similarly to userdata above, triggered on node count changes.
Nonetheless, the API exposes a project customdata field and Terraform does not offer access to this field potentially keeping users from creative solutioning.