terraform_binary

Rules

terraform_binary

load("@rules_terraform//terraform:terraform_binary.bzl", "terraform_binary")

terraform_binary(name, env, root, workspace)

Runs terraform on a terraform_module root. Arguments pass through: bazel run //x:terraform -- plan, -- apply, -- state list. The engine runs in a temp copy of the built module directory, providers and modules already installed, so nothing is fetched at run time.

init is the exception: it installs that directory into the module's source directory and initializes the backend there, so the native CLI works in that directory afterwards.

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{}
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""