Terraform-compliance is a lightweight, security and compliance-focused BDD (Behavior Driven Development) test framework against Terraform. It enables negative testing capability for infrastructure-as-code, allowing teams to define and enforce policies against Terraform plans before deployment. It is an open-source tool that can be installed via pip or run via Docker. The library is currently at version 1.14.1 and sees frequent updates, often tied to supporting new Terraform CLI versions.
pip install terraform-complianceNo compatibility data collected yet for this library.
This quickstart demonstrates how to use `terraform-compliance` by defining a simple Terraform resource, generating a plan, converting it to JSON, writing a BDD feature file for compliance, and then running the compliance checks. Ensure you have Terraform CLI installed and your feature files adhere to Gherkin syntax.
Always check the `terraform-compliance` release notes for compatibility with your Terraform CLI version. Upgrade `terraform-compliance` to the latest version (`pip install --upgrade terraform-compliance`) when upgrading Terraform CLI.
Familiarize yourself with Gherkin syntax and BDD principles. Review the extensive examples provided in the `terraform-compliance` documentation and user-friendly-features repository for common patterns.
Ensure your Python environment is up-to-date or explicitly manage dependencies if you are on an older Python version. Using a virtual environment is highly recommended to isolate `terraform-compliance` dependencies.
After generating your binary plan (`terraform plan -out=myplan.out`), convert it to JSON using `terraform show -json myplan.out > myplan.json`. Then, pass the `myplan.json` file to `terraform-compliance` via the `-p` argument.
Verify the path to your feature files. Ensure the directory contains files ending with `.feature` and that the specified path is correct and accessible. If using a Git repository, ensure the URL is correct and includes a `git:` prefix.
Update `terraform-compliance` to its latest version using `pip install --upgrade terraform-compliance`. If the issue persists, consult the `terraform-compliance` GitHub releases or documentation for specific Terraform CLI version compatibility.
No dependency data recorded yet.