Skip to content

Init/apply is broken for remote backends #195

@ghost

Description

Original init command works if we add TF_WORKSPACE env var, but apply for some reason runs init again, but explicitly unsets TF_WORKSPACE, resulting in a error:

export workspace
unset TF_WORKSPACE
...
terraform init -input=false -no-color $INIT_ARGS "$module_path"
terraform workspace select -no-color "$workspace" "$module_path" || terraform workspace new -no-color "$workspace" "$module_path"
terraform apply -auto-approve $PLAN_ARGS "$module_path"
Initializing modules...

Initializing the backend...

The currently selected workspace (default) does not exist.
  This is expected behavior when the selected workspace did not have an
  existing non-empty state. Please enter a number to select a workspace:
  
  1. test-ci

  Enter a value: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions