
Part 2: Hands-On with AWS Kiro, AgentCore, and Transform—Building the 2026 Agentic DevOps Stack
A practical, code-first tutorial breaking down how to write deterministic EARS specifications in AWS Kiro, manage persistent session state with Bedrock AgentCore, and execute structural AST code rewrites using ATX blueprints.
Our previous overview on the shift toward Spec-Driven Development (SDD) sparked an incredible conversation about moving past unreliable AI chat prompts. The consensus among cloud engineers was clear: production workflows require predictable, auditable outcomes rather than relying solely on conversational prompting.
In this follow-up tutorial, we bypass the high-level theory to build a practical reference implementation of the 2026 agentic DevOps stack.
Lab 1: Enforcing Deterministic System Specs with AWS Kiro
AWS Kiro shifts the developer's focus from writing loose chat prompts to writing structured specification files. It guides agentic actions using an immutable specification file organized via EARS (Easy Approach to Requirements Syntax).
At its core, EARS follows a simple requirement structure based on conditional lifecycles:
1
WHEN [Trigger Event] THE SYSTEM SHALL [Expected Result]
Step 1: Create the Project Specification File
Create a file named
requirements.md In your project root directory. This template illustrates how to map out a regional routing pipeline so an agent can parse it without drifting off track.1
2
3
4
5
6
7
8
9
10
11
12
# Module: Multi-Region Event Bridge Pipeline
## Functional Specifications (EARS Syntax)
### Rule 1: Payload Validation
* **Trigger & Action:** WHEN a new JSON payload arrives via the REST API, THE SYSTEM SHALL verify that the `version_id` field uses correct Semantic Versioning (e.g., 1.0.4).
* **Failure Exception:** WHEN the validation fails, THE SYSTEM SHALL block the request, log a warning to CloudWatch, and return an HTTP 422 error code.
### Rule 2: Compliance-Based Routing Boundaries
* **Trigger & Action:** WHEN the incoming payload's `origin_country` field equals 'EU', THE SYSTEM SHALL route the traffic exclusively to the `eu-west-1` region.
* **Trigger & Action:** WHEN the incoming payload's `origin_country` field equals 'US', THE SYSTEM SHALL route the traffic exclusively to the `us-east-1` region.
Use code with caution.Step 2: Designing a Governance Policy Hook
To prevent accidental deployment of overly permissive IAM profiles or misconfigured security groups, teams can hook agentic reviews directly into git development loops.
Disclaimer: The hook configuration below illustrates a possible governance pattern and may require adaptation to current Kiro capabilities and steering formats.
Create a reference file at
.kiro/hooks/pre-commit-guardrail.kiro.hook:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"hookVersion": "2026.1.0",
"meta": {
"name": "IAM Least-Privilege Verification",
"description": "Enforces strict security boundaries on newly written AWS infrastructure code."
},
"lifecycle": {
"stage": "pre-commit",
"trigger": "on-file-change",
"pattern": "**/*.tf|**/*.json|**/template.yaml"
},
"action": {
"type": "autonomousAgentScan",
"engine": "claude-3-5-sonnet-v2",
"parameters": {
"strictMode": true,
"maxAgentRetries": 3,
"steeringReferences": [
"#[[file:.kiro/steering/security-policy.md]]"
]
},
"instructions": "Scan modified infrastructure files. If a wildcard ('*') is detected inside an IAM 'Action' or 'Resource' block, block the commit. Propose a structural replacement using explicit resource names and permissions."
}
}
Use code with caution.Lab 2: Designing State-Saving Multi-Session Memory in Bedrock AgentCore
Early AI integrations suffered from context amnesia as soon as an execution thread completed, the state machine cleared. Amazon Bedrock AgentCore resolves this by separating execution context from long-term memory streams, allowing micro-agents to safely retain state across background workflows.
Disclaimer: The code below serves as a conceptual reference architecture demonstrating persistent memory patterns with the AgentCore runtime engine.

The Blueprint Implementation:
agentcore_runtime/app_agent.py1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import uuid
import json
from bedrock_agentcore.runtime import BedrockAgentCoreApp
from bedrock_agentcore.memory import PersistentMemoryBridge
from strands.agent import MicroAgent
# Initialize our conceptual AgentCore container application
app = BedrockAgentCoreApp(name="InventoryAutomationSystem")
# Hook up a serverless state storage abstraction layer
memory_bridge = PersistentMemoryBridge(
storage_provider="dynamodb",
table_name="AgentCoreMemoryState",
encryption_enabled=True
)
def handle_transaction(payload: dict) -> dict:
"""
Processes warehouse tasks while keeping memory intact across sessions.
"""
session_id = payload.get("sessionId", str(uuid.uuid4()))
user_query = payload.get("message")
# 1. Retrieve the historical data context from our database bridge
active_context = memory_bridge.load_context(session_id=session_id)
historical_traits = active_context.get_long_term_memory(key="user_preferences")
# 2. Initialize the agent shell, passing the long-term context traits
warehouse_agent = MicroAgent(
role="WarehouseAuditor",
backstory=f"You audit stock logs. Note these historical user habits: {historical_traits}",
deterministic_mode=True
)
# 3. Execute the operation within the isolated session wrapper
result = warehouse_agent.execute(prompt=user_query, context=active_context)
# 4. Extract any user parameters discovered dynamically during execution
newly_learned_facts = result.metadata.get("discovered_traits")
if newly_learned_facts:
active_context.append_long_term_memory(key="user_preferences", value=newly_learned_facts)
# 5. Flush state mutations back down to our persistent database layer
memory_bridge.save_context(session_id=session_id, context=active_context)
return {
"status": "SUCCESS",
"sessionId": session_id,
"agentReply": str(result.response)
}
Use code with caution.Deploying the Abstraction Layer
These deployment targets outline how an infrastructure-first multi-agent container service is pushed to cloud environments:
1
2
3
4
5
6
# Analyze your code configuration and set up target Fargate container files
agentcore configure --entrypoint app_agent.py --runtime container-fargate
# Build the stack and launch the active cloud runtime infrastructure
agentcore launch --stack-name OrderProcessorAgentStack --environment production
Use code with caution.Lab 3: Modernizing Monoliths with AWS Transform Custom (ATX)
When converting legacy backends (like old Java configurations) into serverless code, basic text regex find-and-replace fails to capture context. Modern modernization platforms leverage Abstract Syntax Tree (AST) transformations to parse code logic paths structurally and rewrite them into native cloud handles without breaking architecture rules.
Disclaimer: The blueprint blocks and commands mapped below serve as an illustrative reference model for structural codebase transformation layouts.

Step 1: Define the AST Rewrite Strategy
Create a blueprint named
atx_blueprints/modernization-blueprint.atx.yaml To demonstrate how legacy servlet nodes can be refactored into decoupled AWS Lambda handlers.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
version: "2026.4"
blueprintId: "servlet-to-lambda-native-rewrite"
engineSpec:
minAtxVersion: "1.2.0"
executionPipeline: "strict-ast-rewrite"
astMappingContext:
sourceRootNode: "javax.servlet.http.HttpServlet"
targetRootNode: "com.amazonaws.services.lambda.runtime.RequestHandler"
transformationRules:
- id: "rewrite-lifecycle-methods"
type: "MethodSignatureRestructuring"
targetNodeCriteria:
methodName: "doPost"
accessModifier: "public"
parameterTypes:
- "javax.servlet.http.HttpServletRequest"
- "javax.servlet.http.HttpServletResponse"
rewritePattern:
accessModifier: "public"
returnType: "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent"
methodName: "handleRequest"
parameterTypes:
- "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent"
- "com.amazonaws.services.lambda.runtime.Context"
- id: "inject-cloudwatch-logger"
type: "FieldInjection"
targetClassCriteria:
hasAnnotation: "org.springframework.stereotype.Component"
injectionPayload:
annotation: "@Autowired"
statement: "private com.amazonaws.services.lambda.runtime.LambdaLogger logger;"
Use code with caution.Step 2: Simulating the Transformation Campaign
The syntax below represents how a refactoring campaign targets codebases to resolve deep technical debt via terminal execution paths:
1
2
3
4
5
6
7
# Execute structural transformation strategy against target legacy codebases
atx custom def exec \
--project-path ./legacy-billing-service \
--strategy-blueprint ./atx_blueprints/modernization-blueprint.atx.yaml \
--execute-pipelines \
--auto-fix-compilation-errors
Use code with caution.Wrapping Up: Your Next Steps
By designing explicit specifications via Kiro, abstracting session states within AgentCore environments, and structuring legacy modernization workflows with AST blueprints, you transition AI workflows away from unpredictable assistants into highly governed engineering assets.
Moving past "vibe coding" isn't about writing less code—it's about creating deterministic, auditable software architectures that can safely execute autonomously inside complex enterprise settings.
The future of DevOps is not about replacing engineers with agents. It is about giving agents clear specifications, governed memory, and controlled transformation workflows so they can operate safely at enterprise scale.
Clone the Lab Repository
Want to explore these folder layouts, sample EARS requirements, and AST blueprint files in your own development workspace? I have built a structural template repository detailing the project files we explored in this lab.
👉 Clone the complete blueprint here: aws-agentic-devops-labs
Let's discuss in the comments below: Are you focusing on building local spec-driven guardrails first, or are you prioritizing cleaning up legacy systems on your team using AST blueprints?
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article