Workspace app.terraform.io mode local execution?

I need to send the parameter inside my terraform init to create a workspace so that “local execution”.

Thank

1 Like

Hi @davispalomino,

Can you help me understand this a bit better? What is your current configuration and how are you using Terraform locally?

By declaring a remote backend in the terraform stanza, it will create the workspace for you once you run terraform init locally.

Thanks!

Hi @joatmon08 , I use a remote “app.terraform.io” -Terraform Enterprise- backend to save my state.

Terraform code (main.tf)

Summary
terraform {
      required_version = "> 0.12.0"
      backend "remote" {
        hostname="app.terraform.io"
        organization="myenterprise"
        workspaces {
          name = "myWorkspaceX"
        }
      }
    }

execution:

terraform init
terraform plan -var ‘region=us-east-1’

Error: Run variables are currently not supported

Summary
The "remote" backend does not support setting run variables at this time.
Currently the only to way to pass variables to the remote backend is by
creating a '*.auto.tfvars' variables file. This file will automatically be
loaded by the "remote" backend when the workspace is configured to use
Terraform v0.10.0 or later.

This is because a workspace is created with remote execution mode.

Every time I run the terraform init it creates a new workspace, when I access Terraform Enterprise to view it creates a workspace by default mode of execution-Remote, I would like to know if I can send a command in terraform init or configure to create a workspace with type of execution-local-

Thank You

1 Like

I ran into a similar problem recently as well. Go into the workspace settings and change to the execution to local. This solved the issue for me.

2 Likes

hi @davispalomino and @davidjeddy – you are correct. We are defaulting any new workspaces to ‘remote execution’ in Terraform Cloud. As @davidjeddy already pointed out, you can change the execution mode to local if you like by going to Settings | General for the specific workspace.

We appreciate the feedback that users will likely want to control this and are exploring options to provide ways for users to do that.

1 Like

hola @davidjeddy
Thanks for your comment, it happens that I can apply changing from remote to local when the workspace is created, but if it is being created by doing “terraform init” by default it is created in remote = (.

Hi @anilmurty1 , We will be aware of the change in order to handle the execution.

Thank You.

I just wanted to +1 this — it’d be really nice if either the CLI or tfe supported setting workspaces to local mode since we can’t use the remote mode without support for variables and better credentials management.

I was experimenting with https://gist.github.com/ffebce5c6ea5e924a44dd002721a38f9 to automatically create a workspace for each of our accounts, which would be ready to use now if I could set the execution mode.

With the addition of https://gist.github.com/29a35dd20dfaf26da0a336cc4091ee41 I now have a hundred local-mode workspaces.

@acdha Thanks for the gist.

Hashicorp’s switch to using remote execution by default on all new workspaces severely impacted my team’s ability to create feature branch environments, as I create workspaces programmatically as part of the process.

To anyone at Hashicorp, we really need a way to define this for ourselves as we don’t all want remote execution by default.

I’ve been told that they’re going to add this to the TFE provider; hopefully that will not be terribly far off.

In the mean time, I’ve expanded on your gist to create a little tool for anyone else having this problem. https://gist.github.com/DevBOFH/7bd65dbcb945cdfce42d21b1b6bc0e1b

Having this default setting on terraform cloud change, was a breaking change for our implementation.

I found it slightly simpler to use a curl command against the api like so…

curl \
--header "Authorization: Bearer $(echo $TF_BACKEND_TOKEN)" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data "{\"data\": {\"type\": \"workspaces\", \"attributes\": {\"operations\": false}}}" \
https://app.terraform.io/api/v2/organizations/$organization/workspaces/$workspace