Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose customdata in equinix_metal_project #145

Open
displague opened this issue Jun 1, 2022 · 1 comment
Open

Expose customdata in equinix_metal_project #145

displague opened this issue Jun 1, 2022 · 1 comment
Labels
area/resources/metal Issues related to Metal APIs enhancement New feature or request

Comments

@displague
Copy link
Member

displague commented Jun 1, 2022

Metal projects offer a customdata field which can be used to store arbitrary JSON.

curl -H "X-Auth-Token: $METAL_AUTH_TOKEN" \
     -H 'Content-type: application/json' \
     -X PUT \
     -d '{"customdata": {"any":["json"]}' \
    https://api.equinix.com/metal/v1/projects/$METAL_PROJECT_ID

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.

@displague displague added the enhancement New feature or request label Jun 1, 2022
@displague
Copy link
Member Author

This will depend on packngo support for Project.CustomData. See equinixmetal-archive/packngo#225

@displague displague added the area/resources/metal Issues related to Metal APIs label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resources/metal Issues related to Metal APIs enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant