Skip to content

Commit

Permalink
Merge pull request #6 from equinix-labs/no-crosstalk
Browse files Browse the repository at this point in the history
fix: allow 2 users with the same access to use different projects
  • Loading branch information
displague authored Mar 25, 2024
2 parents 1f2eb47 + 9ae160c commit 367b7da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
19 changes: 14 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
locals {
project_id = var.create_project ? equinix_metal_project.nutanix.*.id[0] : data.equinix_metal_project.nutanix.id
}

resource "equinix_metal_project" "nutanix" {
count = var.create_project ? 1 : 0
name = var.metal_project_name
}

data "equinix_metal_project" "nutanix" {
name = "devrel-marques-testing"
name = var.metal_project_name
}

resource "equinix_metal_vlan" "test" {
project_id = data.equinix_metal_project.nutanix.id
project_id = local.project_id
description = var.metal_vlan_description
metro = "da"
}

resource "equinix_metal_device" "bastion" {
project_id = data.equinix_metal_project.nutanix.id
project_id = local.project_id
hostname = "bastion"
user_data = templatefile("${path.module}/templates/bastion-userdata.tftpl", {
"metal_auth_token" : var.metal_auth_token,
Expand All @@ -30,7 +39,7 @@ resource "equinix_metal_port" "bastion_bond0" {

resource "equinix_metal_device" "nutanix" {
count = 1
project_id = data.equinix_metal_project.nutanix.id
project_id = local.project_id
hostname = "nutanix-devrel-test-${count.index}"
user_data = templatefile("${path.module}/templates/nutanix-userdata.tftpl", {})
operating_system = "nutanix_lts_6_5"
Expand All @@ -40,7 +49,7 @@ resource "equinix_metal_device" "nutanix" {

resource "equinix_metal_project_ssh_key" "ssh_key" {
name = "nutanix-ssh-key"
project_id = data.equinix_metal_project.nutanix.id
project_id = local.project_id
public_key = tls_private_key.ssh_key.public_key_openssh
}

Expand Down
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ variable "metal_auth_token" {
variable "metal_vlan_description" {
default = "ntnx-demo"
}

variable "metal_project_name" {
description = "The name of the Metal project in which to deploy the cluster. If create_project is false the project will be looked up by name."
}

variable "create_project" {
default = true
description = "(Optional) to use an existing project matching `metal_project_name`, set this to false"
}

0 comments on commit 367b7da

Please sign in to comment.