Skip to content

Conversation

@westonplatter
Copy link
Member

@westonplatter westonplatter commented Sep 22, 2025

what

  • Add terraform refresh in our task commands so it's similar to terraform [plan | apply]

why

  • There are situations where we need terraform refresh while migrating state from local to a remote backend.

references

Summary by CodeRabbit

  • New Features
    • Added a Terraform task to refresh state for a selected environment.
    • Uses environment-specific variables file and supports additional Terraform arguments.
    • Includes a pre-run check to ensure the variables file exists.
    • Behavior aligns with existing Terraform tasks for a consistent workflow.
    • Runs quietly in the current working directory to reduce noise.

@westonplatter westonplatter requested a review from a team as a code owner September 22, 2025 16:22
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

Walkthrough

A new task named refresh was added to lib/terraform/Taskfile.yml. It includes a description, multi-line summary, working directory set to {{.USER_WORKING_DIR}}, silent: true, and reuses shared vars via *vars. A precondition checks for the presence of {{.TFVARS_FILE}}. The command sequence runs: terraform refresh -var-file {{.TFVARS_FILE}} {{.TF_ARGS}}. The task mirrors the structure of existing Terraform tasks (init/plan/apply).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: add terraform refresh command" succinctly and accurately captures the primary change—adding a Terraform "refresh" Taskfile task—and aligns with the PR description and the changes to lib/terraform/Taskfile.yml; it is concise, specific, and uses a conventional commit-style prefix that makes the intent clear to reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/terraform-refresh-command

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/terraform/Taskfile.yml (1)

84-85: Fix usage/example typos (tofu → terraform; add task).

Copy/paste error: keep terminology consistent with other tasks.

Apply this minimal diff if you keep the refresh command:

-      Usage: task terraform:refresh -- ENVIRONMENT [tofu refresh arguments]
-      Example: terraform tofu:refresh -- automation
+      Usage: task terraform:refresh -- ENVIRONMENT [terraform refresh arguments]
+      Example: task terraform:refresh -- automation
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4300f54 and e449e3f.

📒 Files selected for processing (1)
  • lib/terraform/Taskfile.yml (1 hunks)

westonplatter and others added 2 commits September 22, 2025 13:28
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@oycyc oycyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but I believe this Taskfile in this repository is out of date. As part of this Taskfile automation, it should also select the workspace to take off the load from the user having to constantly switch tofu workspace select [abc]. See our mp-infra, I believe that accounts for it.

@westonplatter
Copy link
Member Author

@oycyc good. I'll merge this PR and then follow up with a different one to address the workspace part that you pointed out.

@westonplatter westonplatter merged commit 2bb2893 into main Oct 10, 2025
3 checks passed
@westonplatter westonplatter deleted the feat/terraform-refresh-command branch October 10, 2025 17:45
westonplatter pushed a commit that referenced this pull request Nov 11, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.5.0](v0.4.0...v0.5.0)
(2025-11-11)


### Features

* add linter configs to the os sync task
([#26](#26))
([6142651](6142651))
* add terraform refresh command
([#33](#33))
([2bb2893](2bb2893))
* add workspace selection
([#35](#35))
([ac8f80c](ac8f80c))
* **pruning:** remove cursor specific task commands.
([#37](#37))
([8c908c2](8c908c2))
* **tf:** default to tofu and allow switching back to terraform
([#38](#38))
([71d42fe](71d42fe))
* **tf:** update the tf:init command to work for TF dynamic backends
([#40](#40))
([0706965](0706965))


### Bug Fixes

* **aqua:** update installer version to pull in checksum fix
([#34](#34))
([b47b0ef](b47b0ef))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants