Local Login to env0 Remote Backend

Remote backends allow running your Terraform deployments both on env0 and locally with access to the remote state. To use the Remote Backend locally, you must log in for your requests will be authorized.
To login, ensure the following conditions are met:

  1. You have a login Token
  2. The current path is the directory of the Terraform stack
  3. The Terraform stack defines a properly configured env0 backend
terraform {
  backend "remote" {
    hostname = "backend.api.env0.com"
    workspaces {
      name = "<YOUR_WORKSPACE_NAME>"

Logging in is simple. All you have to do is:

  1. Run terraform login backend.api.env0.com
  2. Enter yes when prompted
  3. Insert your token

Generating a Token

To generate a token, you must create a Personal API Key.
After the API Key has been created, the token will be listed under the Using it locally for Remote Backend.
Alternatively, Admins can create an API Key with a specific role.


Avoid Creating One Token For Multiple Users

Terraform's workspace locking mechanism prevents state corruption by enforcing that two users cannot plan nor apply simultaneously and overwrite each other's state.

Issuing the same token to multiple users causes the locking mechanism to be ignored, as env0 will be unable to differentiate between different users when they use the same token.