← Back to gregblotzer.com

Infra-Agent

AWS Bedrock · CDK · Python · Lambda · GitHub Actions

A Bedrock-powered multi-agent system that takes a natural language infrastructure description or an architecture diagram and produces validated, security-scanned Terraform. Users submit either a text prompt or a diagram file and receive a validated HCL artifact, a configuration manifest with source tracking, and a generated runbook — all in S3.

The project is private but documented publicly. The architecture, ADRs, post-mortems, and runbook are referenced below.

Two agents run in AWS Bedrock supervisor mode. The orchestrator receives all requests and delegates to the infra-agent, then calls a GenerateDocs action group that reads the uploaded IaC from S3 and produces a runbook and configuration manifest. The infra-agent runs a ReAct loop across five action groups: GenerateIaC, ProcessDiagram, ValidateIaC, ScanIaC, and UploadIaC.

There are two input paths that produce identical outputs. The text path submits a natural language description directly to the orchestrator. The diagram path uploads a file to S3, where an upload_router Lambda detects the file type and routes it: draw.io and XML files go to an XML parser Lambda that produces a Normalized Intermediate Representation; PNG and JPG files go through a two-step pipeline of Rekognition label detection followed by a Bedrock Vision call. Either path injects a structured IR and manifest into the orchestrator message before any agent is invoked, then routes to the infra-agent's ProcessDiagram action group.

Both paths converge at the same validation and security scan: the infra-agent calls ValidateIaC (terraform validate and tflint) and ScanIaC (Checkov) before uploading. If validation fails, the error is passed back to GenerateIaC for a targeted fix and retried up to twice.

Preprocessing step vs. dedicated diagram agent

The diagram pipeline was built as a preprocessing step rather than a dedicated Bedrock agent. An S3-triggered Lambda parses the diagram and injects structured context into the orchestrator message before any agent is invoked. This keeps the agent count low and avoids the latency and cost of an additional agent hop for what is fundamentally a data transformation step. The conditions under which promoting the pipeline to a dedicated agent would be warranted are documented in ADR 001.

Gap resolver refuses to default security-sensitive parameters

When the diagram is missing required parameters — AMI IDs, passwords, access keys — the gap_resolver explicitly refuses to substitute defaults. Instead it surfaces them as required user inputs and returns a gaps_found response. This was a deliberate choice: silently substituting unsafe values would produce IaC that looks complete but carries hidden security assumptions. The agent fails loudly rather than quietly wrong.

Formal data contracts for IR and manifest

The Normalized Intermediate Representation and the configuration manifest are both defined as formal JSON schemas. Every parameter in the manifest records its source and any agent reasoning that produced it. This gives the generated IaC a verifiable provenance chain from diagram input to deployed resource.

GitHub Actions with OIDC authentication — no long-lived AWS credentials stored as secrets. Pull requests run unit tests, CDK synth, and Checkov static analysis. Pushes to main trigger a staged deploy: a draft deploy creates a new numbered version and a staging alias, integration tests run three end-to-end tests against that alias, and promotion updates the production alias only if all tests pass. If integration tests fail the production alias stays on the last good version with no rollback needed.

Unit tests mock all AWS clients via dependency injection, so the full test suite runs without an AWS account.

Bedrock guardrails block off-topic requests, prompt injection, profanity, PII, and harmful content. IAM policies are scoped to specific resource ARNs with no wildcard write permissions. S3 output buckets have public access blocked, SSE-S3 encryption, and versioning enabled. The CI deploy role trust policy is scoped to pushes from the main branch only. Pre-commit hooks enforce credential detection and Python style on every commit.

AWS Bedrock (Agents, Guardrails, supervisor mode, Rekognition, multi-model), CDK (Python), Lambda, GitHub Actions, S3, SSM, IAM (OIDC), CloudWatch, Docker, Checkov, tflint.

Two models in use: Claude Sonnet 4.5 for the infra-agent and orchestrator, Claude Sonnet 4.6 via cross-region inference profile for the PNG vision pipeline.

github.com/dablotz/infra-agent — README, ADRs, post-mortem, and runbook.