# modules/controlplane

**Spinbox is experimental: APIs change and data may be lost.** What is built and what proves it is on [Status](https://docs.spinbox.dev/reference/status.md); what Spinbox does not do is on [Limitations](https://docs.spinbox.dev/overview/limitations.md).

> spin-terraform-aws, the network, bucket, database, control plane and proxy, used on its own.

<!-- Generated by tools/refgen from spin-terraform-aws:modules/controlplane/variables.tf. Edit the source, not this file. -->

Source: `github.com/spin-stack/spin-terraform-aws//modules/controlplane?ref=v20261123.01`. Generated from its variables and outputs.

## Variables

| Variable | Type | Default |
|---|---|---|
| [`spin_version`](#spin_version) | `string` | **required** |
| [`domain`](#domain) | `string` | **required** |
| [`identity_record_days`](#identity_record_days) | `number` | `400` |
| [`collector`](#collector) | `object({ metric_interval = optional(string, "60s") })` | `{}` |
| [`name`](#name) | `string` | `"spin"` |
| [`internal_zone`](#internal_zone) | `string` | `"spin.internal"` |
| [`acme_email`](#acme_email) | `string` | `""` |
| [`vpc_cidr`](#vpc_cidr) | `string` | `"10.42.0.0/16"` |
| [`availability_zones`](#availability_zones) | `number` | `8` |
| [`instance_type`](#instance_type) | `string` | `"t8i.medium"` |
| [`root_volume_gb`](#root_volume_gb) | `number` | `40` |
| [`admin_email`](#admin_email) | `string` | `""` |
| [`flow_logs`](#flow_logs) | `bool` | `true` |
| [`dns_query_logs`](#dns_query_logs) | `bool` | `false` |
| [`log_retention_days`](#log_retention_days) | `number` | `30` |
| [`proxy_allowed_cidrs`](#proxy_allowed_cidrs) | `list(string)` | `["0.0.0.0/0"]` |
| [`proxy_instance_type`](#proxy_instance_type) | `string` | `"t8i.micro"` |
| [`decommission`](#decommission) | `bool` | `false` |
| [`object_lock_days`](#object_lock_days) | `number` | `30` |
| [`encryption_key_versions`](#encryption_key_versions) | `list(number)` | `[1]` |
| [`identity_keys`](#identity_keys) | `list(object({ kid = string retired = optional(string) }))` | `[]` |
| [`database_lock_days`](#database_lock_days) | `number` | `7` |
| [`runner_policy`](#runner_policy) | `object({ shutdown_grace = optional(string, "100s") preemption_source = optional(string, "aws") })` | `{}` |
| [`installation_config`](#installation_config) | `string` | `""` |
| [`runner_idle_minutes`](#runner_idle_minutes) | `number` | `60` |
| [`quiet_hours`](#quiet_hours) | `string` | `""` |
| [`time_zone`](#time_zone) | `string` | `"UTC"` |
| [`tags`](#tags) | `map(string)` | `{}` |
| [`image_publisher`](#image_publisher) | `string` | `"277203350136"` |
| [`image_ids`](#image_ids) | `map(string)` | `{}` |
| [`monthly_budget_usd`](#monthly_budget_usd) | `number` | the module's own |
| [`security_emails`](#security_emails) | `list(string)` | `[]` |
| [`budget_emails`](#budget_emails) | `list(string)` | `[]` |
| [`image_measurements`](#image_measurements) | `map(list(object({ pcr4 = string pcr7 = string pcr12 = string statement = optional(string) bundle = optional(string) # Why the build is not to be run: no machine of it # is trusted, and a release whose newest build is revoked is not installed (attested_key.tf). revoked = optional(string) })))` | the module's own |
| [`runner_instance_types`](#runner_instance_types) | `list(string)` | `["c8i.*","c8id.*","m8i.*","m8id.*","r8i.*","r8id.*"]` |
| [`runner_vcpus`](#runner_vcpus) | `object({ min = number, max = number })` | `{"max":48,"min":32}` |
| [`runner_spot`](#runner_spot) | `bool` | `true` |
| [`max_runners`](#max_runners) | `number` | `1` |
| [`runner_rollout`](#runner_rollout) | `string` | `"idle"` |
| [`runner_drain_seconds`](#runner_drain_seconds) | `number` | `150` |
| [`runner_groups`](#runner_groups) | `string` | `""` |
| [`runner_data_volume_gb`](#runner_data_volume_gb) | `number` | `0` |

### spin_version

The release the installation runs: a release, v&lt;YYYYMMDD>.&lt;N>, or a channel - edge, every release once its images are published and checked on EC2, or stable, one a person promoted. Every machine boots the Spin OS image of the release, as the image catalog has it and its release signed it (the spin provider). A channel is read at every plan, so the release it names moves an installation when its next plan is applied.

- Type: `string`
- **Required**

### domain

The base domain: the dashboard is app.&lt;domain>, workspaces are \*.ws.&lt;domain>.

- Type: `string`
- **Required**

### identity_record_days

How many days the record of each identity a host signs is kept (identity/issued/ in the volumes bucket): longer than the bucket's lock, and long enough to answer who took an identity when.

- Type: `number`
- Default: `400`

### collector

The collector: how often metrics are pushed to it. Which Alloy it is, is the image's.

- Type: `object({ metric_interval = optional(string, "60s") })`
- Default: `{}`

### name

The installation's name, one per region of an account: every resource's prefix, the SSM path (/spin/&lt;name>/...) each machine's document is at, and - with the region - every IAM name. Two installations of one account may share a name in two regions, and not in one (claim.tf).

- Type: `string`
- Default: `"spin"`

### internal_zone

The private zone the components reach each other by: cp.&lt;this> and proxy.&lt;this>, resolved only inside the VPC.

- Type: `string`
- Default: `"spin.internal"`

### acme_email

The address Let's Encrypt writes to; empty is admin@&lt;domain>.

- Type: `string`
- Default: `""`

### vpc_cidr

The VPC's range, a /16. One /20 public subnet per availability zone is carved from its first half, and one /24 for the proxy per zone from x.x.136.0 on.

- Type: `string`
- Default: `"10.42.0.0/16"`

### availability_zones

How many zones to make subnets in, at most: a region with fewer gets one in each. The control plane, the proxy and the runners may each be started in any of them, which is what gives a group somewhere to go when a zone runs out - and a zone left out is spot pools a runner is never drawn from. A subnet is its zone's by index, so raising this adds subnets and moves none.

- Type: `number`
- Default: `8`

### instance_type

The control plane's machine: the control plane, its database (PostgreSQL), the collector, and the stores of logs, traces and metrics it runs.

- Type: `string`
- Default: `"t8i.medium"`

### root_volume_gb

The control plane's disk: beside the read-only OS, /var takes the rest - the database, the logs' and metrics' stores and their caches. A new size is a new machine, replaced beside the old.

- Type: `number`
- Default: `40`

### admin_email

Who the first administrator signs in as; empty is admin@&lt;domain>. The one-time password is in the admin_password_parameter output's parameter.

- Type: `string`
- Default: `""`

### flow_logs

Keep the VPC's flow log in CloudWatch: every connection a security group accepted or refused, but no DNS to the VPC's resolver, which it does not see. At a few hosts it is cents a month; a fleet whose workspaces move a lot of data pays about $0.50 a GB of flow records.

- Type: `bool`
- Default: `true`

### dns_query_logs

Keep the VPC resolver's query log in CloudWatch: every name looked up, a workspace's included. It is Route 53 Resolver's, and off unless asked for. Each installation that turns it on takes one of the ten CloudWatch Logs resource policies a region of an account may have.

- Type: `bool`
- Default: `false`

### log_retention_days

How long the flow and query logs are kept.

- Type: `number`
- Default: `30`

### proxy_allowed_cidrs

Where users may reach the proxy on 443 from: the dashboard, workspaces and SSH. Anywhere by default; an office's or a VPN's ranges close the installation to everyone else. The runners reach it from inside the VPC whatever this says, and 80 stays open for the ACME challenge.

- Type: `list(string)`
- Default: `["0.0.0.0/0"]`

### proxy_instance_type

The proxy's machine: Caddy and nothing else, the one address the internet reaches.

- Type: `string`
- Default: `"t8i.micro"`

### decommission

Set to true, and applied, before destroying the installation: its buckets lose the policies that refuse every object write from outside the VPC - the destroy runs from outside it - and a destroy empties every bucket, data included, bypassing the GOVERNANCE retention once the legal holds are lifted (README.md, "Removing an installation"). Never set on an installation that is to keep its data.

- Type: `bool`
- Default: `false`

### object_lock_days

The bucket's default Object Lock retention, in GOVERNANCE mode. A deleted object's bytes last this long, and the bucket's lifecycle (bucket.tf) removes them a day after.

- Type: `number`
- Default: `30`

### encryption_key_versions

The versions of the control plane's encryption key its document names, each a key of its own agreed with the one KMS key (attested_key.tf): the highest seals, every one listed opens what was sealed under it. A rotation appends the next version and applies - the control plane is replaced onto it - then runs `controlplane crypto rotate`; a version is removed only once that reports nothing left under it and the database archive keeps no base backup from before (spin-stack/runbooks key-rotation). A version removed while anything is sealed under it is that data lost.

- Type: `list(number)`
- Default: `[1]`

### identity_keys

The identity keys workspaces' tokens and certificates are signed with past the installation's first, each by the kid `controlplane identity rotate` prints, newest last: the newest not retired signs, and every one listed is published at id.&lt;domain> and verifies what it signed until its retired time (RFC 3339), which `controlplane identity retire` prints. The first key is listed only to retire it. A key the control plane made that is not listed here is never published, accepted or signed with (spin-stack/runbooks identity-audit-failing).

- Type: `list(object({ kid = string retired = optional(string) }))`
- Default: `[]`

### database_lock_days

The database archive's default Object Lock retention, in GOVERNANCE mode: how long what a delete or an overwrite left there can still be restored. The lifecycle removes it a day after (database_bucket.tf). Every base backup and WAL segment the archive prunes is held this long, so the archive's size is this many days of it on top of what it keeps: a week is the window to notice a wrong delete.

- Type: `number`
- Default: `7`

### runner_policy

The host policy a runner starts with when it joins: how long it stays up once told to stop - a little less than the two minutes a spot reclaim gives - and the cloud that announces a reclaim.

- Type: `object({ shutdown_grace = optional(string, "100s") preemption_source = optional(string, "aws") })`
- Default: `{}`

### installation_config

The installation's config file (spin's configs/spin-example.yaml), as YAML. This module adds
what it knows - the domain, who joins as a host, the autoscaling settings below - and writes
it where the control plane reads it at every start, which seeds the database from it before
it serves. What the file later says differently is shown in the dashboard to apply or
dismiss, and nothing is written over what an administrator decided.

- Type: `string`
- Default: `""`

### runner_idle_minutes

How long the fleet has no workspace running, starting or waiting before the runners' group is emptied.

- Type: `number`
- Default: `60`

### quiet_hours

HH:MM-HH:MM in time_zone when an idle fleet is emptied at once rather than after runner_idle_minutes. A workspace asked for then still brings a runner up. Empty is none.

- Type: `string`
- Default: `""`

### time_zone

The IANA zone quiet_hours are in.

- Type: `string`
- Default: `"UTC"`

### tags

Tags on everything this module creates.

- Type: `map(string)`
- Default: `{}`

### image_publisher

The AWS account that publishes Spin OS's images (spin-stack/ami): an image the catalog names is one it owns, or it is not booted.

- Type: `string`
- Default: `"277203350136"`

### image_ids

Spin OS AMIs of your own, one per role - control-plane, runner and proxy - instead of those the catalog names for spin_version in this region. Each must carry that release, laid for that role: a machine refuses a document of another release, and an image laid for another role.

- Type: `map(string)`
- Default: `{}`

### monthly_budget_usd

What the installation may cost in a month, in US dollars: an AWS Budget on its spin:installation tag (budget.tf), which the control plane reads and alerts reach. Null is no budget.

- Type: `number`
- Default: `null` (the module's own default)

### security_emails

Who AWS emails when the control plane's role starts a machine itself (alarms.tf), and when the control plane is down and again when it is back (uptime.tf). Each address confirms each of the two topics once, and an unconfirmed one is told nothing.

- Type: `list(string)`
- Default: `[]`

### budget_emails

Who AWS emails when the month's cost passes 80 % or 100 % of monthly_budget_usd, or is forecast to pass it.

- Type: `list(string)`
- Default: `[]`

### image_measurements

The builds of each role's image - control-plane, runner and proxy - oldest first, each the PCRs an instance of it measures (its manifest's measurements, SHA384 in lowercase hex), instead of the catalog's: the control plane's key is answered to the control plane's builds (attested_key.tf), a host joins only as the runner's, and the proxy is given its token only as the proxy's (host_attestation). The control plane's and the runner's also carry statement and bundle, base64, as spin-os images sign writes them: what their images' publisher signed of those PCRs. The last of a role's is the image image_ids names. Required with image_ids.

- Type: `map(list(object({ pcr4 = string pcr7 = string pcr12 = string statement = optional(string) bundle = optional(string) # Why the build is not to be run: no machine of it # is trusted, and a release whose newest build is revoked is not installed (attested_key.tf). revoked = optional(string) })))`
- Default: `null` (the module's own default)

### runner_instance_types

The types the group may start, as EC2's allowed_instance_types takes them: names, or patterns
with \* (c8id.\*). The group starts any type they match that has vcpus and the disk data_volume_gb
leaves the data on - a local NVMe while it is 0, so a d variant - and AWS adds the sizes and
types it brings out without this list changing.

Keep them one CPU generation: a checkpoint records the processor and its flags as -cpu host
showed them (MachineIdentity in spin's internal/runner/vmm), and resumes only onto a host that
shows the same - a workspace suspended at night on one family and brought back on another
cold-boots. Nested virtualization is offered on C8i, M8i, R8i (and their d variants), C7i, M7i,
R7i and I7i. Not c8i\* for c8i.\*: that matches the flex types too.

For spot, the more pools a request can draw on the likelier a machine, and one type is one
pool per zone. How the types these match score in a region, before installing:
  aws ec2 get-spot-placement-scores --target-capacity 1 --region-names &lt;region> \
    --single-availability-zone --instance-requirements-with-metadata \
    '{"ArchitectureTypes":["x86_64"],"InstanceRequirements":{"VCpuCount":{"Min":32,"Max":48},"MemoryMiB":{"Min":65536},"LocalStorage":"required","AllowedInstanceTypes":[&lt;the types>]}}'

- Type: `list(string)`
- Default: `["c8i.*","c8id.*","m8i.*","m8id.*","r8i.*","r8id.*"]`

### runner_vcpus

How many vCPUs a runner may have, at least and at most: each type instance_types matches within it is a pool the group may draw on. max is also what the quota is sized by (quota.tf).

- Type: `object({ min = number, max = number })`
- Default: `{"max":48,"min":32}`

### runner_spot

Every host a spot instance. The policy a runner joins under (the control plane module's runner_policy) is what tells each one a stop is a reclaim.

- Type: `bool`
- Default: `true`

### max_runners

The most runners the group may have. How many it has is the control plane's to decide: none until a workspace waits for a host, and none again once nothing has run for the control plane module's runner_idle_minutes.

- Type: `number`
- Default: `1`

### runner_rollout

How a new release reaches the runners. idle: when the fleet next empties - no workspace running, starting or being saved - the next host boots it, and no workspace is moved for it; until then a host keeps the old release, which a replaced control plane refuses when it registers again. rolling: the hosts are replaced at once, one at a time, each old one's workspaces suspended to the bucket and resumed on the new one - for a fleet that never empties.

- Type: `string`
- Default: `"idle"`

### runner_drain_seconds

How long a host the group is taking away is held while it empties itself: the termination hook's timeout. At least the pool token's --shutdown-grace; the hook is left to expire, so this is also how long each scale-in takes.

- Type: `number`
- Default: `150`

### runner_groups

The runners module's runner_groups output, what takes the runners' groups away on a destroy: the control plane's group depends on it, so it goes first and makes none of them again.

- Type: `string`
- Default: `""`

### runner_data_volume_gb

An EBS volume for the runner's data, for an instance type with no local NVMe. Zero uses the instance store, which is the right disk for volumes' cache and costs nothing more. A machine's boot takes an empty EBS volume where it has one, and the instance store otherwise.

- Type: `number`
- Default: `0`

## Outputs

| Output | What it is |
|---|---|
| `name` | The installation's name, claimed in its region (claim.tf), which the runners' group and security group are named for. |
| `iam_name` | What the installation's IAM names begin with: its name and its region, since IAM is the account's and two regions may each have an installation of one name. The runners' role and instance profile are named for it. |
| `vpc_id` | The VPC the runners go in. |
| `subnet_ids` | One public subnet per zone, for the runners' group. |
| `security_group_id` | The control plane's group; the runners module opens 8080 on it to its own. |
| `session_manager_policy_arn` | Session Manager into a machine, and nothing else of SSM: what the runners' role is given in place of AmazonSSMManagedInstanceCore, which reads every parameter. |
| `url` | The control plane as runners reach it, the address its certificate names. |
| `ca_cert` | The installation's CA certificate, which every component trusts the control plane by. |
| `runner_document_arn` | The runners' document, the one object of the documents' bucket the runners' role reads. |
| `runner_user_data` | A runner's user data: its role and the runners' document, as the systemd credentials Spin OS's spin-boot takes. |
| `images` | The Spin OS images of the installation's release, by role - the control plane's, the runners' and the proxy's: each one's id and root device. The runners module boots the runner's. |
| `boot_log_group` | The CloudWatch log group every machine's boot writes to, a stream per &lt;role>/&lt;step>/&lt;instance-id>: a role's machines are one stream prefix. |
| `runner_boot_log_policy_arn` | Writing a runner's boot to that group, under runner/ and nothing else: the runners module attaches it to the runners' role. |
| `standard_vcpus` | The on-demand standard vCPUs the control plane's and the proxy's machines take at most: two of each while an update replaces one. The runners module counts them against the quota on-demand runners share. |
| `name_servers` | The domain's public zone's nameservers, which its registrar points at. |
| `domain` | The base domain; the runners' relay is tunnel.app.&lt;domain>, dialled at relay_dial. |
| `public_zone_id` | The domain's public zone, where the installation's names are. |
| `identity_key_arn` | The KMS key the installation's identity key is sealed under, which only an attested runner opens. |
| `internal_zone_id` | The private zone the components reach each other by, cp.&lt;internal_zone> and proxy.&lt;internal_zone>. |
| `relay_dial` | Where a runner dials the relay, host:port: the proxy inside the VPC, by the name the proxy of the moment points at itself. |
| `collector` | Where every process of the installation pushes its telemetry, host:port. Where the collector sends it is set in the dashboard. |
| `boundary_arn` | The permissions boundary every role of the installation carries; the runners module puts it on the runners' role. |
| `disk_key_arn` | The KMS key the machines' EBS disks are encrypted under (disks.tf); the runners module names it on the runners' launch template. |
| `proxy_ip` | The proxy's elastic IP, where every name of the installation's domain points: the one address of the installation the internet reaches. |
| `proxy_group` | The proxy's group of one. Its machine, for `aws ssm start-session --target` (it has no SSH): aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names &lt;this> --query 'AutoScalingGroups[0].Instances[0].InstanceId'. |
| `bucket` | The volumes' bucket: every workspace's disk, versioned under Object Lock, reached only through the VPC's endpoint. |
| `database_bucket` | The database's archive: the base backups and WAL the control plane ships as it writes, and restores from when its machine is replaced. Its role alone reaches it. |
| `database_handover_bucket` | The database's handover records: which control plane machine holds it, and the requests for it. Unversioned, its role alone reaches it. |
| `controlplane_group` | The control plane's group of one. `aws autoscaling start-instance-refresh --auto-scaling-group-name &lt;this>` replaces its machine beside itself; its machine is reached with `aws ssm start-session`, as the proxy's is. |
| `admin_email` | Who the first administrator signs in as. |
| `admin_password_parameter` | The SSM SecureString holding the first administrator's one-time password: aws ssm get-parameter --with-decryption --name &lt;this>. The first sign-in asks for a new one. |
| `region` | The region everything here is in, read from the provider rather than asked for. |
| `runner_idle_minutes` | How long the fleet is idle before the runners' group is emptied, which is why a first workspace waits for a machine's boot. |
| `runners` | What this module decides of the runners, for the runners module: the launch template's name, which the control plane makes each host class's group from, its role, which the runners module grants the groups to, what a template's machine needs of an instance type, and what the quota is sized by. |
