Operations

Deployments

Operating ulex deployments: the ten-state machine, what ulex does and does not do during a deployment, polling correctly, reading structured logs, cancel, rollback, and the failure modes worth automating.

Warning

ulex does not run your application. POST /deployments models the lifecycle — states, steps, logs, resource records, credential issuance, rollback — deterministically and in about 1.5 seconds, so you can build and demonstrate a delivery pipeline without a CI runner, a container registry, or AWS credentials. Treat its output as a receipt, not as a runtime.

#The state machine

Ten states, strict transitions. Anything not in this table is 409 invalid_state_transition.

text
                 ┌──────────► cancelled (terminal)
                 │
queued ─► provisioning ─► configuring ─► building ─► deploying ─► verifying ─► succeeded
   │            │              │             │            │            │             │
   └────────────┴──────────────┴─────────────┴────────────┴────────────┘     │
                                                                              ▼
                              failed ─► queued (retry)                  rolled_back
                                                                              │
                                                                              ▼
                                                                           queued
FromMay become
queuedprovisioning, cancelled, failed
provisioningconfiguring, failed, cancelled
configuringbuilding, failed, cancelled
buildingdeploying, failed, cancelled
deployingverifying, failed, cancelled, rolled_back
verifyingsucceeded, failed, rolled_back, cancelled
succeededrolled_back
failedqueued — a retry reuses the same dep_… and replaces steps[]
cancelled— terminal
rolled_backqueued — a redeploy

#Start one

bash
curl -sS -X POST "$BASE/deployments" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: deploy-acme-support-9f3c1a7" \
  -d '{
    "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
    "environment": "prod",
    "confirm": true,
    "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
    "branch": "main",
    "commit_message": "Add SAML SP wiring",
    "strategy": "simulated"
  }'
json
{
  "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
  "object": "deployment",
  "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
  "environment": "prod",
  "state": "queued",
  "domain": "acme-support.ulexid.com",
  "strategy": "simulated",
  "resources": [],
  "issued": {},
  "steps": [],
  "error": null,
  "progress_percent": 0,
  "created_at": "2026-09-29T14:48:20.000Z"
}
strategyWhat ulex does
simulatedthe full modelled lifecycle. Nothing leaves the control plane
agent_directnothing. You run the steps and report progress with PATCH /deployments/{id}; ulex tracks state and issues credentials
cloudformationrenders and cfn describes a template. Does not deploy
synthesizeproduces a CloudFormation/SAM template and a local invoke image

environment is required on POST /deployments (set to "prod" on the hosted control plane). Limit: 3 concurrent per tenant.

A prod deployment requires ulex:admin and an explicit confirm: true. Without the second value the call is 400 validation_failed with param: "confirm" and retryable: false:

json
{
  "error": {
    "code": "validation_failed",
    "message": "A prod deployment requires confirm: true.",
    "param": "confirm",
    "retryable": false,
    "hint": "Re-send with \"confirm\": true. This interlock exists so a mistargeted call cannot promote an application into production."
  }
}

The confirm: true interlock ensures a copy-pasted payload or retry loop cannot trigger a deployment without explicit confirmation.

commit_sha is 7–40 lowercase hex characters or null.

#Poll correctly

bash
curl -sS "$BASE/deployments/$DEP_ID" -H "Authorization: Bearer $ULEX_API_KEY" | jq '{state, progress_percent, error, step: (.steps[] | select(.state=="running") | .name)}'
text
queued          0    null              -
provisioning    12   null              provision-application
configuring     31   null              configure-saml-sp
building        48   null              build
deploying       67   null              deploy
verifying       88   null              verify
succeeded       100  null              -
Warning

Poll on state, not on progress_percent. Two steps can be at the same percentage, and progress_percent is a coarse hint. state is the only field with a defined contract.

Terminal states are succeeded, failed, cancelled and rolled_back. queued, provisioning, configuring, building, deploying and verifying are not.

ts
export async function deployAndWait(
  applicationId: string,
  environment: string = "prod",
  opts: { commit_sha?: string; branch?: string; timeoutMs?: number } = {},
) {
  const { id: deploymentId } = await tools.ulex_deploy({
    application_id: applicationId,
    environment,
    confirm_production: true,
    commit_sha: opts.commit_sha ?? null,
    branch: opts.branch ?? "main",
    idempotency_key: `deploy-${applicationId}-${environment}-${opts.commit_sha ?? "head"}`,
  });

  const terminal = new Set(["succeeded", "failed", "cancelled", "rolled_back"]);
  const deadline = Date.now() + (opts.timeoutMs ?? 120_000);

  for (;;) {
    if (Date.now() > deadline) {
      await tools.ulex_cancel_deployment({ deployment_id: deploymentId });
      throw new Error(`deployment ${deploymentId} timed out and was cancelled`);
    }
    // 250 ms is well inside the ~1.5 s simulated lifecycle and costs 4 calls
    // per deployment against a 600/minute budget.
    await new Promise((r) => setTimeout(r, 250));
    const d = await tools.ulex_get_deployment({ deployment_id: deploymentId });
    if (!terminal.has(d.state)) continue;

    if (d.state !== "succeeded") {
      const failedStep = d.steps.find((s) => s.state === "failed")?.name;
      const logs = await tools.ulex_get_deployment_logs({
        deployment_id: deploymentId,
        step: failedStep,
        tail: 50,
      });
      throw new Error(
        `deployment ${d.state} at step ${failedStep ?? "?"}: ${d.error?.code ?? "unknown"} — ${d.error?.message ?? ""}\n` +
          logs.lines.map((l) => `  [${l.level}] ${l.message}`).join("\n"),
      );
    }
    return d;
  }
}

#Issued credentials

On a successful deployment, issued is populated. It is the only place credentials come back as a set.

json
{
  "issued": {
    "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
    "client_secret": "cs_Tn4Wv8Kp2LmQ6Rb9Yc3Xd7Fs1Hg0Ja5E",
    "api_key": "ulex_sk_live_7Qm2KpLx9Tb4Ns8RfWy3Zc1Hjf6Ee0Au",
    "saml_entity_id": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B",
    "saml_acs_url": "https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso",
    "saml_idp_metadata_url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata",
    "oidc_issuer": "https://ulexid.com",
    "scim_base_url": "https://ulexid.com/api/v1/scim/v2",
    "scim_bearer_token": "scim_7Bq4Nxf2Vk9Lc3MdT6hR8wS1yP5aG0eJ",
    "authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize",
    "token_endpoint": "https://ulexid.com/api/v1/oauth2/token",
    "admin_email": "dana@acme.example",
    "admin_password": null
  }
}
Warning

Store issued in the same call that produced it. A client_secret or scim_bearer_token is returned once by design; a deployment receipt you did not persist is a credential you have to rotate.

issued is retained on the terminal GET and then never re-issued. A rollback produces a deployment with an empty issued block, because those credentials belonged to the revision you left.

#Logs

bash
curl -sS "$BASE/deployments/$DEP_ID/logs?step=verify&tail=50" -H "Authorization: Bearer $ULEX_API_KEY" | jq
json
{
  "object": "deployment_logs",
  "deployment_id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
  "steps": [
    { "name": "verify", "state": "succeeded", "duration_ms": 232, "message": "Health check passed" }
  ],
  "lines": [
    { "ts": "2026-09-29T14:48:21.688Z", "level": "info", "step": "verify", "message": "GET / 200 in 41ms" },
    { "ts": "2026-09-29T14:48:21.701Z", "level": "info", "step": "verify", "message": "GET /.well-known/openid-configuration 200 in 12ms" },
    { "ts": "2026-09-29T14:48:21.720Z", "level": "warn",  "step": "verify", "message": "JWKS cache cold; 1 remote fetch" },
    { "ts": "2026-09-29T14:48:21.920Z", "level": "info", "step": "verify", "message": "deployment succeeded" }
  ]
}
LevelMeaning
debugverbose; off unless you ask for it
infostep lifecycle
warndegraded but not fatal: a cold cache, a slow dependency, a retry
errorthe step failed. deployment.error carries the machine-readable code

Every line is scrubbed before storage: no client secrets, no tokens, no raw environment values. If you need a value in a log, redact it yourself at the source — you will not be able to add it later.

Omit step to get every step. tail is 1–2,000, default 200.

#Cancel

bash
curl -sS -X POST "$BASE/deployments/$DEP_ID/cancel" -H "Authorization: Bearer $ULEX_API_KEY"
json
{ "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF", "object": "deployment", "state": "cancelled", "progress_percent": 60, "finished_at": "2026-09-29T14:48:21.500Z" }

Cancelling a terminal deployment is 409 invalid_state_transition. Cancel is terminal: cancelled → {}. The only way forward is a new deployment.

Cancelling mid-verifying leaves the previous revision serving, because ulex has already cut over by that point and the verify step is only checking. That is the correct semantic.

#Rollback

bash
curl -sS -X POST "$BASE/deployments/$DEP_ID/rollback" \
  -H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
  -d '{"to_deployment_id":"dep_01M3PSW4VRJVGQ82XD4EZ3T6SD"}'
json
{
  "id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD",
  "object": "deployment",
  "state": "rolled_back",
  "domain": "acme-support.ulexid.com",
  "progress_percent": 100,
  "rolled_back_from": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
  "finished_at": "2026-09-29T14:52:04.000Z"
}

A rollback is a new deployment. The original is not mutated. to_deployment_id defaults to the last succeeded deployment for the same application and environment. issued is empty.

Rollback is legal from deploying, verifying and succeeded. Rolling back a failed deployment is 409 invalid_state_transition — there is nothing to roll back to, and you should start a new deployment instead.

#Retry versus new deployment

SituationDo
A step failed transiently (deployment_failed, error.retryable: true)failed → queued. Same dep_…, fresh steps[]
The commit is wronga new deployment. Retrying re-runs the same bad input
A step failed because of configurationfix the configuration first. A retry re-fails identically

The audit trail keeps the original failure: deployment.failed and deployment.started both fire, and you can see the sequence in GET /audit-events?target_id={id}.

#Failure modes worth automating

error.codeMeaningAutomation
provision_application_failedthe OIDC client could not be registeredcheck application.limit_reached; usually too many redirect URIs
configure_saml_sp_failedSP metadata could not be publishedcheck the application's cookie_domain and whether an SP already claims that entity id
configure_scim_failedthe SCIM endpoint could not be boundcheck the directory is not already bound to another organization
build_failedthe simulated bundle step failedinspect the step logs; with strategy: simulated this indicates a malformed input, not a code problem
verify_healthcheck_failedthe post-deploy health probe did not passread the verify step logs; ulex cannot reach the simulated app's own health endpoint

Every deployment.* action is audited, and deployment.started, deployment.succeeded, deployment.failed and deployment.cancelled are all available as webhook events. Subscribe to them instead of polling.

#List and history

bash
curl -sS -G "$BASE/deployments" -H "Authorization: Bearer $ULEX_API_KEY" \
  --data-urlencode 'application_id=app_01M3PSV7J8TBSPHG95CYSEX32B' \
  --data-urlencode 'environment=prod' \
  --data-urlencode 'order=desc' --data-urlencode 'limit=20' | jq '.data[] | {id, state, commit_sha, created_at}'
text
dep_01M3PSVP70YQ9Y1YD8QMC42JXF  succeeded    9f3c1a7  2026-09-29T14:48:20.000Z
dep_01M3PSW4VRJVGQ82XD4EZ3T6SD  rolled_back  3f8b2c1  2026-09-28T18:02:11.000Z

List responses omit steps and issued. Read the individual deployment for those.

#What ulex does not do

State it plainly in any deliverable:

  • It does not build your code. commit_sha is recorded, not compiled.
  • It does not push an image or run a container.
  • It does not run your tests.
  • It does not create AWS resources in your account.
  • It does not change your DNS.
  • domain is a modelled hostname, not a resolvable one.

What it does do: give you a deterministic, auditable, machine-readable delivery receipt, with realistic state transitions, step-level logs, resource records, and credentials — so the pipeline you are building has something to talk to on day one.

#Reference