<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adrian Taut on Medium]]></title>
        <description><![CDATA[Stories by Adrian Taut on Medium]]></description>
        <link>https://medium.com/@adriantaut?source=rss-22af1a2d0e33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gZwzxz86fhDFfoTZ1hat1Q.jpeg</url>
            <title>Stories by Adrian Taut on Medium</title>
            <link>https://medium.com/@adriantaut?source=rss-22af1a2d0e33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 12:58:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adriantaut/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an ECS Golden Path with Claude Code and AWS CDK]]></title>
            <link>https://medium.com/zar-engineering/building-an-ecs-golden-path-with-claude-code-and-aws-cdk-d4a580496801?source=rss-22af1a2d0e33------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4a580496801</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aws-cdk]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Adrian Taut]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 09:33:47 GMT</pubDate>
            <atom:updated>2026-01-20T09:33:47.325Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How AI-assisted infrastructure development requires a different mindset than typical application coding</em></p><p>At ZAR, we recently embarked on creating a <strong><em>Golden Path</em></strong> for ECS deployments: a set of opinionated, reusable AWS CDK constructs that encode our best practices for running containerized services. What made this project unique wasn’t just the technical challenge, but the approach. Pair-programming with Claude Code, Anthropic’s AI coding assistant, marked a departure from previous iterations on this theme.</p><p>This article shares our experience, the surprises we encountered, and why infrastructure-as-code presents unique challenges for AI-assisted development.</p><h4><strong>Our CDK Library: A Home for L3 Constructs</strong></h4><p>Before diving into the Golden Path, it’s worth explaining where these constructs live. We maintain an internal CDK library that serves as our repository for Layer 3 (L3) constructs.</p><p><strong>Why a dedicated library?<br></strong>AWS CDK provides three levels of constructs:</p><ul><li><strong>L1 (CloudFormation Resources)</strong>: Direct mappings to CloudFormation resources</li><li><strong>L2 (Curated Constructs)</strong>: AWS-provided abstractions with sensible defaults</li><li><strong>L3 (Patterns)</strong>: Opinionated, higher-level abstractions combining multiple resources</li></ul><p>L3 constructs encode organizational knowledge including our security policies, naming conventions, tagging standards, and operational patterns. Storing them in a versioned, shared library means:</p><ol><li><strong>Consistency</strong>: Every team uses the same patterns</li><li><strong>Governance</strong>: Security and compliance requirements are baked in</li><li><strong>Velocity</strong>: New services get production-ready infrastructure in minutes</li><li><strong>Evolution:</strong> Improvements benefit all consumers automatically</li></ol><p>Our library includes constructs for VPCs, Route53 Hosted Zones, shared ALBs, and now the ECS Golden Path.</p><h4><strong>What is a Golden Path?</strong></h4><p>A Golden Path (or “paved road”) is a pre-configured, opinionated way to accomplish a common task. For ECS, our Golden Path includes:</p><ul><li><strong>EcsFargateCluster</strong>: Creates ECS clusters with Container Insights V2, ECS Exec logging, and Fargate capacity providers</li><li><strong>EcsFargateTaskDefinition</strong>: Task definitions with automatic logging, KMS permissions for secrets, and init process handling</li><li><strong>EcsFargateService</strong>: Base Fargate service with auto-scaling and native Blue/Green deployment support</li><li><strong>SharedAlbEcsFargateService</strong>: ALB-fronted service extending EcsFargateService, adding DNS and health checks</li></ul><p>The goal? Allow teams to deploy a production-ready ECS service with ~20 lines of CDK code instead of 200+.</p><h4>How the Constructs Connect</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*WC0SUA-oH2JHKscSp5dLuQ.png" /></figure><p>Each layer builds on the one below, adding capabilities while hiding complexity. Teams can use <em>SharedAlbEcsFargateService</em> for most web services, or drop down to <em>EcsFargateService</em> for internal services without ALB exposure.</p><h3>The AI-Assisted Development Experience</h3><h4><strong>What Worked Well</strong></h4><p>Claude excelled at several aspects of CDK development:</p><p><strong>1. Boilerplate Generation</strong></p><p>CDK constructs involve significant boilerplate — interfaces, props validation, JSDoc comments, type exports. Claude generated these consistently and correctly.</p><pre>export interface EcsFargateTaskDefinitionProps extends EcsAppProps, VpcProps {<br>  /**<br>   * Container image to deploy.<br>   */<br>  readonly image: ecs.ContainerImage;<br><br>  /**<br>   * CPU units for the task.<br>   * @default 1024 (1 vCPU)<br>   */<br>  readonly cpu?: FargateCpuValue;<br>  // ... 20+ more props with defaults and documentation<br>}</pre><p><strong>2. Test-Driven Development</strong></p><p>We followed a TDD approach, and Claude proved adept at writing CDK assertions:</p><pre>it(&#39;should add KMS decrypt permission when secrets are provided&#39;, () =&gt; {<br>  const stack = new cdk.Stack();<br>  new EcsFargateTaskDefinition(stack, &#39;TaskDef&#39;, {<br>    appName: &#39;TestApp&#39;,<br>    deployEnvironment: &#39;staging&#39;,<br>    image: ecs.ContainerImage.fromRegistry(&#39;nginx&#39;),<br>    secrets: {<br>      DB_PASSWORD: ecs.Secret.fromSecretsManager(secret, &#39;password&#39;),<br>    },<br>  });<br><br>  Template.fromStack(stack).hasResourceProperties(&#39;AWS::IAM::Policy&#39;, {<br>    PolicyDocument: {<br>      Statement: Match.arrayWith([<br>        Match.objectLike({<br>          Action: &#39;kms:Decrypt&#39;,<br>          Effect: &#39;Allow&#39;,<br>        }),<br>      ]),<br>    },<br>  });<br>});</pre><p><strong>3. AWS CLI for Resource Comparison</strong></p><p>When migrating existing infrastructure to use our new constructs, Claude used AWS CLI commands to compare current vs. synthesized resources:</p><pre># Check current ECS cluster configuration<br>aws ecs describe-clusters --clusters ZarECSCluster<br><br># Compare with CDK synth output<br>cdk synth --quiet &amp;&amp; cat cdk.out/ZarCoreStack.template.json | jq &#39;.Resources | to_entries[] | select(.value.Type == &quot;AWS::ECS::Cluster&quot;)&#39;</pre><p>This was invaluable for ensuring migrations wouldn’t cause unexpected resource replacements.</p><h4><strong>The Hard Parts: Why Infrastructure is Different</strong></h4><p>Here’s where things got interesting. Writing infrastructure code with AI assistance is fundamentally different from application code, and we learned this the hard way.</p><p><strong>1. You Can’t Just “Rename Things”</strong></p><p>In a Rails app, renaming a class is a refactor. In CDK, renaming a Construct ID can be catastrophic:</p><pre>// Before<br>new ecs.Cluster(this, &#39;EcsFargateCluster&#39;, { ... });<br><br>// After - DANGER!<br>new ecs.Cluster(this, &#39;Cluster&#39;, { ... });</pre><p>This simple change causes CloudFormation to:</p><ol><li>Create a <em>NEW</em> cluster named differently</li><li>Delete the <em>OLD</em> cluster</li><li>Which deletes all services, tasks, and causes downtime</li></ol><p>Claude initially suggested these kinds of “cleanup” refactors. We had to explicitly establish rules: <strong><em>never rename Construct IDs for existing infrastructure without understanding the replacement implications</em></strong><em>.</em></p><p><strong>2. Testing Requires Real AWS Environments</strong></p><p>Unlike unit tests that run in milliseconds, validating ECS constructs requires:</p><ul><li>Actual <em>cdk deploy</em> operations (5–15 minutes)</li><li>Blue/Green deployments that fail at runtime, not during <em>cdk synth</em></li><li>Load balancer health checks that timeout</li><li>Secrets Manager permissions that only manifest at container startup</li></ul><p>We couldn’t just run <em>npm test</em> and ship. Every significant change required deployment to a staging environment.</p><p><strong>3. The Blast Radius is Different</strong></p><p>A bug in application code might affect one user’s request. A bug in infrastructure code can:</p><ul><li>Take down an entire service</li><li>Orphan resources costing money</li><li>Create security vulnerabilities across all environments</li><li>Cause data loss if databases are accidentally replaced</li></ul><p>This required a different review process. We had Claude generate <strong><em>cdk diff</em></strong> outputs and analyzed them carefully before any deployment.</p><p><strong>4. Native ECS Blue/Green Deployment Complexity</strong></p><p>We chose native ECS Blue/Green deployments over CodeDeploy-backed deployments for simplicity. But even “native” comes with complexity:</p><pre>deploymentController: {<br>  type: ecs.DeploymentControllerType.ECS,<br>},<br>circuitBreaker: { enable: true, rollback: true },</pre><p>Native ECS Blue/Green still has constraints:</p><ul><li>Deployment circuit breaker behavior affects rollback timing</li><li>Health check grace periods interact with deployment timeouts</li><li>Minimum/maximum healthy percent settings can cause deployment stalls</li><li>ALB target group draining impacts deployment speed</li></ul><p>Claude could write the code, but understanding the operational implications required human judgment and real-world testing.</p><h4><strong>Migration Strategy</strong></h4><p>Migrating existing infrastructure to Golden Path constructs required careful planning:</p><ol><li><strong>Inventory Current Resources</strong>: Used AWS CLI to document all existing resource names and configurations</li><li><strong>Match Logical IDs</strong>: Ensured our constructs generated the same CloudFormation logical IDs where resource replacement was not an option</li><li><strong>Use `cdk diff` Religiously</strong>: Every change was diffed before deployment</li><li><strong>Incremental Migration</strong>: Migrated one service at a time, not everything at once</li><li><strong>Keep Escape Hatches</strong>: Some legacy services needed to deviate from the Golden Path temporarily</li></ol><h3><strong>Codifying the Learnings: A Claude Code Skill</strong></h3><p>After encountering the “you can’t just rename things” problem multiple times, we decided to codify these learnings into a <strong><em>Claude Code Skill</em></strong> — a reusable set of instructions that guides Claude when working on CDK infrastructure migrations.</p><p>The skill lives in our CDK library at `.claude/skills/cdk-infrastructure-migration/` and includes:</p><pre>.claude/skills/cdk-development/<br>├── SKILL.md                    # Main skill with rules and patterns<br>└── references/<br>    └── migration-patterns.md   # Detailed migration scenarios</pre><h4><strong>What the skill covers:</strong></h4><ul><li><strong>Core Principles</strong>: Construct ID safety, resource naming best practices, the blast radius problem</li><li><strong>Pre-Deployment Validation</strong>: Multi-layer strategy with cdk-nag, synthesis checks, and AWS CLI comparison</li><li><strong>Migration Patterns</strong>: Migrating to L3 constructs, keeping logical IDs during refactoring, blue/green infrastructure</li><li><strong>Common Pitfalls</strong>: Renaming stacks, changing construct hierarchy, updating L3 libraries</li><li><strong>ECS-Specific Guidance</strong>: Native Blue/Green deployments, task definition changes, IAM role updates</li><li><strong>Checklists</strong>: Pre-deployment checklist, testing strategy</li></ul><h4><strong>Key rules encoded:</strong></h4><ul><li><strong>Construct IDs are sacred: </strong>Never rename without understanding CloudFormation implications</li><li><strong>Always run `cdk diff` first: </strong>Look for <em>replace</em> operations before deploying</li><li><strong>Compare with live resources: </strong>Use AWS CLI to verify expected vs. actual state</li><li><strong>Understand the blast radius: </strong>Infrastructure bugs affect entire services, not single requests</li></ul><p>The skill also includes a pre-deployment hook that warns before running <em>cdk deploy</em>:</p><pre>hooks:<br>  PreToolUse:<br>    - matcher: Bash(cdk deploy*)<br>      command: echo &quot;⚠️ STOP - Have you reviewed &#39;cdk diff&#39; output for resource replacements?&quot;</pre><p>This turns our hard-learned lessons into guardrails that protect future development sessions — whether with Claude or human developers following the same patterns.</p><h3><strong>Lessons Learned</strong></h3><ol><li><strong>Establish guardrails early</strong>: Create explicit rules about what AI can and cannot modify (Construct IDs, resource names, etc.)</li><li><strong>Always verify with real deployments</strong>: <em>npm test</em> passing means nothing if <em>cdk deploy</em> fails</li><li><strong>Leverage AI for documentation</strong>: Claude wrote excellent JSDoc comments and README content</li><li><strong>Have AI generate comparison commands</strong>: Using AWS CLI to verify expected vs. actual state</li><li><strong>Encode opinions, but allow escape hatches</strong>: Strong defaults, optional overrides</li><li><strong>Test with real services</strong>: Our test suite includes actual service deployments, not just unit tests</li><li><strong>Document the “why”</strong>: Every default should have a documented rationale</li><li><strong>Version carefully</strong>: Breaking changes in shared constructs affect all consumers</li></ol><h3><strong>Conclusion</strong></h3><p>Building ECS Golden Path constructs with Claude Code was productive — we shipped faster than we would have alone. But it also highlighted that infrastructure-as-code requires a fundamentally different approach to AI-assisted development.</p><p>The code runs in production, not in isolation. Mistakes aren’t caught by compilers or linters — they’re caught by failed deployments, downtime, or worse. AI can accelerate the journey, but humans must remain firmly in the driver’s seat for infrastructure decisions.</p><p>Our Golden Path is now in production, powering multiple services at ZAR. The constructs encode months of operational learning into reusable patterns.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4a580496801" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zar-engineering/building-an-ecs-golden-path-with-claude-code-and-aws-cdk-d4a580496801">Building an ECS Golden Path with Claude Code and AWS CDK</a> was originally published in <a href="https://medium.com/zar-engineering">ZAR Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>