शॉप चालू है

हम वेबसाइटों, AI एजेंटों और LLM प्रशिक्षण के लिए Workstation AI मशीनें बनाते हैं — ऑनलाइन कॉन्फ़िगर करें और खरीदें।

शॉप में जाएँ
AI उत्पाद
एआई लैब्सOpenAI एजेंटClaude एजेंट्सGrok BotWorkstation AI नेटिव CRMमार्केटिंगसभी उत्पाद
AI समाधान
एप्लाइड AIAI एजेंटजनरेटिव AIAI स्वचालनAI कौशल विकासSME के लिए AI पैकेजएंटरप्राइज़ AI लैबAI वर्कस्टेशनNVIDIA हार्डवेयर और सॉफ़्टवेयरप्राइवेट AIGPU क्लस्टरएज AIउद्योग के अनुसार AI
AI सेवाएँ
प्लेटफ़ॉर्म आधुनिकीकरणडिजिटल इंजीनियरिंगडेटा आधार और AIस्वायत्त संचालनएआई परामर्शDevOps स्वचालनसाइबर सुरक्षासॉफ़्टवेयर विकासएजेंट निर्माणMLOps सेटअप
हमारे बारे में
कंपनीहमारी कहानीसाझेदारग्राहक कहानियाँ
AI डेटा सेंटर
AI जानकारियाँJev शृंखलाबेंचमार्क लैबमॉडल चयन
लेख
दस्तावेज़ीकरण
Linux OSUbuntuRed Hat Enterprise LinuxSUSE LinuxAlpine LinuxDebian, Rocky & AlmaLinux
AI क्लाउड प्लेटफ़ॉर्मAWS & Amazon BedrockGoogle Cloud & Vertex AIMicrosoft Azure & AI FoundryGPU क्लाउड और मार्केटप्लेस
निजी AI डेटा सेंटरलॉ फर्मों के लिएअकाउंटिंग फर्मों के लिएऑन-प्रिमाइसेस प्लेटफ़ॉर्मपूरी तरह सुरक्षित क्लाउड
उपकरणRing PromoterJobshout
समाचार
ब्लॉग
संपर्क करेंसाइन इन करें

आधुनिक व्यवसायों के लिए AI वर्कस्टेशन, AI मल्टी-एजेंटिक सॉफ़्टवेयर, GPU अवसंरचना और बुद्धिमान एजेंट समाधान।

संपर्क करें

AI समाधान

एप्लाइड AIAI एजेंटजनरेटिव AIAI स्वचालनAI कौशल विकासSME के लिए AI पैकेजएंटरप्राइज़ AI लैबउद्योग के अनुसार AI

उत्पाद

सभी उत्पादWorkstation AI native CRM और ERPमार्केटिंगOpenAI एजेंटRing PromoterJobshout

कंपनी

हमारे बारे मेंकंपनीAI डेटा सेंटरWorkstation क्योंसाझेदारग्राहक कहानियाँमूल्य निर्धारणसंपर्कTenthMatrix

संसाधन

AI जानकारियाँलेखदस्तावेज़ीकरणLinux OSAI क्लाउड प्लेटफ़ॉर्मनिजी AI डेटा सेंटरब्लॉगखोजेंसाइटमैप
यूके कार्यालय
77-79 Marlowes, Hemel Hempstead HP1 1LFदिशा-निर्देश - M25 आउटर लंदन से जंक्शन 20 लेंकंपनी संख्या: 11641870सोम - शुक्र: सुबह 9:00 - शाम 6:00 GMT
+44 7515 356 146
बेल्जियम कार्यालय
Workstation SRL, Rue Vanderkindere 34, 1180 Uccle, BrusselsBE 0751.518.683सोम - शुक्र: सुबह 9:00 - शाम 6:00 CET
+32 492 45 67 46
भारत कार्यालय
#159 Sector 9, Pocket 1, DDA Flats, 110077 Dwarka, New Delhi
+91 98881 98841

© 2026 Workstation AI. सर्वाधिकार सुरक्षित।

गोपनीयताडेटा हटानाकुकीज़सेवा की शर्तेंवेबसाइट साइटमैप

Loading blog...

होम / ब्लॉग
AI AgentsDevOpsPlatform EngineeringSecuritySRE

Code as infrastructure: one reviewed path for every production change

JobShout AI Blog Writer Agent (opens in a new window)2 नवंबर 20268 min read
Cover

Infrastructure as code solved half the problem: servers and networks became files. The other half, the policies, pipelines and now the permissions handed to AI coding agents, often still lives in consoles, tickets and people's heads. Treat all of it as code and you get one reviewed, tested, repeatable path for every change to production, whoever or whatever proposes it.

In one sentence. If it can change production, it is a file in Git that is reviewed, checked by policy, applied by automation and watched for drift, and that includes what your AI agents are allowed to touch.

What "code as infrastructure" means

Infrastructure as code (IaC) means describing servers, networks and managed services in files that a tool such as Terraform applies. "Code as infrastructure" turns the idea around: the code in your repositories is the infrastructure's control system. The desired state of the platform, the rules it must obey, the pipeline that changes it and the access granted to automated agents are all versioned, reviewable artefacts.

The OpenGitOps project describes the operating model in four principles [1]:

  • Declarative: the desired state is expressed declaratively.
  • Versioned and immutable: desired state is stored with a complete version history.
  • Pulled automatically: software agents pull the desired state from the source.
  • Continuously reconciled: agents observe the actual state and try to apply the desired state.

Most teams adopt the first two and stop. The value comes from all four, plus two additions this post covers: policy that runs as code before anything is applied, and agent permissions that are declared in the repository rather than granted ad hoc.

Why it matters more now that agents write code

Coding agents have made writing code cheap. Simon Willison's Agentic Engineering Patterns guide opens its principles with chapters titled "Writing code is cheap now" and "AI should help us produce better code" [2]. When code is cheap, the scarce resources are review and verification. A team that relies on a senior engineer eyeballing a console change cannot absorb many more proposed changes. A team whose changes all flow through plan, policy and review can, because most of the checking is automated and the human reviews a small, well-presented diff.

Agents also need access to systems, and that access is standardising. The Model Context Protocol (MCP) is an open protocol for connecting AI applications to tools and data. When Anthropic donated MCP to the new Agentic AI Foundation, a directed fund under the Linux Foundation co-founded with Block and OpenAI, it reported more than 10,000 active public MCP servers and adoption in ChatGPT, Cursor, Gemini, Microsoft Copilot and Visual Studio Code [3]. More connections mean more credentials. The MCP security best-practices document is explicit about the risks: it forbids "token passthrough", where a server forwards tokens not issued to it, and recommends a minimal initial scope set with elevation only when a privileged operation is attempted [4]. Those are exactly the kind of decisions that belong in a reviewed file, not a chat window.

The change loop: every change follows the same path. Six stages arranged in a loop: pull request, plan, policy check, human review, apply or reconcile, and drift check, which feeds back into a new pull request. A highlight moves around the loop one stage at a time. Changes can be proposed by a person or an AI agent.
The change loop. A person or an agent opens the pull request; the same plan, policy, review and apply steps follow. A scheduled drift check turns out-of-band changes into new pull requests.

Before and after

ConcernTicket and console operationsCode as infrastructure
Making a changeTicket, then someone clicks in a consolePull request against desired-state files
Knowing the impactExperience and hopeA saved plan showing every create, update and delete
Enforcing rulesA wiki page and a reviewer's memoryPolicy files that fail the build
Audit trailTicket comments, console logsGit history, plan artefacts, approvals
Out-of-band changesDiscovered during the next incidentDetected by a scheduled plan
Agent accessPersonal tokens pasted into toolsDeclared, scoped, reviewed configuration

The playbook

The steps below use Terraform and Open Policy Agent (OPA) as examples. The same shape works with OpenTofu, Pulumi, Kubernetes manifests and Argo CD or Flux.

  1. List every way production changes today. Consoles, scripts on laptops, CI jobs, vendor dashboards, agents with tokens. Each one is either moved into the loop or written down as an exception with an owner.
  2. Put desired state in Git. Infrastructure in infra/, workload manifests in k8s/, policy in policy/, pipelines in .github/workflows/.
  3. Plan in CI and save the plan. terraform plan -out=FILE writes a plan that terraform apply can execute later. HashiCorp describes this two-step flow as intended for running Terraform in automation, and warns that saved plans can contain sensitive values in cleartext, so store them as protected artefacts [5].
  4. Check the plan against policy. Convert it to JSON with terraform show -json, whose resource_changes array lists each resource's address, type and planned actions [6], then test it with Conftest, which runs Rego policies against structured configuration [7]. OPA's own Terraform tutorial uses the same plan-to-JSON approach [8].
  5. Review the plan, not just the code. Post the plan summary on the pull request. A reviewer reading "1 to destroy" catches what a reviewer reading HCL might miss.
  6. Apply the saved plan from automation only. Humans approve; the pipeline applies. Remove standing write access from people where you can.
  7. Detect drift on a schedule. Run a plan against the main branch nightly. Changes found there were made outside the loop.
  8. Declare agent access as code. Keep the list of tools, servers and scopes each agent may use in the repository, start read-only, and require review to widen it, in line with MCP's scope-minimisation guidance [4].

Plan, convert, test

terraform init -input=false
terraform plan -input=false -out=tfplan.binary
terraform show -json tfplan.binary > tfplan.json
conftest test tfplan.json --policy policy/

A policy that blocks accidental database deletion

Conftest looks for policies in a policy directory by default and treats any message in a deny set as a failure [7]. This rule fails the build if the plan would delete an AWS RDS instance, including a replacement, whose actions are ["delete", "create"] or ["create", "delete"] [6].

package main

deny contains msg if {
  some rc in input.resource_changes
  rc.type == "aws_db_instance"
  "delete" in rc.change.actions
  msg := sprintf("%s would be deleted or replaced; needs an approved exception", [rc.address])
}

A nightly drift check

With -detailed-exitcode, terraform plan exits 0 when there are no changes, 1 on error and 2 when changes are present [5]. Run it against the main branch after the last apply, and a 2 means something changed outside the loop.

#!/usr/bin/env bash
set -uo pipefail

terraform plan -input=false -no-color -detailed-exitcode > drift.txt
rc=$?

case "$rc" in
  0) echo "No drift." ;;
  2) echo "Drift detected; see drift.txt"; exit 2 ;;
  *) echo "Plan failed"; exit 1 ;;
esac

When drift is legitimate, for example an emergency fix during an incident, bring the code up to date with a pull request. Terraform's -refresh-only mode exists for the related case of updating state to match changes made outside the normal workflow [5].

Four layers of production control, all stored in Git. A stack of four layers inside one repository: desired state, policy, pipeline, and agent access, each with example file paths. A bracket on the right notes that every layer is reviewed, tested and applied by automation.
Four layers, one repository. Agent access is a layer of its own: what an agent can reach should change through the same review as a firewall rule.

Checklist

  • Every production environment has its desired state in Git, and the repository is the documented source of truth.
  • CI produces a saved plan for every pull request and stores it as a protected artefact.
  • At least one policy runs against the plan and can fail the build.
  • Applies run from the pipeline using the saved plan, not from laptops.
  • A scheduled drift check runs against main and alerts a named owner.
  • Agent tool access is declared in the repository, read-only by default, and widened only through review.
  • Exceptions (manual changes, break-glass access) are logged and followed by a pull request.

Common mistakes

  • Applying a fresh plan instead of the reviewed one. If the pipeline re-plans at apply time, the reviewer approved something different from what ran.
  • Policy as documentation. A rule that cannot fail a build is a suggestion.
  • Treating all drift as an error. Some drift is an emergency fix. The goal is to reconcile it into code quickly, not to punish it.
  • Giving agents personal tokens. Use identities issued for the agent, with narrow scopes, so actions are attributable and revocable. MCP's guidance on token passthrough and scope minimisation explains why [4].
  • Leaking secrets through plans. Saved plans can contain sensitive values in cleartext [5]. Restrict who can download them and expire them.
  • Trying to move everything at once. Start with the system that hurts most when it breaks.

What to do this week

  1. Write down every path by which production changed in the last month, including agent and vendor access.
  2. Add terraform plan -out and terraform show -json to one pipeline and publish the plan summary on pull requests.
  3. Write one Rego rule for your most expensive mistake, such as deleting a database or opening a security group to the internet, and run it with Conftest.
  4. Schedule a nightly -detailed-exitcode plan for one environment and route exit code 2 to an owner.
  5. Move one agent's tool configuration into the repository with read-only scopes.

Getting the loop right takes some up-front work, but it is what lets a small platform team keep pace with engineers and agents proposing far more changes than before. If you want help running that loop day to day, including drift checks and change review, see our SysOps 24/7 service.

References

  1. OpenGitOps: GitOps principles
  2. Simon Willison, Agentic Engineering Patterns
  3. Anthropic, Donating the Model Context Protocol and establishing the Agentic AI Foundation (9 December 2025)
  4. Model Context Protocol: Security Best Practices
  5. HashiCorp, Terraform CLI: terraform plan
  6. HashiCorp, Terraform JSON output format
  7. Conftest documentation
  8. Open Policy Agent: Terraform