AI IaC generation: where manual infrastructure breaks
At night, a cloud security rule is changed by hand from the console to clear an incident. In the morning it disappears: the next configuration apply returns the state from the declaration, and no one remembers why the edit was made.
This is configuration drift: live infrastructure diverges from the declared state, the discrepancy accumulates unnoticed, and surfaces at release.
Next is environment divergence. The test environment and production diverge in versions, labels, and network policies, and a defect reproducible in one is not caught in the other.
Manual infrastructure descriptions in the wiki become outdated the day after an edit — it is no longer possible to determine the source of truth.
Rollback turns into archaeology: you have to find out when the manifest changed, what changes were made bypassing the description, who has a local copy. This costs hours of downtime, and some edits still remain in the system.
AI IaC generation makes the infrastructure description the source artifact: intent is formulated in words, the output is verifiable Terraform modules, Ansible roles, and K8s manifests, and the actual state is automatically compared with them.
Drift is caught at validation, not at an incident. Below we break down how this works and what it delivers over the long term.
Measurable effects: what changes after moving to code-based description
Manual environment assembly relies on a sequence of steps that each engineer remembers differently.
While an environment is brought up "like last time," preparing the environment takes days, and the divergence between test and production environments surfaces at release.
Code-based infrastructure description removes this sequence: the environment is deployed from the declaration in full and identically on every run.
The first effect is environment preparation speed: a full environment for a task is brought up in tens of minutes instead of several days. The declaration is applied idempotently, so a repeated run does not break what is already configured.
The second is the share of manual edits: a change goes through a description file, validation, and history recording rather than through the console, so the share of changes made outside the declaration drops to single-digit percentages.
The third effect is the class of failures that disappears entirely. Configuration drift between environments and "it works in test but not in production" are no longer reproduced: both environments are assembled from one description.
Rollback comes down to reverting the previous description state — an operation of minutes, not memory-based recovery.
Release predictability rests on the fact that environment state is always derivable from code.
Before apply, the change is validated in the test environment: Terraform shows a plan before changes are made, and this plan is read at review — you can see which resources will be recreated and which will change in place. As a result, release no longer depends on who is on duty and is determined by repository contents.
Infrastructure generation formats: comparing approaches and modes
Configuration generation formats differ not by syntax but by source of truth: some modes rely on pre-written infrastructure templates, others on an already deployed environment.
This determines the output: a repeatable blueprint, a managed module, or a map of what actually runs in the environments.
| Option | When it fits | Limitations |
|---|---|---|
| Manual infrastructure templates | one or two similar environments, rare changes | environments diverge after the first manual edits; synchronization relies on agreements |
| Template library: Terraform modules | several environments and teams, repeatable service types | requires discipline for module versioning and interface backward compatibility |
| Parsing existing infrastructure | the environment already runs, there is no description or it is outdated | only what is captured in the inventory is transferred; resources created manually outside code remain outside the schema |
| Assembly from a service description | new projects and standard services | requires a formalized input; non-standard combinations still need engineer refinement |
How to choose a mode
Modes are not mutually exclusive: parsing existing infrastructure often becomes the first step, after which the environment is moved to Terraform modules and repeatable service descriptions.
It is reasonable to start with what gives control over current environments, not with the newest approach — otherwise the template will diverge from reality on the first edit.
Work order: from parsing the current schema to handing over regulations
Before the first generation, engineers capture the actual state of the environment: what is running, what manages it, which resources live outside declarative descriptions.
Without this reconciliation, the model reproduces an averaged schema, and the first plan apply diverges from reality.
- Resource inventory. We go through accounts and clusters, record nodes, load balancers, storage, DNS records and connections between them, and separately mark resources created manually.
- Schema and module breakdown. We lay out the environment by environments and owners, identify the common core and reusable Terraform blocks — networks, image registries, access roles.
- Setting up generation for your environment. We build naming conventions, labels, network policies, and limits into the setup so descriptions come out according to your rules, not abstract ones.
- Change plan validation. We deploy a copy of the environment, compare the plan with the inventory, and fix discrepancies before they reach production.
- Phased apply. We move resources in groups — first non-critical services, then core ones, with rollback points and state validation after each step.
- Pipeline control. We add style and security checks so every change passes automated control before merge.
- Handover of regulations. We hand over environment descriptions, schemas, access rules, and the expansion procedure, and train the team to make edits independently.
Deliverable set: module registry, environment schemas, regulations
The result of generation is not a one-off set of files but a repository from which the environment is reproduced repeatedly: descriptions are built for current Terraform branches and your image registry rules.
What exactly remains with the customer is listed below; each artifact is validated on a test environment and handed over with instructions on how to change it.
- Module registry. Blocks with input and output variables, default values, and type constraints — a new service is brought up by calling a module, not by copying someone else's code.
- Environment schemas. Separate parameter sets for development, pre-production, and production environments — one description yields predictably different configurations without manual edits.
- Access roles and secrets. Permissions are tied to groups, secrets are stored outside the repository and issued at deployment time — a description leak does not open access to the environment.
- Change regulation. Review rules, mandatory plan validation before apply, prohibition of manual edits in the environment — the divergence between description and fact is visible at validation, not after a failure.
- Infrastructure documentation. Resource map, dependencies between services, and failure points — a new engineer understands the environment from the document, not from colleagues' stories.
- Recovery description. Procedure for bringing up the environment from scratch, backup composition, and validated rollback steps — the environment returns to a working state in one run.
The set lives in your version control system: with edit history, reviewer comments, and the ability to roll back to the previous environment state.
How configuration drift decreased: implementation results before and after
The environment is distributed: several environments, dozens of nodes, three teams with access to the control panel.
Settings were edited by hand directly on live services — over a quarter, about 40% divergence accumulated between environments: test behaved differently from production, and a failure in the production environment could not be reproduced.
Recovery after a failure took up to four hours: the configuration was assembled from memory and screenshots.
What was changed
The infrastructure description was moved to Terraform — the repository became the single source of truth, and manual edits in the panel were closed off with a role model.
Existing resources were described from their current state, broken into modules, and the change plan was run across all three environments: discrepancies were cleaned up before apply, not after an incident. Pre-apply checks rejected edits that broke connections between services and the load balancer.
What became
The change plan in each environment shows zero unplanned edits — discrepancies stopped accumulating, and the test environment became a reproducible copy of production.
Recovering the environment from the repository takes 20 minutes instead of four hours; rollback is a return to the previous state in version control with confirmation, without manual investigation.
A new environment is brought up by copying modules rather than assembling from a list of steps, so the environment scales without growing the number of discrepancies.
How does the template approach differ from assembly from a service description?
These are not competing methods but two modes of one pipeline. A template is a proven framework of modules, roles, and base policies into which values are substituted.
Assembly from a description is when the entire surrounding infrastructure is deployed from a textual service description (application type, dependencies, traffic, storage): network, load balancing, secrets, permissions, observability.
| Approach | When it fits | Limitations |
|---|---|---|
| Template-based | standard services, repeatable environments, strict requirements for predictability | non-standard combinations are added manually; the template accumulates exceptions |
| Assembly from a description | a new service or stream of services, heterogeneous stack, frequent composition changes | requires infrastructure parsing at the input: without inventory, the description will be incomplete |
| Hybrid | most production environments | requires a regulation: what counts as a deviation and how it returns to the template |
Infrastructure parsing is needed where part of the configuration lives outside code: manual edits on servers, "temporary" exceptions in access rules, dependencies known to only one engineer.
Until this is captured, any generation will reproduce only the visible part and diverge from reality on the first change.
In practice, modes are combined: the framework holds the base — network, security, unified naming and tagging conventions — while generation covers the variable part.
Environments then differ by service description rather than by a set of manual refinements, and divergence between environments is visible at validation before apply, not after a failure.
Technical concerns: limitations, security, environment support
Configuration generation speeds up preparing an environment draft but does not replace engineering validation. The model does not know your constraints: network policies, audit requirements, provider quotas, and services that cannot be recreated.
Therefore, generated infrastructure descriptions in Terraform go through review in version control and a preliminary change plan before apply — discrepancies are visible before anything changes in production.
Part of the work remains manual, and this is a deliberate decision. Areas with a high cost of error — network zones, access roles, state migration — are written by the engineer, while we use generation for standard modules and repeating services.
We implement in phases: first one environment or one deployment, then expand without affecting already running resources.
What will have to be added manually after generation?
The draft covers the standard part: compute resources, networks, storage, base permissions. We add manually what depends on your context — non-standard policies, integrations with internal systems, regulator requirements. Each such place is marked with a comment and documented in the module documentation.
Will secrets end up in the generated code?
The descriptions contain only references to the secret store; values are substituted at apply time. Access is granted through roles with a limited term and an access log, and repository history is checked separately so keys do not settle in artifacts.
Who maintains the configurations after handover?
We hand over a set of modules, environment variables, the change regulation, and the rollback procedure — your team maintains them independently. If support is needed, we stay on for maintenance: provider updates, resolution of plan deviations, module refinement for new services.
Let's discuss the task: what to send and how we will return with an estimate and plan
To return with an estimate and work plan rather than general words, we need a minimum of inputs — usually enough to state the scope and timeline.
You can discuss the task in free form: describe what is currently described by code and what you would like to describe; we will clarify the rest on a call.
- which platforms and providers are in the environment: one cloud environment, several, or a hybrid with your own servers;
- current repositories with infrastructure descriptions and examples of changes still made manually;
- requirements for development, test, and production environments, and rules for promoting changes between them;
- security policies and access separation: who can change what, which checks are mandatory before apply;
- reference configurations that already work, and the criteria by which you consider a description correct;
- constraints: regulations, services that must be preserved, unacceptable downtime;
- access to the test environment or its equivalent — to validate generation on real descriptions, not demo ones.
We review what you send, compare it with the architecture, and return with an estimate and work plan: implementation options, composition of infrastructure description templates, environment schemas, change validation policies, phases, timelines, and checkpoints. If something is missing at the input, we will say directly what it can be replaced with.







