Infrastructure as Code Management
Manage IaCM workspaces, variable sets, module and provider registries, and Ansible resources with the Harness Infrastructure as Code Management API.
The Infrastructure as Code Management (IaCM) API manages the workspaces that run your OpenTofu and Terraform code, the variables they use, and the private registries they pull modules and providers from.
Request basics
API key token: Send it in the
x-api-keyheader on every request. Go to Manage API keys to create a key and token.Account ID: Send it in the
Harness-Accountheader on every request, rather than as a query parameter.Organization and project IDs: Most endpoints take them as the
organdprojectpath parameters. Go to Organizations and projects to find these identifiers.Base URL: Send requests to
https://app.harness.io/gateway/iacm, followed by the endpoint path.
Example request
List the workspaces in a project:
curl "https://app.harness.io/gateway/iacm/api/orgs/ORG_ID/projects/PROJECT_ID/workspaces" \
-H "x-api-key: $HARNESS_API_KEY" \
-H "Harness-Account: ACCOUNT_ID"Replace ACCOUNT_ID, ORG_ID, and PROJECT_ID with your own values, and set HARNESS_API_KEY to your API key token.
Find an endpoint
Endpoint paths are relative to the base URL.
Workspaces: The unit IaCM runs. A workspace holds your code location, state, variables, and the connector to your cloud. List workspaces with
GET /api/orgs/{org}/projects/{project}/workspaces. Go to Workspaces to create and manage workspaces.Variable sets: Reusable groups of variables, secrets, and connectors that you attach to many workspaces at once. List a project's variable sets with
GET /api/orgs/{org}/projects/{project}/configuration-variable-sets. Go to Variable Sets to create and attach a variable set.Workspace templates: Preset workspace settings that teams start from, so new workspaces follow the same standards. Create a template with
POST /api/orgs/{org}/projects/{project}/workspace/templates. Go to Workspace templates to create a workspace template.Module registry: A private registry for OpenTofu and Terraform modules that your workspaces can reference. List modules with
GET /api/modulesand register one withPOST /api/modules. Go to Module Registry to register a module.Provider registry: A private registry for OpenTofu and Terraform providers. List providers with
GET /api/providers. Go to Provider Registry to publish a provider.Executions and approvals: Plan and apply runs for a workspace, and the approvals that gate them. List runs with
GET /api/orgs/{org}/projects/{project}/executionsand approvals withGET /api/orgs/{org}/projects/{project}/approvals. Go to Approval Step to add an approval step.Drift remediation: Detecting differences between your code and the live infrastructure, and proposing fixes. Read a workspace's drift settings with
GET /api/orgs/{org}/projects/{project}/workspaces/{workspace}/drift-config, and the project's remediation settings withGET /api/orgs/{org}/projects/{project}/remediation/config. Go to Drift Detection and Ephemeral Workspaces to set up drift detection.Costs and insights: Estimated cost changes and resource insights for each workspace. List estimated costs with
GET /api/orgs/{org}/projects/{project}/costs. Go to Cost Estimation to turn on cost estimation.Ansible: Inventories and playbooks for configuring the machines your infrastructure creates. List playbooks with
GET /api/ansible/playbookand recent runs withGET /api/ansible/activities. Go to Get Started With Ansible to set up your first inventory and playbook.
Last updated
Was this helpful?