---
title: "Deploy a version"
url: "https://docs.alisx.com/how-to/alis-build/deploy-a-version/"
---
# Deploy a version

Apply a built service version's Terraform into one or more deployment environments. Deploy is the third step of Define, Build, Deploy and the only one that changes running infrastructure.

## Prerequisites

- A built version. `alis product view <org>.<product>` lists each service's latest version and state.
- The target environment ids. Read them with `alis context view --json`; never guess them.

## Deploy the latest version

=== "CLI"

    ```bash title="Terminal"
    alis deploy acme.sh.orders.v1 -e <env-id>
    ```

    The latest built version is deployed. Pass `--version 1.4.2` for a specific one. Repeat `-e` for several deployment environments; when the product has exactly one deployment environment it is used without `-e`, otherwise the command lists the ids to choose from. Inside the service folder the package id can be omitted.

=== "Console"

    1. Open the product and go to **Services**. The table compares versions across deployment environments.
    2. Select the service's cell in the target environment.
    3. Pick a version from the list and deploy it. The same dialog offers **Destroy** for removing the deployment.

## Plan first

```bash title="Terminal"
alis deploy acme.sh.orders.v1 -e <env-id> --plan-only
```

Only `terraform plan` runs. Use it whenever `infra/*.tf` changed and before any production deploy. A plan is not gated by the production confirmation or by designated branches; a frozen deployment refuses plans too.

## Pass the production gate

A deploy to a deployment environment marked as production asks for confirmation. At an interactive terminal the CLI prompts `[y/N]`. In scripts, with `--json`, or from a coding agent, the command exits with code 3 and an error envelope with code `PRODUCTION_CONFIRMATION_REQUIRED`; re-run the exact command with `--confirm-production` once a person has approved that version and deployment environment.

```bash title="Terminal"
alis deploy acme.sh.orders.v1 --version 1.4.2 -e <prod-env-id> --confirm-production
```

## Deploy from a non-designated branch

When a deployment environment designates branches (`alis environment branches`), a version built from a commit on another branch triggers a confirmation. Interactively you are asked; otherwise pass `--allow-branch-mismatch`. The deploy is warned about, never blocked outright.

## Respect a feature freeze

A product admin can freeze a service's deployment in a deployment environment with `alis service freeze <package-id> -e <env-id>`, or from the service's deploy options in the TUI and the console. While it is frozen, every deploy, plan and destroy of that service there is refused with the error code `DEPLOYMENT_FROZEN` (exit code 1), before anything is built or applied. There is no override flag: ask a product admin to lift it with `alis service unfreeze`. `alis service view` shows `featureFreeze` per deployment environment, and the TUI marks a frozen deployment with a snowflake in place of its status mark.

## Wait, or not

`--async` prints the operation name and returns; `alis operations wait <name>` re-attaches. The finished operation lists each `deployments[]` entry with its `state` (`RUNNING` on success, `DEPLOY_FAILED`, `PLANNED`, `PLAN_FAILED` and others), a `logsUri` and, on failure, the error. `alis logs deploy <operation>` prints the Terraform log tail.

## Remove a deployment

In the console's deploy dialog, **Destroy** asks whether to destroy the cloud infrastructure and then remove the deployment, or remove the deployment only and leave the infrastructure; **Destroy deployment** confirms. In the TUI, press ++x++ on the deployment environment cell and confirm the destroy plan.

## Related

- [Promote to production](https://docs.alisx.com/how-to/alis-build/promote-to-production.md)
- [Deployment environments and versions](https://docs.alisx.com/explanation/environments-and-versions.md)
- [Operations and output](https://docs.alisx.com/reference/dbd/operations-and-output.md)
