Deployments
A deployment is a queued attempt to make running infrastructure match an instance's saved configuration. Deployments are immutable records: they capture what was tried, with what params, when, and what happened.
Instances and deployments​
An instance has a params field that holds its current configuration. A deployment carries a frozen snapshot of instance.params from the moment it was created, plus the bundle version to run.
Editing an instance changes what the next deployment will use. Creating a deployment pins a copy of the current configuration and asks the system to apply it.
Two ways to deploy a change​
Massdriver supports two ways to deploy a change to an instance. The difference is when instance.params is updated and whether human approval is required before the apply runs.
Direct — createDeployment​
instance.params is overwritten immediately and the deployment enters the queue at PENDING.
Use this when the change does not require review.
Propose-and-approve — proposeDeployment + approveDeployment​
The proposed params live only on the deployment record while it sits in PROPOSED. instance.params is untouched. On approval, the snapshot is copied into instance.params and the deployment enters the queue at APPROVED. On rejection, neither moves.
Use this when a change requires review before applying — for example, production environments or tagged resources requiring elevated approval.
PLANdeployments are not part of the propose-and-approve flow. A plan is a non-destructive preview, so it does not require approval.
Separation of duty​
An environment can require that a proposal is approved by somebody other than the person who proposed it. Enable Separation of duty on the environment, in the environment form or the environments table.
With the setting on, approveDeployment is refused when the subject calling it is the same account or service account that called proposeDeployment. Approval has to come from a second reviewer.
Rejection is not gated by the setting. Anyone with instance:deploy, including the proposer, can withdraw a proposal with rejectDeployment. A proposer with only instance:propose cannot reject, so their proposal stays open until a reviewer approves or rejects it.
The setting is read from the environment at the moment of approval, so turning it on takes effect on proposals that are already open.
The field is separationOfDuty on the V2 API, and separation_of_duty on the massdriver_environment Terraform resource.
separation_of_duty and decommission_protection default to false and are sent on every apply. An environment that was protected outside of Terraform is unprotected on the next apply unless the setting is in your configuration.
The lifecycle​
A deployment walks through a state machine after creation. Direct pushes enter at PENDING; proposals enter at PROPOSED.
| Status | Meaning |
|---|---|
PROPOSED | Awaiting human approval. Does not hold a queue slot. |
REJECTED | Proposal denied. Terminal. |
APPROVED | Proposal accepted. instance.params advanced. Queued. |
PENDING | Queued, waiting its turn. |
RUNNING | The provisioner is applying changes. |
COMPLETED | Apply succeeded. Infrastructure matches the snapshot. |
FAILED | Apply errored. See What happens when a deployment fails. |
ABORTED | Operator cancelled. An in-flight apply is not stopped. |
COMPLETED, FAILED, REJECTED, and ABORTED are terminal. To try again, create a new deployment.
The queue​
Every instance has its own queue. Only one deployment per instance can be RUNNING at a time.
PROPOSEDdeployments are outside the queue. Open proposals do not block direct-push work. Approval moves a proposal into the queue.APPROVEDandPENDINGdrain together in creation order. A proposal keeps the time it was proposed, so a proposal approved late runs ahead ofPENDINGdeployments created after it.- The queue is per-instance. Two instances in the same environment deploy independently.
- Queued deployments are not rebased. Each queued deployment carries the snapshot it captured at enqueue, even if earlier items in the queue change the infrastructure. Editing
instance.paramsdoes not change a queued deployment. To pick up an edit, abort the queued deployment and create a new one. PLANdeployments take a queue slot. A plan is a real deployment record.- When an instance is
DECOMMISSIONED, its pendingDECOMMISSIONdeployments are deleted.
What gets snapshotted​
When a deployment is created, the following are frozen into the deployment record:
params: the instance's configuration values, includingmd_metadata(name prefix, tags, alarm webhook)connection_params: the resources filling the bundle's dependenciesversion: the bundle release to runactionandmessage
The following are looked up at run time, not snapshotted:
- Secrets: encrypted at rest. Required secrets are checked when the deployment is created, and values are read again on dispatch. Rotating a secret takes effect on the next deployment without re-queuing.
- Bundle release contents: the snapshot pins the version string, and the bundle is pulled from its repository at run time. Bundle releases are immutable once published, so the result is still deterministic.
Past deployments can be audited through their params field. On an instance's History tab, Compare deployments diffs any two, with a Hide identical toggle and a path search. mass deployment compare does the same from the CLI.
What happens when a deployment fails​
The apply step is non-transactional. The provisioner makes a series of API calls across one or more cloud providers, and any of those calls can fail partway through. Cloud APIs do not support atomic rollback across providers.
When a RUNNING deployment transitions to FAILED:
instance.paramshas already moved to reflect the requested configuration.- Real infrastructure is in whatever state the provisioner reached before the error.
- Nothing is rolled back automatically.
To recover, edit instance.params to a configuration that can reconcile cleanly and create a new deployment. To revert, roll back to a past COMPLETED deployment with rollbackDeployment. The source must be a COMPLETED PROVISION deployment. Rollback creates a PROPOSED deployment with its bundle version, params, and connections, which runs once approved.
ABORTED does not unwind work already done either. Aborting a RUNNING deployment marks it ABORTED and frees the queue, but the provisioner is not stopped: the apply in flight runs to its end, and the next queued deployment can start while it does.
Compared to a merge queue​
Massdriver's deployment queue resembles a merge queue with apply-before-merge semantics (GitHub merge queue, Bors, Aviator) in shape (a per-instance queue, snapshotted entries, an optional review step), but the failure semantics are reversed.
| Merge queue with apply-before-merge | Massdriver deployment | |
|---|---|---|
| What runs first | The check ("apply"). Main only advances if the check passes. | Desired state advances. The apply runs against it. |
| Failed entry | Main is unchanged. The PR drops out of the queue. | instance.params has already moved. Real infrastructure is in a partial state. |
| Recovery | None needed. Nothing changed. | Edit params and create a new deployment. |
| Why it works | Git is transactional. The "world" only changes at merge. | Cloud APIs are not transactional. The "world" changes as the apply runs. |
Apply-before-merge is not possible for infrastructure. A merge queue can speculatively integrate and test PRs before merging because tests run against a sandboxed copy of the world (a CI runner) and merging is atomic. Infrastructure provisioning has neither property:
- There is no sandbox. The apply is the change. A plan is approximate — many failures (quota limits, IAM evaluation, race conditions with sibling resources, provider bugs) only surface at apply time.
- There is no atomic merge. An apply makes a series of API calls across one or more cloud providers. Each call commits to the world the moment it returns 200. There is no way to undo the half that succeeded if the second half fails.
- Applies are slow. Provisioning an RDS instance or an EKS cluster can take 10–40 minutes. Speculatively integrating a queue of these in parallel is not practical the way it is for CI builds.
In place of automatic rollback, Massdriver provides an immutable record of every attempt, per-instance serialization, deterministic snapshots, an optional propose-and-approve gate, and a recovery path: edit params and create a new deployment.
API quick reference​
| Mutation | Effect on instance.params | Deployment status |
|---|---|---|
createDeployment | Overwritten immediately with the supplied params. Not touched for PLAN. | PENDING |
proposeDeployment | Not touched — params live only on the deployment | PROPOSED |
approveDeployment | Overwritten with the proposal's snapshot | PROPOSED → APPROVED |
rejectDeployment | Not touched | PROPOSED → REJECTED |
abortDeployment | Not touched | PENDING / APPROVED / RUNNING → ABORTED |
planDeployment | Not touched. Runs a new PLAN with an existing deployment's params | PENDING |
rollbackDeployment | Not touched until approved | New deployment at PROPOSED |
Related Documentation​
- Components, Instances & Deployments — how deployments fit into the overall lifecycle.
- Dependencies & Links — what
connection_paramsresolves from.