- Local execution mode - First you need to change the workspace settings in Terraform Cloud to enable local runs, so you need to go to the
General Settingsof the workspace and change theExecution Modeto Local. - Generating a token for authentication - To authenticate to Terraform Cloud remote backend you need to generate an API token, so under the
User settingsunderTokensand create an API token. Please save the token, we will need it in the further steps. - If you are running terraform version 1.2.0 or up you will need to add the following environment variables:
- If not you will need to add an
env0.ymlfile - In your Terraform git repo you will need to add anenv0.ymlfile in the Terraform folder and add the following code:
- Now you are ready to run your Template and the remote backend should be stored in Terraform Cloud.
Further reading
- Terraform backend configuration: local and remote options
- Manage Terraform remote state with a remote backend