Skip to content

Commit e449e3f

Browse files
feat: add terraform refresh command
1 parent 4300f54 commit e449e3f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

lib/terraform/Taskfile.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,20 @@ tasks:
7474
msg: "Variables file does not exist: {{.TFVARS_FILE}}"
7575
cmds:
7676
- terraform apply -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}
77+
78+
refresh:
79+
desc: Refresh the Terraform state to match the real-world infrastructure.
80+
summary: |
81+
Refreshes the Terraform state for a specified environment, using a file to load the variables.
82+
The `terraform refresh` arguments can be optionally passed in.
83+
Requires a variables file specific to the environment to be present.
84+
Usage: task terraform:refresh -- ENVIRONMENT [tofu refresh arguments]
85+
Example: terraform tofu:refresh -- automation
86+
dir: "{{.USER_WORKING_DIR}}"
87+
silent: true
88+
vars: *vars
89+
preconditions:
90+
- sh: test -f {{.TFVARS_FILE}}
91+
msg: "Variables file does not exist: {{.TFVARS_FILE}}"
92+
cmds:
93+
- terraform refresh -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}

0 commit comments

Comments
 (0)