tofu_test

Rules

tofu_test

load("@rules_terraform//tofu:tofu_test.bzl", "tofu_test")

tofu_test(name, env, env_inherit, root, workspace)

Runs tofu test on the root module's .tftest.hcl files as a Bazel test. Each run block is a JUnit test case in Bazel's XML report, and the lock and module manifest the test ran against are kept as undeclared test outputs. --test_arg is ignored.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
envEnvironment variables for the engine, set over the host's for a run and over the hermetic one for a test: TF_VAR_<name> for a root keyed on an input variable, TF_LOG, TF_CLI_ARGS_plan. Values are literal. TF_WORKSPACE here and workspace must agree.Dictionary: String -> Stringoptional{}
env_inheritVariables the test takes from the environment bazel test ran in, AWS_PROFILE say. The variables tests scrub for hermeticity (the CLI configuration ones) cannot be inherited, and the runner says so.List of stringsoptional[]
rootThe terraform_module target that serves as the root module.Labelrequired
workspaceRun in this Terraform workspace, over anything the environment or --test_env sets. Unset, the environment's TF_WORKSPACE applies, else default. One test per workspace is how a root keyed on terraform.workspace gets each one checked, and one binary per workspace runs it with no workspace select first.Stringoptional""