Skip to main content
Remote backends allow running your Terraform deployments both on env zero and locally with access to the remote state. To use the remote backend locally, you must log in so your requests are authorized. To log in, 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 env zero backend
backend.tf
PROJECT_ID in the backend configurationThe PROJECT_ID is only required if the env zero environment does not exist in the env zero UI. If this is the first time you are creating an env zero environment with the remote backend configuration, specify the PROJECT_ID so env zero knows which project to place it in. If you are updating the backend configuration for an existing environment, you do not need to specify the PROJECT_ID.
To log in:
  1. Run terraform login backend.api.env0.com
  2. Enter yes when prompted
  3. Insert your token
Module registry and remote backend use separate endpointsThe module registry and remote backend are hosted on different API endpoints. To use both with the same API key, you must also set up the token for api.env0.com. See Private Registry authorization for details.

Generating a token

To generate a token, create a Personal API key. After the API key is created, the token appears under Using it locally for Remote Backend. Admins can also create an API key with a specific role.
Avoid sharing tokens between usersTerraform’s workspace locking mechanism prevents state corruption by ensuring two users cannot plan or apply simultaneously. Issuing the same token to multiple users defeats this mechanism, since env zero cannot differentiate between users sharing a token.

Logout

To log out, navigate to backend.api.env0.com/logout/{Token} in your browser.

Next steps