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 login 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 an API Key.

Creating API Keys can only be done by an Organization Admin. If you do not have this permission, contact an Organization Admin to generate the token.


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.


User Login (Coming Soon)

env0 will be releasing a user login method that will remove the requirement for admins to generate an API key per user.

Did this page help you?