An environment is an entity representing a deployment managed by env0.
To view your environments, choose a Project and then select the Environments tab.
The Environments screen shows a list of all the environments in the current project that you have permissions to see.
For each environment, you can see the template it came from, the revision (the git branch on which the Terraform code for it resides), the owner, the status, the remaining time-to-live for it, and the number of cloud resources it currently consumes (for Active environments).
To perform actions on an environment, or to view more details, click on it and then drill down to Environment Details.
In the Environment Details screen, you can execute operations such as Destroy Environment or Redeploy. You can also view the logs from the latest deployment, the Terraform outputs, the Variables used in deploy, and the Deployment History.
An environment can be in one of the following states:
- Active - successfully deployed, and up and running.
- Inactive - successfully destroyed, manually or automatically.
- Deploy in progress - currently being deployed.
- Undeploy in progress - currently being undeployed.
- Failed - errors were encountered during deployment/undeployment
- Waiting for approval - a change has been initiated by a user with Planner role. A Deployer's approval is required to execute the change.
When your environment is in the Active status, you are able to see the resources it includes just by clicking into the Environment.
Resources are grouped by their 'provider' and 'type', for example - all AWS S3 buckets will appear together.
Use the search box in the top right to filter the resources list.
Time-to-live is the amount of time before env0 automatically destroys the environment (if it is Active).
You set the time-to-live when you create or redeploy an environment. Possible pre-defined values are: 12 hours, 1 day, 3 days, 1 week, 1 month, and infinite. It is also possible to set a specific date for the environment end of life.
An infinite time-to-live means the environment will never be destroyed automatically. This is useful for static environments like staging or production, but is not recommended for development environments.
An administrator can control the default and the maximum TTL values using TTL Policies.
Non-admin users can set the time-to-live to any value that the Policy for the current Project allows.
A user with admin role can override the Policy setting.
To create an environment, choose a specific Project, select the Templates tab, and then click Run Now on the template you want to use.
If you don't see the Run Now button on the templates, check that you are in the context of a specific Project, not the Organization.
Click Run to start the deployment, The Environment Details page will open, and the progress will be shown in the Deployment Logs section.
During the deployment, env0 runs terraform plan and terraform apply. The outputs and state are stored.
If the deployment is successful, its status will be set to Active, and the user will receive an email notifying him that the environment has been successfully created.
If the deployment fails, the user will get an email notification (with details) and the environment status will be set to Failed.
An environment set with a time-to-live other than infinite is automatically destroyed when its time limit is reached.
To manually destroy an environment, select the Environment Details page of an Active environment, and click Destroy Environment at the top right (it looks like a stop sign).
For any destroy process, whether it's via time-to-live or manual, if a current deploy or destroy of your environment is in process, your destroy will be queued and will automatically start once it reaches its turn. You can cancel a queued destroy from the Deployments tab.
When an Active environment is destroyed, an undeploy process starts. If it ends successfully, the environment status is set to Inactive, and the user will receive an email notification that his environment has been destroyed.
If the undeployment fails, the environment status will be set to Failed, and the user will receive an email notification with details.
When destroying an environment, env0 will use the same code that was used in the last deploy process. If you'd like an updated version of the code to be used in the undeploy process, enable the "Checkout updated code" option.
To redeploy an environment, navigate to the Environment Details page, and then click Redeploy in the top right corner.
If your environment is currently running a deploy/destroy, your new deployment will be queued and will start after the current deploy/destroy completes. You can view your previous and queued deployments - as well as cancel a queued deployment - from the Deployments tab.
When you redeploy an Inactive environment, env0 will execute terraform apply on the environment, and deploy it again. If the deployment is successful the environment will go back to Active.
As part of the redeploy, a new time-to-live needs to be set for the environment. If the time-to-live is not changed, the destroy time set for the original deployment will be used for the new one. If this date has passed, you will not be able to run the redeploy until a new time-to-live is set.
In addition to time-to-live, new values can be assigned to other variables.
When you redeploy an Active environment, the environment is updated with all changes made in the code for the template.
You can set a new value for time-to-live, but this is not necessary. Also, the values of other variables can be altered.
It is possible to stop an ongoing deploy/destroy that was made by mistake, encountered some issues or just taking too long.
To abort a deploy/destroy of an environment, navigate to the Environment Details page, and then click the red Abort button. in the top right corner.
Aborting is a destructive action
When aborting, a graceful shutdown of the current execution is attempted with a 1 minute timeout. If the timeout reached the deploy/destroy process will be forcefully be terminated.
Therefore, aborting a deploy/destroy might result in a lost state or orphaned resources.
Please use it with caution.
When your environment is in the process of a destroy or deploy, requested actions (deploy/destroy) will enter a Queued state and will be initiated after current actions are completed. If you wish to cancel any of these queued actions before they are initiated, you can do so by using the Cancel button that is on the right side of the table in the Deployments tab.
In order to import an existing environment you’ll need to have already completed these prerequisites
- Connect your VCS and your cloud account
- Create a template pointing to your Terraform code
- Add any variables your existing environment was deployed with.
Importing Existing Environments
You can import already running environments into env0 as long as your environment was deployed using Terraform, using a remote state backend.
Once you've completed that, just follow these steps:
- Go to your “Default Organization Project” and enter the “Project Templates” page
- Find the template you’ve added, and click “Run Now”
- Under “Workspace name”, enter your existing Terraform workspace name.
- Uncheck the “Approve plan automatically” checkbox. This will guarantee that no changes will be made accidentally.
- Click “Run”
Terraform will read the existing state from your remote backend. A plan will be created and displayed for your approval. If the code and variables are identical to how you’ve last deployed this environment, you will see that there are no resources planned to change.
If you are happy with the results of the plan, click “Approve”, or “Cancel”.
Your environment is now managed by env0!
For every flow executed on an environment (create, destroy, or redeploy), env0 first creates a Terraform Plan. Executing the plan requires approval from a user with Deployer privligies.
Users with a Deployer or Admin role can have their action automatically approved by checking the Approve plan automatically checkbox. In this case, the plan will execute with no need for further approval.
A user with Planner role cannot automatically approve his own plans.
If the user doesn't set automatic approval, env0 will wait after the Terraform Plan is created until a Deployer has actively approved the plan to execute.
An environment that is waiting for approval will have the status of Waiting for Approval. A user with a Deployer role can approve the plan for deployment or cancel it. Choose the Environment Details screen, and click Deploy for the plan to be executed, or Cancel to cancel it.
To help users manage their environments, env0 lets users archive those environments that are no longer in use, moving them to the ARCHIVED list.
By default, all environments are listed in the ACTIVE tab, including environments that have manually or automatically been destroyed.
To archive an environment, select it in the ACTIVE tab, and click Archive Environment.
To move an archived environment back into the ACTIVE tab, select it in the ARCHIVED tab, and click "Restore Environment".
Updated 12 days ago