Skip to main content

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.

INSTANCEinstance.paramsthe desired configurationedits change the nextdeployment onlycopyDEPLOYMENTparamsconnection_paramsbundle versionfrozen when createdPROVISIONERapplies the copyto realinfrastructure

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.

createDeploymentparams submittedwrites instance.paramsimmediatelyPENDINGRUNNINGCOMPLETEDa PLAN deployment is queued the same way and leaves instance.params alone

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.

proposeDeploymentparams stay on itPROPOSEDapproveDeploymentwrites instance.paramsAPPROVEDRUNNINGCOMPLETEDrejectDeploymentREJECTEDnothing is written

Use this when a change requires review before applying — for example, production environments or tagged resources requiring elevated approval.

PLAN deployments 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.

PROPOSEDproposed by danaparams live on the deploymentDANA APPROVESrefused — same subject proposed itdeployment stays PROPOSEDSAM APPROVESparams written to the instanceAPPROVEDdana can still reject the proposalwithdrawing is not gated by the settingthe setting is read from the environment at approval time, for user and service account subjects alike

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.

Terraform sends this on every apply

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.

proposeDeploymentcreateDeploymentPROPOSEDREJECTEDPENDINGAPPROVEDRUNNINGCOMPLETEDFAILEDABORTEDapproveDeploymentrejectDeploymentdequeueddequeuedabortDeployment, from PENDING, APPROVED, or RUNNING
StatusMeaning
PROPOSEDAwaiting human approval. Does not hold a queue slot.
REJECTEDProposal denied. Terminal.
APPROVEDProposal accepted. instance.params advanced. Queued.
PENDINGQueued, waiting its turn.
RUNNINGThe provisioner is applying changes.
COMPLETEDApply succeeded. Infrastructure matches the snapshot.
FAILEDApply errored. See What happens when a deployment fails.
ABORTEDOperator 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.

INSTANCE QUEUEoldest created first, one runs at a timeRUNNINGcreated 09:00APPROVEDcreated 09:02PENDINGcreated 09:05PENDINGcreated 09:07PROPOSEDapproveDeploymentwaits outside the queue and holds no slota proposal approved at 09:10 still sorts by 09:02, ahead of newer PENDING workwhen the running deployment finishes, fails, or is aborted, the next one is sent
  • PROPOSED deployments are outside the queue. Open proposals do not block direct-push work. Approval moves a proposal into the queue.
  • APPROVED and PENDING drain together in creation order. A proposal keeps the time it was proposed, so a proposal approved late runs ahead of PENDING deployments 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.params does not change a queued deployment. To pick up an edit, abort the queued deployment and create a new one.
  • PLAN deployments take a queue slot. A plan is a real deployment record.
  • When an instance is DECOMMISSIONED, its pending DECOMMISSION deployments are deleted.

What gets snapshotted​

When a deployment is created, the following are frozen into the deployment record:

  • params: the instance's configuration values, including md_metadata (name prefix, tags, alarm webhook)
  • connection_params: the resources filling the bundle's dependencies
  • version: the bundle release to run
  • action and message

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.params has 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-mergeMassdriver deployment
What runs firstThe check ("apply"). Main only advances if the check passes.Desired state advances. The apply runs against it.
Failed entryMain is unchanged. The PR drops out of the queue.instance.params has already moved. Real infrastructure is in a partial state.
RecoveryNone needed. Nothing changed.Edit params and create a new deployment.
Why it worksGit 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​

MutationEffect on instance.paramsDeployment status
createDeploymentOverwritten immediately with the supplied params. Not touched for PLAN.PENDING
proposeDeploymentNot touched — params live only on the deploymentPROPOSED
approveDeploymentOverwritten with the proposal's snapshotPROPOSED → APPROVED
rejectDeploymentNot touchedPROPOSED → REJECTED
abortDeploymentNot touchedPENDING / APPROVED / RUNNING → ABORTED
planDeploymentNot touched. Runs a new PLAN with an existing deployment's paramsPENDING
rollbackDeploymentNot touched until approvedNew deployment at PROPOSED