Terraform Cloud defaults to remote execution

I’m trying to use terraform cloud for remote state storage only, but “terraform init” always create new workspaces with execution mode set to remote, is there a way to change it?

As far as I could tell, not directly through the backend configuration.

You have to create the workspace first and set operations to false: https://www.terraform.io/docs/providers/tfe/r/workspace.html

Saw that, but it’s not that comfortable, requiring more bookkeeping in a separate place: i would need another module which hosts workspaces definition.
In some sort of “self service” infrastructure it’s not that comfortable

I’m not able to see any default Terraform Cloud workspace overrides via the UI.

A few options to change the remote execution setting are the radio button in the workspace settings UI, an API request, or via Terraform itself.

I wanted to have the behavior set to local execution by default. To do so I created a variable which defaults to false, and checks whether to enable or disable the remote execution setting. I have it abstracted at the module level, but this will work for a terraform project.


variable "remote_execution" {
    type    = bool
    default = false


resource "tfe_workspace" "silver" {
  name         = "test"
  organization = "test"
  operations   = var.remote_execution == true ? true : false

Right, but it can’t be done automatically on the same module with other local modules, since it would fail at the start of the first plan.
For example:


This would fail, where staging and prod references module1 where most code is (staging and prods are just for differences in envs with both tf code and *.auto.tfvar, and setting workspace name)

Just to give some more information, we are using also atlantis to make it more useful for our work style but it still is the same when run locally.
ps. This structure also give us a quite simple atlantis setup, just setting the various projects

I see what you are saying, when you have a Terraform Cloud workspace being auto-created while running terraform init it is set to remote execution by default and isn’t a way to change it.

From the last block under the Workspaces heading:

If previous state is present when you run terraform init and the corresponding remote workspaces are empty or absent, Terraform will create workspaces and/or update the remote state accordingly.

I would make the best effort to make sure all Terraform Workspaces are created with remote execution disabled before terraform init/plan is run against that remote backend.

In the case of you having multiple terraform CLI workspaces, you can use a count to make the creation of the Terraform Cloud workspace unique.

Below I’ve included some working HCL based off the above snippets. I added an extra ternary operator to resolve the problem creating a unique resource across all workspaces. Whichever terraform workspace it matches will be the one it is created in. You could definitely modify this to add to your module:

resource "tfe_workspace" "silver" {
  count = terraform.workspace == "default" ? 1 : 0

  name                  = "silver"
  organization          = "silver"
  auto_apply            = false
  terraform_version     = "0.12.10"

  operations        = var.remote_execution == true ? true : false