Skip to content

feat: support default workspace in tf plan/apply/refresh#49

Merged
oycyc merged 2 commits into
mainfrom
feat/tf-default-workspace-support
May 17, 2026
Merged

feat: support default workspace in tf plan/apply/refresh#49
oycyc merged 2 commits into
mainfrom
feat/tf-default-workspace-support

Conversation

@oycyc
Copy link
Copy Markdown
Contributor

@oycyc oycyc commented May 16, 2026

Summary

  • task tf:{plan,apply,refresh} with no args runs against the default workspace without -var-file; -- <env> preserves the named-workspace flow.
  • Motivation: with the backend role now split into READONLY/READWRITE (no default), task tf:* is the supported entry point and needs to handle default-workspace modules.
    • previously I could do tofu apply and it applies against the default workspace.
    • but now the backend role is REQUIRED, and Taskfiles determines it and sets it as env var
    • now I need to apply against default workspaces using Taskfiles (aka task t:tf:apply (default) vs task t:tf:apply -- prod)

PROOF OF VALIDATION

image

When no workspace argument is passed (e.g. `task tf:apply`), skip
`workspace select` and `-var-file` so default-workspace modules
relying on *.auto.tfvars work. Passing an environment arg
(`task tf:apply -- automation`) preserves the existing behavior.
A leading `-` is treated as a tofu/terraform flag, not a workspace,
so `task tf:apply -- -auto-approve` works against the default
workspace.

Motivation: previously, default-workspace modules could be applied
directly with `tofu apply` since the backend role had a default.
Now that the backend role is split into READONLY/READWRITE and must
be injected at init time, `task tf:*` is the supported entry point,
so it needs to handle default-workspace modules too.
@oycyc oycyc requested a review from a team as a code owner May 16, 2026 21:16
@oycyc oycyc requested a review from glaracuente May 16, 2026 21:16
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

This PR modifies lib/tf/Taskfile.yml to enhance flexibility in Terraform/OpenTofu task execution. The setup task variable TF_ARGS now intelligently parses CLI arguments—flags starting with - pass through as-is, while other arguments are treated as Terraform options. The tf:plan, tf:apply, and tf:refresh tasks were updated to support optional workspace usage: preconditions now allow missing tfvars files when no workspace is specified, and commands conditionally apply workspace selection and -var-file arguments only when a workspace is configured. This enables both default workspace workflows (without environment-specific tfvars) and explicit workspace-with-tfvars workflows from the same task definitions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • masterpointio/taskit#40: Both PRs modify Terraform/OpenTofu task definitions in lib/tf/Taskfile.yml by changing command templates and preconditions for tf:plan, tf:apply, and tf:refresh.
  • masterpointio/taskit#38: Both PRs update lib/tf/Taskfile.yml command templates for the same three Terraform tasks with different behavioral changes.
  • masterpointio/taskit#35: Both PRs modify Terraform task flows to improve workspace handling during plan/apply/refresh operations.

Suggested reviewers

  • gberenice
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding support for default workspace usage in Terraform task operations (plan/apply/refresh).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tf-default-workspace-support

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@oycyc oycyc merged commit 1b38f29 into main May 17, 2026
2 checks passed
@oycyc oycyc deleted the feat/tf-default-workspace-support branch May 17, 2026 14:51
oycyc pushed a commit that referenced this pull request May 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.6.0](v0.5.0...v0.6.0)
(2026-05-17)


### Features

* allow backend role arn to init (AIR-1495)
([#48](#48))
([80fb117](80fb117))
* support default workspace in tf plan/apply/refresh
([#49](#49))
([1b38f29](1b38f29))


### Bug Fixes

* pin GitHub Actions to commit SHAs (INT-326)
([#45](#45))
([953d140](953d140))

---
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.

2 participants