Preface: The Gap Between Working and Deployed
The Cloud AI Engineer — The Pramana Framework, Companion 10
By the end of Companion 9, the loop knew when to stop.
It ran on a session branch. It committed atomically. It verified against three signals. It opened a pull request when the goal was met, an issue when it was not. It had a trace. It had a cost budget. It had a human review gate before anything touched main. Arjun had scheduled the first nightly run, gone home, and found a clean pull request waiting for review at 9:15 in the morning.
The loop worked.
Running it on a laptop had been a prototype. Running it in GitHub Actions on a schedule was close to production. But the question that emerged the morning after the first successful nightly run was not whether the loop could terminate correctly. It was whether the infrastructure around the loop — the inference layer, the queue, the runtime, the permissions, the observability, the cost tracking — could hold under conditions the laptop had never faced.
The laptop did not have a timeout ceiling. AWS Lambda has fifteen seconds by default, or fifteen minutes if you configure it. The loop routinely ran for twenty-five.
The laptop did not throttle under load. Bedrock does. The Diwali sale would bring twelve hundred customer service queries in ninety minutes. The agent handling those queries ran inference on every one of them.
The laptop had one process, one region, one environment. The production system had three agent types, two regions, six MCP-connected backends, and an SQS queue that had never been stress-tested.
The laptop had Arjun watching it. Production, at 3 AM, had CloudWatch — or was supposed to.
This book is about the gap between a working agent and a deployed one.
The gap is not primarily about the agent code. The agent code from Companion 4 through Companion 9 runs correctly. The gap is about the infrastructure the agent runs inside: the inference service, the invocation model, the queue that manages load, the runtime that does not have a timeout ceiling, the IAM role that cannot do more than the agent should be trusted to do, the observability stack that ensures that when something fails at 3 AM there is a log entry to read in the morning, and the infrastructure-as-code that makes the entire system reproducible in a second region with a single command.
These are not agent problems. They are infrastructure problems with agent-specific requirements.
The senior agentic AI roles that filled the market in 2025 and 2026 were explicit about this: AWS experience was not a bonus. It was a requirement. Not because AWS is the only cloud, but because the failure modes of cloud-native agent deployment are specific, predictable, and teachable — and a candidate who has not encountered them in practice is a candidate who will encounter them in production, where the cost of learning is measured in customer impact and AWS bills.
Sanjaya understood this.
Sanjaya had been Draupadi's operations head through Book 4. He had built the audit trail infrastructure for the multi-tenant system — the DynamoDB table with three GSIs and an IAM Deny condition that made the audit log immutable even to the engineers who wrote to it. He had been the person in the room who wrote the fifth whiteboard problem in Book 4, the one about what the audit trail needed to record and in what form. His presence there was not as a narrator but as the person who had already built the system three times and knew what the second and third systems required that the first one never anticipated.
He had joined zUdyog as infrastructure lead two weeks before the Diwali sale. Draupadi had recommended him. The timing was not a coincidence.
The whiteboard in the Bengaluru office still had Book 4's problems in the upper corner — Sanjaya's handwriting in the fifth line, smaller and more precise than Krishna's. Chapter 1 adds five new lines. Sanjaya writes the fourth one himself, for the second time across the series. What he writes is about IAM. What he does not say, while writing it, is that he has already designed the solution.
Chapter 1 opens in the Bengaluru office, introduces the five infrastructure failures that structure this book — Lambda timeout, queue saturation, cost attribution loss, IAM over-permission, and the empty CloudWatch log — and examines AWS Bedrock as the inference layer: the model invocation API, the authentication difference from the Anthropic API, the token budget configuration, and the pricing model that changes how you think about context window discipline. Chapter 2 builds the Lambda-based event-driven agent — the deployment pattern for short-running agents, the timeout design principles, and the cases where Lambda is the right answer and the cases where it is not.
Chapter 3 addresses SQS as the queue that manages work: the asynchronous invocation pattern that decouples agent processing from request arrival, the dead-letter queue that handles failed messages, and the visibility timeout alignment that prevents the same message from being processed twice when an agent run exceeds expected duration. Chapter 4 moves to ECS Fargate — the deployment runtime for agents that cannot fit inside Lambda's ceiling: the autonomous coding loop from Companion 9, the containerised LangGraph runtime, and the auto-scaling policy that matches concurrency to queue depth.
Chapter 5 builds the IAM layer: tool-scoped execution roles, least-privilege policies for every backend the agents can reach, and the structural argument for why trust at the architecture level is not replaceable by trust at the guardrail level. Chapter 6 assembles the observability stack — structured JSON logging, custom CloudWatch metrics, X-Ray distributed traces, and the correlation between CloudWatch and LangSmith that makes agent decision auditing possible from both sides of the invocation boundary. Chapter 7 addresses cost management: per-agent attribution through resource tagging, per-session cost tracking, budget alarms, and the organisational discipline of knowing, to the quarter-rupee, what each agent type costs to run.
Chapter 8 puts the infrastructure into code with AWS CDK: the four stacks that deploy the complete system — inference, queue, agent runtime, observability — as version-controlled Python that reproduces in eu-west-1 with the same command it used for ap-south-1.
The final chapter assembles the full reference architecture and runs it under Diwali sale load: twelve hundred customer service queries in ninety minutes, six autonomous coding sessions running simultaneously on Fargate, Bedrock scaling to absorb the inference volume, SQS buffering the peak, IAM holding the permission boundaries, CloudWatch recording every invocation, and the CDK stack ready to deploy a second instance to the EU region in seventeen minutes.
There is a Pramana that is not only honest in development but observable in production — one that leaves a trace of every decision, charges only for what it used, respects the boundary of what it was permitted to access, and can be read by a human the morning after it ran.
Building that Pramana requires more than a correct agent. It requires the infrastructure the agent runs inside: the inference layer that scales, the queue that manages what the inference layer cannot absorb, the runtime that is sized to the work, the permission boundary that is structurally enforced, the observability stack that makes the night's activity legible in the morning, the cost tracking that makes the bill attributable to the decision that caused it, and the infrastructure code that makes the entire system reproducible rather than fragile.
The loop worked. The question was whether AWS could keep up.
This book is the answer.