Local Login to env zero Remote Backend
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 for your requests will be authorized.To login, ensure the following conditions are met:
- You have a login Token
- The current path is the directory of the Terraform stack
- The Terraform stack defines a properly configured env zero backend
backend.tf
A note regarding the PROJECT_ID in the backend configurationThe PROJECT_ID is only required if the env zero environment does not exist in the env zero UI. For example, if this is the first time you are creating a new env zero environment with the env zero remote backend configuration, you need to specify the PROJECT_ID so that env zero will know where to put your new env zero environment. Otherwise, if you are simply updating the backend configuration for an existing env zero environment, you do not need to specify the PROJECT_ID.
- Run
terraform login backend.api.env0.com
- Enter
yes
when prompted - Insert your
token
A note regarding Module Registry & Remote BackendTechnically, the two services are hosted on different api endpoints, so in order to use both the module registry and the remote backend with the same API key, you will have to also setup the token for
api.env0.com
Please see the section on Private Registry authorization for more details.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 UsersTerraform’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 env zero will be unable to differentiate between different users when they use the same token.
Logout
In case you need to logout, you can browse tobackend.api.env0.com/logout/{Token}