Assess Equinix Metal with cnspec
Query and assess Equinix Metal infrastructure with cnspec
Rely on cnspec to query and assess your Equinix Metal infrastructure, including organizations, projects, devices, SSH keys, and users.
Prerequisites
To analyze your Equinix Metal environment with cnspec, you must have:
- cnspec installed on your workstation
- An Equinix Metal account
- An Equinix Metal API token
Configure access to Equinix Metal
To create an API token:
- Log in to the Equinix Metal console.
- Navigate to your user settings.
- Generate an API token.
Connect to Equinix Metal
To query resources within an organization:
cnspec shell equinix org ORG_ID --token YOUR_API_TOKENTo query resources within a specific project:
cnspec shell equinix project PROJECT_ID --token YOUR_API_TOKENYou can also set the PACKET_AUTH_TOKEN environment variable instead of passing the --token flag:
export PACKET_AUTH_TOKEN=your_token_here
cnspec shell equinix org ORG_IDScan Equinix Metal
To scan your Equinix Metal organization:
cnspec scan equinix org ORG_ID --token YOUR_API_TOKENYou can also create your own policies to meet your specific requirements.
Example queries
Retrieve organization information
cnspec> equinix.metal.organizationList projects
cnspec> equinix.metal.projects { name id createdAt }List devices in a project
cnspec> equinix.metal.projects[0].devices { hostname state }Retrieve device details
cnspec> equinix.metal.devices { hostname state billingCycle os }List SSH keys
cnspec> equinix.metal.sshKeysList users
cnspec> equinix.metal.usersLearn more
-
To learn more about how the MQL query language works, read Write Effective MQL.
-
For a list of all the Equinix resources and fields you can query, read the Equinix Resource Pack Reference.