Skip to content

Commit

Permalink
feat: deploy to specific hardware reservations
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Apr 24, 2024
1 parent 719de3d commit 7d0ab93
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
28 changes: 21 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ locals {

# Pick an arbitrary private subnet, we recommend a /22 like "192.168.100.0/22"
subnet = "192.168.100.0/22"

nutanix_reservation_ids = { for idx, val in var.nutanix_reservation_ids : idx => val }
}

resource "terraform_data" "input_validation" {
lifecycle {
precondition {
condition = length(var.nutanix_reservation_ids) == 0 || length(var.nutanix_reservation_ids) == var.nutanix_node_count
error_message = "var.nutanix_reservation_ids must be empty to use on-demand instance or must have ${var.nutanix_node_count} items to use hardware reservations"
}
}
}

resource "equinix_metal_project" "nutanix" {
Expand Down Expand Up @@ -96,17 +107,20 @@ resource "equinix_metal_gateway" "gateway" {
}

resource "equinix_metal_device" "nutanix" {
count = var.nutanix_node_count
project_id = local.project_id
hostname = "nutanix-devrel-test-${count.index}"
operating_system = "nutanix_lts_6_5"
plan = "m3.large.x86"
metro = var.metal_metro
hardware_reservation_id = "next-available"
count = var.nutanix_node_count
project_id = local.project_id
hostname = "nutanix-devrel-test-${count.index}"
operating_system = "nutanix_lts_6_5"
plan = "m3.large.x86"
metro = var.metal_metro

hardware_reservation_id = lookup(local.nutanix_reservation_ids, count.index, null)
wait_for_reservation_deprovision = length(var.nutanix_reservation_ids) > 0

ip_address {
type = "private_ipv4"
}

}

resource "null_resource" "wait_for_firstboot" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ variable "nutanix_node_count" {
type = number
default = 3
}

variable "nutanix_reservation_ids" {
description = "Hardware reservation IDs to use for the Nutanix nodes. If specified, the length of this list must be the same as `nutanix_node_count`. Each item can be a reservation UUID or `next-available`. If you use reservation UUIDs, make sure that they are in the same metro specified in `metal_metro`."
type = list(string)
default = []
}

0 comments on commit 7d0ab93

Please sign in to comment.