API: Infrastructure as Code

REST API endpoints for IaC validation, planning, and deployment.

API: Infrastructure as Code

Overview

The IaC API provides programmatic access to the Infrastructure as Code engine. Submit stack definitions for validation, generate execution plans, apply changes, and destroy stacks.

Endpoints

MethodPathDescription
POST/v1/iac/validateValidate a stack definition
POST/v1/iac/planGenerate an execution plan
POST/v1/iac/applyApply a stack (execute the plan)
POST/v1/iac/destroyDestroy all resources in a stack
## Validate Stack
POST /v1/iac/validate

Request body is the full Stack JSON. Returns validation results:

{
  "valid": true,
  "errors": [],
  "warnings": ["Resource 'web-server' has no security groups defined"]
}

Generate Plan

POST /v1/iac/plan

Request body is the Stack JSON. Returns a list of planned actions:

{
  "actions": [
    {"action": "create", "kind": "VPC", "name": "production", "details": {"cidr": "10.0.0.0/16"}},
    {"action": "create", "kind": "Subnet", "name": "web-tier", "details": {"cidr": "10.0.1.0/24"}},
    {"action": "create", "kind": "Instance", "name": "web-01", "details": {"type": "cx31"}}
  ],
  "summary": {
    "create": 3,
    "update": 0,
    "delete": 0
  }
}

Apply Stack

POST /v1/iac/apply

Executes the plan. Returns an operation ID for tracking:

{
  "operation_id": "op-iac-001",
  "status": "running",
  "planned_actions": 3
}

Destroy Stack

POST /v1/iac/destroy

Destroys all resources defined in the stack in reverse dependency order. Returns an operation ID.

{
  "operation_id": "op-iac-002",
  "status": "running",
  "planned_deletions": 3
}