# Provisioning

> End-to-end cloud infrastructure provisioning (VPCs, clusters, VMs, datastores, registries, load balancers) across AWS, GCP, and Azure.

Source: https://zop.dev/developer-docs/operations/provisioning

---

Stand up cloud infrastructure end-to-end from a single wizard.
ZopDay creates VPCs, Kubernetes clusters, VMs, datastores, registries,
and load balancers across AWS, GCP, and Azure, using the same
credentials you connected for discovery and scheduling.

**Info**

Spaces themselves (cluster registration) are covered in
[Deployment Spaces](https://zop.dev/docs/deployments/deployment-spaces). Auto-remediation
workflows started from a recommendation's Remediate button are covered in
[Recommendations](https://zop.dev/docs/operations/recommendations).

**Info**

Provisioning lives in the **ZopDay** app at
`/zopday`. It shares authentication, RBAC, teams, and audit
logs with the main ZopNight app, same login, same org, same role
model.

## How provisioning runs

No OpenTofu, no remote agents: ZopDay talks to the cloud SDKs (AWS,
GCP, Azure) directly. After a fresh cluster is up it is registered as a
[Deployment Space](https://zop.dev/docs/deployments/deployment-spaces)
automatically, and a resource sync starts so it appears in your inventory.

## What you can provision

<table>
  <thead>
    <tr>
      <th>Category</th>
      <th>AWS</th>
      <th>GCP</th>
      <th>Azure</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>Kubernetes</strong></td>
      <td>EKS</td>
      <td>GKE</td>
      <td>AKS</td>
    </tr>
    <tr>
      <td><strong>VMs / compute</strong></td>
      <td>EC2 + ASG + ALB / NLB</td>
      <td>Compute Engine + MIG + GCLB</td>
      <td>VM Scale Sets + Azure LB</td>
    </tr>
    <tr>
      <td><strong>Datastores</strong></td>
      <td>RDS (MySQL / Postgres), ElastiCache (Redis)</td>
      <td>Cloud SQL (MySQL / Postgres), Memorystore (Redis)</td>
      <td>Database for MySQL / Postgres, Azure Cache for Redis</td>
    </tr>
    <tr>
      <td><strong>Registry</strong></td>
      <td>ECR</td>
      <td>Artifact Registry</td>
      <td>ACR</td>
    </tr>
    <tr>
      <td><strong>Networking</strong></td>
      <td>VPC, Subnets, VPC Peering</td>
      <td>VPC, Subnets, DNS Zones</td>
      <td>VNet, Subnets</td>
    </tr>
    <tr>
      <td><strong>In-cluster components</strong></td>
      <td colSpan="3">Cluster and VM components (ingress, observability, cert-manager, and platform add-ons), installed through the <a href="#components">Components</a> endpoints</td>
    </tr>
  </tbody>
</table>

## How it works

1. **Pick a space:** choose a connected cloud account and a region. ZopNight discovers existing VPCs, subnets, and DNS zones in the background so the wizard can offer real options instead of free-text fields.
2. **Pick a resource type:** cluster, VM, datastore, or component.
3. **Configure:** instance size, version, networking, backup retention, etc. Sensible defaults are pre-filled.
4. **Review:** ZopNight shows the IAM operations it will perform and the estimated monthly cost before any action runs.
5. **Provision:** ZopDay applies the changes through cloud SDKs; progress streams to the UI; the request is recorded in the [audit log](https://zop.dev/docs/administration/audit-logs). On success, freshly created clusters auto-register as spaces and resources flow into Reports + Recommendations.

**Tip**

Datastore credentials (root passwords, connection strings) are written
to the cloud provider's secret manager: AWS Secrets Manager, GCP
Secret Manager, or Azure Key Vault. ZopNight stores only the secret
reference, never the secret value.

## RBAC

Provisioning ships with four policy categories so platform teams can
delegate provisioning without granting full tenancy admin:

| Policy | What it grants |
| --- | --- |
| `space:view / create / update / delete` | Manage Deployment Spaces (cloud account + region pairs targeted for provisioning) |
| `provisioning:view / create / update / delete` | Run, monitor, modify, and tear down provisioning jobs |
| `service:view / create / update / delete` | Manage in-cluster components attached to a space |
| `deployment:view / create / update / delete` | Manage application deployments |

Default System roles inherit these policies; custom roles need
explicit grants. See
[Roles & Permissions](https://zop.dev/docs/administration/roles-permissions)
for how to assemble them.

## Provisioning jobs

### POST /provisioning-jobs

Submit a new provisioning job for a cluster, VM, datastore or network.

The body names what to create (`resourceType`) and where (`provider`, `region`,
`cloudAccountId`). `resourceType` is one of `cluster`, `vm`, `postgres`, `mysql`, `redis` or
`vpc`. The fields inside `config` depend on the resource type. `kind` defaults to `create`; send
`"kind": "update"` with a `resourceUid` to change an existing resource.

```bash title="Cluster (EKS)"
curl -X POST https://api.zop.dev/provisioning-jobs \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "platform-prod",
    "provider": "aws",
    "region": "us-east-1",
    "resourceType": "cluster",
    "cloudAccountId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
    "config": {
      "k8sVersion": "1.30",
      "nodeType": "m5.large",
      "minNodes": 2,
      "maxNodes": 6,
      "existingVpcId": "vpc-0abc"
    }
  }'
```

```bash title="Datastore (RDS Postgres)"
curl -X POST https://api.zop.dev/provisioning-jobs \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "checkout-db",
    "provider": "aws",
    "region": "us-east-1",
    "resourceType": "postgres",
    "cloudAccountId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
    "config": {
      "engineVersion": "16.3",
      "instanceClass": "db.t3.medium",
      "storageGb": 50,
      "multiAz": true,
      "backupEnabled": true,
      "backupRetentionDays": 7
    }
  }'
```

```bash title="VMs behind a load balancer (EC2 + ALB)"
curl -X POST https://api.zop.dev/provisioning-jobs \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "checkout-edge",
    "provider": "aws",
    "region": "us-east-1",
    "resourceType": "vm",
    "cloudAccountId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
    "config": {
      "mode": "asg",
      "instanceType": "m5.large",
      "minInstances": 2,
      "maxInstances": 6,
      "image": "ubuntu-22-04-lts",
      "loadBalancer": true,
      "exposePorts": [80, 443]
    }
  }'
```

### GET /provisioning-jobs

List provisioning jobs, with status.

### GET /provisioning-jobs/{id}

Get a job

### PATCH /provisioning-jobs/{id}

Update lightweight job fields (name, tags) without re-running the pipeline.

### DELETE /provisioning-jobs/{id}

Tear down a previously created cluster, VM, datastore, or network.

### POST /provisioning-jobs/{id}/retry

Retry a failed job from the last successful step. Useful for transient failures (rate-limited cloud API, throttled subnet creation).

### Databases under a job

Datastore jobs are the parent of one or more *databases*,
logical schemas the application code will connect to. Each database
has its own credentials and is provisioned by issuing
`CREATE DATABASE` + `CREATE USER` against the
parent server.

### POST /provisioning-jobs/{jobID}/databases

Create a database on the parent datastore.

```bash title="Request"
curl -X POST "https://api.zop.dev/provisioning-jobs/job_abc/databases" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "name": "checkout", "owner": "checkout_app" }'
```

### GET /provisioning-jobs/{jobID}/databases

List databases under a job.

### GET /provisioning-jobs/{jobID}/databases/{dbID}

Get a database with its connection metadata (server, port, secret reference).

### DELETE /provisioning-jobs/{jobID}/databases/{dbID}

Drop the database and revoke its user.

### Connections

A connection is a stored set of credentials (host, port, user, secret
reference) an application fetches at deploy time. Connections live
either at job scope (one set of credentials shared across all
databases on the server) or at database scope (one set per database).

#### Job-scoped

### POST /provisioning-jobs/{jobID}/connections

Create a job-scoped connection.

### GET /provisioning-jobs/{jobID}/connections

List job-scoped connections.

### GET /provisioning-jobs/{jobID}/connections/{connID}

Get a job-scoped connection by ID.

### DELETE /provisioning-jobs/{jobID}/connections/{connID}

Delete a job-scoped connection (does not drop the database user).

#### Database-scoped

### POST /provisioning-jobs/{jobID}/databases/{dbID}/connections

Create a connection scoped to a specific database.

### GET /provisioning-jobs/{jobID}/databases/{dbID}/connections

List connections scoped to a database.

### GET /provisioning-jobs/{jobID}/databases/{dbID}/connections/{connID}

Get a database-scoped connection.

### DELETE /provisioning-jobs/{jobID}/databases/{dbID}/connections/{connID}

Delete a database-scoped connection.

## Components

Cluster and VM components (ingress controllers, observability agents,
cert-manager and similar add-ons) are installed onto a Deployment Space
through the components endpoints.

### GET /components

List the component catalog for a target (?targetType=), or poll an install (?actionId=).

### POST /components

Install or re-apply a component on a space. Returns an actionId to poll.

```bash title="Request"
curl -X POST https://api.zop.dev/components \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "spaceId": "<space id>",
    "targetType": "cluster",
    "component": "ingress-nginx"
  }'
```

`targetType` is `cluster` for a Kubernetes space or `vm` for a VM space.

### POST /components/{component}/upgrade

Upgrade an installed component.

## VPC Peering on Architecture

VPC peering connections are first-class on the Architecture canvas
alongside transit gateways and interconnects. When you provision a
cluster or datastore in a peered VPC, the link is rendered
automatically and click-throughs land on the discovered peering
connection's detail.

See [Resources](https://zop.dev/docs/core-concepts/resources)
for the full discovered-resource model and
[Deployment Spaces](https://zop.dev/docs/deployments/deployment-spaces)
for cluster registration.
