The command-line tool for the env0 platform.
- deploy - Creates a new environment or deploy an existing environment.
- destroy - Destroys an existing environment.
- approve - Resumes a deployment that awaits an approval.
- cancel - Cancels a deployment that awaits an approval.
$ yarn global add @env0/cli
# or
$ npm install -g @env0/cli
Run env0 help
to get a helpful list of supported commands and arguments.
Sets configurable options for the CLI. If no arguments are given, displays a set of prompts that will help you configure the CLI options.
Initiates a new deployment on env0, whether for a new environment or for an existing one.
Initiates a new deployment to destroy and existing environment.
Runs an approval of an existing deployment that is waiting to be approved (AKA waiting in plan stage).
Cancels an existing deployment that is waiting to be approved (AKA waiting in plan stage).
The arguments are loaded from env0 configuration files, environment variables and CLI parameters. The order of precedence of the arguments is:
-
env0
CLI explicit parameters - Environment Variables
- Configuration File
env0 API Key (Required)
- Usage:
--apiKey
- Alias:
-k
env0 API Secret (Required)
- Usage:
--apiSecret
- Alias:
-s
env0 Organization ID (Required)
- Usage:
--organizationId
- Alias:
-o
env0 Project ID (Required)
- Usage:
--projectId
- Alias:
-p
The Blueprint ID you wish to deploy with (Required for new environments)
- Usage:
--blueprintId
- Alias:
-b
The environment name you wish to create, or deploy to an existing one (Required for existing environments)
- Usage:
--environmentName
- Alias:
-e
The environment id you wish to re-deploy. If both the environment name and ID are specified, the environment ID will take precedence
- Usage:
--environmentId
- Alias: N/A
(Optional) - A name for Terraform Workspace created for your new environment. This cannot be changed after an environment was created
- Usage:
--workspaceName
- Alias:
-w
The environment variables to set on the deployed environment - works only on deploy and can be multiple, the format is "environmentVariableName1=value"
- Usage:
--environmentVariables
- Alias:
-v
For sensitive environment variables, use:
- Usage:
--sensitiveEnvironmentVariables
- Alias:
-q
The terraform variables to set on the deployed environment - works only on deploy and can be multiple, the format is "terraformVariableName1=value"
- Usage:
--terraformVariables
- Alias:
-u
Your GIT revision, can be a branch, a tag or a commit hash. (For existing environments - if not specified, will use the previously defined revision)
- Usage:
--revision
- Alias:
-r
Requires approval for deployment. Valid values are either "true" or "false".
- Usage:
--requiresApproval <true/false>
- Alias:
-a
Disable automatic state refresh on 'plan -destroy' phase.
- Usage:
--skipStateRefresh <true/false>
- Alias:
-z
A list of resources to explicitly include in the deployment, delimited by a comma. Format is "resource1,resource2,resource3"
- Usage:
--targets
- Alias:
-t
After initial deployment, a configuration file will be created under ~/.env0/config.json
This file holds your last action's required parameters and will spare you from re-configuring the required parameters on every action.
ENV0_API_KEY
ENV0_API_SECRET
ENV0_ORGANIZATION_ID
ENV0_PROJECT_ID
ENV0_BLUEPRINT_ID
ENV0_ENVIRONMENT_NAME
ENV0_ENVIRONMENT_ID
https://docs.env0.com/reference
https://www.env0.com/blog/introducing-the-env0-cli
You can compile and run the CLI from source by cloning the repo from Github and then running the following:
# Clone the repo from github
# Make sure env0 lib is not installed globally
npm install
npm link # link your local copy of the CLI to your terminal path
- Run
export ENV0_API_URL=https://api-server
to change the API URL
Default url is set tohttps://api.env0.com
- Run
env0 configure