Commit 42d93ce8 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/configurable-init' into 'master'

feat(init): make terraform init options configurable

See merge request to-be-continuous/terraform!142
parents c2be57b3 bf89584c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ The Terraform template uses some global configuration used throughout all jobs.
| `scripts-dir` / `TF_SCRIPTS_DIR` | Terraform (hook) scripts base directory (relative to `$TF_PROJECT_DIR`) | `.` |
| `output-dir` / `TF_OUTPUT_DIR` | Terraform output directory (relative to `$TF_PROJECT_DIR`). Everything generated in this directory will be kept as job artifacts. | `tf-output` |
| `extra-opts` / `TF_EXTRA_OPTS` | Default Terraform extra options (applies to all Terraform commands) | _none_ |
| `init-opts` / `TF_INIT_OPTS` | Default Terraform extra [init options](https://developer.hashicorp.com/terraform/cli/commands/init) | _none_ |
| `init-opts` / `TF_INIT_OPTS` | Default Terraform extra [init options](https://developer.hashicorp.com/terraform/cli/commands/init) | `-reconfigure` |
| `workspace` / `TF_WORKSPACE` | Default Terraform project [workspace](https://developer.hashicorp.com/terraform/language/state/workspaces) | _none_ (do not use workspaces) |
| `apply-opts` / `TF_APPLY_OPTS` | Default Terraform extra [apply options](https://developer.hashicorp.com/terraform/cli/commands/apply) | _none_ |
| `destroy-opts` / `TF_DESTROY_OPTS` | Default Terraform extra [destroy options](https://developer.hashicorp.com/terraform/cli/commands/destroy) | _none_ |
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
    {
      "name": "TF_INIT_OPTS",
      "description": "Default Terraform extra [init options](https://developer.hashicorp.com/terraform/cli/commands/init)",
      "default": "-reconfigure",
      "advanced": true
    },
    {
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ spec:
      default: ''
    init-opts:
      description: Default Terraform extra [init options](https://developer.hashicorp.com/terraform/cli/commands/init)
      default: ''
      default: '-reconfigure'
    workspace:
      description: Default Terraform project [workspace](https://developer.hashicorp.com/terraform/language/state/workspaces)
      default: ''
@@ -806,7 +806,7 @@ stages:
    fi

    # shellcheck disable=SC2154,SC2086,SC2046
    terraform init -reconfigure $tf_backend_opts $(echo "$extra_opts" | envsubst_cli) $(echo "$opts" | envsubst_cli)
    terraform init $tf_backend_opts $(echo "$extra_opts" | envsubst_cli) $(echo "$opts" | envsubst_cli)
  }

  function tf_workspace_select() {