BXUP Track progress & test yourself — free
Cloud & Solutions Architecture · Playbook · Core · ~4 min read
CLOUD & SOLUTIONS ARCHITECTURE · PLAYBOOK · CORE

IaC Skeletons from an Approved Design

The design is approved; now it must become Terraform someone can actually build on. AI drafts the module skeletons as the design-to-build handoff artifact — and nothing ships until the draft survives the validate→plan→policy→cost chain, because LLMs hallucinate resource types and attributes with total confidence.

Tier: Core · Hands-on time: ~30 minutes

Research on LLM-generated Terraform is blunt: models invent HCL resource types, misname attributes, and misremember provider schemas — code that looks idiomatic and fails terraform validate, or worse, validates and provisions something subtly different from the design. The architect's job here is not to write the modules (the platform team owns the build) but to hand over a skeleton that encodes the design's decisions — boundaries, naming, non-negotiable settings — with the failure modes already caught. The deterministic gate chain, not the architect's eyeball, is what decides the skeleton is sound.

When to use

  • An approved design (pb-06 winner, reviewed HLD) needs its first infrastructure expression for the build team.
  • You want the design's non-negotiables (encryption, network boundaries, tagging) encoded in code, not prose, at handoff.
  • A reference architecture (pb-09) needs translating into your org's module conventions.

Skip AI when your platform team has a module registry that covers the design — composing existing blessed modules by hand beats generating fresh code they will have to review harder.

Prerequisites

  • The approved designHLD, verified diagram (pb-07), and the ADRs recording key decisions.
  • Claude Code or Copilot in a repo primed with your org's conventions (an existing module as a style example is worth a page of instructions).
  • The gate chain installedterraform validate and terraform plan against a sandbox account; a policy scanner (Checkov-class); a cost estimator (Infracost-class). Category 05 owns operating this chain in CI; the architect must still run it before handoff.
  • Provider documentation openthe registry docs for every provider in play.

The workflow

  1. Extract the design's invariants first. Before generating, list what the code must encode because the design says so: network boundaries, encryption settings, region pinning, naming/tagging standards, the deny-by-default posture. These are the skeleton's reason to exist — a skeleton without invariants is scaffolding anyone could have generated.

  2. Generate module by module, not stack at once.

    Generate a Terraform module skeleton for the retrieval tier of
    orbit-docs-copilot, following the conventions in modules/example-service/.
    
    Design invariants (must be encoded, not commented):
    - All data resources in eu-central-1 only; no cross-region replication.
    - Postgres (with pgvector) reachable only from the app subnet; no
      public accessibility anywhere.
    - Encryption at rest with a customer-managed key passed in as a
      variable; encryption settings must not be defaulted.
    - Mandatory tags: service, env, data-classification, cost-center —
      as required variables, not literals.
    
    Rules:
    - Variables with types and descriptions; outputs for everything a
      consuming module needs; no hardcoded environment values.
    - Where you are not certain an attribute name is correct for the
      provider version, add a comment "# CHECK-DOCS" on that line
      rather than guessing silently.
    - Skeleton depth: resources, wiring, and invariants — not every
      optional attribute. The platform team owns completion.
    
  3. Run the chain, in order, and fix in conversation. terraform validate catches invented resource types and attribute names — expect it to catch some; that is the chain doing its job, not a reason to distrust the whole draft. Then terraform plan against the sandbox: read the plan output resource by resource — this is where "validates but provisions the wrong thing" surfaces (a publicly accessible database that validated fine). Paste errors back with scope: "fix only the failing attribute, change nothing else."

  4. Gate for policy, then cost. Checkov-class scanning catches the security defaults models love (open egress, unencrypted state, wildcard IAM). Infracost turns the plan into money — AI-drafted skeletons habitually over-provision (three NAT gateways where the design implies one, oversized instances "for safety"). Every policy finding is either fixed or documented as a deliberate exception; every cost line is sanity-checked against the design's cost model.

  5. Audit the invariants by hand. The chain proves the code is valid, compliant, and priced — not that it encodes your design. Walk the invariant list from step 1 against the final code: is region pinning enforced or defaulted? Could a consumer override the encryption key requirement? Is the database's network path actually restricted to the app subnet? This ten-minute read is the architect's signature on the handoff.

  6. Hand off with provenance. PR the skeleton with: the design links (HLD, ADRs), the chain results (validate/plan/policy/cost outputs), the CHECK-DOCS resolutions, and an explicit "skeleton, not production" label. The platform team receives a starting point whose failure modes are pre-caught and whose decisions are traceable — the handoff artifact the design phase owes the build phase.

Verify before you trust it

  • The chain ran clean, in order. validate → plan → policy → cost, outputs attached to the PR. A skeleton that skipped the plan step has not met reality yet, and "it validates" is the weakest possible claim about Terraform.
  • Every CHECK-DOCS comment is resolved against provider docs. The model flagged its own uncertainty; honoring that flag by reading the registry page is the cheapest verification in this track. Unresolved flags do not ship.
  • Plan output matches the diagram. Resources in the plan map to boxes in the verified pb-07 diagram — count them. Extra resources are model padding (delete or justify); missing ones are silent scope loss (the worse failure, because nothing errors).
  • Invariants are structural, not commentary. For each design invariant, try to violate it as a module consumer (override the variable, omit the tag). If the violation plans successfully, the invariant is a suggestion — push it into validation blocks or policy checks.

Restricted-environment variant

Skeletons for client estates encode client network topology and naming — MSA-governed material. Generate inside the boundary: Claude Code against the client-tenancy endpoint, or a local coding model via Ollama (HCL generation degrades gracefully on smaller models when the prompt carries a style example). The gate chain is fully offline-capable — validate, plan against the client's sandbox account, Checkov and Infracost run locally — so the verification story is identical in every environment. Never run terraform plan for a client stack from outside their approved credential path; the chain runs where the client's credentials legitimately live.

Key Takeaway:

The skeleton's value is the invariants it encodes and the chain it survived. AI writes HCL fast; validate→plan→policy→cost decides whether it is infrastructure or fiction.

This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in