Skip to main content

MCP-backed Terraform assistant with ephemeral-values compliance.

Project description

Terraform Guardrail MCP

Terraform Guardrail MCP is a Python-based MCP server + CLI + minimal web UI that helps AI assistants and platform teams generate valid Terraform code and enforce ephemeral-values compliance. It targets multi-cloud teams and focuses on reducing configuration drift, secret leakage, and invalid provider usage.

What it does

  • MCP server that exposes provider metadata and compliance checks
  • CLI for scanning Terraform configs and state for sensitive leaks
  • Minimal web UI for quick scans and reports
  • Rules engine focused on ephemeral values, write-only arguments, and secret hygiene

Architecture

flowchart LR
    subgraph Interfaces
        CLI[CLI]
        MCP[MCP Server]
        WEB[Web UI]
    end

    subgraph Core
        SCAN[Compliance Engine]
        GEN[Snippet Generator]
    end

    REG[Terraform Registry]
    TF[Terraform CLI]

    CLI --> SCAN
    WEB --> SCAN
    MCP --> SCAN
    MCP --> GEN
    SCAN --> TF
    GEN --> REG
    MCP --> REG
flowchart TB
    INPUTS[Inputs: .tf, .tfvars, .tfstate] --> PARSE[Parse & Normalize]
    PARSE --> RULES[Apply Rules TG001-TG005]
    RULES --> REPORT[Findings + Summary Report]
    REPORT --> OUTPUT[CLI JSON / UI Render / MCP Response]

MVP scope (v0.1)

  • Scan .tf and .tfvars for sensitive values and missing ephemeral = true
  • Scan .tfstate for leaked sensitive values
  • Provider metadata retrieval for AWS and Azure via Terraform Registry
  • MCP server with scan_terraform and get_provider_metadata tools
  • Minimal web UI for uploading a file and viewing the report

Quickstart

python -m venv .venv
source .venv/bin/activate
pip install -e "[dev]"

# CLI scan
terraform-guardrail scan examples

# snippet generation
terraform-guardrail generate aws aws_s3_bucket --name demo

# MCP server (stdio)
terraform-guardrail mcp

# Web UI
terraform-guardrail web

CLI examples

# scan a directory
terraform-guardrail scan ./examples --format json

# scan state files too
terraform-guardrail scan ./examples --state ./examples/sample.tfstate

# enable schema-aware validation (requires terraform CLI + initialized workspace)
terraform-guardrail scan ./examples --schema

Web UI

Visit http://127.0.0.1:8000 and upload a Terraform file to view a compliance report.

Streamlit App

streamlit run streamlit_app.py

Streamlit Cloud deployment

  1. Push this repo to GitHub.
  2. Create a new Streamlit Cloud app.
  3. Set the main file path to streamlit_app.py.
  4. Deploy (Streamlit will install from requirements.txt).

MCP tools (current)

  • scan_terraform: Run compliance checks over a path and optional state file.
  • get_provider_metadata: Fetch provider metadata from Terraform Registry (AWS + Azure).
  • generate_snippet: Generate Terraform snippets for common AWS/Azure resources.

Roadmap

  • Schema-aware code generation using provider schemas
  • fix command to apply safe rewrites for ephemeral values
  • Multi-environment policies and OPA-compatible output
  • Stack-aware orchestration and drift detection

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terraform_guardrail-0.2.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terraform_guardrail-0.2.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file terraform_guardrail-0.2.0.tar.gz.

File metadata

  • Download URL: terraform_guardrail-0.2.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for terraform_guardrail-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8112c98fbfa64e08e8eb91129e26bb47272820311e72659cbc5e313eab0a0257
MD5 08d873fb8cf646cf1de739a9d8ce4196
BLAKE2b-256 a8050a8d202ce707e81ea336e9d31f34fe4dabcf79b80a9f13ab95903ebd9c70

See more details on using hashes here.

File details

Details for the file terraform_guardrail-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for terraform_guardrail-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b87def28a28d88ea6081744776a45e094c8567d2400c3df4cd62b0666b2a478
MD5 7bcb88764836a04eb17f52871e7fe5cb
BLAKE2b-256 3578e99db98b3923a3c93d8d8bd00f05e7b0f8c32a6ae597b77366f668570d32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page