environments: in the repository’s env0.workflow.yml. From the CLI you can:
- Deploy the whole workflow with a different branch and variables for each sub-environment, using a manifest file.
- Deploy or destroy a single sub-environment, or run the workflow from one sub-environment onward.
environments: in env0.workflow.yml, not its templateName.
Prerequisites
- The env zero CLI, signed in or with API key environment variables set
- A workflow template whose
env0.workflow.ymldefines the sub-environments. See Create a new workflow and the workflow file reference.
Deploy with per-sub-environment branches and variables
1
Write a manifest
The manifest is a YAML or JSON file. Every field is optional.
deploy.yaml
Each variable takes
name and value. type is environment (default) or terraform. sensitive defaults to false. Unknown fields are rejected.2
Deploy
Pass the manifest to
environment deploy for an existing workflow environment, or to environment create --template for a new one:3
Verify each sub-environment's branch
alias, plus the blueprintRevision and status of its latest deployment.How the manifest combines with flags
- Workflow-level
variablesmerge with--var,--secret, and--tf-var. A flag wins over the manifest for the same variable name and type. --revisionwins over the manifest’srevision.- Per-sub-environment values come only from the manifest.
--manifestcannot be combined with--repository.
Turn sub-environments on and off
The manifest has no per-sub-environmentdisabled field. Toggle a sub-environment with a workflow-level variable that env0.workflow.yml reads, for example disabled: ${DISABLE_PAYMENTS}, and set that variable under the manifest’s top-level variables.
Alias checks
The workflow ignores an override for an alias it does not recognize, so the CLI checks aliases first. A wrong alias exits64 and lists the valid ones.
- On
deploy, the check runs before anything is sent. Nothing is deployed. - On
create, the environment does not exist yet. The CLI creates it, then waits up to about 30 seconds for the workflow to resolve and checks the aliases. A wrong alias fails after the environment exists, so destroy it and create it again with a fixed manifest. If the workflow does not resolve in time,createexits0and the nextdeploychecks the aliases.
deploy --manifest checks aliases against the last resolved workflow file. If the environment’s only deployment failed before the workflow resolved, deploy once without --manifest first.
Deploy or destroy part of a workflow
Pass--node <alias> with the workflow environment’s id:
- The result is one deployment on the workflow environment.
--waitexits with its final status. - A wrong alias exits
64, and nothing is sent. - The workflow’s revision is fixed:
--nodecannot be combined with--revisionor a manifestrevision. Per-sub-environment manifest values still apply to the sub-environments that run. destroy --nodedoes not accept--skip-state-refresh,--checkout-updated-code, or--requires-approval.- To bring back a destroyed sub-environment, run
deploy --node <alias>.
Create a workflow environment from scratch
1
Create a template for each sub-environment
Each sub-environment in For a private repository, add
env0.workflow.yml that uses templateName needs a Terraform, OpenTofu, Terragrunt, or other non-workflow template. A sub-environment cannot point to another workflow template.--vcs-connection-id with an id from env0 vcs list.2
Create the workflow template
Point
--path at the directory that holds env0.workflow.yml:template create assigns the template to your stored project, or to --project. environment create only deploys templates assigned to the target project.3
Create the environment
--manifest to set per-sub-environment branches and variables on the first deployment.deployment get, deployment logs, and context show the reason in errorMessage, for example Nested workflows are not allowed.
Next steps
- Command reference - Every CLI command and flag.
- Workflow file reference - All
env0.workflow.ymlsettings. - Workflow variables - Pass variables to sub-environments.