Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ includes:
aqua: lib/aqua
aws: lib/aws
components: lib/components
cursor: lib/cursor
mixins: lib/mixins
os: lib/os-modules
snaplet: lib/snaplet
terraform:
taskfile: lib/terraform
aliases: [tf]
tf:
taskfile: lib/tf
toolbox: lib/toolbox

tasks: {}
10 changes: 5 additions & 5 deletions aqua.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
registries:
- type: standard
ref: v4.78.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.433.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: go-task/task@v3.31.0
- name: TomWright/dasel@v2.4.1
- name: stedolan/jq@jq-1.7.1
- name: go-task/task@v3.45.4
- name: TomWright/dasel@v2.8.1
- name: stedolan/jq@jq-1.8.1
tags: [cursor]
- name: cli/cli@v2.74.2
- name: cli/cli@v2.83.0
tags: [gh]
16 changes: 9 additions & 7 deletions lib/terraform/Taskfile.yml → lib/tf/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ tasks:
sh: echo "{{.BACKEND_CONFIG_PATH}}/{{.WORKSPACE}}.backend.tf"
TFVARS_FILE:
sh: echo "{{.TFVARS_PATH}}/{{.WORKSPACE}}.tfvars"
TF_CMD:
sh: '[ "${USE_TERRAFORM}" = "true" ] && echo "terraform" || echo "tofu"'

init:
desc: Initialize Terraform working directory with a backend configuration file.
Expand All @@ -39,7 +41,7 @@ tasks:
- sh: test -f {{.BACKEND_CONFIG_FILE}}
msg: "Backend configuration file does not exist: {{.BACKEND_CONFIG_FILE}}"
cmds:
- terraform init -backend-config {{.BACKEND_CONFIG_FILE}} {{.TF_ARGS}}
- "{{.TF_CMD}} init -backend-config {{.BACKEND_CONFIG_FILE}} {{.TF_ARGS}}"

plan:
desc: Generate a Terraform execution plan Terraform loading variable values from the given file.
Expand All @@ -56,8 +58,8 @@ 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}}
- "{{.TF_CMD}} workspace select -or-create {{.WORKSPACE}}"
- "{{.TF_CMD}} plan -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}"

apply:
desc: Create or update infrastructure according to Terraform configuration files in the current directory.
Expand All @@ -74,8 +76,8 @@ 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}}
- "{{.TF_CMD}} workspace select -or-create {{.WORKSPACE}}"
- "{{.TF_CMD}} apply -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}"

refresh:
desc: Refresh the Terraform state to match the real-world infrastructure (safer via apply -refresh-only).
Expand All @@ -92,5 +94,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}}
- "{{.TF_CMD}} workspace select -or-create {{.WORKSPACE}}"
- "{{.TF_CMD}} apply -refresh-only -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}"