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

2 Likes

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.

1 Like

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
1 Like

Sorry to necro an old thread, but has there been any progress on this? I’d like to be able to specify my stacks as local-mode only while continuing to use TF cloud to store state.

+1 for me.

It would really help us out if we could set the default for new Terraform workspaces to Local Execution Mode. Or, maybe even better, introduce a parameter inside the Remote State configuration in the Terraform plan to toggle between ‘Remote’ and ‘Local’ execution.

We use Modules to create all our resources on our different environments (instead of Workspaces), so new Workspaces are not created manually in Terraform Cloud upfront.

1 Like

+1, It’s REALLY anoying that we have to do go through the UI to disable remote …

thx for the curl hack @sirtimbly. that’s at least somewhat mitigating the pain …

+1

Please consider this change. It’s been a long time waiting for this