Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/terraform/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ tasks:
silent: true
internal: true
vars: &vars
ENV:
WORKSPACE:
sh: echo "{{.CLI_ARGS}}" | cut -d ' ' -f1 | xargs
TF_ARGS:
sh: echo "{{.CLI_ARGS}}" | cut -s -d ' ' -f2- | xargs
BACKEND_CONFIG_FILE:
sh: echo "{{.BACKEND_CONFIG_PATH}}/{{.ENV}}.backend.tf"
sh: echo "{{.BACKEND_CONFIG_PATH}}/{{.WORKSPACE}}.backend.tf"
TFVARS_FILE:
sh: echo "{{.TFVARS_PATH}}/{{.ENV}}.tfvars"
sh: echo "{{.TFVARS_PATH}}/{{.WORKSPACE}}.tfvars"

init:
desc: Initialize Terraform working directory with a backend configuration file.
Expand Down Expand Up @@ -56,6 +56,7 @@ tasks:
- sh: test -f {{.TFVARS_FILE}}
msg: "Variables file does not exist: {{.TFVARS_FILE}}"
cmds:
- terraform workspace select -or-create {{.WORKSPACE}}
- terraform plan -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}

apply:
Expand All @@ -73,6 +74,7 @@ tasks:
- sh: test -f {{.TFVARS_FILE}}
msg: "Variables file does not exist: {{.TFVARS_FILE}}"
cmds:
- terraform workspace select -or-create {{.WORKSPACE}}
- terraform apply -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}

refresh:
Expand All @@ -90,4 +92,5 @@ tasks:
- sh: test -f {{.TFVARS_FILE}}
msg: "Variables file does not exist: {{.TFVARS_FILE}}"
cmds:
- terraform workspace select -or-create {{.WORKSPACE}}
- terraform apply -refresh-only -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}