maf-sandbox-terraform
Experimental. Releases before 1.0 may change or remove APIs. Importing this package emits
MafSandboxTerraformExperimentalWarning.
Validate Terraform or OpenTofu projects offline. Optional formatting tools return changed file contents for the model to save through host file tools.
Requires Python 3.12–3.14. The Python package does not include the Terraform or OpenTofu CLI.
pip install maf-sandbox-terraform
Attach the tools
from maf_sandbox_terraform import make_terraform_tools
tools = make_terraform_tools(
router,
file_store,
"infrastructure-agent",
context,
engine="terraform",
image="terraform-sandbox:local",
formatting=False,
)
The host supplies a router, file store and CallerContext. It chooses engine="terraform" or engine="opentofu" and a matching image. With no configured backend the factory returns [].
| Engine | Validation tool | Optional formatting tool |
|---|---|---|
| Terraform | terraform_validate |
terraform_format |
| OpenTofu | opentofu_validate |
opentofu_format |
The model supplies files: list[str] and root_module: str = ".". It cannot select CLI flags, an image or an engine.
Build images using the image guide. The usage guide provides runnable examples and dependency preparation.
Inputs
Supply a complete manifest of configuration files, local modules and referenced text assets. Every name must appear in the caller's listing. Completeness checks cover only files that the host exposes there.
Terraform accepts .tf and .tf.json. OpenTofu also accepts .tofu and .tofu.json, using its native precedence rules. The root must contain recognized configuration. Upload names cannot traverse with ..; valid relative module references inside files are preserved.
State, plans, variable-value files, CLI credentials, plugin binaries and reserved directories are refused. Inputs are text only, with limits of 64 files, 8 MiB per file and 32 MiB total.
Validation
The fixed launcher runs these commands without interaction or terminal color:
init -backend=false, using prepared modules and a filesystem provider mirror.validate -json, checking the verdict, diagnostic counts and exit status.fmt -check -recursive, reporting formatting separately.
A supplied root lock file is read-only during initialization. Without one, a generated lock exists only inside the disposable guest. No command writes back to the host store.
Initialization failure or malformed, inconsistent, truncated or oversized output means incomplete validation. Use the fixed completion and verdict to interpret a hidden report. Successful validation does not prove that a deployment will succeed.
Formatting
Set formatting=True to attach the separate formatting tool. It runs fmt -recursive -no-color without initialization or validation, so a base image without providers is sufficient.
The report maps store-relative paths to complete changed file contents. Unchanged files are omitted. Saving them is a separate host file-write call with the host's approval policy.
All changed files are returned together, or none are. CLI output and returned file bytes share a 128 KiB budget. The complete JSON report, including escaping and metadata, must also fit 128 KiB.
A timeout, formatter failure or overflow returns Formatting INCOMPLETE without partial text. Use a smaller complete manifest if possible. A single changed file over the limit cannot be returned. Hidden argument names also withhold file text and locations.
Execution and labels
The kind requires POSIX, EXEC, FILES_IN, at least container isolation, closed network access and a separate sandbox per call. Disposal is mandatory. There is no direct-download fallback for missing dependencies.
All phases share exec_timeout_seconds: 120 by default, finite and at most 600. Host execution adds five seconds for transport and cleanup. Cancellation waits for bounded execution before disposal.
Providers execute native code and may read other guest paths. Use a dedicated image without credentials, sensitive files or host mounts. This tool exposes no plan, apply, destroy, import or state operations.
Both tools use the SandboxResult contract. Core renders separate content items for completion, an optional verdict, fixed failure reasons, untrusted output and standing guidance. Validation exposes valid or invalid; formatting exposes changed or unchanged. An incomplete call reports completed=False and no verdict.
Completion, declared verdicts, fixed reasons and guidance remain readable while FIDES may hide engine reports, session exception details and formatted file contents. Formatting-check details within a validation report remain untrusted. The host supplies confidentiality and later-tool policy. See the kind guide for the complete contract.
Live validation covers Linux amd64 Docker images. ACAS and WSLC execution remain unverified. When the launcher changes, rebuild both base and prepared images; prepared-image receipts bind to its reader_sha256.
Release files for maf-sandbox-terraform 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| maf_sandbox_terraform-0.4.0.tar.gz | 12.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| maf_sandbox_terraform-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.3 kB
Release files / maf_sandbox_terraform-0.4.0.tar.gz
| Download URL | maf_sandbox_terraform-0.4.0.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bcc15a3539c8af24f8856ba3b2ff6a9a47f0455b45f549117469ba52db93f850
|
|
BLAKE2b-256 checksum How to use checksums |
d798e3067ac84a44c725758827aa529b8eb39d5515f238e9bf5d0c04d2824195
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / maf_sandbox_terraform-0.4.0-py3-none-any.whl
| Download URL | maf_sandbox_terraform-0.4.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c7486ab421b9424f613c4e6adb5ef027a862de5f5215d439098a0cb5a94bc92
|
|
BLAKE2b-256 checksum How to use checksums |
93d684da9684f2842a9797ee7fc348b37e0213d2f291172bcf52a192539075b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency log