Docs

Step protocol

The step protocol is how Alien runs a custom resource's controller. Alien sends the controller one step at a time and saves the state that comes back, so a controller in any language can run a custom resource.

Each step is one request and one reply. This is the first step that creates a DNS zone on AWS:

Request
{
  "protocol": 1,
  "stepId": "53192f8f-e269-41e7-8125-cbffc5ffaf0a",
  "deploymentId": "dep_acme-http-lifecycle",
  "resourceId": "zone",
  "resourceType": "acme/dns-zone",
  "platform": "aws",
  "resourcePrefix": "q6aa0b26",
  "initialSetupAuthority": "importedHandoff",
  "lifecycle": "live",
  "resource": { "type": "acme/dns-zone", "id": "zone", "domain": "internal.acme.dev" },
  "previousResource": null,
  "dependencies": {},
  "setupRun": false,
  "setupRunId": null,
  "state": null,
  "transitions": [],
  "credentials": null,
  "cloud": { "platform": "aws", "accountId": "123456789012", "region": "us-east-1" },
  "deadline": "2026-11-06T18:11:07Z"
}
Reply
{
  "protocol": 1,
  "stepId": "53192f8f-e269-41e7-8125-cbffc5ffaf0a",
  "result": "stepped",
  "controller": {
    "state": { "state": "createWait", "zoneId": "ZB112BA32" },
    "status": "provisioning",
    "progress": "Waiting for the zone to become active",
    "outputs": { "type": "acme/dns-zone", "zoneId": "ZB112BA32" },
    "bindingParams": null,
    "onFailureStatus": "provision-failed",
    "updateStart": { "outcome": "refused", "message": "Cannot transition to update from state: CreateWait" },
    "deleteStart": { "outcome": "allowed", "status": "deleting" },
    "teardownStart": { "outcome": "allowed", "status": "deleting" }
  },
  "suggestedDelayMs": null,
  "heartbeats": []
}

Every request also carries deploymentConfig, left out of the examples on this page.

When you need it

You rarely need this page. export_controllers! in the Extension SDK implements the controller's side of every message here, and alien extensions build builds a controller only from a Rust crate. Read it to debug a step, or to see exactly what a module and Alien exchange.

Hooks, such as modifiers, interceptors, and importers, are always Rust and never use this protocol.

The module

A controller is a WebAssembly module built for wasm32-wasip1. Alien starts a new instance for each step, writes the request into the module's memory, and reads the reply from it.

The module exports:

ExportTypeWhat it is
memoryMemoryThe module's linear memory
alien_controller_abi_v1() -> ()The marker of a controller module, version 1
alien_alloc(len: i32) -> i32Returns len bytes of the module's memory for Alien to write to
alien_controller_step(ptr: i32, len: i32) -> i64Answers the request at ptr, len bytes of JSON
_initialize() -> ()Optional. Alien calls it once before the step

alien_controller_step returns the reply packed in an i64: its address in the low 32 bits, and its length in the next 31. Set bit 63 when the module can't answer, with the bytes saying why.

The module imports only WASI preview 1 and the two functions Cloud calls describes. Alien refuses a module that imports anything else.

The sandbox gives the module the clock and random numbers, and no sockets, files, or environment variables. What it writes to stderr goes into the error of a step that traps.

Local controllers

Under alien dev, Alien runs no module. It starts the controller crate's native binary as a process and writes one JSON object per line on its stdin. The controller answers with one line on stdout.

Alien sends one request at a time to the process and waits for its reply. If the process exits, or writes anything on stdout that isn't the reply, Alien stops it and its children and starts it again on the next step. Write logs to stderr.

alien extensions build runs the binary with --controllers to read what it registers. Print each type's platforms as JSON and exit, such as {"acme/dns-zone":["local"]}. The build refuses a binary that lists any platform but local.

Listed controllers

alien extensions build asks the module which controllers it has, with a controllers message in place of a step:

{"protocol":1,"op":"controllers"}

Answer with each type's platforms, without a cloud call:

{"protocol":1,"controllers":{"acme/dns-zone":["aws","azure","gcp"]}}

The build writes those platforms into the bundle, and refuses a module that lists local.

Request

Prop

Type

A Dependency holds what you may read about another resource. It never holds that resource's own saved state.

Prop

Type

Cloud calls

A module has no credentials and no sockets. It sends a request by calling an import, and Alien checks the request, signs it, and sends it:

ImportTypeSends
alien_cloud_v1::send(ptr: i32, len: i32) -> i64A request to the step's cloud
alien_http_v1::send(ptr: i32, len: i32) -> i64A request to an origin the extension declares, with none of the deployment's credentials

Each takes a JSON request at ptr and returns a packed reply, in memory Alien gets from alien_alloc. With bit 63 set, the bytes are a line of text that starts refused: or failed:.

cloud in the step request says where the calls go. It is tagged by platform:

platformFields
awsaccountId, region
gcpprojectId, region
azuresubscriptionId, tenantId

A request to alien_cloud_v1::send names a service and a path. Alien picks the scheme, the host, and the port:

Prop

Type

A request to alien_http_v1::send has method, url, headers, body, and bodyBase64. url is an absolute https URL on a declared origin.

Both return the same reply:

Prop

Type

A step sends at most 50 requests through the two imports together. A request body is at most 6 MiB, and Alien reads at most 8 MiB of a response. Controllers lists the hosts Alien sends to and what it refuses.

Alien sends each request once. A failed: line means Alien tried to send the request and got no answer, so it may still have reached the cloud. A refused: line means Alien didn't send it, and the same request is refused again.

Whose credentials sign the calls depends on who drives the deployment:

Who drivesCredentials
The Alien manager, in a push deploymentShort-lived credentials for the extension's identity, new for each step
The Operator, in a pull deploymentThe extension's identity
The setup CLI, during initial setupNone. cloud is null, and the module's cloud calls are refused.
alien devNone. A local controller makes no cloud calls.

Initial setup creates the extension's identity from your permission sets. Calls signed as it show in the customer's audit log apart from Alien's.

A step with no cloud credentials, as on Linux servers, carries cloud: null. Alien refuses alien_cloud_v1::send for it, and alien_http_v1::send still reaches the declared origins.

Reply

result says what happened:

resultMeaningFields
steppedThe step rancontroller, suggestedDelayMs, heartbeats
failedThe step ran and failedcontroller, error
refusedThe controller didn't run the step, for example an unknown type or protocol versionerror, supportedProtocols

Prop

Type

The view

Between steps, Alien asks a controller what an update or a delete would do, and reads its status and outputs. It can't wait on a round trip there, so every reply carries a view. It holds those answers, computed by your controller from its current state.

Prop

Type

A TransitionPreview is { "outcome": "allowed", "status": "updating" }, the status the resource gets, or { "outcome": "refused", "message": "..." }, why your controller can't start it from this state. A refused update keeps the resource as it is. A delete or a teardown is the customer's to start: Alien starts it even when you refuse, with the status deleting, and your controller gets the transition with its next step. If your controller then refuses the delete, or fails it with an error that isn't retried or runs out of retries, that resource shows DeleteFailed with your message, and the rest of the stack still deletes. A delete your controller hasn't finished 30 minutes after it started ends DeleteFailed too, whatever it answers; a delay you ask for during a delete is cut to the time left, and a retry gives the delete another 30 minutes. The resources it depends on stay until it is deleted, as they do for Alien's own resources.

When Alien starts a transition, it answers from the view and sends the transition in the next request's transitions. Apply each one, in order, before you step:

TransitionAlien sends it when
update-startThe resource's config changed. previousResource holds the old config.
delete-startThe resource left the stack
teardown-startAlien tears down what initial setup created for the resource
failureAlien marked the last step failed. Move to the state that gives onFailureStatus.
reset-stay-countAlien retries a failed resource. Reset your polling count.

Statuses

status, onFailureStatus, and a preview's status are one of Alien's resource statuses, pending, provisioning, provision-failed, running, updating, update-failed, deleting, delete-failed, teardown-required, deleted, or refresh-failed.

Imported resources

A frozen custom resource created by a setup template has no controller state yet. Your importer turns the template's outputs into your controller's fields, and Alien saves them without calling your controller.

The resource's first step then carries them in pendingImport, with state set to null, and so does each step after it until one replies with a state. Load them as your state, without a cloud call, and then step from there:

pendingImport
{ "state": "ready", "zoneId": "Z123" }

alien extensions test and alien release check the same thing with your importer's fixtures. They send your controller a load message in place of a step:

{"protocol":1,"op":"load","resourceType":"acme/dns-zone","platform":"aws","state":{"state":"ready","zoneId":"Z123"}}

Load the state without stepping and without a cloud call. Answer {"protocol":1,"view":{...}} with your view, or {"protocol":1,"refused":"<message>"} when you can't read the state. The check fails when your controller refuses it, or when the view's state, status, or outputs differ from what the importer wrote.

Step ids and retries

Each attempt has its own stepId. When a step ends without a reply, Alien sends the same request again with the same stepId:

  • Same step id. A module keeps nothing between steps, so the step runs again from the state in the request. Make every call safe to repeat, with a key the cloud checks, such as Route53's caller reference.
  • New step id. A new step, even when the rest of the request matches the last one.

A failed reply with retryable: true is retried with backoff. Any other failure fails the resource with the code EXTENSION_STEP_FAILED and a message that starts with your code, such as the controller failed (ZONE_LIMIT): .... Alien acts on its own codes, so a code of yours never stands in for one, with these exceptions:

  • EXTENSION_STEP_DEADLINE: your step reached its deadline, as Deadline describes.
  • EXTENSION_STEP_REFUSED: the step can't succeed; it isn't retried.
  • DEPENDENCY_NOT_READY, except while the resource deletes: something the step needs isn't ready yet; the step waits and runs again.
  • REMOTE_RESOURCE_NOT_FOUND, while the resource deletes: the resource is already gone, and the delete ends.

Deadline

Each step has 60 seconds, and deadline gives the exact time. For longer work, start it, reply with a suggestedDelayMs, and check on it in the next step.

When a step reaches its deadline before it finishes, reply failed with code EXTENSION_STEP_DEADLINE, retryable: true, and your state as it is, so an id you already saved is kept.

Alien cuts a call still open at the deadline, and refuses one sent after it. Either way the step fails with EXTENSION_STEP_DEADLINE and Alien sends it again, whatever the module replied.

Alien stops a module that hasn't replied 2 seconds after the deadline. It also stops a module that computes for too long without a call, at about 4 billion WebAssembly instructions. A stopped step fails with EXTENSION_STEP_DEADLINE and runs again from the state Alien last saved.

One Alien process runs at most 64 module steps at a time, at most 16 of one project's, and at most 2 of one deployment's. A step past any of these limits waits for one to end before its 60 seconds start.

Errors Alien reports

When a step fails, the resource shows one of these codes:

CodeWhenRetried
EXTENSION_CONTROLLER_UNREACHABLEThe module trapped, for example on a panic, or needed more than its 64 MiB of memory. Under alien dev, the process exited or sent no reply by the deadlineYes
EXTENSION_PROTOCOL_UNSUPPORTEDThe reply's protocol is newer than Alien's, or your controller doesn't speak the request's version and answered result: refused with supportedProtocolsNo
EXTENSION_PROTOCOL_ERRORThe reply isn't a step reply, names another stepId, is larger than 16 MiB, or the module returned with bit 63 setNo
EXTENSION_STEP_REFUSEDYour controller replied refused for another reasonNo
EXTENSION_STEP_FAILEDYour controller replied failed; the message starts with your codeWhen your error says so
EXTENSION_STEP_DEADLINEYour controller replied failed at its deadline, a call was cut at the deadline or sent after it, or Alien stopped the moduleYes

Protocol versions

The current version is 1. Both the request and the reply carry protocol:

  • Alien reads the reply's protocol before the rest. A reply with a newer version fails the resource with EXTENSION_PROTOCOL_UNSUPPORTED, and the message names both versions.
  • Refuse a request whose version you don't speak, with result: refused and the versions you do in supportedProtocols.

Next

  • Extension SDK: export_controllers! and the #[controller] model in Rust
  • Controllers: where controllers run in each deployment
  • Security: what an extension can reach

On this page