Cloud

Query Equinix Metal

Query Equinix Metal infrastructure with cnquery

Rely on cnquery to query and inventory your Equinix Metal infrastructure. Explore devices, projects, SSH keys, and more within your Equinix Metal organization.

Requirements

To analyze your Equinix Metal environment with cnquery, you must have:

Configure access to Equinix Metal

To create an API token:

  1. Log in to the Equinix Metal console.
  2. Navigate to your user settings.
  3. Generate an API token.

Connect to Equinix Metal

Query an organization

To query resources within an organization:

cnquery shell equinix org ORG_ID --token YOUR_API_TOKEN
For...Substitute...
ORG_IDYour Equinix Metal organization ID

Query a project

To query resources within a specific project:

cnquery shell equinix project PROJECT_ID --token YOUR_API_TOKEN
For...Substitute...
PROJECT_IDYour Equinix Metal project ID

You can also set the PACKET_AUTH_TOKEN environment variable to omit the --token flag.

Example queries

This query retrieves organization information:

cnquery> equinix.metal.organization
equinix.metal.organization: {
  name: "My Organization"
  ...
}

This query retrieves all projects:

cnquery> equinix.metal.projects
equinix.metal.projects: [
  0: equinix.metal.project name="Production"
  1: equinix.metal.project name="Development"
  ...
]

This query retrieves all devices:

cnquery> equinix.metal.devices
equinix.metal.devices: [
  0: equinix.metal.device hostname="server-1"
  ...
]

This query retrieves SSH keys:

cnquery> equinix.metal.sshKeys
equinix.metal.sshKeys: [
  0: equinix.metal.sshKey label="my-key"
  ...
]

This query lists devices with their details:

cnquery> equinix.metal.devices { hostname state facility plan }

Exit the cnquery shell

To exit the cnquery shell, either press Ctrl + D or type exit.

Learn more

On this page