Skip to content

Conversation

@westonplatter
Copy link
Member

@westonplatter westonplatter commented Nov 11, 2025

what

  • We're modernized our TF backend strategy to use a single dynamic backend file.
  • Therefore, we can remove the backend file switching and simplify the tf:init command
  • Additionally, revised the task desc and summary attributes to highlight ability to use either Terraform or OpenTofu as a follow up to feat(tf): default to tofu and allow switching back to terraform #38

why

references

Summary by CodeRabbit

  • New Features

    • Added support for OpenTofu as an alternative tool to Terraform for infrastructure management, selectable via configuration.
  • Improvements

    • Simplified backend configuration handling by removing fixed backend-file requirements.
    • Introduced new public configuration variable for specifying custom Terraform variables path location.
    • Updated task naming conventions and descriptions to reflect dual tool support.

@westonplatter westonplatter requested a review from a team as a code owner November 11, 2025 17:09
Copy link
Member

@Gowiem Gowiem left a comment

Choose a reason for hiding this comment

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

Thanks Weston :shipit: !

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

This PR refactors the Terraform tasks in lib/tf/Taskfile.yml to support both Terraform and OpenTofu tools. It introduces a dynamic TF_CMD variable that switches between "terraform" and "tofu" based on the USE_TERRAFORM configuration setting. Backend file handling is generalized by removing BACKEND_CONFIG_FILE preconditions and replacing tool-specific commands with generic TF_CMD invocations across init, plan, apply, and refresh tasks. The refresh task implementation changes to use "apply -refresh-only" instead of the native refresh command. Task descriptions are updated to reflect dual-tool support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12-15 minutes

  • Verify the TF_CMD conditional logic correctly selects between "terraform" and "tofu" based on USE_TERRAFORM
  • Confirm the refresh task's transition from "refresh" command to "apply -refresh-only" is functionally equivalent and compatible with both tools
  • Ensure TFVARS_PATH variable is consistently applied across all affected tasks and maintains backward compatibility

Possibly related PRs

Suggested reviewers

  • gberenice
  • Gowiem
  • oycyc

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 accurately describes the main change: updating the tf:init command to support dynamic backends, which aligns with the PR's core objective of modernizing the backend strategy.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/update-tf-init

📜 Recent 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 71d42fe and 3e484ad.

📒 Files selected for processing (1)
  • lib/tf/Taskfile.yml (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-12T15:44:10.001Z
Learnt from: gberenice
Repo: masterpointio/terraform-users-groups-automation-googleworkspace PR: 1
File: examples/import-existing-org/imports.tf:7-7
Timestamp: 2025-05-12T15:44:10.001Z
Learning: In Terraform, local variables defined in one .tf file are available throughout all other .tf files in the same module directory, which allows for referencing locals across different files.

Applied to files:

  • lib/tf/Taskfile.yml
🔇 Additional comments (5)
lib/tf/Taskfile.yml (5)

12-27: Well-structured variable setup for dynamic tool selection.

The introduction of TF_CMD with sensible defaults and the TFVARS_PATH variable demonstrates clean abstraction. The shell conditional properly defaults to OpenTofu when USE_TERRAFORM is not explicitly set to "true", which is a safe and intuitive design.

Please verify that the USE_TERRAFORM environment variable is documented in the project's setup or environment configuration guide so users understand how to toggle between Terraform and OpenTofu.


30-40: Clean simplification of the init task.

The removal of backend file handling and the straightforward use of TF_CMD aligns well with the dynamic backend strategy. The descriptions clearly indicate dual-tool support, and the decision to not require a tfvars file for init is correct.


43-59: Plan task implementation is consistent and well-documented.

The precondition check for the tfvars file is appropriate, and the dual-tool support is clearly communicated. The command structure mirrors the intended pattern across all tasks.


62-78: Apply task refactor maintains consistency with plan task.

The structure and preconditions follow the same pattern as the plan task, which promotes maintainability. Descriptions clearly indicate dual-tool support.


81-97: Refresh task properly modernized to use apply -refresh-only.

The migration away from the deprecated terraform refresh command to apply -refresh-only is well-documented in the summary and correctly implemented. This change is forward-compatible and aligns with Terraform upstream recommendations.


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.

@westonplatter westonplatter merged commit 0706965 into main Nov 11, 2025
3 checks passed
@westonplatter westonplatter deleted the feat/update-tf-init branch November 11, 2025 17:11
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.

3 participants