Login
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:
- You have a login Token
- The current path is the directory of the Terraform stack
- The Terraform stack defines a properly configured env0 backend
terraform {
backend "remote" {
hostname = "backend.api.env0.com"
organization = "<YOUR_ORGANIZATION_ID>.<YOUR_PROJECT_ID>"
workspaces {
name = "<YOUR_WORKSPACE_NAME>"
}
}
}
A note regarding the PROJECT_ID in the backend configuration
The PROJECT_ID is only required if the env0 environment does not exist in the env0 UI. For example, if this is the first time you are creating a new env0 environment with the env0 remote backend configuration, you need to specify the PROJECT_ID so that env0 will know where to put your new env0 environment. Otherwise, if you are simply updating the backend configuration for an existing env0 environment, you do not need to specify the PROJECT_ID.
Logging in is simple. All you have to do is:
- Run
terraform login backend.api.env0.com
- Enter
yes
when prompted - 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.
Updated 24 days ago