<?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 Jay Kumar  on Medium]]></title>
        <description><![CDATA[Stories by Jay Kumar  on Medium]]></description>
        <link>https://medium.com/@jay-kumar?source=rss-5d4bd2a7da19------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T69Z38HnNAWSR8KT72fRDg.png</url>
            <title>Stories by Jay Kumar  on Medium</title>
            <link>https://medium.com/@jay-kumar?source=rss-5d4bd2a7da19------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:02:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jay-kumar/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[One Forgotten File, 512,000 Lines Exposed: The Claude Code Leak]]></title>
            <link>https://jay-kumar.medium.com/one-forgotten-file-512-000-lines-exposed-the-claude-code-leak-5bf73f4b56bc?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bf73f4b56bc</guid>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 12:32:30 GMT</pubDate>
            <atom:updated>2026-04-01T12:32:30.870Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happened?</h3><p>So here’s the short version. On March 31, 2026, a researcher named Chaofan Shou stumbled onto something wild. Anthropic’s Claude Code, their popular AI coding assistant that runs in the terminal, had accidentally shipped its entire source code out into the open. No hack involved. No insider drama. Just a forgotten file sitting inside an npm package for anyone to grab.</p><p>The file in question was a roughly 60-megabyte source map called cli.js.map. It was bundled into version 2.1.88 of the @anthropic-ai/claude-code package on the npm registry. Shou posted about it on X (formerly Twitter) around 4:23 AM ET, and the post blew up almost instantly, eventually pulling in millions of views. Within hours, the roughly 512,000-line TypeScript codebase had been downloaded, copied to GitHub, and was being picked apart by thousands of curious developers.</p><p>Anthropic tried to pull the package and started issuing DMCA takedown notices, but by that point the horse had well and truly left the barn. Multiple GitHub repositories were hosting the code, with one accumulating tens of thousands of stars and forks within hours. A Korean developer even did a clean-room rewrite in Python that reportedly hit 50,000 GitHub stars in about two hours, making it one of the fastest-growing repositories in GitHub’s history. The internet had its copies, and there was no putting that genie back in the bottle.</p><p>And here’s the thing that makes this even more painful for Anthropic: this wasn’t the first time. A similar source map exposure reportedly happened back in early 2025, which Anthropic patched at the time. The same type of mistake, happening twice within roughly a year, is a tough look for a company that prides itself on being careful.</p><h3>Okay, But What Actually Is a Source Map?</h3><p>If you’re not a developer, this part is worth reading carefully because it’s the key to understanding the whole story. And I promise it’s not complicated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fHo0tPMiDR3Y1rKyJnXcmA.png" /></figure><p>When developers write code in languages like TypeScript, they can’t ship it directly to users. Browsers and tools like Node.js only understand JavaScript. So there’s a build step where TypeScript gets converted into JavaScript. And while they’re at it, the code also gets minified, which basically means all the nice formatting, spacing, and readable variable names get stripped away. Everything gets squished into as few characters as possible to make it smaller and faster.</p><p>The result runs great. But it looks like absolute gibberish to a human. If something breaks, the error message might say something like “line 1, column 48293” and you’d be staring at a wall of letters with no idea what went wrong.</p><p>That’s where source maps come in. A source map is basically a translation file. It’s a JSON file (ending in .map) that says “that mess at column 48293 actually corresponds to line 57 in your original file called auth-handler.ts.” It lets developers debug their nice, readable code even though the computer is actually running the compressed stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78M-DI8UtvYiV6MEajnLDA.png" /></figure><h3>So How Does a .map File Expose Source Code?</h3><p>There are two main ways a source map can reveal your original code.</p><p>The first is through a field called “sourcesContent.” When this is turned on, the .map file doesn’t just contain the mapping. It embeds the full text of every original source file right inside the JSON. Anyone who gets that file can reconstruct every line of original code.</p><p>The second way, which is what actually happened in the Claude Code case, is through references. The map file contained a reference that pointed to a zip archive hosted on Anthropic’s own Cloudflare R2 cloud storage. That zip contained the complete, unobfuscated source code. So the .map file was essentially a signpost saying “hey, the full source is right over here, come grab it.” And people did.</p><p>Here’s an analogy that might help. Imagine you shredded a confidential document and tossed it in a public dumpster. Sounds safe, right? But then you also threw in a note with an address that says “go to this location, there’s a complete unshredded copy in a box on the shelf.” That note is basically what the .map file did here.</p><h3>So How Did Anthropic Mess This Up?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ZqahDmItBh4eUF8XQcgdg.png" /></figure><p>Claude Code is built with TypeScript and uses Bun as its bundler. Now here’s the thing about Bun: it generates source maps by default unless you explicitly tell it to stop. During development, that’s great. You want those maps around for debugging.</p><p>The problem comes when you publish the package. When someone at Anthropic ran npm publish to push version 2.1.88 to the npm registry, that massive cli.js.map file tagged along for the ride. It was never supposed to be there.</p><p>How does something like that slip through? It boils down to how npm decides which files get included in a published package. There are basically a few ways to control this:</p><blockquote>The “files” field in package.json, which acts as a whitelist of what to include.</blockquote><blockquote>A .npmignore file, which acts as a blacklist of what to exclude.</blockquote><blockquote>If neither is set up properly, npm can end up including everything in the directory.</blockquote><p>So all it really takes is a missing *.map line in your .npmignore, or a files pattern that’s a bit too broad. One small oversight and your source maps ship to the world alongside your published package.</p><p>Anthropic confirmed this was what happened. Their official statement, shared with multiple news outlets including The Register and Axios, called it “a release packaging issue caused by human error, not a security breach.” They emphasized that no customer data or credentials were exposed. But the entire intellectual property behind one of their most successful products? Yeah, that was out there now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5LUoPdkN4VNKKml-qhJrSg.png" /></figure><h3>What Did People Find Inside?</h3><p>Once the code was out, developers dug in fast. And what they found was genuinely surprising. The reconstructed codebase had about 1,900 files and over 500,000 lines of code. This wasn’t some simple wrapper that calls an API. Claude Code turned out to be a deeply engineered system, almost like a mini operating system built specifically for AI-assisted coding.</p><p>Here are some of the more interesting discoveries.</p><h4>Animal Codenames for Models</h4><p>Anthropic uses animal-themed internal codenames for their models. “Capybara” maps to a Claude 4.6 variant, “Fennec” is the name for Opus 4.6, and there’s an unreleased model codenamed “Numbat” that’s still being tested. Internal comments showed Capybara was already on version 8, with developers noting it had a 29–30% false claims rate, which was actually a regression compared to an earlier version’s 16.7% rate.</p><h4>Undercover Mode</h4><p>This was probably the most talked-about finding. There’s a feature called “Undercover Mode,” roughly 90 lines of code, that strips any trace of Anthropic from commits and pull requests when Claude Code is used on external repositories. It tells the AI not to mention codenames, internal Slack channels, or even the words “Claude Code” in any public-facing output. The system prompt literally says: “You are operating UNDERCOVER… Do not blow your cover.” The implication is pretty clear: Anthropic employees use Claude Code when contributing to open-source projects, and the tool actively hides that an AI was involved. You can force it on with an environment variable, but there’s no way to force it off.</p><h4>A Three-Layer Memory System</h4><p>The code revealed a sophisticated memory architecture that goes way beyond simple chat history. There’s a lightweight index file called MEMORY.md that stays permanently loaded in context, then topic-specific files that get pulled in only when needed, and raw transcripts that are searched with grep-style lookups but never fully reloaded. The system also checks its memory against the actual code before taking action, which is designed to reduce mistakes and hallucinations during long coding sessions.</p><h4>A Whole Pipeline of Unreleased Features</h4><p>Buried in the code were references to features that haven’t been announced yet. Things like KAIROS, which appears to be an always-on background agent that watches your working environment and can act without being prompted. ULTRAPLAN, which offloads complex planning to a remote cloud session running Opus 4.6 with up to 30 minutes of dedicated thinking time. A “Buddy” companion that works like a Tamagotchi pet in your terminal, with 18 species, rarity tiers, and RPG stats like “DEBUGGING” and “SNARK.” And various multi-agent swarm capabilities for having multiple AI agents coordinate in parallel.</p><h4>A Frustration Detector</h4><p>This one made a lot of people chuckle. The code includes a regex pattern that scans for signs that the user is getting frustrated. It looks for certain words and expressions of annoyance. Presumably this is used to adjust how the AI responds when you’re having a rough time with your code. Hacker News users had a lot of fun noting just how extensive the list of flagged words was.</p><h3>What’s the Actual Impact?</h3><h4>A Major IP Loss</h4><p>According to VentureBeat, Anthropic is running at a reported $19 billion annualized revenue run rate, and Claude Code alone reportedly generates around $2.5 billion a year. So this leak wasn’t just embarrassing. It handed competitors a complete blueprint for how to build a production-grade AI coding agent. Permission systems, multi-agent orchestration, memory management, tool integration, the whole thing. Anthropic started sending DMCA takedown notices, but the code had already spread to decentralized platforms and countless forks that are much harder to take down.</p><h4>Real Security Risks</h4><p>Because the leak showed exactly how Claude Code handles hooks and MCP server connections, security researchers warned that bad actors could now build malicious repositories specifically designed to trick the tool into running unauthorized commands or leaking data. Making things worse, a separate supply-chain attack hit the axios npm package on the same day. According to multiple reports, anyone who installed or updated Claude Code via npm on March 31 between 00:21 and 03:29 UTC might have pulled in a compromised version of axios containing a remote access trojan. Security researchers urged affected users to rotate all credentials and consider full system reinstalls.</p><h4>A Gift to Competitors</h4><p>For other companies building AI coding tools, the leaked code is a goldmine. It doesn’t just show what Anthropic has built. It shows where they’re struggling. Internal error rates, architectural decisions they’re still debating, areas where the models underperform. That kind of insight into a competitor’s internal benchmarks is normally the stuff of dreams.</p><h4>The Developer Community’s Reaction</h4><p>Reactions online were mostly a mix of genuine admiration and a bit of cringing sympathy. A lot of people were impressed by the engineering quality and surprised at how much more sophisticated Claude Code is than anyone guessed from the outside. But there was also plenty of commentary about the irony of the whole thing. A tool built to help engineers write better code got taken down by a build configuration mistake. You can’t make this stuff up.</p><h3>What Should Developers Take Away From This?</h3><p>Whether you’re working alone on side projects or shipping code at a big company, this incident has some really practical lessons. None of them are complicated, which honestly makes the whole story hit even harder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_A9sFcY_5hj9_aVknbF7qg.png" /></figure><h4>1. Check what you’re actually publishing</h4><p>Before every npm publish, run npm pack — dry-run. It shows you the exact list of files that will end up in the package. If you see a huge .map file in there, that’s your cue to stop and fix things. Better yet, make this a required check in your CI pipeline so no human has to remember to do it.</p><h4>2. Treat source maps like source code</h4><p>Whether your .map files have embedded sourcesContent or references pointing to your original files, those maps can expose your entire codebase. Treat them with the same care you’d give the source code itself. Don’t let them anywhere near a published package unless you’re doing it on purpose.</p><h4>3. Be explicit about what gets included and excluded</h4><p>Don’t trust defaults. Add *.map to your .npmignore file. Even better, use a strict “files” whitelist in package.json that only lists the specific files your users actually need. If you’re feeling thorough, do both.</p><h4>4. Turn off source maps in production builds</h4><p>If your product is closed source, just don’t generate source maps for production builds in the first place. With Bun, source maps are on by default, so you have to actively opt out. Check your bundler’s documentation for how to do this. It takes about 30 seconds.</p><h4>5. Build systems that catch mistakes, not memos that remind people</h4><p>People make mistakes. That’s just how it is. The solution isn’t writing a wiki page that says “remember to exclude .map files.” The solution is adding a CI step that automatically fails the build if a .map file shows up in the publish set. Automate the guardrails. That’s the only way they actually work consistently, especially when teams are shipping fast under pressure.</p><h3>The Irony of It All</h3><p>Here’s what really gets me about this story. Anthropic had actually built a whole internal system called “Undercover Mode” whose entire purpose was to prevent internal information from leaking out through AI-generated commits. They clearly thought about information security. They invested real engineering time into it.</p><p>And then the entire source code just… walked out the front door. Through a misconfigured build pipeline. Because somebody forgot to exclude .map files from the npm package. For the second time in a little over a year.</p><p>It’s a perfect reminder that security doesn’t have a single front door you can guard. It’s more like a house with a hundred windows, and you need to check every single one. You can build the fanciest lock in the world for the main entrance, but if the kitchen window is open, none of that matters.</p><p>For what it’s worth though, the developer community’s takeaway wasn’t all negative. A lot of people came away genuinely impressed by the quality of what Anthropic built. The code showed real depth, real creativity, and real craft. The architecture, the tooling, the clever solutions to genuinely hard problems. It’s all there, and it paints a picture of a team that really cares about what they’re building.</p><p>Sometimes the best lessons come from the most unexpected places. And if a 60MB .map file can teach the entire industry to double-check their npm publish pipeline, well, maybe that’s a silver lining worth something.</p><blockquote><strong>Disclaimer: </strong><em>This article is written for educational purposes. All code referenced remains the intellectual property of Anthropic. The analysis is based solely on publicly reported information from major news outlets and security researchers.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bf73f4b56bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI That Breaks AWS Infrastructure on Purpose, Then Tells You Exactly What to Fix]]></title>
            <link>https://jay-kumar.medium.com/ai-that-breaks-aws-infrastructure-on-purpose-then-tells-you-exactly-what-to-fix-e4e3403fd188?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e3403fd188</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[chaos-engineering]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 08:27:05 GMT</pubDate>
            <atom:updated>2026-04-01T08:27:05.754Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How to build a Chaos Monkey–style resilience framework on AWS, complete with AI-powered analysis, autonomous agents via Bedrock AgentCore, and self-healing infrastructure that fixes itself before you even wake up.</em></p><h3><strong>The Uncomfortable Truth About Production</strong></h3><p>Here’s something most teams won’t admit in a sprint retro: <strong>they have no idea how their system behaves when something breaks.</strong> Sure, the load balancer is configured. The auto-scaling group has a policy. CloudWatch alarms exist. But has anyone actually killed a production EC2 instance at 2 PM on a Tuesday to see what happens?</p><p>That’s what Chaos Engineering is about. Netflix famously built <strong>Chaos Monkey</strong> back in 2011 to randomly terminate instances in production. The logic was beautifully simple. If your architecture can’t survive a dead server, better to find out now than during a Black Friday traffic spike.</p><p>The good news? AWS now gives us native tools to do this properly. And in 2025–2026, the game has shifted dramatically. We’re not just breaking things anymore. We’re using <strong>AI agents that plan which things to break, observe the fallout, and autonomously fix what they find.</strong> That’s the leap from Chaos Monkey to what I’d call Chaos Agent.</p><blockquote><strong>What We’re Building</strong></blockquote><blockquote><em>A fully automated chaos experiment framework using AWS FIS, Step Functions, Lambda, CloudWatch, Bedrock, AgentCore, and SNS. AI agents plan experiments, analyze blast radius, generate resilience reports, and optionally self-heal infrastructure with bounded, policy-controlled autonomy.</em></blockquote><h3>A Unique Perspective: Why Most Chaos Engineering Fails</h3><p>Let me say something that might be unpopular: <strong>most chaos engineering implementations are theater.</strong> Teams set up FIS, run an experiment once during a quarterly “game day,” write a postmortem nobody reads, and call it done. That’s not chaos engineering. That’s a checkbox.</p><p>The fundamental problem is the <strong>observe-and-act gap</strong>. Traditional chaos gives you data (metrics, logs, alarms) but leaves the hardest part entirely to humans: interpreting that data and taking action. And humans are busy. They’re shipping features, fighting fires, and attending standups. The chaos report sits in a Confluence page gathering dust.</p><p>What if we closed that gap? What if the system that broke things could also understand the damage, prioritize the fixes, and even apply some of them autonomously? That’s not science fiction. With Amazon Bedrock AgentCore, it’s a pattern you can start building today.</p><h3>The Three Generations of Chaos Engineering</h3><p><strong>Generation 1, Chaos Monkey (2011–2020): </strong>Random instance termination. Binary outcome: did the system survive, yes or no? Manual observation. Great for proving a point to leadership, but limited in scope and learning.</p><p><strong>Generation 2, Managed Chaos (2020–2024): </strong>AWS FIS, Gremlin, LitmusChaos. Structured experiments with stop conditions and blast radius control. Better safety, richer fault types (network, API throttling, AZ failures). But still human-driven analysis and remediation.</p><p><strong>Generation 3, Agentic Chaos (2025+): </strong>AI agents that plan experiments based on system topology and historical gaps, execute them with safety guardrails, observe the fallout at near real-time cadence, generate actionable reports, and trigger bounded self-healing runbooks. This is where Bedrock AgentCore enters the picture.</p><blockquote><strong>The Key Insight</strong></blockquote><blockquote>The real value of chaos engineering isn’t in breaking things. It’s in what happens after things break. If that “after” is a Slack message that nobody reads, you’ve wasted everyone’s time. The goal is to close the loop: break, observe, understand, fix. AI agents close the loop.</blockquote><h3>The Architecture: A Bird’s-Eye View</h3><p>The system has three phases: <strong>Inject</strong>, <strong>Observe</strong>, and <strong>Analyze + Heal</strong>. Here’s how each phase maps to AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEq9kI-_v-ZkTPFmHraRCw.png" /></figure><p><strong>Phase 1, Inject: </strong>EventBridge triggers a Step Functions state machine on a cron schedule. The first Lambda step checks the SSM kill-switch, then starts an AWS FIS experiment targeting tagged EC2/ECS resources. The state machine enters a wait loop (polling FIS status every 30 seconds) that can run comfortably for as long as the experiment needs to finish.</p><p><strong>Phase 2, Observe: </strong>CloudWatch captures metrics (5xx errors, latency, healthy host count, CPU) and application logs during the chaos window. Note that standard CloudWatch metrics have a 1–5 minute reporting delay for most services, so for short experiments the anomaly data may arrive after the fault is already resolved. For tighter feedback loops, push custom metrics via the CloudWatch embedded metric format or use OpenTelemetry with shorter flush intervals.</p><p><strong>Phase 3, Analyze + Heal: </strong>Once FIS completes, Step Functions invokes the analysis Lambda, which pulls all metrics and logs, sends them to Amazon Bedrock for AI analysis, stores the resilience scorecard in DynamoDB, and pushes the report to Slack via SNS. If the AgentCore-based Healer Agent is enabled, it can take bounded remediation actions like scaling out an ASG, restarting unhealthy ECS tasks, or creating incident tickets.</p><h3>What Each Service Does (and Why It’s Here)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67nOSqM8fdFFoWDFAYw0vQ.png" /></figure><h3>Step 1: Define the Experiment with AWS FIS</h3><p>AWS Fault Injection Simulator is essentially Chaos Monkey as a managed service. You define an <strong>experiment template</strong> that says “here’s what I want to break, here’s who I want to break it for, and here’s when to stop.”</p><p><em>fis-experiment-template.json</em></p><pre>{<br>  &quot;description&quot;: &quot;Chaos Monkey: Kill random EC2 in ASG&quot;,<br>  &quot;targets&quot;: {<br>    &quot;myInstances&quot;: {<br>      &quot;resourceType&quot;: &quot;aws:ec2:instance&quot;,<br>      &quot;resourceTags&quot;: { &quot;ChaosTarget&quot;: &quot;true&quot; },<br>      &quot;selectionMode&quot;: &quot;COUNT(1)&quot;,<br>      &quot;filters&quot;: [{<br>        &quot;path&quot;: &quot;State.Name&quot;,<br>        &quot;values&quot;: [&quot;running&quot;]<br>      }]<br>    }<br>  },<br>  &quot;actions&quot;: {<br>    &quot;terminateInstance&quot;: {<br>      &quot;actionId&quot;: &quot;aws:ec2:terminate-instances&quot;,<br>      &quot;targets&quot;: { &quot;Instances&quot;: &quot;myInstances&quot; }<br>    }<br>  },<br>  &quot;stopConditions&quot;: [{<br>    &quot;source&quot;: &quot;aws:cloudwatch:alarm&quot;,<br>    &quot;value&quot;: &quot;arn:aws:cloudwatch:...:alarm:HighErrorRate&quot;<br>  }],<br>  &quot;roleArn&quot;: &quot;arn:aws:iam::...:role/FISChaosRole&quot;<br>}</pre><p>The selectionMode: &quot;COUNT(1)&quot; means it only kills one instance at a time. The stopConditions block is your safety net: if the HighErrorRate alarm triggers, FIS automatically aborts. Non-negotiable.</p><blockquote><strong>Pro Tip:</strong> Tag your chaos-eligible resources with ChaosTarget: true. Gradually opt services into chaos experiments instead of going full &quot;burn it all down&quot; on day one. Start with stateless services behind a load balancer.</blockquote><h3>Step 2: Schedule It with EventBridge</h3><p>The whole point of Chaos Monkey is that it runs <strong>regularly and without warning</strong>. EventBridge lets us set up a cron schedule:</p><p><em>eventbridge-rule.yaml</em></p><pre>ChaosScheduleRule:<br>  Type: AWS::Events::Rule<br>  Properties:<br>    Name: chaos-monkey-schedule<br>    Description: &gt;-<br>      Fires 7 times per weekday (10:00, 11:00, ..., 16:00 UTC).<br>      Each trigger starts one chaos experiment run.<br>    ScheduleExpression: &quot;cron(0 10-16 ? * MON-FRI *)&quot;<br>    State: ENABLED<br>    Targets:<br>      - Arn: !GetAtt ChaosStateMachine.Arn<br>        Id: chaos-trigger<br>        RoleArn: !GetAtt EventBridgeSfnRole.Arn</pre><p>This fires 7 times per weekday (once every hour from 10:00 through 16:00 UTC). We run it during business hours on purpose. The team is awake, alert, and ready to observe. Running chaos at 3 AM doesn’t test your system. It tests how fast your on-call can reach their laptop.</p><h3>Step 3: The Orchestrator (Step Functions)</h3><p>Step Functions is purpose-built for this kind of async, multi-step workflow. Each step is a short Lambda invocation, and Step Functions handles the waiting between them. The state machine loops through a Wait and CheckStatus cycle until FIS reports a terminal state, then proceeds to analysis and notification. You get visual execution history, native retry logic, and the ability to run for as long as the experiment requires.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3h1XZ1KOpDj_kV2UMmJ9aw.png" /></figure><p><em>chaos-state-machine.asl.json</em></p><pre>{<br>  &quot;StartAt&quot;: &quot;CheckKillSwitch&quot;,<br>  &quot;States&quot;: {<br>    &quot;CheckKillSwitch&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:lambda:...:check-kill-switch&quot;,<br>      &quot;Next&quot;: &quot;IsKillSwitchOn&quot;<br>    },<br>    &quot;IsKillSwitchOn&quot;: {<br>      &quot;Type&quot;: &quot;Choice&quot;,<br>      &quot;Choices&quot;: [{<br>        &quot;Variable&quot;: &quot;$.killSwitch&quot;,<br>        &quot;StringEquals&quot;: &quot;ON&quot;,<br>        &quot;Next&quot;: &quot;SkipExperiment&quot;<br>      }],<br>      &quot;Default&quot;: &quot;StartExperiment&quot;<br>    },<br>    &quot;StartExperiment&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:lambda:...:start-fis&quot;,<br>      &quot;Next&quot;: &quot;WaitForExperiment&quot;<br>    },<br>    &quot;WaitForExperiment&quot;: {<br>      &quot;Type&quot;: &quot;Wait&quot;,<br>      &quot;Seconds&quot;: 30,<br>      &quot;Next&quot;: &quot;CheckExperimentStatus&quot;<br>    },<br>    &quot;CheckExperimentStatus&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:lambda:...:check-fis-status&quot;,<br>      &quot;Next&quot;: &quot;IsExperimentDone&quot;<br>    },<br>    &quot;IsExperimentDone&quot;: {<br>      &quot;Type&quot;: &quot;Choice&quot;,<br>      &quot;Choices&quot;: [{<br>        &quot;Variable&quot;: &quot;$.experimentState&quot;,<br>        &quot;StringMatches&quot;: &quot;completed|stopped|failed&quot;,<br>        &quot;Next&quot;: &quot;AnalyzeResults&quot;<br>      }],<br>      &quot;Default&quot;: &quot;WaitForExperiment&quot;<br>    },<br>    &quot;AnalyzeResults&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:lambda:...:analyze-chaos&quot;,<br>      &quot;Next&quot;: &quot;NotifyTeam&quot;<br>    },<br>    &quot;NotifyTeam&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:lambda:...:send-report&quot;,<br>      &quot;End&quot;: true<br>    },<br>    &quot;SkipExperiment&quot;: {<br>      &quot;Type&quot;: &quot;Succeed&quot;,<br>      &quot;Comment&quot;: &quot;Kill switch is ON. Skipping.&quot;<br>    }<br>  }<br>}</pre><p>Each Lambda in this pipeline runs for a few seconds at most. The WaitForExperiment state is a Step Functions Wait, not a Lambda sleep, so it costs nothing and can run for hours if needed. The state machine loops between Wait and CheckExperimentStatus until FIS reports completion, then proceeds to analysis and notification.</p><h3>Step 4: The Analysis Lambda (Bedrock Integration)</h3><p>The analyze-chaos Lambda is where AI enters the picture. It pulls metrics and logs from the chaos window and asks Bedrock to interpret them:</p><p><em>analyze_chaos.py</em></p><pre>import boto3, json<br>from datetime import datetime, timedelta<br><br>cw      = boto3.client(&quot;cloudwatch&quot;)<br>logs    = boto3.client(&quot;logs&quot;)<br>bedrock = boto3.client(&quot;bedrock-runtime&quot;)<br>dynamo  = boto3.resource(&quot;dynamodb&quot;).Table(&quot;ChaosScoreboard&quot;)<br>sns     = boto3.client(&quot;sns&quot;)<br><br>SNS_TOPIC = &quot;arn:aws:sns:us-east-1:...:chaos-reports&quot;<br>LOG_GROUP = &quot;/ecs/my-application&quot;<br><br><br>def lambda_handler(event, context):<br>    &quot;&quot;&quot;Called by Step Functions after FIS completes.&quot;&quot;&quot;<br>    exp_id = event[&quot;experimentId&quot;]<br>    state  = event[&quot;experimentState&quot;]<br>    start  = datetime.fromisoformat(event[&quot;startTime&quot;])<br>    end    = datetime.fromisoformat(event[&quot;endTime&quot;])<br><br>    # Pull metrics from the chaos window<br>    metrics = {}<br>    for m in [&quot;HTTPCode_Target_5XX_Count&quot;,<br>              &quot;TargetResponseTime&quot;,<br>              &quot;HealthyHostCount&quot;, &quot;CPUUtilization&quot;]:<br>        data = cw.get_metric_statistics(<br>            Namespace=&quot;AWS/ApplicationELB&quot;,<br>            MetricName=m,<br>            StartTime=start - timedelta(minutes=5),<br>            EndTime=end + timedelta(minutes=10),<br>            Period=60,<br>            Statistics=[&quot;Average&quot;, &quot;Maximum&quot;, &quot;Sum&quot;]<br>        )<br>        metrics[m] = data[&quot;Datapoints&quot;]<br><br>    # Pull error logs<br>    log_resp = logs.filter_log_events(<br>        logGroupName=LOG_GROUP,<br>        startTime=int(start.timestamp() * 1000),<br>        endTime=int(end.timestamp() * 1000),<br>        filterPattern=&quot;ERROR&quot;, limit=50<br>    )<br>    error_logs = [<br>        ev[&quot;message&quot;]<br>        for ev in log_resp.get(&quot;events&quot;, [])<br>    ]<br><br>    # Call Bedrock for AI analysis<br>    prompt = f&quot;&quot;&quot;You are an AWS resilience engineer.<br>    Analyze this chaos experiment concisely.<br>    EXPERIMENT: {exp_id}  STATUS: {state}<br>    METRICS: {json.dumps(metrics)}<br>    ERROR LOGS: {chr(10).join(error_logs[:20])}<br>    Provide as JSON:<br>    1. resilience_score (1-10) with justification<br>    2. what_broke and why<br>    3. recovery_time_seconds observed<br>    4. Top 3 actionable recommendations<br>    5. next_experiment_risk assessment&quot;&quot;&quot;<br><br>    resp = bedrock.invoke_model(<br>        modelId=(<br>            &quot;anthropic.claude-sonnet-4-20250514-v1:0&quot;<br>        ),<br>        contentType=&quot;application/json&quot;,<br>        body=json.dumps({<br>            &quot;anthropic_version&quot;: &quot;bedrock-2023-05-31&quot;,<br>            &quot;max_tokens&quot;: 2048,<br>            &quot;messages&quot;: [<br>                {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: prompt}<br>            ]<br>        })<br>    )<br>    body = json.loads(resp[&quot;body&quot;].read())<br>    ai_report = body[&quot;content&quot;][0][&quot;text&quot;]<br><br>    # Store scorecard<br>    dynamo.put_item(Item={<br>        &quot;experiment_id&quot;: exp_id,<br>        &quot;timestamp&quot;: datetime.utcnow().isoformat(),<br>        &quot;state&quot;: state,<br>        &quot;ai_report&quot;: ai_report<br>    })<br><br>    return {<br>        &quot;experimentId&quot;: exp_id,<br>        &quot;report&quot;: ai_report<br>    }</pre><p><em>sample-ai-output.json</em></p><pre>{<br>  &quot;resilience_score&quot;: 6.5,<br>  &quot;score_justification&quot;: &quot;System recovered within SLA<br>    but showed cascading latency during failover.&quot;,<br><br>  &quot;what_broke&quot;: &quot;After instance termination, the ALB<br>    continued routing to draining target for ~45s.<br>    23 requests received 502 errors. Replacement<br>    launched in 68s, health checks after 40s more.&quot;,<br><br>  &quot;recovery_time_seconds&quot;: 108,<br><br>  &quot;recommendations&quot;: [<br>    &quot;Increase ALB deregistration delay to 120s.&quot;,<br>    &quot;Add /ready endpoint separate from /health.&quot;,<br>    &quot;Enable cross-zone load balancing.&quot;<br>  ],<br><br>  &quot;next_experiment_risk&quot;: &quot;MEDIUM. Ready for<br>    multi-instance termination once dereg fixed.&quot;<br>}</pre><p>That’s not a dashboard. That’s an <em>engineering recommendation</em>, the kind of thing a senior SRE would write after an hour staring at Grafana. Except it takes 4 seconds and runs automatically.</p><blockquote><strong><em>Where AI Adds Value:</em></strong><em> CloudWatch tells you what happened. The AI reads all of that together and tells you why it matters and what to do. It’s the difference between a dashboard full of red and a paragraph that says “Your connection pool didn’t drain gracefully because ECS deregistration delay is 0 seconds. Set it to 120.”</em></blockquote><h3>The Next Leap: Autonomous Chaos Agents with Bedrock AgentCore</h3><p>Everything we’ve built so far is solid and production-ready, but it follows a rigid, scripted pattern: one cron trigger, one experiment template, one analysis pass. <strong>What if the chaos system could think?</strong></p><p>Amazon Bedrock AgentCore is AWS’s managed platform for deploying AI agents that can reason, plan, use tools, and take actions, all with enterprise-grade session isolation and built-in observability. It became generally available in October 2025 and is available in 9 AWS regions. The AgentCore SDK has been downloaded over 2 million times, and production customers include PGA TOUR, Cox Automotive, and Thomson Reuters.</p><h3>AgentCore Service Maturity (As of March 2026)</h3><p>Before you design around AgentCore, know which services are GA and which are still in preview:</p><p><strong>Generally Available:</strong> Runtime (session isolation, A2A protocol support, 8-hour execution windows), Gateway (MCP, APIs, Lambda tools), Identity (OAuth, IAM auth), Memory (managed + self-managed strategies), Observability (CloudWatch dashboards, OpenTelemetry), Code Interpreter, Browser.</p><p><strong>GA as of March 2026:</strong> Policy (natural-language guardrails converted to Cedar, intercepts Gateway tool calls in real time). Policy went GA on March 3, 2026.</p><p><strong>Still in Preview:</strong> Evaluations (13 pre-built evaluators for correctness, safety, tool selection, available in 4 regions: us-east-1, us-west-2, ap-southeast-2, eu-central-1). Do not rely on Evaluations for production workloads yet. Use it for testing and iteration.</p><h3>The Multi-Agent Chaos Architecture (Conceptual)</h3><p><strong>A note on honesty:</strong> the five-agent architecture I’m about to describe is a <em>design pattern</em>, not a turnkey system you can deploy in an afternoon. Each individual agent is buildable today using AgentCore’s GA services. However, the multi-agent coordination layer (how these agents hand off context, share memory, and make collective decisions) requires careful design work using the A2A protocol, which AgentCore Runtime supports but which has limited reference implementations for this use case. I’m presenting this as an architectural vision with one concrete agent implementation below.</p><p>Here’s how we decompose the chaos lifecycle into five specialized agents:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMJ0K0IiUY3zD9oMCk6auw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqnMuR_Yh4dQXx450-QmGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNr0DfUXWlitzogpZU8LZw.png" /></figure><h3>How AgentCore Services Power Each Agent</h3><p><strong>AgentCore Runtime: </strong>Each chaos agent runs in an isolated, serverless environment with up to 8 hours of execution time. Runtime handles scaling and session isolation, ensuring one agent’s session can’t interfere with another’s.</p><p><strong>AgentCore Memory: </strong>This is the game-changer. With episodic memory, the Planner Agent remembers what happened in previous experiments. It knows that the last three runs all surfaced connection pool issues. It knows that AZ-b hasn’t been tested in 6 weeks. It knows that the team fixed the deregistration delay after Experiment #47 but hasn’t verified the fix yet. This institutional memory transforms chaos from a random exercise into a strategic program.</p><p><strong>AgentCore Policy : </strong>You can define boundaries in plain English: “The Healer Agent can restart ECS tasks and adjust ASG desired count by at most +2, but must never modify Route 53 records or security groups without human approval.” Policy converts this to Cedar and integrates with Gateway to intercept every tool call in real time.</p><p><strong>AgentCore Gateway: </strong>Transforms your existing AWS APIs and Lambda functions into agent-compatible tools via MCP. The Executor Agent doesn’t need custom integration code for FIS. Gateway exposes it as an MCP-compatible tool that any agent can discover and call. You can also plug in third-party tools: PagerDuty, Jira, Slack.</p><p><strong>AgentCore Observability: </strong>Full visibility into end-to-end agent execution via CloudWatch dashboards and OpenTelemetry. You can trace exactly why the Planner Agent chose to test AZ-c today, what tools the Executor Agent called, and how long the Analyst Agent took to generate its report.</p><blockquote><strong>Why AgentCore Over Raw Lambda?</strong> Lambda is great for deterministic scripts. But chaos engineering benefits from adaptive behavior: agents that learn from history and make contextual decisions. AgentCore gives you managed runtime with 8-hour sessions, episodic memory across experiments, policy guardrails for production safety, and built-in observability. You could build all of this yourself, but AgentCore abstracts the infrastructure so you can focus on resilience logic.</blockquote><h3>Working Example: The Planner Agent (Strands Framework)</h3><p>Here’s a concrete implementation of the Planner Agent using the <strong>Strands Agents</strong> framework, which is one of the open-source frameworks supported by AgentCore. This is a real agent, not just a Bedrock API call wrapped in a function, with tool definitions, system prompts, and a deployable structure:</p><p><em>chaos_planner_agent.py (Strands Agent)</em></p><pre>from strands import Agent, tool<br>from strands.models.bedrock import BedrockModel<br>import boto3, json<br><br><br>@tool<br>def list_chaos_targets():<br>    &quot;&quot;&quot;List all AWS resources tagged for chaos.&quot;&quot;&quot;<br>    rg = boto3.client(&quot;resource-groups-tagging-api&quot;)<br>    result = rg.get_resources(<br>        TagFilters=[<br>            {&quot;Key&quot;: &quot;ChaosTarget&quot;, &quot;Values&quot;: [&quot;true&quot;]}<br>        ]<br>    )<br>    return [<br>        t[&quot;ResourceARN&quot;]<br>        for t in result[&quot;ResourceTagMappingList&quot;]<br>    ]<br><br><br>@tool<br>def get_experiment_history(days: int = 30):<br>    &quot;&quot;&quot;Get recent chaos results from DynamoDB.&quot;&quot;&quot;<br>    dynamo = boto3.resource(&quot;dynamodb&quot;)<br>    table = dynamo.Table(&quot;ChaosScoreboard&quot;)<br>    response = table.scan(Limit=50)<br>    return response.get(&quot;Items&quot;, [])<br><br><br>@tool<br>def get_fis_templates():<br>    &quot;&quot;&quot;List available FIS experiment templates.&quot;&quot;&quot;<br>    fis = boto3.client(&quot;fis&quot;)<br>    result = fis.list_experiment_templates()<br>    return [<br>        {&quot;id&quot;: t[&quot;id&quot;],<br>         &quot;description&quot;: t.get(&quot;description&quot;, &quot;&quot;),<br>         &quot;tags&quot;: t.get(&quot;tags&quot;, {})}<br>        for t in result[&quot;experimentTemplates&quot;]<br>    ]<br><br><br>SYSTEM_PROMPT = &quot;&quot;&quot;You are a chaos engineering planner.<br>Use your tools to:<br>1. List all chaos-eligible targets<br>2. Review experiment history (last 30 days)<br>3. List available FIS templates<br><br>Then recommend the next experiment based on:<br>- Coverage gaps (untested targets or fault types)<br>- Unverified fixes from previous experiments<br>- Risk level (start LOW, escalate gradually)<br><br>Respond with JSON: target_arn, fis_template_id,<br>fault_type, risk_level, rationale, prerequisites.&quot;&quot;&quot;<br><br>model = BedrockModel(<br>    model_id=&quot;anthropic.claude-sonnet-4-20250514-v1:0&quot;,<br>    max_tokens=1024<br>)<br><br>planner = Agent(<br>    model=model,<br>    system_prompt=SYSTEM_PROMPT,<br>    tools=[<br>        list_chaos_targets,<br>        get_experiment_history,<br>        get_fis_templates<br>    ]<br>)<br><br><br>if __name__ == &quot;__main__&quot;:<br>    result = planner(<br>        &quot;Plan the next chaos experiment.&quot;<br>    )<br>    print(result)</pre><p>This is a real Strands agent with three defined tools. When you invoke it, the agent reasons about which tools to call, in what order, and how to interpret the results. If the experiment history shows a gap in AZ testing, it will notice and recommend it. If a previous fix hasn’t been verified, it will flag that.</p><p><strong>To deploy this on AgentCore Runtime</strong> (rather than running it locally), you’d use the AgentCore CLI to package and deploy the agent, configure its tools through AgentCore Gateway, attach an AgentCore Memory store for cross-session learning, and define Policy guardrails. Strands, LangGraph, CrewAI, and Google ADK are all supported.</p><h3>The Self-Healing Layer: When AI Fixes What It Broke</h3><p>This is where things get genuinely exciting, and where you need to be the most careful. The Healer Agent is an optional component that takes automated remediation actions for <strong>low-risk, well-understood failure modes</strong>. The key word is “low-risk.”</p><h3>What the Healer Agent Can Do (Safely)</h3><p><strong>1. Scale Out an Auto Scaling Group.</strong> If the experiment reveals the ASG is too small to absorb an instance loss, the Healer can increase the desired count by at most +2 (enforced by Policy) and create a Jira ticket for permanent right-sizing.</p><p><strong>2. Restart Unhealthy ECS Tasks.</strong> If tasks are stuck in a degraded state after the experiment, the Healer can force-stop and re-launch them. This is a safe, idempotent operation.</p><p><strong>3. Update SSM Parameters.</strong> Configuration values like connection pool sizes, retry counts, and similar tuning knobs can be updated in SSM. The Healer modifies the parameter and triggers a rolling restart.</p><p><strong>4. Create Incident Records.</strong> For issues requiring human intervention (database failover, DNS changes, security group modifications), the Healer creates a PagerDuty incident or Jira ticket with the full AI analysis attached.</p><h3>Safety Considerations You Cannot Skip</h3><p>Self-healing sounds great in a blog post. In practice, it introduces several risks that you need to design around explicitly:</p><p><strong>Idempotency:</strong> What if the Healer runs twice? Every remediation action must be idempotent. Check the current state before acting, not just blindly apply a delta. For ASG scaling, read the current desired count and set it to a target value. Don’t increment it.</p><p><strong>Blast Radius of the Fix:</strong> Scaling up an ASG <em>during</em> a chaos experiment can mask the very failure you’re trying to observe. If the Healer adds capacity while FIS is still injecting faults, you won’t learn whether your original capacity was sufficient. The Healer should only act <em>after</em> the FIS experiment has reached a terminal state.</p><p><strong>Conflict with Active Experiments:</strong> If the Healer restarts ECS tasks while FIS is still running a network disruption experiment, the experiment results become unreliable. Build a simple lock: before acting, the Healer checks whether any FIS experiment is currently in a “running” state and backs off if so.</p><p><strong>Audit Trail:</strong> Every action the Healer takes must be logged with full context: what triggered it, what the AI analysis said, what action was taken, and what the outcome was. AgentCore Observability handles this via CloudWatch and OpenTelemetry, but also write a structured record to DynamoDB.</p><blockquote><strong><em>The Policy Guardrail:</em></strong><em> The Healer Agent’s power is strictly bounded by AgentCore Policy (GA as of March 2026). Define rules like: “Can adjust ASG desired count by at most +2. Cannot modify security groups. Cannot touch Route 53. Must get Slack approval before changing any alarm threshold.” Every tool call goes through Gateway, which checks Policy in real time.</em></blockquote><h3>What Else Can Be Done</h3><p>We’ve covered the core architecture and the agentic extension. Here are the directions I’m most excited about.</p><p>We’ve covered the core architecture and the agentic extension. Here are the directions I’m most excited about.</p><h4>1. Chaos-as-Code in CI/CD Pipelines</h4><p>Embed FIS experiments directly into your CodePipeline or GitHub Actions workflow. Every deployment triggers a chaos experiment against staging. The AI agent evaluates whether the new code introduces resilience regressions. If the resilience score drops below a threshold, the deployment is automatically rolled back. This is continuous resilience validation.</p><h4>2. Predictive Chaos with ML Models</h4><p>Use Amazon SageMaker to train models on your historical chaos data in DynamoDB. The model learns which system configurations correlate with poor resilience scores. Instead of waiting for the next experiment to find a problem, the model proactively flags risky configurations: “Your new deployment reduced the ECS task count from 4 to 2 in us-east-1a. Based on historical data, this has a 73% probability of failing the AZ-failure experiment.”</p><h4>3. Multi-Agent Swarms for Complex Systems</h4><p>For large microservice architectures (50+ services), deploy a swarm of specialized agents, one per service domain (payments, auth, search), that coordinate via the A2A protocol. Each agent understands its domain’s failure modes deeply, and they collaborate to simulate cascading failures across service boundaries. This is largely aspirational today. The A2A protocol is supported but multi-agent chaos coordination has few reference implementations.</p><h4>4. MCP-Powered Chaos Tool Discovery</h4><p>The Model Context Protocol is becoming the standard for how AI agents discover and interact with tools. AgentCore Gateway supports MCP natively. The open-source LitmusChaos project has released an MCP server that lets AI agents discover, trigger, and monitor chaos experiments through natural language. Imagine telling your chaos agent: “Test whether the payment service can handle a Redis failover during peak hours.”</p><h4>5. Resilience-Aware Cost Optimization</h4><p>Here’s a perspective nobody talks about: chaos data is <em>cost optimization data</em>. If your experiments consistently show the system survives with 3 instances instead of 5, you’re over-provisioned. Feed chaos results into AWS Cost Explorer analysis via Bedrock, and the AI can recommend where to safely reduce capacity. The chaos scorecard becomes a <strong>right-sizing signal</strong>.</p><h4>6. Game Day Automation</h4><p>Traditional game days are expensive. With the agentic architecture, run “virtual game days” where the AI agent system executes a progressive sequence of experiments (starting mild, escalating in severity), monitors the team’s response in Slack, and generates a comprehensive game day report.</p><h4>7. Compliance and Audit Trail with AI</h4><p>For regulated industries (fintech, healthcare, government), AgentCore’s Observability and Policy features create an audit trail: every agent decision, every tool call, every policy check is logged. The AI can generate compliance-ready reports formatted to meet SOC 2, HIPAA, or FedRAMP requirements.</p><blockquote><strong><em>The Bigger Picture:</em></strong><em> Chaos engineering is evolving from a practice (something teams do) into a platform capability (something your infrastructure does for itself). The combination of AWS FIS for fault injection, Step Functions for orchestration, Bedrock for AI reasoning, and AgentCore for autonomous agent deployment creates a system that continuously validates, reports on, and improves its own resilience.</em></blockquote><h3>The Safety System (This Is Non-Negotiable)</h3><p><strong>Never run chaos experiments without a kill-switch.</strong> Our architecture uses four layers of safety:</p><p><strong>Layer 1: FIS Stop Conditions.</strong> CloudWatch alarms that auto-abort the experiment if error rates cross a threshold.</p><p><strong>Layer 2: SSM Kill-Switch.</strong> A simple parameter (/chaos/kill-switch) checked as the first step before starting any experiment. Any human on the team can flip it instantly.</p><p><strong>Layer 3: AgentCore Policy (GA).</strong> Natural-language guardrails converted to Cedar that bound what AI agents can do. Every tool call is intercepted by Gateway and validated against Policy in real time.</p><p><strong>Layer 4: EventBridge Scheduling.</strong> Experiments fire 7 times per weekday (hourly from 10:00 through 16:00 UTC). No surprises at 2 AM. No chaos on holidays.</p><pre># Enable chaos experiments<br>aws ssm put-parameter \<br>  --name &quot;/chaos/kill-switch&quot; \<br>  --value &quot;OFF&quot; --type String --overwrite<br><br># STOP everything right now<br>aws ssm put-parameter \<br>  --name &quot;/chaos/kill-switch&quot; \<br>  --value &quot;ON&quot; --type String --overwrite</pre><h3>Deploying the Whole Thing</h3><p>Here’s the practical sequence to get this running:</p><p><strong>1. Tag Your Targets.</strong> Add ChaosTarget: true to EC2 instances or ECS services. Start with one non-critical service.</p><p><strong>2. Create the IAM Roles.</strong> Deploy the FIS role with condition-scoped policy (only tagged resources). Create the Step Functions execution role and Lambda execution roles with least-privilege permissions.</p><p><strong>3. Create the FIS Experiment Template.</strong> Start with single instance termination. Add the CloudWatch alarm stop condition.</p><p><strong>4. Deploy the Step Functions State Machine.</strong> Use the ASL definition from Step 3. Wire up the individual Lambda functions for each step: check-kill-switch, start-fis, check-fis-status, analyze-chaos, send-report.</p><p><strong>5. Set Up EventBridge.</strong> Create the cron rule targeting your Step Functions state machine. Start with once per week, then increase frequency as confidence grows.</p><p><strong>6. Create the SSM Kill-Switch.</strong> Initialize /chaos/kill-switch as OFF. Make sure the whole team knows how to flip it.</p><p><strong>7. (Optional) Deploy AgentCore Agents.</strong> When ready for Gen 3 chaos, deploy the Planner Agent on AgentCore Runtime using Strands, LangGraph, or CrewAI. Configure Policy guardrails. Enable Memory for cross-experiment learning. Start with the Planner + Analyst agents; add the Healer only after thorough testing in staging.</p><p><strong>8. Run Your First Experiment Manually.</strong> Don’t wait for the cron. Trigger the state machine by hand, watch metrics, read the AI report. Iterate on the Bedrock prompt if needed.</p><h3>Final Thoughts</h3><p>Chaos engineering isn’t about being reckless. It’s about being <em>honest</em>. Every system has weaknesses, and the question is whether you discover them in a controlled experiment at 2 PM or in a production outage at 2 AM.</p><p>What makes this approach different is the AI layer. Not as a gimmick, but as the thing that closes the loop. FIS breaks things. CloudWatch observes. Step Functions orchestrates. Bedrock understands. AgentCore acts. The whole pipeline runs serverless, costs almost nothing at rest, and produces actionable intelligence that actually drives engineering change.</p><p>We’re at an inflection point. Chaos engineering is evolving from “a practice teams do quarterly” to “a continuous, adaptive capability built into the infrastructure itself.” The tools are here. Some are GA, some are maturing. The question is whether your team is ready to close the observe-and-act gap.</p><p>Start small. Kill one instance. Read the AI report. Fix what it finds. Then do it again. That’s the whole game.</p><p><em>Build for failure, and you’ll rarely experience it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4e3403fd188" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Brought AWS to My Laptop (and Why You Might Want To)]]></title>
            <link>https://jay-kumar.medium.com/how-i-brought-aws-to-my-laptop-and-why-you-might-want-to-ee12da04d057?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee12da04d057</guid>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 07:02:32 GMT</pubDate>
            <atom:updated>2025-11-12T07:02:32.280Z</atom:updated>
            <content:encoded><![CDATA[<p>In the cloud world, whenever we develop any application which uses cloud native services, it is always difficult to test or run it completely local. There are many a times where we work on a feature of the app which uses cloud native service such as S3 bucket, DynamoDB etc. For testing these kind of feature we need to either deploy the app to dev environment or connect to AWS resources using local credentials which is slow, costly and frankly annoying.</p><p>That’s when I came across a really helpful framework called LocalStack. This really saved my day and changed how i do local testing.</p><p>Now the question is what is LocalStack? so basically it is a way to run most of the AWS services locally on the machine which require no internet connection, no AWS accounts &amp; no AWS credentials. Its like running a mini AWS account in a Docker.</p><h3>Why I Needed It</h3><p>So in one of the project i was working on a feature for an application that stored files in S3, stored metadata in DynamoDB and also used SQS for queueing background jobs. Whenever i made a small change i had to redeploy to AWS just to check if the feature is working as expected.<br>The other option was to use AWS credentials in local to connect to AWS environment but i did not had enough permission on AWS.</p><p>Not only that wasted time, but it also felt very annoying. It was blocking me to iterate fast. Then i saw LocalStack which promised “AWS on your laptop” and i was excited to try it out.</p><h3>Setting it up (Takes &lt; 5 Minutes)</h3><p>Here is how I got the mini AWS environment running.</p><p>Create a simple docker-compose.yml</p><pre>services:<br>  localstack:<br>    image: localstack/localstack:latest<br>    container_name: localstack<br>    ports:<br>      - &quot;4566:4566&quot;  # main edge port for all AWS services<br>    environment:<br>      - DEBUG=1<br>      - AWS_DEFAULT_REGION=us-east-1<br>    volumes:<br>      - &quot;.localstack:/var/lib/localstack&quot;<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;</pre><p>Then run:</p><pre>docker compose up -d</pre><p>And my own local AWS cloud is running on the machine on <a href="http://localhost:4566/">http://localhost:4566</a></p><h3>Using It (Meet awslocal)</h3><p>To run aws cli commands for my local mini AWS account, I installed a wrapper for AWS CLI:</p><pre>pip install awscli-local</pre><p>Now I was able to use the general aws cli command like normal AWS environment as below:</p><pre>awslocal s3 mb s3://demo-bucket<br>awslocal s3 ls<br>awslocal sqs create-queue --queue-name demo-queue</pre><h3>Automating Setup with init.sh Script</h3><p>After I installed and started using the localstack i realized that everytime i had to create the same resources like S3, SQS, for testing my feature within the local AWS stack. Then I discovered LocalStack’s <strong>init scripts</strong>, which helped me automate that setup so everything is ready the moment it starts.</p><p>All I had to do is write a small shell script and mount it in the container. For example:<br>init/ready.d/01-bootstrap.sh</p><pre>#!/usr/bin/env bash<br>set -e<br><br>echo &quot;Bootstrapping LocalStack resources...&quot;<br><br>awslocal s3 mb s3://app-bucket<br>awslocal sqs create-queue --queue-name event-queue<br>awslocal dynamodb create-table \<br>  --table-name UserData \<br>  --attribute-definitions AttributeName=id,AttributeType=S \<br>  --key-schema AttributeName=id,KeyType=HASH \<br>  --billing-mode PAY_PER_REQUEST<br><br>echo &quot;Local AWS environment ready!&quot;</pre><p>Then i had to update the docker-compose.yml to mount it:</p><pre>volumes:<br>  - &quot;./init:/etc/localstack/init&quot;</pre><p>Now whenever i start the localstack, it automatically spins up the S3 bucket, SQS queue and DynamoD table. This is great where we need the same resources for local testing and team environment every time for the application testing. No more manual AWS CLI commands every time you restart Docker.</p><h3>Testing Code Against LocalStack</h3><p>Here’s a quick Python example using <strong>boto3</strong>.</p><h4>S3: Upload and list files</h4><pre>import boto3<br><br>s3 = boto3.client(<br>    &quot;s3&quot;,<br>    endpoint_url=&quot;http://localhost:4566&quot;,<br>    aws_access_key_id=&quot;test&quot;,<br>    aws_secret_access_key=&quot;test&quot;,<br>    region_name=&quot;us-east-1&quot;<br>)<br><br>s3.create_bucket(Bucket=&quot;demo-bucket&quot;)<br>s3.put_object(Bucket=&quot;demo-bucket&quot;, Key=&quot;hello.txt&quot;, Body=b&quot;hello world&quot;)<br>print(s3.list_objects_v2(Bucket=&quot;demo-bucket&quot;))</pre><p>The above script will start writing to the local S3 bucket and not the real one.</p><h4>SQS: Send and read messages</h4><pre>import boto3<br><br>sqs = boto3.client(<br>    &quot;sqs&quot;,<br>    endpoint_url=&quot;http://localhost:4566&quot;,<br>    aws_access_key_id=&quot;test&quot;,<br>    aws_secret_access_key=&quot;test&quot;,<br>    region_name=&quot;us-east-1&quot;<br>)<br><br>qurl = sqs.create_queue(QueueName=&quot;demo-queue&quot;)[&quot;QueueUrl&quot;]<br>sqs.send_message(QueueUrl=qurl, MessageBody=&quot;hi from localstack&quot;)<br>msgs = sqs.receive_message(QueueUrl=qurl, MaxNumberOfMessages=1)<br>print(msgs[&quot;Messages&quot;][0][&quot;Body&quot;])</pre><p>This will use the local SQS queue for sending and receiving the message. This needs no cloud, no cost and can run also when I am in a flight.</p><h3>Going Further: Infrastructure with Terraform</h3><p>Once i was comfortable with Localstack, i took it further by using terraform for deploying the infrastructure into my mini AWS environment on the docker.</p><p>Here is how i do it:</p><h4>Step 1: Install Terraform and tflocal</h4><pre>brew install terraform<br>pip install terraform-local</pre><p>tflocal is a small wrapper that automatically configures Terraform to point to LocalStack.</p><h4>Step 2: Create Terraform files</h4><p>main.tf</p><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 5.0&quot;<br>    }<br>  }<br>}<br><br>provider &quot;aws&quot; {<br>  region                      = &quot;us-east-1&quot;<br>  access_key                  = &quot;test&quot;<br>  secret_key                  = &quot;test&quot;<br>  skip_credentials_validation = true<br>  skip_metadata_api_check     = true<br>  s3_use_path_style           = true<br><br>  endpoints {<br>    s3       = &quot;http://localhost:4566&quot;<br>    sqs      = &quot;http://localhost:4566&quot;<br>    dynamodb = &quot;http://localhost:4566&quot;<br>  }<br>}<br><br>resource &quot;aws_s3_bucket&quot; &quot;example&quot; {<br>  bucket = &quot;tf-demo-bucket&quot;<br>}<br><br>resource &quot;aws_sqs_queue&quot; &quot;example&quot; {<br>  name = &quot;tf-demo-queue&quot;<br>}</pre><h4>Step 3: Apply your infrastructure</h4><pre>tflocal init<br>tflocal apply</pre><p>This will spin up the mentioned S3 bucket and SQS in local AWS environment.</p><p>This can be verified by :</p><pre>awslocal s3 ls<br>awslocal sqs list-queues</pre><p>This will also help in testing our terraform templates before deployment. This involves no cost, no real AWS account or no surprises.</p><h3>Bonus Tip: Combine with AWS SAM or CDK</h3><p>Localstack also integrates very well with AWS SAM or CDK. As my localstack was running perfectly i also had a use case to run my serverless locally for testing. I use SAM very often for running serverless services. So i wanted to try if it helps in running it locally and guess what? it worked beautifully.</p><p>Here’s how I made it work. I started by running my Lambdas locally using SAM’s built-in emulator:</p><pre>sam local start-api</pre><p>This actually spins the API Gateway locally and also integrates with the lambda functions. This is one great way to test it. But when i wanted to test that how my full stack is going to behave on cloud like Lambda + API Gateway + DynamoDB, this is where the localstack integration with SAM helped me. I installed localstack compatible SAM CLI:</p><pre>pip install aws-sam-cli-local<br>samlocal deploy --stack-name myapp --capabilities CAPABILITY_IAM</pre><p>This deployed my entire stack on the local AWS environment instead of the real AWS Cloud. This enabled me in testing the API calls Lambda events, and DynamoDB reads/writes completely offline in the same way if it is running on cloud.</p><p>The same thing can be done with CDK as well. We just need to point the CDK app’s environment to localstack and it will deploy the infracture to the local AWS as well.</p><h3>Things I Learned Along the Way</h3><ul><li><strong>Use port 4566</strong> — older tutorials might mention random ports per service. Ignore those.</li><li><strong>Mount Docker socket</strong> — if you want to run Lambda functions, LocalStack uses Docker under the hood to emulate them.</li><li><strong>Persist state</strong> — mount a volume like .localstack:/var/lib/localstack if you want your data to survive restarts.</li><li><strong>Don’t expect 100% feature parity</strong> — LocalStack covers the common use cases extremely well, but very specific AWS features (like some Step Functions integrations or CloudWatch metrics) may behave differently.</li></ul><h3>Why I’ll Keep Using It</h3><p>Localstack made my development very easy and convenient. Previously i had to redeploy or mock half my stack for testing any feature development, but with LocalStack I can spin up AWS like environment locally, test new features instantly and push to the real cloud when i am confident.</p><p>If you work with AWS-based systems, whether it’s serverless apps, data pipelines, or simple S3+Lambda workflows <strong>try LocalStack</strong>. You’ll wonder how you ever worked without it.</p><h3>Quick Resources</h3><ul><li><a href="https://docs.localstack.cloud/getting-started/">LocalStack official docs</a></li><li><a href="https://github.com/localstack/localstack?utm_source=chatgpt.com">LocalStack GitHub</a></li><li><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs">Terraform AWS provider</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee12da04d057" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon Q Developer: The Game-Changing AI Agent That’s Revolutionizing Software Development]]></title>
            <link>https://jay-kumar.medium.com/amazon-q-developer-the-game-changing-ai-agent-thats-revolutionizing-software-development-6f2ff0b83dde?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f2ff0b83dde</guid>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 12:52:43 GMT</pubDate>
            <atom:updated>2025-11-03T12:52:43.801Z</atom:updated>
            <content:encoded><![CDATA[<p>The world of software development is undergoing a seismic shift. While developers have long dreamed of an AI companion that could understand their codebase, implement complex features, and handle tedious tasks, Amazon Q Developer has turned this vision into reality. This isn’t just another code completion tool — it’s a revolutionary AI agent system that’s transforming how developers build, secure, and maintain software.</p><h3>The Agent Revolution: More Than Just Code Completion</h3><p>What sets Amazon Q Developer apart from traditional coding assistants is its sophisticated agent-based architecture. Unlike tools that provide simple code suggestions, Amazon Q Developer employs five specialized AI agents, each designed to excel in specific aspects of software development:</p><p><strong>The Development Agent (/dev) </strong>stands as the crown jewel of the system. This powerhouse transforms natural language descriptions into fully implemented features across multiple files. When you describe a feature like “Create a complete checkout system for our e-commerce platform,” the agent doesn’t just generate code snippets — it analyzes your entire codebase, understands existing patterns, and implements a comprehensive solution spanning databases, APIs, frontend components, and tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*rWlZI4-f5Ggowy21YOQQmw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*FAqNGTT53vfhxPQ30gGj4Q.png" /></figure><p><strong>The Documentation Agent (/doc)</strong> tackles one of developers’ most dreaded tasks: writing and maintaining documentation. This agent automatically generates comprehensive documentation including README files, API documentation, and data flow diagrams directly from your codebase. What previously took hours of manual work now happens in seconds with accuracy that reflects your actual project structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*DeW71p3whlvtadAIZfZPVg.png" /></figure><p><strong>The Testing Agent (/test)</strong> revolutionizes quality assurance by automatically generating unit tests with impressive coverage. It identifies edge cases that are easy to overlook, creates tests for null inputs and empty string checks, and updates testing frameworks with simple prompts. Companies like Audible have reported increasing test coverage from 10% to 100% while saving over 50 hours of development time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*PAloDx8z2pP-p6N-oOhzMg.png" /></figure><p><strong>The Review Agent (/review) </strong>serves as your personal code reviewer, identifying security vulnerabilities, code quality issues, and potential bugs before they reach production. It performs comprehensive analysis including vulnerability scanning, code duplication detection, and adherence to best practices — all integrated seamlessly into your development workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*ewKWqn19hUn-lATLvvqynw.png" /></figure><p><strong>The Transformation Agent (/transform)</strong> modernizes legacy applications with unprecedented efficiency. This agent can upgrade Java applications to newer versions, port .NET applications from Windows to Linux up to 4 times faster, and reduce licensing costs by up to 40%. Companies like Coupang successfully transformed 70+ Java applications in just 2 months with a team of 5 developers — representing a 90% reduction in project timeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*WLO71GzedZTOHXU3DddCVw.png" /></figure><h3>Performance That Leads the Industry</h3><p>Amazon Q Developer’s improvement is backed by rigorous benchmarking. The system has consistently increasing in the SWE-bench leaderboard, achieving higher success rate in solving complex real-world GitHub issues. This represents more than double the performance compared to seven months prior, demonstrating rapid continuous improvement.</p><p>The SWE-bench benchmark tests AI systems’ ability to automatically resolve GitHub issues using real-world Python repositories. Amazon Q Developer’s success stems from several technical innovations:</p><ul><li>Advanced retrieval methods that leverage structured representations of code to identify relevant context</li><li>Aggressive context optimization to maximize token efficiency and reduce latency</li><li>Multiple self-validation steps throughout the problem-solving process</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuHzs7seROmHDds4OTbrIQ.png" /></figure><p>AWS reports that Amazon Q Developer can speed up various software development tasks by up to 80%, while maintaining the highest reported code acceptance rate among multi-line code suggestion tools.</p><h3>Security and Enterprise Readiness</h3><p>In an era where security vulnerabilities can cost companies millions, Amazon Q Developer’s security features provide enterprise-grade protection. The system employs advanced static analysis techniques to identify vulnerabilities across multiple categories:</p><ul><li><strong>SQL Injection detection</strong> for unsafe database queries</li><li><strong>Cross-Site Scripting (XSS) </strong>identification in web applications</li><li><strong>Secrets Exposure</strong> scanning for hardcoded credentials</li><li><strong>Insecure Dependencies</strong> flagging for outdated libraries</li><li><strong>Configuration Flaws</strong> examination for cloud infrastructure misconfigurations</li></ul><p>The security scanning integrates seamlessly into the development workflow, providing real-time feedback as developers write code. This shift-left approach catches vulnerabilities early in the development cycle, reducing remediation costs and improving overall application security.</p><h3>Comprehensive IDE Integration and Ecosystem Support</h3><p>Amazon Q Developer has wide IDE support. The system integrates with popular development environments including Visual Studio Code, JetBrains IDEs (IntelliJ, PyCharm, WebStorm), Eclipse, and Visual Studio. This broad compatibility ensures developers can leverage AI assistance within their preferred workflows without disruption.</p><p>The authentication system offers flexibility for different organizational needs. Individual developers can quickly start with AWS Builder ID (no AWS account required), while enterprise teams can leverage IAM Identity Center for centralized management. Sessions can extend up to 90 days for enhanced productivity.</p><p>Recent additions include Model Context Protocol (MCP) support, allowing developers to connect external tools and services for even richer contextual development workflows. This openness demonstrates Amazon’s commitment to creating an extensible platform rather than a closed system.</p><h3>Pricing That Scales with the Needs</h3><p>Amazon Q Developer’s pricing structure reflects its comprehensive capabilities while remaining accessible to developers at all levels. The Free Tier provides substantial value with 50 agentic requests per month, basic transformation capabilities, and core security features.</p><p>The Pro Tier at $19 per user per month offers expanded limits with 1,000 agentic requests monthly, enhanced transformation capabilities, and enterprise-grade features including IP indemnity and automatic opt-out from data collection.</p><p>A new Pro+ Tier launching August 2025 will provide 3,000 agentic requests per month for $39, targeting power users who need higher limits with predictable pricing.</p><h3>The Future of AI-Assisted Development</h3><p>From its ground-breaking agent architecture to its industry-leading performance metrics, Amazon Q Developer isn’t just keeping pace with the AI revolution — it’s leading it. For developers and organizations ready to embrace the future of software development, Amazon Q Developer offers the most comprehensive, secure, and capable AI assistant available today.</p><p><em>Want to see Amazon Q Developer in action? Read the follow-up technical guide, “[</em><a href="https://jay-k.medium.com/amazon-q-developer-technical-guide-mastering-ai-powered-development-daa6e59dfbf8"><em>Amazon Q Developer Technical Guide: Mastering AI-Powered Development</em></a><em>],” for step-by-step setup instructions and practical tips for getting started today.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f2ff0b83dde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon Q Developer Technical Guide: Mastering AI-Powered Development]]></title>
            <link>https://jay-kumar.medium.com/amazon-q-developer-technical-guide-mastering-ai-powered-development-daa6e59dfbf8?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/daa6e59dfbf8</guid>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 12:52:02 GMT</pubDate>
            <atom:updated>2025-11-03T12:53:27.307Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon Q Developer has emerged as a game-changing AI assistant that transforms how developers build, secure, and maintain software. Building on the comprehensive overview from the previous blog, this technical guide provides step-by-step instructions for implementing and utilizing all of Amazon Q Developer’s features to maximize your development productivity.</p><h3>Getting Started: Installation and Setup</h3><h3>IDE Integration Setup</h3><p>Amazon Q Developer integrates seamlessly with all major development environments. Here’s how to set it up:</p><p>Visual Studio Code Installation</p><ol><li>Open VS Code and navigate to the Extensions marketplace</li><li>Search for “Amazon Q” and install the extension</li><li>After installation, click the Amazon Q icon in the sidebar</li><li>Choose your authentication method (more details below)</li></ol><p>JetBrains IDEs Installation</p><ol><li>Open your JetBrains IDE (IntelliJ, PyCharm, WebStorm, etc.)</li><li>Go to File → Settings → Plugins</li><li>Search for “Amazon Q” and install the plugin</li><li>Restart your IDE and locate the Amazon Q tool window</li></ol><p>Eclipse Installation</p><ol><li>Navigate to Help → Eclipse Marketplace</li><li>Search for “Amazon Q” and install the extension</li><li>Restart Eclipse and find the Amazon Q panel</li></ol><h3>Authentication Options</h3><p>Amazon Q Developer offers flexible authentication methods to suit different development needs:</p><p><strong>AWS Builder ID (Recommended for Individual Developers)</strong></p><ul><li>No AWS account required — perfect for getting started quickly</li><li>Setup time: Less than 2 minutes</li><li>Session duration: Up to 90 days if configured after April 2024</li><li>Use case: Personal projects, learning, or trying out Q Developer</li></ul><p><strong>IAM Identity Center (Enterprise Teams)</strong></p><ul><li>Requires: Existing AWS organizational account</li><li>Session duration: 8 hours (standard) or up to 90 days (configured)</li><li>Use case: Enterprise teams with centralized user management</li><li>Benefits: Centralized administration, policy management, usage monitoring</li></ul><h3>CLI Installation</h3><p>The Amazon Q Developer CLI brings AI assistance directly to your terminal:</p><p>macOS Installation</p><pre>brew install amazon-q</pre><p>Linux Installation</p><pre># Download the installer<br>curl --proto &#39;=https&#39; --tlsv1.2 -sSf &quot;https://desktop-release.codewhisperer.us-east-1.amazonaws.com/latest/q-x86_64-linux-musl.zip&quot; -o &quot;q.zip&quot;<br><br># Extract and install<br>unzip q.zip<br>cd q<br>chmod +x install.sh<br>./install.sh</pre><p>Windows Installation (WSL)</p><pre># From Windows command prompt<br>wsl -d Ubuntu<br><br># Install dependencies<br>sudo apt update<br>sudo apt install curl unzip -y<br><br># Download and install<br>curl --proto &#39;=https&#39; --tlsv1.2 -sSf &quot;https://desktop-release.codewhisperer.us-east-1.amazonaws.com/latest/q-x86_64-linux-musl.zip&quot; -o &quot;q.zip&quot;<br>unzip q.zip<br>cd q<br>chmod +x install.sh<br>./install.sh</pre><p>CLI Authentication</p><pre># Login to Amazon Q<br>q login<br><br># Choose &quot;Use for Free with Builder ID&quot;<br># Follow the browser authentication flow</pre><h3>Core Features and Technical Implementation</h3><h3>Five Specialized AI Agents</h3><p>Amazon Q Developer’s agent-based architecture provides specialized capabilities for different development tasks:</p><h3>Development Agent (/dev)</h3><p>The Development Agent transforms natural language descriptions into fully implemented features across multiple files.</p><p><strong>Technical Implementation:</strong></p><pre>/dev Create a complete checkout system for our e-commerce platform that includes:<br>- Shopping cart management with persistent storage<br>- Payment processing integration with Stripe<br>- Real-time inventory checking and updates<br>- Order confirmation and tracking system<br>- Email notifications for order status changes<br>- Admin dashboard for order management</pre><p><strong>Key Capabilities:</strong></p><ul><li>Multi-file implementation: Spans databases, APIs, frontend components, and tests</li><li>Contextual awareness: Understands existing codebase patterns and architecture</li><li>Iterative development: Builds features incrementally based on feedback</li><li>Language support: Java, Python, JavaScript, TypeScript</li></ul><p><strong>Best Practices for /dev:</strong></p><ul><li>Be specific: Include functionality, inputs, outputs, and error handling requirements</li><li>Provide scaffolding: Reference existing patterns and libraries in your codebase</li><li>Limit scope: Keep requests to approximately 5 files or fewer for optimal results</li><li>Use descriptive prompts: The more detail you provide, the better the implementation</li></ul><h3>Testing Agent (/test)</h3><p>The Testing Agent automatically generates comprehensive unit tests to improve code coverage.</p><p><strong>Technical Implementation:</strong></p><pre>/test Generate unit tests for the factorial function in Python</pre><p><strong>Features:</strong></p><ul><li>Automatic test generation: Creates tests for individual functions or entire files</li><li>Edge case identification: Identifies null inputs, empty strings, and boundary conditions</li><li>Framework support:</li><li>Java: JUnit 4, JUnit 5, JUnit Jupiter, Mockito</li><li>Python: PyTest, Unittest</li><li>IDE integration: Right-click menu option for “Generate Tests”</li></ul><p><strong>Usage Patterns:</strong></p><ul><li>File-based testing: Open the code file you want to test, then use /test</li><li>Function-specific testing: Highlight specific functions and use the IDE menu integration</li><li>Batch testing: Generate tests for multiple functions in a single request</li></ul><h3>Review Agent (/review)</h3><p>The Review Agent performs comprehensive code analysis for security vulnerabilities and quality issues.</p><p><strong>Technical Implementation:</strong></p><pre>/review</pre><p><strong>Security Scanning Capabilities:</strong></p><ul><li>SAST scanning: Detects SQL injection, XSS, resource leaks</li><li>Secrets detection: Identifies hardcoded passwords, API keys, database strings</li><li>Infrastructure as Code (IaC): Scans for misconfigurations and compliance issues</li><li>Dependency analysis: Flags outdated or vulnerable third-party libraries</li></ul><p><strong>Code Quality Analysis:</strong></p><ul><li>Performance issues: Identifies inefficient algorithms and resource usage</li><li>Code duplication: Detects repeated code patterns</li><li>Best practices: Ensures adherence to AWS and industry standards</li><li>Deployment risk assessment: Evaluates risks related to code deployment</li></ul><p><strong>Security Detectors:</strong></p><ul><li>OWASP Top 10: Comprehensive coverage of critical security vulnerabilities</li><li>CWE Top 25: Common weakness enumeration patterns</li><li>Custom AWS patterns: Specific AWS service security best practices</li></ul><h3>Documentation Agent (/doc)</h3><p>The Documentation Agent generates comprehensive project documentation.</p><p><strong>Technical Implementation:</strong></p><pre>/doc</pre><p><strong>Documentation Types:</strong></p><ul><li>README files: Project overview, setup instructions, usage examples</li><li>API documentation: Endpoint descriptions, parameters, response formats</li><li>Data flow diagrams: Visual representations of system architecture</li><li>Code comments: Inline documentation for complex functions</li><li>Architecture documentation: High-level system design explanations</li></ul><p><strong>Supported Languages:</strong></p><ul><li>Java, Python, JavaScript, TypeScript</li></ul><h3>Transformation Agent (/transform)</h3><p>The Transformation Agent modernizes legacy applications with automated upgrades.</p><p><strong>Technical Implementation:</strong></p><pre>/transform</pre><p><strong>Capabilities:</strong></p><ul><li>Java version upgrades: Migrate from Java 8 to Java 11, 17, or later</li><li>.NET modernization: Transform .NET applications for cross-platform deployment</li><li>Syntax updates: Automatic code rewriting for new language features</li><li>Dependency management: Update libraries and frameworks to compatible versions</li><li>Unit test conversion: Transform existing tests to work with new versions</li></ul><p><strong>Real-world Impact:</strong></p><ul><li>70+ Java applications transformed in 2 months with a 5-developer team</li><li>90% reduction in project timeline compared to manual migration</li><li>4x faster .NET application porting from Windows to Linux</li></ul><h3>Inline Code Suggestions</h3><p>Amazon Q Developer provides real-time code completions as you type.</p><p><strong>Technical Features:</strong></p><ul><li>Context-aware suggestions: Based on existing code, comments, and filenames</li><li>Multi-line completions: From single lines to fully formed functions</li><li>Language support: Comprehensive coverage of popular programming languages</li><li>Customizable: Adapts to your coding style and organizational patterns</li></ul><p><strong>Prompting Techniques:</strong></p><ul><li>Function prompts: Descriptive function names trigger relevant implementations</li><li>Single-line comments: # function to calculate average of numbers</li><li>Multi-line comments: Detailed docstring-style descriptions</li><li>Inline prompts: Ctrl+I (Windows/Linux) or Cmd+I (Mac) for contextual assistance</li></ul><p><strong>Navigation and Acceptance:</strong></p><ul><li>Cycle suggestions: Use &lt; and &gt; arrow keys to browse alternatives</li><li>Accept suggestions: Press Tab to accept the entire suggestion</li><li>Partial acceptance: Ctrl+Tab (Windows/Linux) or Option+Tab (Mac) for word-by-word acceptance</li></ul><h3>Workspace Context Awareness</h3><p>Amazon Q Developer’s workspace context provides comprehensive project understanding.</p><p><strong>Technical Implementation:</strong></p><pre>@workspace Which resources are deployed by the workshop stack?</pre><p><strong>Indexing Process:</strong></p><ul><li>Local indexing: Creates searchable index of your entire codebase</li><li>Incremental updates: Automatically updates as you modify files</li><li>Filtering: Excludes binaries, .gitignore files, and non-essential content</li><li>Performance: Initial indexing takes 5–20 minutes, with elevated CPU usage</li></ul><p><strong>Configuration:</strong></p><ol><li>Add @workspace to your Amazon Q chat prompt</li><li>Enable indexing in Amazon Q settings (prompted on first use)</li><li>Configure thread count for faster indexing (optional)</li><li>Monitor indexing progress in IDE status bar</li></ol><p><strong>Use Cases:</strong></p><ul><li>Project understanding: “How is authentication handled across the application?”</li><li>Code navigation: “Where is the user validation logic implemented?”</li><li>Architecture analysis: “What are the dependencies between these microservices?”</li><li>Troubleshooting: “What could be causing the performance issue in the payment flow?”</li></ul><h3>Code Customization</h3><p>Amazon Q Developer can be customized to understand your organization’s specific code patterns.</p><p><strong>Setup Process:</strong></p><ol><li>Subscribe to Pro tier: Required for customization features</li><li>Connect data source: Link to GitHub, GitLab, Bitbucket, or Amazon S3</li><li>Create customization: Upload code samples (minimum 20MB recommended)</li><li>Review evaluation: Check the customization quality score</li><li>Activate and share: Deploy to users and groups</li></ol><p><strong>Technical Requirements:</strong></p><ul><li>Repository size: 20MB minimum, 80MB typical for effective customization</li><li>Code quality: Well-structured, documented code for better AI training</li><li>Access control: IAM roles and policies for secure customization management</li></ul><p><strong>Benefits:</strong></p><ul><li>Organization-specific suggestions: AI learns your internal APIs and patterns</li><li>Consistent coding style: Maintains architectural consistency across teams</li><li>Reduced onboarding time: New developers get context-aware assistance</li><li>Improved code quality: Suggestions align with established best practices</li></ul><h3>Security and Vulnerability Management</h3><p>Amazon Q Developer provides comprehensive security scanning and vulnerability detection.</p><h4><strong>Security Scanning Types:</strong></h4><p><strong>Static Application Security Testing (SAST):</strong></p><ul><li>SQL injection detection</li><li>Cross-site scripting (XSS) identification</li><li>Resource leak detection</li><li>Buffer overflow prevention</li></ul><p><strong>Secrets Scanning:</strong></p><ul><li>Hardcoded password detection</li><li>API key identification</li><li>Database connection string discovery</li><li>Certificate and token exposure</li></ul><p><strong>Infrastructure as Code (IaC) Analysis:</strong></p><ul><li>AWS configuration validation</li><li>Security group rule assessment</li><li>IAM policy analysis</li><li>Resource access control verification</li></ul><p><strong>Automated Remediation:</strong></p><ul><li>Automatic fixes: In-place code updates for common vulnerabilities</li><li>Remediation guidance: Step-by-step instructions for complex issues</li><li>Best practice recommendations: Secure coding pattern suggestions</li><li>AWS service integration: Recommendations for AWS Secrets Manager, KMS, etc.</li></ul><p><strong>Quota Limits:</strong></p><ul><li>Auto scans: 200KB input artifact size, 200KB source code size</li><li>Project scans: 500MB input artifact size, 50MB source code size</li></ul><h3>Advanced Features and Integrations</h3><h4>Console-to-Code Integration</h4><p>Amazon Q Developer bridges the gap between console experimentation and production code.</p><p><strong>Technical Workflow:</strong></p><ol><li>Prototype in AWS Console: Use console to configure services and test functionality</li><li>Capture actions: Amazon Q automatically records your console interactions</li><li>Generate Infrastructure as Code: Create CloudFormation, CDK, or Terraform templates</li><li>Deploy to production: Use generated code for repeatable deployments</li></ol><p><strong>Use Cases:</strong></p><ul><li>Lambda function development: Console testing → production-ready code</li><li>Resource analysis: “What are the IAM roles for this Lambda function?”</li><li>Troubleshooting: “How is this Lambda function getting invoked?”</li><li>Operational insights: Multi-service dependency analysis</li></ul><h4>CLI Agent Features</h4><p>The Amazon Q Developer CLI provides terminal-based AI assistance.</p><p><strong>Core Capabilities:</strong></p><ul><li>Conversation persistence: Resume previous sessions with q chat --resume</li><li>Context management: /save and /load commands for conversation state</li><li>MCP server support: Extensible through Model Context Protocol</li><li>Tool integration: Native support for Git, Docker, AWS CLI, and hundreds of other tools</li></ul><p><strong>Technical Commands:</strong></p><pre># Start interactive chat<br>q chat<br><br># Resume previous conversation<br>q chat --resume<br><br># Save current conversation<br>/save<br><br># Load previous conversation<br>/load<br><br># Get help and diagnostics<br>q doctor</pre><p><strong>Advanced Features:</strong></p><ul><li>File system operations: Read and write files locally</li><li>AWS API integration: Direct access to AWS services</li><li>Shell command execution: Run bash commands with AI assistance</li><li>Real-time feedback: Iterative development with continuous updates</li></ul><h3>Best Practices and Optimization</h3><h4>Effective Prompting Strategies</h4><p><strong>Development Agent Optimization:</strong></p><ul><li>Be specific: Include detailed requirements, error handling, and integration points</li><li>Provide context: Reference existing patterns and architectural decisions</li><li>Iterate incrementally: Build features in manageable chunks</li><li>Review and refine: Use feedback loops to improve implementations</li></ul><p><strong>Testing Agent Maximization:</strong></p><ul><li>Prepare dependencies: Install required testing libraries before running /test</li><li>Add __init__.py files: Ensure Python project structure for successful test execution</li><li>Review generated tests: Validate test cases and add edge cases as needed</li><li>Integrate with CI/CD: Use generated tests in automated pipelines</li></ul><h4>Security Integration Workflow</h4><p><strong>Proactive Security Scanning:</strong></p><ol><li>Enable auto-scan: Activate real-time vulnerability detection</li><li>Regular project scans: Run comprehensive security reviews before releases</li><li>Remediation priority: Address high-severity vulnerabilities first</li><li>Team integration: Share security findings with development teams</li></ol><p><strong>Compliance and Standards:</strong></p><ul><li>OWASP alignment: Ensure coverage of Top 10 security risks</li><li>Industry standards: Validate against CWE Top 25 weaknesses</li><li>AWS best practices: Follow cloud-specific security guidelines</li><li>Regular updates: Keep detectors current with latest security policies</li></ul><h4>Performance Optimization</h4><p><strong>IDE Configuration:</strong></p><ul><li>Indexing optimization: Increase thread count for faster workspace indexing</li><li>Exclude unnecessary files: Configure .gitignore to reduce indexing overhead</li><li>Monitor CPU usage: Manage resource consumption during initial indexing</li><li>Regular maintenance: Clear cache and rebuild indexes periodically</li></ul><p><strong>CLI Performance:</strong></p><ul><li>Background loading: Leverage MCP server background initialization</li><li>Conversation management: Use save/load for efficient context switching</li><li>Tool integration: Optimize external tool configurations for faster responses</li></ul><h3>Real-World Implementation Mock Examples</h3><h4>E-commerce Platform Development</h4><p>Scenario: Building a complete online store with inventory management, user authentication, and payment processing.</p><p><strong>Implementation Strategy:</strong></p><ol><li>Architecture Planning: Use workspace context to understand existing codebase structure</li><li>Feature Development: Implement checkout system using /dev agent</li><li>Security Review: Scan for vulnerabilities using /review agent</li><li>Testing Suite: Generate comprehensive tests using /test agent</li><li>Documentation: Create user guides and API documentation using /doc agent</li></ol><p><strong>Expected Outcomes:</strong></p><ul><li>Development time: Reduced from 4 weeks to 2–3 days</li><li>Test coverage: 85%+ automated coverage from initial implementation</li><li>Security posture: Proactive vulnerability detection and remediation</li><li>Documentation quality: Comprehensive, automatically updated documentation</li></ul><h4>Legacy Application Modernization</h4><p>Scenario: Upgrading a Java 8 enterprise application to Java 17 with modern frameworks.</p><p><strong>Implementation Strategy:</strong></p><ol><li>Assessment: Use /review to identify modernization opportunities</li><li>Incremental Transformation: Apply /transform for systematic upgrades</li><li>Testing Validation: Generate new tests for upgraded components</li><li>Security Hardening: Apply modern security best practices</li><li>Documentation Updates: Refresh technical documentation for new architecture</li></ol><p><strong>Expected Outcomes:</strong></p><ul><li>Migration time: 90% reduction compared to manual migration</li><li>Code quality: Improved maintainability and performance</li><li>Security enhancement: Modern security patterns and practices</li><li>Team productivity: Faster development cycles with updated tooling</li></ul><p>Amazon Q Developer represents a fundamental shift in how developers approach software development. By leveraging its comprehensive agent-based architecture, contextual awareness, and security-first approach, development teams can achieve unprecedented productivity gains while maintaining high code quality and security standards. The key to success lies in understanding each feature’s capabilities, implementing proper workflows, and continuously optimizing based on your team’s specific needs and development patterns.</p><p>Curious about the big-picture impact and industry-leading features of Amazon Q Developer? Check out our in-depth introduction, “[<a href="https://jay-k.medium.com/amazon-q-developer-the-game-changing-ai-agent-thats-revolutionizing-software-development-6f2ff0b83dde">Amazon Q Developer: The Game-Changing AI Agent That’s Revolutionizing Software Development</a>],” to discover how these tools are transforming modern development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daa6e59dfbf8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding AWS Control Tower Account Factory for Terraform (AFT)]]></title>
            <link>https://jay-kumar.medium.com/understanding-aws-control-tower-account-factory-for-terraform-aft-47028fc56b3?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/47028fc56b3</guid>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aft]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[control-towers]]></category>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 13 Feb 2023 07:46:21 GMT</pubDate>
            <atom:updated>2023-02-13T07:46:21.364Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Initially around 2018, the multi-account provisioning system in AWS was called Landing Zone. AWS Landing Zone helped the users to setup multi account AWS environment with all the recommended best practices. Later it was rebranded to AWS Control Tower with some additional features. It provides a central management of multi account AWS organization.</p><p>After IAC was getting evolved in the IT industry, most of the organization wanted to leverage IAC to provision and customize AWS accounts. Since AWS Control Tower do not come with an API, it was not possible to automated it using IAC (Terraform). AWS then collaborated with hashicorp to build a new product named as Account Factory for Terraform(AFT) which solves this problem.</p><h3>What is AWS Control Tower?</h3><p>AWS developed Control Tower to automate the setup of landing zone which helps to run secure and scalable workloads. AWS Control Tower is a well architected account management system. It offers a streamlined workflow for vending and managing multi AWS accounts centrally. It helps to keep the accounts aligned with all the prescriptive best practices and offers centralized governance, guardrails with controls that can be centrally managed. Under the hood it orchestrates other AWS services such as AWS Organizations, AWS Service Catalog, AWS IAM Identity Center, Configs, etc.</p><p>AWS Control Tower basically automates the setup of landing zone using a multi account AWS environment, centralized identity management for all the accounts using AWS SSO, centralized logging using cloudtrail &amp; configs to the centralized logging account, preventive and detective guardrails deployed to the governed accounts, etc.</p><p>AWS Control Tower also comes with a built in account factory which helps the customer to provision standardized accounts with a pre approved account configuration. It also comes with a dashboard which can help the AWS account administrators to see provisioned accounts across your enterprise, controls enabled for policy enforcement, controls enabled for continuous detection of policy non-conformance, and noncompliant resources organized by accounts and OUs.</p><h3>Possible Automations of Control Tower landing zone &amp; Account Vendings</h3><p>Before diving into AFT and how it works, lets see what are possible automation ideas beside AFT which can be used to automate usage of control tower and vending of new accounts with customizations.</p><ol><li>As discussed earlier, there were no public API endpoints available for control tower which can be used directly write automation around control tower, vending and customizing new account. So users ends up provisioning the account in the click-ops way using control tower console.</li><li>CfCT: In May’2021, AWS came up with Customizations for AWS Control Tower (CfCT). It is a gitops driven pipeline to provision and customize the AWS accounts using cloudformation and SCPs.</li><li>Custom Terraform Module: One other way to automate landing zone and account provisioning is creating your own terraform custom module by targeting control tower underlying services such as AWS Organizations, AWS Service Catalog, etc.</li><li>AFT: In Nov’2021, AWS in collaboration with Hashicorp came up with this product call AWS Control Tower Account Factory for Terraform (AFT). In this blog, we will be going through this service and try to understand its underlying architecture.</li></ol><h3>What is AFT?</h3><p>AWS Control Tower Account Factory for Terraform (AFT) is a terraform module which is developed and owned by AWS Control Tower team in collaboration with Hashicorp. It helps in automating the provisioning and customization of new accounts to comply with organization security guidelines.</p><p>It uses a gitops driven automation to provision and customize AWS Control Tower accounts. Source configuration can be stored in any repository type that is supported by code star i.e. AWS CodeCommit, GitHub, GitHub Enterprise, BitBucket.</p><p>As AFT is a open source module, AWS or Hashicorp user can customize the module as per their organization need. It can be customized to deploy additional guardrails, network configurations, roles, etc.</p><p>AFT also comes built in with additional feature options capabilities such as automated enrollment of account to enterprise support, AWS cloudtrail data events for S3, automatic deletion of default VPCs in all regions.</p><h3>Pre-requisites</h3><ol><li>AWS Control Tower: AWS Control Tower needs to be already enabled in AWS organization account.</li><li>AFT OU &amp; Account: Provision a AFT account in a separate AFT OU using control tower where all the resources needed to run the AFT will reside.</li><li>AdministratorAccess Policy User: An IAM user with administrator policy to deploy AFT.</li><li>Terraform v0.15+: Terraform v0.15+ installed locally.</li><li>AWS CLI: AWS CLI installed.</li></ol><p>AFT currently supports the below execution environments:</p><ul><li>Terraform Open Source</li><li>Terraform Cloud</li><li>Terraform Enterprise</li></ul><p>There 2 steps to use AFT. The first is to bootstrap and deploy the AFT module and then use it to deploy and customize the control tower accounts.</p><h3>Deployment of AFT: Code Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pnHk1VGy7NWR7X0nBiFNJw.png" /></figure><p>As we already discussed earlier that AFT is a terraform module available in github repository. To deploy AFT, we can reference the terraform module as shown in the above picture and pass in the required variables. Once we deploy it, it will deploy all the resources need for the AFT to run. Let&#39;s dive in and look into high level overview of the code.</p><ol><li>source: To deploy AFT, a open source github repository needs to be referenced as shown in the screenshot.</li><li>CT Account IDs: Account IDs of the control tower accounts &amp; regions need to passed in to the respective variables such as ct_mangement_account_id, log_archive_account_id etc.</li><li>Optional Parameters: Here the parameters such as terraform_distribution and vcs_provider needs to be passed.</li><li>Feature Flags: As we discussed in the previous section that AFT comes with few built in feature flags. This can be enabled and disables by passing the bool values to this variables.</li></ol><p>These were some of the high level variables needed to deploy AFT. There many more optional variables which can be used to customize the AFT. You can reference those variables <a href="https://registry.terraform.io/modules/aws-ia/control_tower_account_factory/aws/latest#inputs">here</a>.</p><h3>AFT Repositories</h3><p>Once the AFT code is deployed, it will provision 4 git repositories which will be used for different purposes. Let&#39;s discuss in details what are the use cases of these repositories:</p><ol><li><strong>aft-global-customizations: </strong>This repository is for deploying customization to all the vended aws accounts with a standard set of resources. This will be helpful in the scenario where an org has to deploy certain resources in all the account for security or audit purposes.</li><li><strong>aft-account-customizations: </strong>This repository is used to deploy customization to a specific account depending on the value of the account_customizations_name parameter in the aft-account-request repository.</li><li><strong>aft-account-provisioning-customizations:</strong> This repository is for customizing the account while vending which is hooked up with a step function to customize the provisioning process for new accounts.</li><li><strong>aft-account-request: </strong>This repository is where you will drop the terraform template to request AFT to provision a new account. This will trigger the account vending pipeline and vends the account. This repository serves as a central source of truth for the account creation process.</li></ol><h3>AFT Components Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*tugqN5igrRvz7Sl50BvBtQ.png" /></figure><p>Once AFT module is deployed, it deploys various AWS resources which work in conjunction with other resources to help vend a AWS account and customize it. When we push a account request template to the aft-account-request repository, AFT kickoff the workflow as shown in the above diagram to vend a new account and customize it.</p><ol><li>As soon as the code is pushed to the remote repository, a codepipeline is kicked off which used the codebuild to create an entry in a dynamodb table with the account details we mentioned in the account template. DynamoDb then used dynamodb stream to trigger a lambda function that sends the details to a SQS queue.</li><li>The SQS queue then triggers another lambda function which kicks off account vending process in the Control Tower.</li><li>Once a new account is created by Control Tower, AFT then triggers additional Lambda functions which kicks off account specific pipeline to apply global and account specific customizations.</li></ol><h3>Vending a New Account</h3><p>Once AFT is deployed and the git repositories mentioned above are available, we can start using those repositories and vend a new account. In this section we will see how to vend a new account.</p><p>Vending a new account is as easy as dropping a terraform template to the <strong><em>aft-account-request</em></strong> repository which will trigger the complete AFT process and vend a new a account within couple of minutes.</p><p>First of all, clone the <strong><em>aft-account-request</em></strong> repository. Create a terraform template for a new account as mentioned below and place it in the terraform directory. Once the code is pushed to the remote repository, it will trigger a codepipeline and create a dynamodb item which in turns trigger the complete account vending process in the backend and in couple of minutes a new account will be available to be used.</p><p>Lets review a sample account template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*21ojstsryd-RXNkYy6o37A.png" /></figure><ol><li><strong>control_tower_parameters:</strong> These are the required control tower parameters needed by the control tower to create a new account.</li><li><strong>account_tags:</strong> This enabled to apply tags to the new account based on the organization need.</li><li><strong>change_management_parameters: </strong>This helps to track the changes to the account request. We can add the fields like change_requested_by and change_reason so that we can track it in future.</li><li><strong>custom_fields :</strong> This attribute let us define additional metadata for the account which can be used in account customization and provisioning configuration.<br><strong>account_customizations_name:</strong> This attribute helps to customize the account using <strong><em>aft-account-customizations</em></strong> repository.</li></ol><h3>Conclusion</h3><p>In this blog, we have learned about how to manage AWS Control Tower in an automated way using AFT. AFT offers automated gitops driven approach which automates the complete provisioning and management of the account vending and customization using AFT pipelines. It gives the best of both the world, AWS &amp; Terraform to manage the multi-account setup in AWS. Also it is supported by AWS and Hashicorp for any operational support needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47028fc56b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DR on AWS: Different Account & Region vs Same Account & Different Region]]></title>
            <link>https://jay-kumar.medium.com/dr-on-aws-different-account-region-vs-same-account-different-region-ab4a3e56d0fb?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab4a3e56d0fb</guid>
            <category><![CDATA[aws-account]]></category>
            <category><![CDATA[cost]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-region]]></category>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 13:30:19 GMT</pubDate>
            <atom:updated>2023-01-23T13:40:19.244Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SzAbMUO5BVUVUynC_-umdg.jpeg" /></figure><h3>Introduction</h3><p>Disaster recovery on AWS is an important part of cloud resilience strategy and focuses on how the workload responds when a disaster strikes. This includes understanding the impact that disasters have on both your business and IT operations, as well as developing a plan to minimize the disruption caused. In the event of a disaster, such as a natural disaster, cyber attack, or human error, having a robust disaster recovery plan in place can help to minimize the damage and ensure that critical systems and data remains available.</p><p>When designing Disaster Recovery on AWS, most of the organizations have a question in mind, whether to use a separate account or the same account in a different region to setup DR environment. It is very valid question but does not have a straightforward answer to it. Both the options has their own advantages and downsides. We have to do tradeoffs no matter which option we choose. So in this blog we will discuss on the considerations, organization should look into before choosing either of the options.</p><h3>Considerations</h3><h4>Security and Isolation</h4><p>Using different account for disaster recovery environment on AWS provides better security and isolation in the event of security disaster. If the primary account is compromised or affected, having a different account for DR will serve the purpose. Having DR in different account will minimize the impact and ensure that the critical systems are available.</p><p>One important thing to consider here is that if the AWS workload account is part of an organization with a single master account, then its respective DR should not be part of the same master account. This is to make sure that if the primary master account is compromised, the DR master account can serve the purpose and ensure all the DR accounts and resources are available.</p><h4>Testing and Validation</h4><p>One important factor of disaster recovery is testing and validation of DR strategy. This is normally done by DR drills. If the DR is setup in a different account, regular testing and validation of disaster recovery plans can be done without impacting the primary account.</p><p>But also to keep in mind that if organization wants to perform real DR drill which hypothetically impact the primary region, then it&#39;s easier to perform drill if the DR is set up in the same account and different region.</p><h4>Built-in replication features for AWS services</h4><p>One of the reason organizations are migrating to cloud is the flexibility of services which cloud provider bring in to build the application. It can be serverless services or storage services such as S3.</p><p>There are some of the AWS services which provide the feature of built in replication of data like S3 bucket replication to another region, multi-region dynamodb table etc. These feature comes very handy when we try to build DR for applications. This feature can be used when we setup DR in the same account another region but it cannot be used if DR setup is in different account as cross region replication for most of the services works only in the same account. This will limit in designing DR for applications and ends up complicating the design of the application DR.</p><h4>Manageability</h4><p>Managing the DR infrastructure is always a parameter to look into while building the DR strategy. Having DR built in a seperate account increases the number of account in an organization and with that also increases the complexity in the design of DR. Managing and monitoring resources across different accounts can be more difficult compare to the DR setup in the same account but different region. This is an important consideration to look for before choosing either of the options.</p><h4>Communication during DR</h4><p>Most of the organization have multiple teams which handles various part of the Infrastructure and applications. It is very important that there are smooth and flawless communication between the teams to make sure that DR failover happens in short interval of time. Using the same account allows for better communication and cooperation between different teams, which can be beneficial in the event of a disaster.</p><h4>Consistency with Control Tower</h4><p>When an organization has AWS Control Tower implemented, there are several considerations to take into account when deciding whether to use different regions within the same account or a different account and different region for disaster recovery. By using the same account with another region for DR, you can ensure consistency with the account structure and security controls established by Control Tower.</p><p>If different account is used for DR, Control Tower resorces &amp; controls will be provisioned in both the regions for all the primary and DR accounts which means that in one set of account unnecessary control tower resources are standing and incurring cost.</p><h4>Cost</h4><p>Cost is an important factor to consider while choosing same account vs different account for DR. Using different region within the same account will be more cost-effective than using seperate account as most of the security &amp; control tower resources can be shared. For ex: Config deployed to different region in same account are way less cost then having deployed in seperate account in both the region. Also with “pay-as-you-go” model, cost of each resources needs to be paid separately in DR account, which can add up quickly.</p><h3>Conclusion</h3><p>As we have seen, there are multiple factors which needs to be considered before choosing between same account different region and different account for DR. Based on that the other factors which can help orgs to come to decision are the organization’s budget and resource constraints, the potential impact of a disaster, organization’s overall risk tolerance and the size and complexity of the organization’s infrastructure.</p><p>I hope this will help in making informed decision in choosing the right option for the organizations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab4a3e56d0fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup CI-CD to provision Amazon Connect using Terraform]]></title>
            <link>https://jay-kumar.medium.com/setup-ci-cd-to-provision-amazon-connect-using-terraform-cb7bcfe9bcb8?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb7bcfe9bcb8</guid>
            <category><![CDATA[codecommit]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[amazon-connect]]></category>
            <category><![CDATA[aws-codepipeline]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 14:37:05 GMT</pubDate>
            <atom:updated>2023-01-02T14:37:05.456Z</atom:updated>
            <content:encoded><![CDATA[<p>In my last <a href="https://medium.com/@jkcrross/automate-amazon-connect-using-iac-e9249528d165">blog</a>, we have built a terraform module for end to end Amazon Connect contact center. In this blog we will look into how we can set up a CICD to automate the deployment of Amazon Connect contact center using the terraform module.</p><h4>Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4MSWwUarQZxvLUCKq773Q.png" /><figcaption>Amazon Connect CI/CD</figcaption></figure><p>As referred in the above architecture, we are going to build CICD codepipeline to deploy end to end Amazon Connect contact center and its dependencies using terraform modules. Codepipeline will have a the below stages:</p><ol><li><strong>CodeCommit — Source Stage: </strong>Terraform module codes will be stored in the codecommit repository and this stage will be pulling the code from the repository and changing it into the pipeline artifact which will be used by the subsequent stages</li><li><strong>CodeBuild — Prereq resources Stage:</strong> This stage will be triggering a codebuild project which will be installing and running a terraform module. This module will provision all the pre-req resources which needs to be integrated with the Amazon Connect like, S3 bucket, Kinesis, Lex Bots, Lambda Function etc.</li><li><strong>CodeBuild — Connect Deployment Stage:</strong> This stage will be triggering a codebuild project which will be installing and running a terraform module. This module will provision all the Amazon Connect resources like Connect Instance, Routing profile, Queue etc.</li></ol><h4>Develop a Prereq resource terraform module</h4><p>Amazon Connect can be integrated with multiple other AWS services like Lambda function, Lex Bots, Kinesis, Comprehend etc. As part of this pipeline we are going to deploy these resources as part of the prereq resources stage. To deploy those resources we need develop a terraform module for it. As part of this blog, we are going to build a terraform pre-req module for a simple lambda function and a lex bot.</p><p>Create a folder and name it as “pre-req-resources”. Create another folder within it &amp; name itas “modules”. Within “module” folder create a main.tf file with the below content</p><pre>variable &quot;function_name&quot; {<br>  description = &quot;Name of the function&quot;<br>}<br><br>variable &quot;filename&quot; {<br>  description = &quot;Name of the code file in zip format&quot;<br>}<br><br>variable &quot;runtime&quot; {<br>  description = &quot;Runtime of the code&quot;<br>  default = &quot;python3.9&quot;<br>}<br><br>variable &quot;function_role_arn&quot; {<br>  description = &quot;ARN of the role which function will assume&quot;<br>}<br><br>variable &quot;handler&quot; {<br>  description = &quot;Lambda function handler&quot;<br>}<br><br>resource &quot;aws_lambda_function&quot; &quot;lambda&quot; {<br>  filename      = var.filename<br>  function_name = var.function_name<br>  role          = var.function_role_arn<br>  handler       = var.handler<br>  source_code_hash = filebase64sha256(&quot;${var.filename}&quot;)<br>  runtime = var.runtime<br>}</pre><p>Within pre-req resources folder create a “main.tf” file with module call by passing the variables values. Also place the function.zip in the same folder.</p><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;4.30.0&quot;<br>    }<br>  }<br>}<br><br><br>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><br>module &quot;lambda_function&quot; {<br>  source = &quot;./modules&quot;<br>  filename = &quot;function.zip&quot;<br>  function_name = &quot;Demo-Insurance&quot;<br>  function_role_arn = &quot;arn:aws:iam::123456789011:role/custom_iam_role&quot;<br>  handler = &quot;index.lambda_handler&quot;<br>  runtime = &quot;python3.8&quot;<br>}</pre><h4>Folder Structure</h4><p>The folder structure for the repository should look like below:</p><p>root<br>├───connect-resources<br>│ │ main.tf<br>│ │<br>│ └───connect-module<br>│ main.tf<br>│ providers.tf<br>│ variables.tf<br>│ variables.tfvar<br>│<br>└───pre-req-resources<br> │ function.zip<br> │ main.tf<br> │<br> └───modules — main.tf</p><p>Place the connect module created in the <a href="https://medium.com/@jkcrross/automate-amazon-connect-using-iac-e9249528d165">last blog</a> in <em>“./connect-resources/connect-module”</em> folder.</p><h4>Setup a code repository</h4><p>First thing first, we need to have a source code repository setup to store our code for a CICD pipeline. AWS CodeCommit is a managed version control git repository where code can be stored privately. It can also be integrated with codepipeline, codebuild etc. Follow the below steps to setup a codecommit repository.</p><ol><li>Navigate to the AWS CodeCommit console.</li><li>Click on <em>Create repository</em> on the right top corner.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEeUK7GVe312h-wIHGEy7Q.png" /></figure><p>3. Provide the “Repository Name” and “Description” and hit <em>Create</em> button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*IKWZlKizEysozAE2jMvG2w.png" /></figure><p>Your repository should be now ready to be used. Clone the repository and push the terraform module from last blog to the remote repository. Follow <a href="https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up.html">this</a> for connect to CodeCommit repository.</p><h4>Create Service Roles</h4><p>We will need 2 service roles for codebuild and codepipeline to assume respectively. Create the below 2 service roles.</p><ol><li>Codebuild Service Role: The codebuild role should be define as below</li></ol><pre>1. The role should be assumed by CodeBuild Service. Below is the trust policy fo the role:<br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;sts:AssumeRole&quot;<br>            ],<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: [<br>                    &quot;codebuild.amazonaws.com&quot;<br>                ]<br>            }<br>        }<br>    ]<br>}<br><br><br>2. The role should have the below managed policies attached.<br><br>AmazonS3FullAccess<br>CloudWatchFullAccess<br>AmazonDynamoDBFullAccess<br>AWSCodeBuildAdminAccess<br>AmazonLexFullAccess<br>AmazonConnect_FullAccess<br>AWSLambda_FullAccess<br>AWSCodeCommitFullAccess</pre><p>2. Codepipeline Service Role: This role will be assumed by codepipeline and it should be defined as below.</p><pre>1. The role should be assumed by codepipeline Service. Below is the trust policy of the role:<br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: &quot;codepipeline.amazonaws.com&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>        }<br>    ]<br>}<br><br><br>2. The role should have below permissions attached:<br><br>{<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: [<br>                &quot;iam:PassRole&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringEqualsIfExists&quot;: {<br>                    &quot;iam:PassedToService&quot;: [<br>                        &quot;cloudformation.amazonaws.com&quot;,<br>                        &quot;elasticbeanstalk.amazonaws.com&quot;,<br>                        &quot;ec2.amazonaws.com&quot;,<br>                        &quot;ecs-tasks.amazonaws.com&quot;<br>                    ]<br>                }<br>            }<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;codecommit:CancelUploadArchive&quot;,<br>                &quot;codecommit:GetBranch&quot;,<br>                &quot;codecommit:GetCommit&quot;,<br>                &quot;codecommit:GetRepository&quot;,<br>                &quot;codecommit:GetUploadArchiveStatus&quot;,<br>                &quot;codecommit:UploadArchive&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;codedeploy:CreateDeployment&quot;,<br>                &quot;codedeploy:GetApplication&quot;,<br>                &quot;codedeploy:GetApplicationRevision&quot;,<br>                &quot;codedeploy:GetDeployment&quot;,<br>                &quot;codedeploy:GetDeploymentConfig&quot;,<br>                &quot;codedeploy:RegisterApplicationRevision&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;codestar-connections:UseConnection&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;elasticbeanstalk:*&quot;,<br>                &quot;ec2:*&quot;,<br>                &quot;elasticloadbalancing:*&quot;,<br>                &quot;autoscaling:*&quot;,<br>                &quot;cloudwatch:*&quot;,<br>                &quot;s3:*&quot;,<br>                &quot;sns:*&quot;,<br>                &quot;cloudformation:*&quot;,<br>                &quot;rds:*&quot;,<br>                &quot;sqs:*&quot;,<br>                &quot;ecs:*&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;lambda:InvokeFunction&quot;,<br>                &quot;lambda:ListFunctions&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;opsworks:CreateDeployment&quot;,<br>                &quot;opsworks:DescribeApps&quot;,<br>                &quot;opsworks:DescribeCommands&quot;,<br>                &quot;opsworks:DescribeDeployments&quot;,<br>                &quot;opsworks:DescribeInstances&quot;,<br>                &quot;opsworks:DescribeStacks&quot;,<br>                &quot;opsworks:UpdateApp&quot;,<br>                &quot;opsworks:UpdateStack&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;cloudformation:CreateStack&quot;,<br>                &quot;cloudformation:DeleteStack&quot;,<br>                &quot;cloudformation:DescribeStacks&quot;,<br>                &quot;cloudformation:UpdateStack&quot;,<br>                &quot;cloudformation:CreateChangeSet&quot;,<br>                &quot;cloudformation:DeleteChangeSet&quot;,<br>                &quot;cloudformation:DescribeChangeSet&quot;,<br>                &quot;cloudformation:ExecuteChangeSet&quot;,<br>                &quot;cloudformation:SetStackPolicy&quot;,<br>                &quot;cloudformation:ValidateTemplate&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;codebuild:BatchGetBuilds&quot;,<br>                &quot;codebuild:StartBuild&quot;,<br>                &quot;codebuild:BatchGetBuildBatches&quot;,<br>                &quot;codebuild:StartBuildBatch&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;devicefarm:ListProjects&quot;,<br>                &quot;devicefarm:ListDevicePools&quot;,<br>                &quot;devicefarm:GetRun&quot;,<br>                &quot;devicefarm:GetUpload&quot;,<br>                &quot;devicefarm:CreateUpload&quot;,<br>                &quot;devicefarm:ScheduleRun&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;servicecatalog:ListProvisioningArtifacts&quot;,<br>                &quot;servicecatalog:CreateProvisioningArtifact&quot;,<br>                &quot;servicecatalog:DescribeProvisioningArtifact&quot;,<br>                &quot;servicecatalog:DeleteProvisioningArtifact&quot;,<br>                &quot;servicecatalog:UpdateProduct&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;cloudformation:ValidateTemplate&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ecr:DescribeImages&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;states:DescribeExecution&quot;,<br>                &quot;states:DescribeStateMachine&quot;,<br>                &quot;states:StartExecution&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;appconfig:StartDeployment&quot;,<br>                &quot;appconfig:StopDeployment&quot;,<br>                &quot;appconfig:GetDeployment&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ],<br>    &quot;Version&quot;: &quot;2012-10-17&quot;<br>}</pre><h4><strong>Create CodeBuild Projects</strong></h4><p>We need to create two code build project for prereq resources and connect resources deployment respectively. Lets build two buildspec files for each build projects. Store the buildspec files in the buildspec folder in the repository.</p><p><strong>Prereq Resources BuildSpec</strong>: buildspec-prereq.yaml</p><pre>version: 0.2<br><br>phases:<br>  install:<br>    on-failure: ABORT<br>    commands:<br>      - set -e<br>      - DEFAULT_PATH=$(pwd)<br>      - TIMESTAMP=$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)<br>      # Install Terraform<br>      - echo &quot;Installing Terraform&quot;<br>      - sudo yum install -y yum-utils<br>      - sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo<br>      - sudo yum -y install terraform<br>      - terraform --version<br>      - echo `aws sts get-caller-identity`<br>  <br>  build:<br>    on-failure: CONTINUE<br>    commands:<br>      - cd pre-req-resources<br>      - terraform init<br>      - terraform apply -auto-approve</pre><p><strong>Connect Resources BuildSpec: </strong>buildspec-connect.yaml</p><pre>version: 0.2<br><br>phases:<br>  install:<br>    on-failure: ABORT<br>    commands:<br>      - set -e<br>      - DEFAULT_PATH=$(pwd)<br>      - TIMESTAMP=$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)<br>      - echo &quot;Installing Terraform&quot;<br>      - sudo yum install -y yum-utils<br>      - sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo<br>      - sudo yum -y install terraform<br>      - terraform --version<br>      - echo `aws sts get-caller-identity`<br>  <br>  build:<br>    on-failure: CONTINUE<br>    commands:<br>      - cd connect-resources<br>      - terraform init<br>      - terraform apply -auto-approve</pre><p>We will use these buildspec files to create two build projects. Follow the below steps.</p><ol><li>Login to the AWS console and navigate to the CodeBuild service.</li><li>Click on “Create Build Project”.</li><li>Fill in the Project Details.</li></ol><pre>Project Name: connect-prereq-resources or connect-resources<br>Source:<br>  Source Provider: AWS CodeCommit<br>  Repository: connet-iac<br>  Reference Type: Branch<br>  Branch: master<br>  Source Version: refs/head/master<br>Environment:<br>  Environment Image: Managed Image<br>  Operating System: Amazon Linux 2<br>  Runtime(s): Standard<br>  Image: aws/codebuild/amazonlinux2-x86_64-standard:4.0<br>  Environment Type: Linux<br>  Service Role: Existing service role<br>  Role Name: &lt;CodeBuild Service Role Created in IAM section&gt;<br>BuildSpec:<br>  Build Specifications: Use a buildspec file<br>  Buildspec name: &lt;PATH to the prereq buildspec FILE&gt;<br>Artifacts:<br>  Type: No artifacts</pre><p>4. Click “<em>Create build project</em>”.</p><p>CodeBuild projects for the deployment of pre-req resources and end to end contact center using connect should be ready.</p><h4>Create Deployment CodePipeline</h4><p>Once the codebuilds are ready, we will now create the CodePipeline which will deploy the end to end contact center using the CodeBuild projects and codecommit repository.</p><ol><li>Login to the AWS console and navigate to the CodePipeline service.</li><li>Click on “Create Pipeline”.</li><li>Fill in the below details:</li></ol><pre>1. Pipeline Name: connect-iac<br>2. Service Role : Existing service role<br>3. Role ARN: &lt;ARN of the codepipeline service role created earlier&gt;</pre><p>4. Click Next &amp; Fill in the below details in “Add Source Stage”</p><pre>1. Source Provider: AWS CodeCommit<br>2. Repository Name: connect-iac<br>3. Branch Name: main</pre><p>5. Click Next &amp; Fill in the below details in “Add build stage”</p><pre>1. Build Provider: AWS CodeBuild<br>2. Region: &lt;Region&gt;<br>3. Project Name: connect-prereq-resources (CodeBuild Project for Pre-req resources)</pre><p>6. Click “<em>Next”</em></p><p>7. Click “<em>Skip deploy stage” &amp; </em>Click on <em>“Skip”</em>.</p><p>8. Review the details and click on <em>“Create Pipeline”.</em></p><p>9. Once the pipeline is created, click in Edit button on the top to add more stages to the pipeline.</p><p>10. Click on the <em>“+ Add Stage” </em>&amp; Provide the Stage name<em>.</em></p><p>11. Click on <em>“+Add action group” </em>&amp; Fill in the below details:</p><pre>1. Action name: Connect-Resource-Deployment<br>2. Action provider: AWS CodeBuild<br>3. Region: &lt;Region&gt;<br>4. Input artifacts: SourceArtifact<br>5. Project name: connect-resources (CodeBuild Project for Connect resources)<br>6. Click on Done</pre><p>12. Click on <em>Save.</em></p><p>The pipeline should be ready to be used. Now whenever any code is committed to the CodeCommit repository, the pipeline will be triggered automatically and deploys the changes to the environment.</p><h4>Conclusion</h4><p>In this blog, we went over creating a CI/CD pipeline to deploy Amazon Connect terraform module and its pre-requisites resources. We have created all the resources needed for the CICD like CodeCommit, CodeBuild projects, CodePipeline, required IAM roles etc.</p><p>There are some resources in Amazon Connect which are yet not available to be deployed through Terraform. For more details on this read my another blog “<a href="https://medium.com/@jkcrross/automate-amazon-connect-terraform-or-cloudformation-4c07a3a2fd06"><strong><em>Automate Amazon Connect: Terraform or Cloudformation ?</em></strong></a>”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb7bcfe9bcb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Amazon Connect: Terraform or Cloudformation ?]]></title>
            <link>https://jay-kumar.medium.com/automate-amazon-connect-terraform-or-cloudformation-4c07a3a2fd06?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c07a3a2fd06</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-connect]]></category>
            <category><![CDATA[cloudformation]]></category>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 04:37:44 GMT</pubDate>
            <atom:updated>2023-01-02T04:37:44.731Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automate Amazon Connect: Terraform or Cloudformation ?</h3><p>In last blog we have discussed how we can automate Amazon Connect provisioning using terraform. We have also seen that how powerful it becomes when we deploy Amazon Connect using a IAC tool like terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYbpzufgpWJYne8pXA5u_Q.jpeg" /></figure><h3>Introduction</h3><p>There are always confusion when we have to decide which IAC tool to use for connect deployment, Terraform or Cloudformation. Many enterprises prefer Terraform and others prefer Cloudformation based on the bench strength and other factors. There are always debate to use one over other. In this blog we are going to discuss on which tool to use for Amazon Connect provisioning. At the end of the blog we will have a clear picture of what suits us the best for Amazon Connect provisioning.</p><h3>Background</h3><h4>What is Terraform?</h4><p>Terraform is a open source IAC tool to automate the infrastructure provisioning. Terraform uses Hashicorp Configuration Language(HCL) which is based on JSON and allows the users to write the the infrastructure as a code. In Terraform, users need to maintain the state of the infrastructure as it stored in the local machine or remote location.</p><h4>What is Cloudformation?</h4><p>Cloudformation is managed AWS IAC service which allows users to provision infrastructure. Cloudformation can be written in JSON or YAML templates where the infrastructure is defined in a declarative manner. Cloudformation manages the infrastructure within stacks. As it is a managed service, Cloudformation takes care of the state and backend infrastructure.</p><h4>Amazon Connect using Cloudformation:</h4><p>Although cloudformation is a great IAC tool to deploy AWS infrastructure, but is it a right tool to provision Amazon Connect resources. Lets find out.</p><p>Below are the Amazon Connect resources which can be deployed using cloudformation.</p><ol><li><strong>Contact Flow:</strong> The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-contactflow.html">AWS::Connect::ContactFlow</a>” is available to provision a contact flow.</li><li><strong>Contact Flow Module: </strong>The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-contactflowmodule.html">AWS::Connect::ContactFlowModule</a>” is available to provision a contact flow module.</li><li><strong>Hours of Operation:</strong> The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-hoursofoperation.html">AWS::Connect::HoursOfOperation</a>” is available to provision hours of operation resource.</li><li><strong>Connect Instance:</strong> The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-instance.html">AWS::Connect::Instance</a>” is available for provisioning connect instance.</li><li><strong>Storage Config:</strong> The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-instancestorageconfig.html">AWS::Connect::InstanceStorageConfig</a>” is available to provision a storage config in a connect instance.</li><li><strong>Phone Number: </strong>The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-phonenumber.html">AWS::Connect::PhoneNumber</a>” is available to claim a phone number to the specified amazon instance or traffic distribution group.</li><li><strong>Quick Connect:</strong> The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-quickconnect.html">AWS::Connect::QuickConnect</a>” is available to provision a quick connect for an Amazon Connect instance.</li><li><strong>Task Template: </strong>The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-tasktemplate.html">AWS::Connect::TaskTemplate</a>” is available to provision a task template for a Amazon Connect instance.</li><li><strong>User:</strong> The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-user.html">AWS::Connect::User</a>” is available to provision a user account for an Amazon Connect instance.</li><li><strong>User Hierarchy Group: </strong>The resource “<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-connect-userhierarchygroup.html">AWS::Connect::UserHierarchyGroup</a>” is available to provision a user hierarchy group.</li></ol><p>The resources which are yet not supported by cloudformation till today (11/11/2022) are below:</p><ol><li>Connect Queues</li><li>Lambda Function Associations</li><li>Lex Bot Associations</li><li>Wisdom Associations</li><li>Hierarchy Structure</li><li>Vocabulary</li><li>Phone Number Association with Contact Flow</li><li>Routing Profile</li><li>Security Profile</li></ol><h4>Amazon Connect using Terraform</h4><p>In this section we are going to look into the resources which we can provision using terraform and the resource which are yet not available to be deployed through terraform. This will give us the idea on which tool fits our need.</p><ol><li><strong>Contact Flow:</strong> The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_contact_flow">aws_connect_contact_flow</a>” is available to provision a contact flow.</li><li><strong>Contact Flow Module: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_contact_flow_module">aws_connect_contact_flow_module</a>” is available to provision a contact flow module.</li><li><strong>Hours of Operation:</strong> The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_hours_of_operation">aws_connect_hours_of_operation</a>” is available to provision hours of operation resource.</li><li><strong>Connect Instance:</strong> The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_instance">aws_connect_instance</a>” is available for provisioning connect instance.</li><li><strong>Storage Config:</strong> The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_instance_storage_config">aws_connect_instance_storage_config</a>” is available to provision a storage config in a connect instance.</li><li><strong>Phone Number: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_phone_number">aws_connect_phone_number</a>” is available to claim a phone number to the specified amazon instance or traffic distribution group.</li><li><strong>Quick Connect:</strong> The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_quick_connect">aws_connect_quick_connect</a>” is available to provision a quick connect for an Amazon Connect instance.</li><li><strong>User:</strong> The resource “aws_connect_user” is available to provision a user account for an Amazon Connect instance.</li><li><strong>User Hierarchy Group: </strong>The resource “aws_connect_user_hierarchy_group” is available to provision a user hierarchy group.</li><li><strong>User Hierarchy Structure: </strong>The resource “aws_connect_user_hierarchy_group” is available to provision a user hierarchy group.</li><li><strong>Connect Queues: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_queue">aws_connect_queue</a>” is available to provision a user hierarchy group.</li><li><strong>Lambda Function Associations: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_lambda_function_association">aws_connect_lambda_function_association</a>” is available to provision a user hierarchy group.</li><li><strong>Lex Bot Associations: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_bot_association">aws_connect_bot_association</a>” is available to provision a user hierarchy group.</li><li><strong>Vocabulary: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_vocabulary">aws_connect_vocabulary</a>” is available to provision a user hierarchy group.</li><li><strong>Routing Profile: </strong>The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_routing_profile">aws_connect_routing_profile</a>” is available to provision a user hierarchy group.</li><li><strong>Security Profile</strong>: The resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_security_profile">aws_connect_security_profile</a>” is available to provision a security profile.</li></ol><p>The resources which are yet not supported by terraform till today (11/11/2022) are below:</p><ol><li>Wisdom Associations</li><li>Task Template</li><li>Phone Number Association with Contact Flow</li><li>Lex Bot (v2) Associations</li></ol><p>Below is the consolidated view of the Amazon Connect resources supported by terraform and cloudformation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*ZJgvDNH3fFvr5WBxOC1ZPg.png" /></figure><h4>Conclusion</h4><p>After comparing both the tools i.e. cloudformation and terraform for Amazon Connect resources provisioning, now we have the fair idea of which resources are supported by each tool. This will help us in deciding which tool will suit us the best based on the type of resources we need to provision in Amazon Connect. This list will get updated with the new releases and I will update the blog accordingly.</p><p>To deep dive and create a reusable Terraform module to deploy end to end contact center using Amazon Connect, read my another blog: <a href="http://Automate Amazon Connect using IaC"><strong><em>Automate Amazon Connect using IaC</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c07a3a2fd06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Amazon Connect using IaC]]></title>
            <link>https://jay-kumar.medium.com/automate-amazon-connect-using-iac-e9249528d165?source=rss-5d4bd2a7da19------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9249528d165</guid>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[amazon-connect]]></category>
            <dc:creator><![CDATA[Jay Kumar ]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 04:36:16 GMT</pubDate>
            <atom:updated>2023-01-02T14:38:56.915Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhIcBQuhH2JfotFTi-1E_A.jpeg" /></figure><h3><strong>Introduction</strong></h3><h4><strong>What is Amazon Connect ?</strong></h4><p>Amazon connect is a AWS service that can help the enterprises to build their contact center within minutes. It provides superior customer service at a lower cost with an easy-to-use omnichannel cloud contact center.</p><p>The features which makes the Amazon Connect stand out of other providers are built in AI &amp; ML, integration with other AWS services like lex bots, lambda, S3 etc., scalability and low cost.</p><h4><strong>What is IaC?</strong></h4><p>Infrastructure as a code is abbreviated as IaC. In the world of cloud computing this term is getting very popular. IaC is a way of deploying the infrastructure using a reusable code. Earlier in the last decade, infrastructure in the cloud world was built manually using console and click ops. There was several disadvantages of building the infrastructure manually which IaC tools solves.</p><p>To name few the the problem which IaC solves are consistency of infra across environments, version controlling infra, scaling infra, large amount of time taken to deploy infra and many more..</p><p>The two most common IAC tool which is widely used in the industry today specially for the AWS cloud are Hashicorp Terraform and AWS Cloudformation.</p><h4><strong>Amazon Connect using IAC</strong></h4><p>Most of the customers are deploying and configuring the Amazon Connect instances manually. It takes lot of time and manual effort to configure the Connect instances. It also limits the scalability as it cannot be extended to different environments. Every time we need to create and configure new instances, it has to be done from scratch. So most the customers wants to provision connect resources quickly and consistently using IAC. There are some limitation in using IAC to deploy connect resources which we will discuss further in the blog.</p><p>In this blog we will be see, how we can make use of combination of terraform and cloudformation to automate the provisioning of the Connect resources.</p><h4>Connect Resources</h4><ol><li><strong>Instance</strong>: Instance contains all the resources and settings of the contact center. This where we create the agent accounts, contact flows, routing profile etc. Use “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_instance">aws_connect_instance</a>” resource from terraform registry to create an instance.</li><li><strong>Phone Number</strong>: To use voice service in amazon connect, a phone number need to be claimed. Latest version of terraform aws provider have a resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_phone_number">aws_connect_phone_number</a>” to claim a phone number.</li><li><strong>Queues: </strong>A queue is used to hold the customers waiting to be answered by agents. There can be one or multiple queues based on logical division of answering a the call. A terraform resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_queue">aws_connect_queue</a>” is used to provision queue in connect.</li><li><strong>Routing Profile: </strong>Routing profile is used to decide, how a customer from a queue will be connected to a agent. A terraform resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_routing_profile">aws_connect_routing_profile</a>” is used to provision queue in connect.</li><li><strong>Hours of operation:</strong> This specifies the hour of operation for a queue. Multiple hours of operation can be created. While creating a queue, hours of operation must be specified. A terraform resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_hours_of_operation">aws_connect_hours_of_operation</a>” is available to provision hours of operation resource.</li><li><strong>Contact Flows: </strong>Contact flow creates a end to end flow through which customer will go through for the contact center. It can have voice, chat, wisdom and tasks, which make the contact center more efficient. A terraform resource “<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_contact_flow">aws_connect_contact_flow</a>” is available to provision hours of contact flow resource.</li></ol><h4>Lets build a terraform module for Amazon Connect end to end contact center.</h4><p>Pre-requisites:</p><ol><li>AWS CLI and Terraform installed</li><li>Basic understanding of terraform</li><li>AWS credential configured.</li></ol><p><strong>providers.tf:</strong></p><p>Create a prodiver terraform file with the below content:</p><pre>terraform {</pre><pre>    required_providers {</pre><pre>       aws = {</pre><pre>          source  = &quot;hashicorp/aws&quot;</pre><pre>          version = &quot;4.38.0&quot;</pre><pre>     }</pre><pre>   }</pre><pre> }</pre><pre>provider &quot;aws&quot; {</pre><pre>    region = &quot;us-east-1&quot;</pre><pre>}</pre><p><strong>main.tf file:</strong></p><p>Create a main.tf file in the same folder. This file will contain all the connect resources.</p><p><strong>Connect Instances: </strong>Add the below code block to the main.tf file, which creates a connect instances. This configuration creates a instance with CONNECT_MANAGED users, inbound/outbound calls as true and logs enables</p><pre>resource &quot;aws_connect_instance&quot; &quot;instance&quot; {<br>  identity_management_type = var.identity_management_type<br>  directory_id = var.directory_id<br>  inbound_calls_enabled    = true<br>  instance_alias           = var.instance_alias<br>  outbound_calls_enabled   = true<br>  contact_flow_logs_enabled = true<br>}</pre><p><strong>Lambda Function Association</strong>: Lambda function can be invoked within the contact flow to perform various task like getting the customer details, adding entry in dynamodb etc. Lambda function need to be associated with the connect instance to use it in the contact flows. Append the below code to the main.tf file. This will associate the lambda function to the instance.</p><pre>resource &quot;aws_connect_lambda_function_association&quot; &quot;lambda_assoc&quot; {<br>  function_arn = var.lambda_function_arn<br>  instance_id  = aws_connect_instance.instance.id<br>}</pre><p><strong>Hours of operation: </strong>Append the below code to the main.tf file which will provision hours of operation with Monday and Tuesday with the working day.</p><pre>resource &quot;aws_connect_hours_of_operation&quot; &quot;hours_of_operation&quot; {<br>  instance_id = aws_connect_instance.instance.id<br>  name        = &quot;${var.common_name} Office Hours&quot;<br>  description = &quot;Demo Test Office Hours&quot;<br>  time_zone   = &quot;EST&quot;</pre><pre>  config {<br>    day = &quot;MONDAY&quot;</pre><pre>    end_time {<br>      hours   = 23<br>      minutes = 8<br>    }</pre><pre>    start_time {<br>      hours   = 8<br>      minutes = 0<br>    }<br>  }</pre><pre>  config {<br>    day = &quot;TUESDAY&quot;</pre><pre>    end_time {<br>      hours   = 21<br>      minutes = 0<br>    }</pre><pre>    start_time {<br>      hours   = 9<br>      minutes = 0<br>    }<br>  }</pre><pre> tags = {<br>    &quot;Name&quot; = &quot;${var.common_name}&quot;<br>  }<br>}</pre><p><strong>Queue: </strong>Append the below code into main.tf file. This provisions a connect queue with the hours of operation created in the pervious block.</p><pre>resource &quot;aws_connect_queue&quot; &quot;queue&quot; {<br>  instance_id           = aws_connect_instance.instance.id<br>  name                  = &quot;${var.common_name} Queue1&quot;<br>  description           = &quot;Test Queue for Terraform&quot;<br>  hours_of_operation_id = aws_connect_hours_of_operation.hours_of_operation.hours_of_operation_id</pre><pre>tags = {<br>    &quot;Name&quot; = &quot;${var.common_name} Test Queue&quot;,<br>  }<br>}</pre><p><strong>Routing Profile: </strong>Append the below code to main.tf file to provision a routing profile.</p><pre>resource &quot;aws_connect_routing_profile&quot; &quot;routing_profile&quot; {<br>  instance_id               = aws_connect_instance.instance.id<br>  name                      = var.common_name<br>  default_outbound_queue_id = aws_connect_queue.queue.queue_id<br>  description               = &quot;${var.common_name} Routing Profile&quot;</pre><pre>media_concurrencies {<br>    channel     = &quot;VOICE&quot;<br>    concurrency = 1<br>  }</pre><pre>queue_configs {<br>    channel  = &quot;VOICE&quot;<br>    delay    = 0<br>    priority = 1<br>    queue_id = aws_connect_queue.queue.queue_id<br>  }</pre><pre>tags = {<br>    &quot;Name&quot; = var.common_name,<br>  }<br>}</pre><p><strong>Security Profile: </strong>Append the below code to the main.tf file to provision a security profile. This security profile will have “BasicAgentAccess” and “OutboundCallAccess” as a permission.</p><pre>resource &quot;aws_connect_security_profile&quot; &quot;security_profile&quot; {<br>  instance_id = aws_connect_instance.instance.id<br>  name        = var.common_name<br>  description = &quot;${var.common_name} security profile&quot;</pre><pre>permissions = [<br>    &quot;BasicAgentAccess&quot;,<br>    &quot;OutboundCallAccess&quot;,<br>  ]</pre><pre>tags = {<br>    &quot;Name&quot; = &quot;${var.common_name}&quot;<br>  }<br>}</pre><p><strong>User: </strong>Append the code the main.tf file to provision a connect managed user. The user will be attached to the security profile provisioned through last block.</p><pre>resource &quot;aws_connect_user&quot; &quot;user&quot; {<br>  instance_id        = aws_connect_instance.instance.id<br>  name               = &quot;<a href="/service/mailto:bob@test.com">bob@test.com</a>&quot;<br>  password           = &quot;Password123&quot;<br>  routing_profile_id = aws_connect_routing_profile.routing_profile.routing_profile_id</pre><pre>security_profile_ids = [<br>    aws_connect_security_profile.security_profile.security_profile_id<br>  ]</pre><pre>identity_info {<br>    first_name = &quot;Bob&quot;<br>    last_name  = &quot;Test&quot;<br>  }</pre><pre>phone_config {<br>    after_contact_work_time_limit = 0<br>    phone_type                    = &quot;SOFT_PHONE&quot;<br>  }<br>}</pre><p><strong>Contact Flow: </strong>Append the below code to the main.tf file to provision a contact flow. The content of the contact flow should be in JSON format in Amazon Contact Flow language. For more information, see <a href="https://docs.aws.amazon.com/connect/latest/adminguide/flow-language.html">Amazon Connect Flow language</a> in the Amazon Connect Administrator Guide. You can extract the JSON file from the existing contact flow. Follow the …. section for the details on how to extract a JSON file from existing contact flows.</p><pre>resource &quot;aws_connect_contact_flow&quot; &quot;demo_test&quot; {<br>  instance_id  = aws_connect_instance.instance.id<br>  name         = var.common_name<br>  description  = &quot;Test Contact Flow for Terraform&quot;<br>  type         = var.contact_flow_type<br>  content     = &lt;&lt;JSON<br>{<br>    &quot;Version&quot;: &quot;2019-10-30&quot;,<br>    &quot;StartAction&quot;: &quot;4e2b5f43-8379-4b90-852b-930de11591de&quot;,<br>    &quot;Metadata&quot;: {<br>      &quot;entryPointPosition&quot;: {<br>        &quot;x&quot;: 20,<br>        &quot;y&quot;: 20<br>      },<br>      &quot;snapToGrid&quot;: false,<br>      &quot;ActionMetadata&quot;: {<br>        &quot;ac3808f0-8313-483a-ae5f-47e4acb83a53&quot;: {<br>          &quot;position&quot;: {<br>            &quot;x&quot;: 806,<br>            &quot;y&quot;: 194<br>          }<br>        },<br>        &quot;4e2b5f43-8379-4b90-852b-930de11591de&quot;: {<br>          &quot;position&quot;: {<br>            &quot;x&quot;: 196,<br>            &quot;y&quot;: 37<br>          },<br>          &quot;useDynamic&quot;: false<br>        },<br>        &quot;c2b9d7f7-36d3-4180-86aa-3f1957870e1a&quot;: {<br>          &quot;position&quot;: {<br>            &quot;x&quot;: 463,<br>            &quot;y&quot;: 38.599998474121094<br>          },<br>          &quot;dynamicMetadata&quot;: {},<br>          &quot;useDynamic&quot;: false<br>        }<br>      }<br>    },<br>    &quot;Actions&quot;: [<br>      {<br>        &quot;Identifier&quot;: &quot;ac3808f0-8313-483a-ae5f-47e4acb83a53&quot;,<br>        &quot;Type&quot;: &quot;DisconnectParticipant&quot;,<br>        &quot;Parameters&quot;: {},<br>        &quot;Transitions&quot;: {}<br>      },<br>      {<br>        &quot;Identifier&quot;: &quot;4e2b5f43-8379-4b90-852b-930de11591de&quot;,<br>        &quot;Parameters&quot;: {<br>          &quot;Text&quot;: &quot;Hello!&quot;<br>        },<br>        &quot;Transitions&quot;: {<br>          &quot;NextAction&quot;: &quot;c2b9d7f7-36d3-4180-86aa-3f1957870e1a&quot;,<br>          &quot;Errors&quot;: [<br>            {<br>              &quot;NextAction&quot;: &quot;ac3808f0-8313-483a-ae5f-47e4acb83a53&quot;,<br>              &quot;ErrorType&quot;: &quot;NoMatchingError&quot;<br>            }<br>          ],<br>          &quot;Conditions&quot;: []<br>        },<br>        &quot;Type&quot;: &quot;MessageParticipant&quot;<br>      },<br>      {<br>        &quot;Identifier&quot;: &quot;c2b9d7f7-36d3-4180-86aa-3f1957870e1a&quot;,<br>        &quot;Parameters&quot;: {<br>          &quot;LambdaFunctionARN&quot;: &quot;${var.lambda_function_arn}&quot;,<br>          &quot;InvocationTimeLimitSeconds&quot;: &quot;3&quot;<br>        },<br>        &quot;Transitions&quot;: {<br>          &quot;NextAction&quot;: &quot;ac3808f0-8313-483a-ae5f-47e4acb83a53&quot;,<br>          &quot;Errors&quot;: [<br>            {<br>              &quot;NextAction&quot;: &quot;ac3808f0-8313-483a-ae5f-47e4acb83a53&quot;,<br>              &quot;ErrorType&quot;: &quot;NoMatchingError&quot;<br>            }<br>          ],<br>          &quot;Conditions&quot;: []<br>        },<br>        &quot;Type&quot;: &quot;InvokeLambdaFunction&quot;<br>      }<br>    ]<br>  }</pre><pre>JSON<br>  tags = {<br>    &quot;Name&quot;        = &quot;${var.common_name} Contact Flow&quot;,<br>    &quot;MaintedBy&quot; = &quot;Terraform&quot;,<br>  }<br>}</pre><p><strong>variables.tf file:</strong></p><p>Create a variables.tf file which will contains all the variables used in the previous code block.</p><pre>variable &quot;instance_alias&quot; {<br>  type = string<br>  description = &quot;Alias name of the instance&quot;<br>}</pre><pre>variable &quot;identity_management_type&quot; {<br>  type = string<br>  description = &quot;Identity management type. Accepted Values: SAML , CONNECT_MANAGED, EXISTING_DIRECTORY&quot;<br>}</pre><pre>variable &quot;contact_flow_type&quot; {<br>  type = string<br>  description = &quot;Type of contact flow&quot;<br>  default = &quot;CONTACT_FLOW&quot;<br>}</pre><pre>variable &quot;common_name&quot; {<br>  type =string<br>  description = &quot;A common name of the amazon connect resources&quot;<br>}</pre><pre>variable &quot;lambda_function_arn&quot; {<br>  description = &quot;ARN of the lambda function for association with connect instance&quot;<br>}</pre><p>The module is now ready to be implemented. Lets implement it by passing in the variables. Let create a tfvars file by passing in the values. Below is the snippet of the tfvar file.</p><pre>instance_alias = &quot;demo-insurance&quot;<br>identity_management_type = &quot;CONNECT_MANAGED&quot;<br>common_name = &quot;Demo Test&quot;<br>lambda_function_arn = &quot;arn:aws:lambda:us-east-1:123456789101:function:demo-function&quot;</pre><p>Lets execute the terraform command to deploy the module.</p><ol><li>Open any terminal and switch the directory to the folder where the terraform code files exist.</li><li>Run “<em>terraform init</em>” command to initialize the aws provider.</li><li>Run “<em>terraform plan</em>” command. It will show the blueprint of what will get provisioned out of the module.</li><li>Run “<em>terraform apply -auto-approve</em>” command to deploy the module resources which will provision all the connect related resources added to the terraform files.</li></ol><h4>Conclusion</h4><p>We have seen in this blog how we can use terraform to build a reusable module to deploy end to end contact center using Amazon Connect.</p><p>Read my another blog to setup CICD pipeline to deploy this module: <a href="https://medium.com/@jkcrross/setup-ci-cd-to-provision-amazon-connect-using-terraform-cb7bcfe9bcb8">Setup CI-CD to provision Amazon Connect using Terraform</a></p><p>There are some resources in Amazon Connect which are yet not available to be deployed through Terraform. For more details on this read my another blog “<a href="https://medium.com/@jkcrross/automate-amazon-connect-terraform-or-cloudformation-4c07a3a2fd06"><strong><em>Automate Amazon Connect: Terraform or Cloudformation ?</em></strong></a>”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9249528d165" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>