@env0/cli
v1.0.24
Published
env0 CLI
Downloads
15,420
Readme
@env0/cli
The command-line tool for the env0 platform.
Features
- 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.
Installation
$ yarn global add @env0/cli
# or
$ npm install -g @env0/cli
Commands Overview
env0 help
Run env0 help
to get a helpful list of supported commands and arguments.
env0 configure <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.
env0 deploy <arguments>
Initiates a new deployment on env0, whether for a new environment or for an existing one.
env0 destroy <arguments>
Initiates a new deployment to destroy and existing environment.
env0 approve <arguments>
Runs an approval of an existing deployment that is waiting to be approved (AKA waiting in plan stage).
env0 cancel <arguments>
Cancels an existing deployment that is waiting to be approved (AKA waiting in plan stage).
Arguments Overview
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
API Key
env0 API Key (Required)
- Usage:
--apiKey
- Alias:
-k
API Secret
env0 API Secret (Required)
- Usage:
--apiSecret
- Alias:
-s
Organization ID
env0 Organization ID (Required)
- Usage:
--organizationId
- Alias:
-o
Project ID
env0 Project ID (Required)
- Usage:
--projectId
- Alias:
-p
Blueprint ID
The Blueprint ID you wish to deploy with (Required for new environments)
- Usage:
--blueprintId
- Alias:
-b
Environment Name
The environment name you wish to create, or deploy to an existing one (Required for existing environments)
- Usage:
--environmentName
- Alias:
-e
Environment ID
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
Workspace Name
(Optional) - A name for Terraform Workspace created for your new environment. This cannot be changed after an environment was created
- Usage:
--workspaceName
- Alias:
-w
Environment Variables
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
Terraform Variables
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
Revision
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
Requires approval for deployment. Valid values are either "true" or "false".
- Usage:
--requiresApproval <true/false>
- Alias:
-a
Skip State Refresh
Disable automatic state refresh on 'plan -destroy' phase.
- Usage:
--skipStateRefresh <true/false>
- Alias:
-z
Targets (Partial Apply)
A list of resources to explicitly include in the deployment, delimited by a comma. Format is "resource1,resource2,resource3"
- Usage:
--targets
- Alias:
-t
Configuration File
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.
Supported Environment Variables
ENV0_API_KEY
ENV0_API_SECRET
ENV0_ORGANIZATION_ID
ENV0_PROJECT_ID
ENV0_BLUEPRINT_ID
ENV0_ENVIRONMENT_NAME
ENV0_ENVIRONMENT_ID
API Reference
https://docs.env0.com/reference
env0 blog:
https://www.env0.com/blog/introducing-the-env0-cli
Compiling from Source
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
Development flow:
- Run
export ENV0_API_URL=https://api-server
to change the API URL
Default url is set tohttps://api.env0.com
- Run
env0 configure