Pre-Beta Pre-beta signups are open now. The full audytx engine is live for pre-beta. Everything free today stays free — paid tiers arrive Sep 01, 2026 from $20/month for unlimited repositories.
Securing AI-generated Terraform · GitHub Copilot

Secure the Terraform GitHub Copilot writes

In our corpus study, agent-written AWS config landed on par with hand-written production modules. The gaps that remained were the cross-resource kind: rotation left unconfigured, escalation paths that only appear when you trace the trust graph. This guide wires audytx into Copilot's agent mode so those get caught before the pull request.

Claude Code → Cursor → GitHub Copilot
Why

Review it while the context is still loaded

The best moment to review agent-written Terraform is while the agent still has the change in its head. Copilot generates the resources, calls audytx, reads the findings, and repairs them before a diff exists. For that to work, the findings have to deserve Copilot's trust — a scanner that cries wolf sends the agent off "hardening" code that was fine. audytx checks every finding against the resource graph first and prints the reason whenever it suppresses one, so what's left is worth fixing.

48.3
findings / 100 resources in AI-generated Terraform — on par with production's 52.2
61%
of HIGH findings trace to one cross-resource gap: Secrets Manager rotation left unconfigured
85
false positives the context layer suppressed on that corpus, each with a rationale

Numbers from the audytx AI-generated Terraform study.

Setup

Two steps

  1. Add audytx to .vscode/mcp.json

    In VS Code, Copilot agent mode reads MCP servers from .vscode/mcp.json. Use a promptString input so VS Code asks for the Client ID once and stores it as a secret — it never sits in the file:

    .vscode/mcp.json
    {
      "inputs": [
        {
          "type": "promptString",
          "id": "audytx-client-id",
          "description": "audytx Client ID (from audytx.com/dashboard)",
          "password": true
        }
      ],
      "servers": {
        "audytx": {
          "type": "http",
          "url": "https://audytx.com/mcp",
          "headers": { "X-Client-ID": "${input:audytx-client-id}" }
        }
      }
    }

    Get the free Client ID first. On the next agent-mode session, Copilot picks up scan_terraform, autofix_terraform, scan_cloudformation, and the rest.

  2. Add repository custom instructions

    GitHub Copilot reads .github/copilot-instructions.md — a repository-wide instruction file that Copilot Chat, agent mode, and Copilot code review all honor. Put the standing scan policy there:

    .github/copilot-instructions.md
    ## Terraform security
    
    Before opening a pull request that changes .tf files, call the
    audytx scan_terraform tool on the full set of Terraform files in
    the repository — not only the diff, because cross-resource reasoning
    needs the unchanged files too. Fix every High and Critical finding and
    re-scan. Use autofix_terraform for the mechanical ones.

    Because .github/copilot-instructions.md is also read by Copilot code review on the pull request itself, the same policy reinforces the review even for changes an agent didn't write.

That's the integration. Next time Copilot writes Terraform in agent mode, it scans the whole tree, reads back findings with file:line evidence and remediation, and fixes the High and Critical ones before the PR.
What it catches

The gaps a single-file review can't see

Here's what tends to surface — the patterns our study found models ship by default:

And the suppressions that stop the agent chasing ghosts — a DLQ not asked to have its own DLQ, a role that reads privileged but can't escalate — each printed with its reasoning, so the call is visible rather than silent.

Also

Same engine on every other surface

The MCP loop is the pre-PR half. For the review, install the GitHub App — one comment per pull request, inline annotations, SARIF to GitHub Code Scanning — so anything the agent misses is caught on the PR alongside Copilot's own code review. Building CloudFormation? The same loop runs with scan_cloudformation, same rule ids and context.

FAQ

Common questions

Where does the Client ID live so it isn't committed?

The promptString input tells VS Code to prompt for the Client ID once and store it as a secret in your profile — the .vscode/mcp.json in the repo references it as ${input:audytx-client-id} and never contains the value.

Does the repository-instructions file affect Copilot on github.com too?

Yes. .github/copilot-instructions.md is honored by Copilot Chat, agent mode in the editor, and Copilot code review on pull requests. So the same scan policy nudges the review even for human-authored changes — though the audytx GitHub App is what actually posts the findings.

Does audytx store the Terraform Copilot sends it?

No. Files are parsed in memory and discarded when the response returns — the same posture as the GitHub App path. Only aggregate scan metadata is recorded, never file contents.

How is this different from Checkov or tfsec in the same repo?

Those are single-resource pattern matchers — they flag a resource for a missing attribute regardless of whether context makes it benign. audytx pre-computes relationship graphs and suppresses findings context proves harmless, with the rationale shown. For an agent, that precision is a clean fix loop instead of false-positive churn. See the benchmark comparison.

Open beta

Close the loop in your next Copilot session

Add the .vscode/mcp.json entry and the repository instructions, and let Copilot review its own Terraform — free during the beta.