Building an Air-Gapped AI Sandbox for Terraform Development

combining VS Code Remote-SSH, Claude Code, Ollama, TFLint, Checkov, and a read-only Azure DevOps mirror

AITERRAFORM

Jack Jalali

12/5/20264 min read

I wanted a development sandbox that could help with my production Terraform code without creating a second access route into production environment. This is practical use case for my earlier post.

The requirements were straightforward:

  • A graphical IDE.

  • An AI harness for AI-assisted development.

  • Inference using local models through Ollama.

  • Terraform formatting, validation, linting, and security scanning.

  • A way to synchronise with Azure DevOps without ever pushing back.

  • No production Azure credentials, production state files, or production deployments from the sandbox.

The finished environment is air-gapped during normal operation. However, I can temporarily enable outbound access for software installation, updates, and repository synchronization.

The hardware

The server is an HPE ProLiant DL380a Gen11 running Ubuntu 24.04.2 LTS, with:

  • Eight NVIDIA L4 GPUs.

  • 24 GB of VRAM per GPU.

  • Ollama already installed with several local models.

  • Enough capacity to experiment with coding models without sending repository contents to a hosted model.

The GPUs are only relevant to model inference. Terraform, TFLint, and Checkov are CPU-based tools.

The architecture

VS Code Remote-SSH was preferable to installing a full desktop on the server. The graphical IDE runs on my workstation, while files, extensions, Claude Code, Ollama, and the Terraform tools run on the server.

That gives me the GUI experience I wanted without adding a desktop environment or using the GPUs for display rendering.

Running Claude Code with local models

The important distinction is that Claude Code is the agent harness. It does not necessarily mean the inference is being performed by an Anthropic-hosted Claude model.

With Ollama’s Claude Code integration, I can start Claude Code using an exact model tag from ollama list:

For the VS Code extension and new Claude Code sessions, the relevant part of ~/.claude/settings.json is:

This means repository prompts and code context are processed by the local model. Using an actual Anthropic-hosted Claude model would be a different operating mode, requiring outbound connectivity and allowing relevant code context to leave the sandbox.

Keeping production Azure out of reach

The sandbox has deliberately been limited to static analysis and local development.

I do not copy these into the environment:

  • Production Terraform state or state backups.

  • Azure service-principal secrets.

  • Azure CLI access tokens.

  • Unreviewed variable files containing credentials.

  • Production .terraform working directories.

The normal commands are:

Synchronizing with Azure DevOps without pushing

The final requirement was to know whether the sandbox was behind Azure DevOps and, when necessary, pull the updates.

Because the initial code directory had been copied manually, a fresh clone was the safest option if its Git history or upstream configuration was uncertain.

For authentication, the preferred arrangement is:

  • A dedicated Azure DevOps identity with only repository Reader access.

  • A short-lived PAT restricted to Code (Read).

  • No PAT embedded in the repository URL.

  • No write-capable credential stored on the sandbox.

Inside the repository, I configured:

the resulting remotes looks like:

The read-only Azure DevOps permissions are the real security boundary. The local Git configuration prevents accidental pushes, but a process on the server could modify that configuration.

Checking whether production has moved

I fetch before inspecting the branch status:

The two numbers represent local-only commits and remote-only commits:

Output Meaning

0 0 Up to date

0 5 Five commits behind production

2 0 Two local-only commits2 5Diverged; stop and reconcile manually

Before updating, I can inspect the incoming production changes:

If the working tree is clean and the branch is behind:

git merge --ff-only @{upsteam}

My operating workflow

The complete workflow is now:

  • Open outbound access temporarily.

  • Fetch from Azure DevOps.

  • Review the incoming commits.

  • Fast-forward the pristine production baseline.

  • Close outbound access.

  • Create or update a separate sandbox development worktree.

  • Use Claude Code with the local Ollama model.

  • Run formatting, validation, TFLint, and Checkov against old and new code.

  • Compare introduced, resolved, and pre-existing findings.

  • Return approved changes through the normal production development process—not through a sandbox push.

The production baseline remains separate from my Claude Code working tree, so AI-assisted edits never contaminate the copy used to represent production.

Some real examples:

Final thoughts

The useful part of this project was not simply getting an AI assistant to edit Terraform.

It was creating clear boundaries around that assistant:

  • Local inference.

  • No production cloud credentials.

  • No production state.

  • No production apply.

  • Read-only source control.

  • Fast-forward-only synchronization.

The result is a sandbox that complements production development without quietly becoming another production access path.

Connect

Email

Follow
Stay up to date