<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Olivier Lemaitre</title>
    <description>The latest articles on Forem by Olivier Lemaitre (@welcloud-io).</description>
    <link>https://forem.com/welcloud-io</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1409022%2Fec6de122-1341-4108-be9d-db814fe0ea73.jpg</url>
      <title>Forem: Olivier Lemaitre</title>
      <link>https://forem.com/welcloud-io</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/welcloud-io"/>
    <language>en</language>
    <item>
      <title>Draw Full Diagrams from Simple Models with Custom Agents in Kiro</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Mon, 06 Apr 2026 16:03:59 +0000</pubDate>
      <link>https://forem.com/welcloud-io/draw-diagrams-from-models-with-custom-agents-in-kiro-13g3</link>
      <guid>https://forem.com/welcloud-io/draw-diagrams-from-models-with-custom-agents-in-kiro-13g3</guid>
      <description>&lt;p&gt;Imagine that you want to document an AWS account, a network topology, an application, etc, with a diagram. That would be a good idea, because it's certainly the best way to do it. &lt;/p&gt;

&lt;p&gt;However this can take time, especially if you have many resources to explore.&lt;/p&gt;

&lt;p&gt;Recently wondered how I could minimize this effort using my Agentic IDE.&lt;/p&gt;

&lt;p&gt;I ended drawing a simple model of what I wanted and then, with one command, asked my IDE to draw a new one with real data.&lt;/p&gt;

&lt;p&gt;In brief, I'm now able to do this kind of thing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;/draw-from-model vpc-and-subnets.model.drawio&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which I can represent this way:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8h0wb5e1deb29fktrft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8h0wb5e1deb29fktrft.png" alt=" " width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wanted to share this, and explain the phases that helped me to get there:&lt;/p&gt;

&lt;p&gt;Phase 1 - Extract data, create Model Diagram, mix both&lt;br&gt;
Phase 2 - Create Diagram Model, deduct data to extract, mix both &lt;br&gt;
Phase 3 - Do it with a custom agent: &lt;strong&gt;/draw-from-model&lt;/strong&gt;&lt;br&gt;
Phase 4 - Draw new diagrams from any model&lt;/p&gt;

&lt;p&gt;N.B.: I chose the AWS Kiro IDE, but you can apply this with another Agentic IDE as long as you can extend it with custom agents.&lt;/p&gt;
&lt;h2&gt;
  
  
  Phase 1 - Extract data, create Model Diagram, mix both
&lt;/h2&gt;

&lt;p&gt;I started with a simple approach, trying to extract the data I wanted first. Before creating a diagram model.&lt;/p&gt;
&lt;h3&gt;
  
  
  1.1 - Extract Data from the AWS Account
&lt;/h3&gt;

&lt;p&gt;So, I started to ask for a script that extracts data from my AWS account. I spotted VPC and Subnets, which are basic and easy to understand.&lt;/p&gt;

&lt;p&gt;A VPC (Virtual Private Cloud) is an isolated network that covers multiple availability zones (a data center to make things simple) in an AWS region. &lt;/p&gt;

&lt;p&gt;VPCs contain Subnets, which are subnetworks associated with an availability zone.&lt;/p&gt;

&lt;p&gt;So here is the prompt I used for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="n"&gt;script&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;extract&lt;/span&gt; &lt;span class="n"&gt;vpc&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;subnets&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;eu&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;west&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;region&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I executed the script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 vpc_subnets_eu_west_1.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And I got a file named &lt;code&gt;vpc_subnets_eu_west_1.json&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1.2 - Draw a model with drawio in your IDE
&lt;/h3&gt;

&lt;p&gt;Then I drew a model of what I wanted with an account, a VPC and multiple subnets (public and private)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswuxkg5wy1kjmsf7po68.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswuxkg5wy1kjmsf7po68.png" alt=" " width="800" height="629"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1.3 - Cross Data and Diagram Model
&lt;/h3&gt;

&lt;p&gt;Then I asked Kiro to cross the extracted data and the diagram model&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;cross #diagram.model.drawio + #vpc_subnets_eu_west_1.json and create a new diagram&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I got a new diagram...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58iexg0l5qzg6e4d7d5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58iexg0l5qzg6e4d7d5l.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not bad at all...I verified on my account and that was exact!&lt;/p&gt;

&lt;h2&gt;
  
  
  Phase 2: Create Diagram Model, deduct data to extract, mix both
&lt;/h2&gt;

&lt;p&gt;Then I thought, maybe we can ask the LLM directly to deduct the data I need from the diagram model. That's what I tried.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Use the model diagram to deduct data to extract
&lt;/h3&gt;

&lt;p&gt;Actually, the data that I want to extract are in the model. So, why should  I specify the data in the prompt forehand and take the risk of forgetting something?&lt;/p&gt;

&lt;p&gt;So, I started to ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;from #diagram.model.drawio generate a python script to extract necessary data from aws account if I want to create an equivalent diagram &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That created another script to extract the data (the same kind of script I created earlier)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; python3 extract_vpc_diagram_data.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is a file name &lt;code&gt;diagram_data.json&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Crossing data and diagram model
&lt;/h3&gt;

&lt;p&gt;Then I crossed the data and diagram again.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;cross #diagram.model.drawio + #diagram_data.json and create a new diagram&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And obtained this diagram:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1kwhk3ds12wkvci2ev8b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1kwhk3ds12wkvci2ev8b.png" alt=" " width="800" height="808"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The layout is a bit different, but the content is similar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Phase 3 - Do it with a custom agent: &lt;strong&gt;/draw-from-model&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;With Kiro, you can create what we call "custom agents", they are files where you can write a workflow of actions (like a shell script in natural language).&lt;/p&gt;

&lt;p&gt;Then this helper can be found in the Kiro Chat interface, thanks to the dash bar ('/').&lt;/p&gt;

&lt;p&gt;For example you can create a &lt;strong&gt;/draw-from-model&lt;/strong&gt; custom agent, taking a model as a parameter, that executes exactly what I did with multiple prompts previously.&lt;/p&gt;

&lt;p&gt;You can write it manually or generate one with this kiro helper &lt;em&gt;/custom-agent-creator&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiux91rhwb1e7znmwl5av.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiux91rhwb1e7znmwl5av.png" alt=" " width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I tried it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;/custom-agent-creator using this context create a custom agent does this steps (extract data from diagram, draw new diagram). Keep custom agent as simple as possible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the result, which actually contains the previous prompt I used, more or less.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faegtxn6zk5tvoye484am.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faegtxn6zk5tvoye484am.png" alt=" " width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And now I can use it in my IDE chat box:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjxoxc7ls83szxfxdj4qt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjxoxc7ls83szxfxdj4qt.png" alt=" " width="800" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;/draw-from-model diagram.model.drawio&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frh8eqid2te1and3gcw0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frh8eqid2te1and3gcw0d.png" alt=" " width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result is similar to what I got previously:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpghrl3x1q8macimdecw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpghrl3x1q8macimdecw.png" alt=" " width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Phase 4 - Draw new diagrams from any model
&lt;/h2&gt;

&lt;p&gt;Then I thought, let's try with a brand new model, with different resources.&lt;/p&gt;

&lt;p&gt;So, I redrew my diagram model asking for API gateways and their integrations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3u0qgmnscm49mh62khi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3u0qgmnscm49mh62khi.png" alt=" " width="800" height="921"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I used my custom agent:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;/draw-from-model diagram.model.drawio&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxmczzqax22lpxx9nvon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxmczzqax22lpxx9nvon.png" alt=" " width="800" height="1018"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not bad at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;LLM are obviously good at crossing data, in this case I wanted to cross network and subnets data from my AWS account with a network and subnets diagram model.&lt;/p&gt;

&lt;p&gt;Then I thought we could extract what I wanted directly from the diagram. It's like I was using my diagram as a query language :)&lt;/p&gt;

&lt;p&gt;Then I took advantage of custom agents to create a helper that I can use from my IDE chat, with any model.&lt;/p&gt;

&lt;p&gt;It's a very nice and promising discovery. It might need some more tests and improvements, but I think I will use it quite often in the future!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>diagrams</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Will I lose my job because of GenAI?</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Tue, 31 Mar 2026 05:32:32 +0000</pubDate>
      <link>https://forem.com/welcloud-io/will-i-lose-my-job-because-of-genai-3pfm</link>
      <guid>https://forem.com/welcloud-io/will-i-lose-my-job-because-of-genai-3pfm</guid>
      <description>&lt;p&gt;Will I lose my job soon? Will my job be replaced by GenAI Agents?&lt;/p&gt;

&lt;p&gt;Many developers (and other professionals) might have that question in mind today.&lt;/p&gt;

&lt;p&gt;To be honest, I don't have the answer to these questions, but that sounds really weird to me when I hear or read that software developers have no future.&lt;/p&gt;

&lt;p&gt;I believe that depends on how we define the developer job.&lt;/p&gt;

&lt;p&gt;Of course, if you are the kind of developer who expects to be given the input and the output of a function and only writes the code inside it...you are dead!&lt;/p&gt;

&lt;p&gt;But, I hope a large majority of developers do more than that today!!!&lt;/p&gt;

&lt;p&gt;If not, they will have to augment their skills. And the good news is that GenAI will help them learn faster!&lt;/p&gt;

&lt;p&gt;Then, maybe, we should stop talking about developers, &lt;strong&gt;but software architects or software engineers&lt;/strong&gt; (who should have coding skills of course - but not only).&lt;/p&gt;

&lt;p&gt;This diagram illustrates this evolution, where developers become software architects / engineers, building more complex applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxd6id917n3cbrkmu7y88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxd6id917n3cbrkmu7y88.png" alt=" " width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's say that a job can be threatened when someone has the choice between asking to a human (slow and expensive) compared to asking to an AI Agent (cheap and fast).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Therefore, can we replace a software engineers with GenAI Agents?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Again I don't have a definitive answer, but my gut feeling is that it will be difficult for COMPLEX applications, which is more and more the norm in many companies. &lt;/p&gt;

&lt;p&gt;Maybe, I'll be worried the day when all companies around the world will have all the same infrastructure, all the same programming language, all the same database engine, all the same application framework, ...&lt;/p&gt;

&lt;p&gt;But this is not the trend I see.&lt;/p&gt;

&lt;p&gt;Applications require more and more sophistication: Event Driven Architecture, Distributed Databases, Micro-Services, Data Lakes, etc...&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;I think because &lt;strong&gt;the purpose of a company is to create value (i.e. improve their customer's life)&lt;/strong&gt; and differentiate from their competitors.&lt;/p&gt;

&lt;p&gt;And &lt;strong&gt;the more you want to create value with software, the more you need it to be sophisticated&lt;/strong&gt; behind the scenes.&lt;/p&gt;

&lt;p&gt;Also, building GenAI agents for our customers will not simplify systems, I actually feel the opposite!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Therefore I'm quite optimistic for software engineers&lt;/strong&gt; in the future 😊 &lt;/p&gt;

&lt;p&gt;I hope sharing this will help people 😊&lt;/p&gt;

</description>
      <category>genai</category>
      <category>developer</category>
      <category>career</category>
    </item>
    <item>
      <title>From Diagram to Code with Kiro CLI &amp; Claude Opus 4.6</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Tue, 10 Feb 2026 06:29:57 +0000</pubDate>
      <link>https://forem.com/welcloud-io/from-diagram-to-code-with-kiro-cli-claude-opus-46-4n0l</link>
      <guid>https://forem.com/welcloud-io/from-diagram-to-code-with-kiro-cli-claude-opus-46-4n0l</guid>
      <description>&lt;p&gt;A chalk talk is a conference session with a lot of interactivity. The speakers ask questions to the audience, draw diagrams on a whiteboard, and the audience asks questions back to the speakers.&lt;/p&gt;

&lt;p&gt;That's one of my preferred session types when I go to AWS re:Invent.&lt;/p&gt;

&lt;p&gt;Here I chose one I attended in 2025 to explore a few techniques I use with GenAI and architectural diagrams.&lt;/p&gt;

&lt;p&gt;I also took the opportunity that Claude Opus 4.6 is out and already available within Kiro CLI (an equivalent to Claude Code at AWS) to push this forward.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. From Picture to Diagram
&lt;/h1&gt;

&lt;p&gt;During a chalk talk (like that could happen in any architecture session), the AWS architecture is hand drawn.&lt;/p&gt;

&lt;p&gt;In this particular session named "Beyond micro services: Event-driven patterns for modern applications", we designed a web site backend, and for scalability reasons we wanted to use an EDA (Event Driven Architecture) workflow to process shipment events (a parcel was shipped for example).&lt;/p&gt;

&lt;p&gt;Here is a picture I took of the architecture during the session:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw46z93vdf6wxft9ewiy1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw46z93vdf6wxft9ewiy1.jpg" alt=" " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the red path, we can see that an application calls an API gateway, then we put the ship event in an SQS queue, which is read by a Lambda function, that writes to a history DynamoDB table, and an EventBridge bus, which triggers a notification to the user via SNS.&lt;/p&gt;

&lt;h3&gt;
  
  
  The transformation prompt
&lt;/h3&gt;

&lt;p&gt;First I started kiro-cli, uploaded my photo in the IDE and chose the Claude Opus 4.6 model...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcr2ygqql36u9stonag0a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcr2ygqql36u9stonag0a.png" alt=" " width="800" height="722"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a diagram from 20251205_085619.jpg&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The result
&lt;/h3&gt;

&lt;p&gt;I obtained a nice mermaid diagram in a markdown file as you can see below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yeq7tfqxcfkjmlq2cog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yeq7tfqxcfkjmlq2cog.png" alt="Architecture-1-Mermaid" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mermaid is a diagram as code notation that allows describing diagrams with text. &lt;/p&gt;

&lt;p&gt;However, I prefer to use Drawio because I can easily add modifications in my diagram with my mouse using &lt;a href="https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio" rel="noopener noreferrer"&gt;Drawio Extension&lt;/a&gt; in &lt;a href="https://kiro.dev/" rel="noopener noreferrer"&gt;Kiro-IDE&lt;/a&gt; (an IDE based on VSCode open source extension, maintained by AWS).&lt;/p&gt;

&lt;p&gt;So, I asked&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a drawio diagram from architecture-diagram.md using 2025 icons&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which gave me this result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4mdcyg44n7hpnn7q4y8s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4mdcyg44n7hpnn7q4y8s.png" alt="Architecture-1-DrawIO" width="800" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B.: I could also ask to directly generate a Drawio diagram from the picture.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. From Picture to Diagram - Second Version
&lt;/h2&gt;

&lt;p&gt;Then during the chat talk, after some discussions we made this architecture evolve.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0xhah6bx3wxtj8xghwl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0xhah6bx3wxtj8xghwl.jpg" alt=" " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, I uploaded another picture and asked the same kind of questions which created another Drawio diagram of the architecture:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a drawio diagram from architecture-diagram-v2.md using 2025 icons&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthbljifno1y0xziefoa8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthbljifno1y0xziefoa8.png" alt="Architecture-2-Drawio" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Why did we update the initial architecture?
&lt;/h1&gt;

&lt;p&gt;You may ask yourself, why did we change our minds?&lt;/p&gt;

&lt;p&gt;This is quite common in design and architecture, the first idea that comes to mind is not always the best one, even if you have a lot of people in the room😊&lt;/p&gt;

&lt;h3&gt;
  
  
  Simply ask Kiro why we replaced a part of the diagram
&lt;/h3&gt;

&lt;p&gt;If it's not obvious (and it's not for a lot of people) you can simply ask kiro-cli.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why Event Driven Shipping flow has a better architecture in architecture-diagram-v2.drawio than in architecture-diagram-v1.drawio?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer was quite impressive because that's exactly the reason why we changed our mind during the chalk talk, here is a chunk of the LLM answer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The Lambda only writes to DynamoDB. The event propagation happens automatically through the stream and pipe.

Here's why that matters across several architectural characteristics:

1. Data Consistency (the biggest win)
- v1: If the Lambda writes to DynamoDB but the put_events call to EventBridge fails (timeout, throttle, transient error), you have data in DynamoDB but no event was published. Consumers never learn about the shipping update. The system is in an inconsistent state.
- v2: The Lambda does a single write. The DynamoDB Stream guarantees that every successful write produces a stream record. EventBridge Pipes reads that stream. There's no dual-write — the event is derived from the data, not published separately.

...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The dual-write problem
&lt;/h3&gt;

&lt;p&gt;So, in brief, in the first architecture the problem is that the &lt;strong&gt;lambda writes in both Event Bridge Bus and DynamoDB Table.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's a trap we can easily fall into because technically... it works. &lt;/p&gt;

&lt;p&gt;However, as you may know, software is not 100% reliable and it can happen that you send a notification to the customer, but (due to an unexpected error) you don't write to the DynamoDB table. That means that you will have an inconsistent state in your system.&lt;/p&gt;

&lt;p&gt;For example, your customer might receive an information and your customer support team doesn't see the same information. That will make things confusing for your users if they have to talk to each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's the 'dual-write' problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the picture below we have that dual-write (the lambda writes in DynamoDB and Event Bridge)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdbnqp4mq0vpovquou13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdbnqp4mq0vpovquou13.png" alt=" " width="381" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solving dual-write problem
&lt;/h3&gt;

&lt;p&gt;In the picture below we have NO dual-write (the lambda writes in the DynamoDB table only)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fya1wj5rz42xlclgk9ckk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fya1wj5rz42xlclgk9ckk.png" alt=" " width="457" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The solution is to write the message in one place only, not more. In this case the user will receive a notification only if each step of the process was successful.&lt;/p&gt;

&lt;p&gt;That's why we added a DynamoDB Stream, and an EventBridge Pipe that can pull messages from the DynamoDB Stream and write to the Event Bridge Bus (EventBridge Pipes avoid maintaining a lambda for that).&lt;/p&gt;

&lt;p&gt;N.B.: For EDA experts, later in the chalk talk we added a dead letter to store the failing messages.&lt;/p&gt;

&lt;h1&gt;
  
  
  From diagram to code
&lt;/h1&gt;

&lt;p&gt;A technique I find very useful is to generate the CDK (Cloud Development Kit) code from my diagrams.&lt;/p&gt;

&lt;p&gt;The generated CDK code can be executed in order to build a template that can be deployed to AWS CloudFormation (an Infrastructure as Code Engine), which atomically creates all the components on AWS. You can find more about this &lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's super powerful. &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create a Kiro steering file
&lt;/h3&gt;

&lt;p&gt;So, First I created a steering (i.e. rule file) that I call my &lt;strong&gt;&lt;em&gt;ProfesionnalTwin&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
inclusion: always
---
&amp;lt;!------------------------------------------------------------------------------------
   Add rules to this file or a short description and have Kiro refine them for you.

   Learn about inclusion modes: https://kiro.dev/docs/steering/#inclusion-modes
-------------------------------------------------------------------------------------&amp;gt; 
- I work with python 3.10
- I work with CDK V2
- I work in AWS eu-west-1 region
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Generate code from the diagram
&lt;/h3&gt;

&lt;p&gt;Then, I used Kiro CLI and asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;architecture-diagram-v2.drawio generate "Event-Driven Shipping Flow" application&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And after a few minutes I got that kind of code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr1vz43wwqcc2ogfympo0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr1vz43wwqcc2ogfympo0.png" alt=" " width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Deploy the generated application
&lt;/h3&gt;

&lt;p&gt;I ran a 'cdk deploy' and the deployment worked right away.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9g5bo0vh0okp0vvrwhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9g5bo0vh0okp0vvrwhg.png" alt=" " width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Generate an end-to-end test
&lt;/h3&gt;

&lt;p&gt;Testing an EDA workflow is not easy, but I can rely on Kiro-CLI for that, so I asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a test that will put a message on the sqs queue and verifiy the workflow output&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It generated a test suite that I could execute to verify the workflow was working:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp7zzk1k66rg75p6gnhoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp7zzk1k66rg75p6gnhoh.png" alt=" " width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Prevent dual-write: From Characteristics to Fitness Functions
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Listing architecture characteristics
&lt;/h3&gt;

&lt;p&gt;Architecture has characteristics (security, scalability, ...), so I asked what sort of the characteristics Kiro CLI could identify in this architecture&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What architecture characteristics can I identify in my shipping flow architecture&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Architecture characteristics I can identify:

1. Scalability / Elasticity
- All components are serverless and scale independently (SQS, Lambda, DynamoDB on-demand, EventBridge)
- No provisioned capacity or concurrency caps anywhere

2. Loose Coupling
- Components communicate through events, not direct calls
- SQS decouples the upstream order management from the shipping-update Lambda
- EventBridge bus decouples the DynamoDB state change from downstream consumers (SNS, event-handler Lambda)
- Adding new consumers requires only a new EventBridge rule — no changes to producers

...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Listing fitness functions
&lt;/h3&gt;

&lt;p&gt;If you want to prevent a drift of your architecture characteristics (scalability reduction, security reduction, ...) you can use what we call "Fitness Functions".&lt;/p&gt;

&lt;p&gt;These are static or dynamic tests that will verify the compliance of your architecture with its characteristics. That's super important if you want to make your architecture evolve while minimizing risks.&lt;/p&gt;

&lt;p&gt;So, I asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What fitness functions can I create for these characteristics?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Based on the characteristics I identified, here are fitness functions you could create beyond the scalability ones you already have:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


## Loose Coupling — Static

- **EventBridge bus exists between producers and consumers** — ensures no direct Lambda-to-Lambda invocations
- **No Lambda environment variables referencing other Lambda ARNs** — proves components don't call each other directly
- **EventBridge rule count matches expected consumer count** — detects accidental tight coupling through hardcoded targets

...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Visualize your fitness functions
&lt;/h3&gt;

&lt;p&gt;To better visualize what fitness functions are and where they apply in my architecture, I simply asked Kiro&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a new Drawio diagram from architecture-diagram-v2.drawio with representation of the implemented fitness functions&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The result is an updated diagram with all the fitness functions (it's focused on scalability only in this case).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmo3nf5bsl79gck4pravb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmo3nf5bsl79gck4pravb.png" alt=" " width="800" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, for the application to be scalable we shouldn't use FIFO queues (they have limited throughput compared to standard queues), and during runtime, message age should be less than 60 seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prevent dual-write problem with a fitness function
&lt;/h3&gt;

&lt;p&gt;I asked an implementation of the previous scalability fitness functions, but I also wanted to focus on our dual-write problem.&lt;/p&gt;

&lt;p&gt;This fitness function should spot this issue in the future if someone (including me) wants to make the architecture evolve and forget about this.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What fitness function can I implement to avoid dual-write implementation?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;## Static — CDK Assertions
&lt;/span&gt;
&lt;span class="n"&gt;Lambda&lt;/span&gt; &lt;span class="n"&gt;functions&lt;/span&gt; &lt;span class="n"&gt;have&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;most&lt;/span&gt; &lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;write&lt;/span&gt; &lt;span class="n"&gt;permission&lt;/span&gt; &lt;span class="err"&gt;—&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;Lambda&lt;/span&gt; &lt;span class="n"&gt;has&lt;/span&gt; &lt;span class="n"&gt;grant_write_data&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;DynamoDB&lt;/span&gt; &lt;span class="n"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;grant_put_events_to&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;EventBridge&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s a dual-write risk.

python
def test_no_lambda_dual_write():
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Lambdas must write to at most one destination — use streams/pipes for fan-out.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    template = _template()
    resources = template.find_resources(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AWS::IAM::Policy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;)

    for logical_id, resource in resources.items():
        statements = resource[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Properties&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PolicyDocument&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Statement&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;]
        write_actions = set()
        for stmt in statements:
            actions = stmt.get(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Action&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, [])
            if isinstance(actions, str):
                actions = [actions]
            for action in actions:
                if any(w in action for w in [
                    &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dynamodb:PutItem&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dynamodb:UpdateItem&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dynamodb:BatchWriteItem&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
                    &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;events:PutEvents&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
                    &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sqs:SendMessage&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
                    &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sns:Publish&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;,
                ]):
                    write_actions.add(action.split(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;)[0])

        assert len(write_actions) &amp;lt;= 1, (
            f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{logical_id} has write permissions to {write_actions} &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;
            f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;— dual-write risk. Use DynamoDB Streams + EventBridge Pipes instead.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;
        )
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is a test suite containing CDK Assertions.&lt;/p&gt;

&lt;p&gt;Actually, the test will scan my CloudFormation template and detect if the lambda is allowed to write to more than one target service.&lt;/p&gt;

&lt;p&gt;Therefore in the future if someone updates the lambda with a new target, the test will fail when executed locally or in the CI/CD pipeline.&lt;/p&gt;

&lt;h1&gt;
  
  
  Continue talking to your diagram
&lt;/h1&gt;

&lt;p&gt;There are multiple ways you can continue to use your diagram to extract some information or generate others.&lt;/p&gt;

&lt;p&gt;Here are a few examples, and I don't think I'm exhaustive here:&lt;/p&gt;

&lt;h3&gt;
  
  
  Show Architecture Patterns
&lt;/h3&gt;

&lt;p&gt;Maybe you prefer to work with EIP (Enterprise Integration Patterns), or at least identify these patterns, for a better communication or simply generalize your architecture in order to use it on another platform.&lt;/p&gt;

&lt;p&gt;Here is an example of what you can do:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Redraw a new shipping flow with Enterprise Integration Patterns&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr86aihps0y59n8z39nxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr86aihps0y59n8z39nxg.png" alt=" " width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We see for example that the shipping update lambda function is a 'Message Translator', EventBridge a 'Publish/Subscribe Channel', ...&lt;/p&gt;

&lt;h3&gt;
  
  
  Show Architecture Constructs
&lt;/h3&gt;

&lt;p&gt;Having a monolithic piece of code to describe your architecture can have some advantages, but for reuse purposes you might want to split this into modules called CDK Constructs in the CDK vocabulary.&lt;/p&gt;

&lt;p&gt;You can ask for some help from Kiro for this&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a new drawio diagram from architecture-diagram-v2.drawio with well defined constructs&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fusdhtpd1nq87ky64amho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fusdhtpd1nq87ky64amho.png" alt=" " width="800" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you can adjust this diagram to your needs and ask Kiro to update your CDK code from your Diagram.&lt;/p&gt;

&lt;h3&gt;
  
  
  Compute Architecture Cost
&lt;/h3&gt;

&lt;p&gt;Another way you can use your diagram is to estimate the cost of your architecture.&lt;/p&gt;

&lt;p&gt;In order to be accurate, I installed the &lt;a href="https://awslabs.github.io/mcp/servers/aws-pricing-mcp-server" rel="noopener noreferrer"&gt;AWS Pricing MCP Server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I asked &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;architecture-diagram-v2.drawio how much would this shipping flow cost with 10000 events per hour&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I got a report with the cost breakdown&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbazgsus0w3yii1w48ul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbazgsus0w3yii1w48ul.png" alt=" " width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Chalk Talks are really interesting and fun. The one I'm talking about in this blog post was the opportunity to learn more about AWS Services and Event Driven Architecture (EDA).&lt;/p&gt;

&lt;p&gt;That was also the opportunity to explore the Kiro CLI capabilities with pictures &amp;amp; diagrams. Especially with the new Claude Opus 4.6 (I guess with can get quite similar results with Claude Sonnet 4.5 by the way).&lt;/p&gt;

&lt;p&gt;That led me to explore more techniques, like asking why an architecture is better than another one. Then list architecture characteristics, generate fitness functions, and prevent from architecture flaws in the future (the dual-write problem in this case).&lt;/p&gt;

&lt;p&gt;When I see all these possibilities, I really feel that we'll be able to build more sophisticated software more easily and software architect jobs will get more and more exciting!&lt;/p&gt;

</description>
      <category>genai</category>
      <category>diagram</category>
      <category>architecture</category>
      <category>kiro</category>
    </item>
    <item>
      <title>Create a Professional Certification Quiz with Kiro</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Sun, 11 Jan 2026 15:23:41 +0000</pubDate>
      <link>https://forem.com/welcloud-io/create-a-professional-certification-quiz-with-kiro-l02</link>
      <guid>https://forem.com/welcloud-io/create-a-professional-certification-quiz-with-kiro-l02</guid>
      <description>&lt;p&gt;I hold many AWS certifications. That doesn't mean I know everything about AWS, far from that. Actually, AWS is so huge that many certification questions will test you on unknown situations. It's also difficult to have an experience with everything, especially with certifications like the &lt;a&gt;"AWS Solutions Architect professional"&lt;/a&gt; which spans tens of AWS services. &lt;/p&gt;

&lt;p&gt;Therefore, you have to prepare for your certification exams in order to "compensate" your weaknesses. The main solutions are to read the FAQs and the documentation of the services, practice them through workshops or at work, draw diagrams, take notes, follow videos on &lt;a href="https://skillbuilder.aws/" rel="noopener noreferrer"&gt;AWS Skill builder&lt;/a&gt; or &lt;a href="https://www.udemy.com/courses/search/?src=ukw&amp;amp;q=aws" rel="noopener noreferrer"&gt;Udemy&lt;/a&gt;, and train with exam-like questions on platforms like &lt;a href="https://portal.tutorialsdojo.com/courses/aws-certified-solutions-architect-professional-practice-exams/" rel="noopener noreferrer"&gt;Tutorial Dojo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The best preparation for me is a combination of all these, but the latest option (training on exam-like questions) is important. I remember how destabilized I was the first time I took an AWS certification exam. At the time (2015) we didn't have a lot of examples and I had no real techniques on how to read and answer questions.&lt;/p&gt;

&lt;p&gt;Therefore, you must be prepared to answer questions. At least, the days before taking the exam, you must train your brain to it. Especially for Professional Certifications.&lt;/p&gt;

&lt;p&gt;I recently had to renew my Solutions Architect Professional certification and I decided to use recent GenAI capabilities with AWS Kiro IDE in order to add another preparation tool and train on my weaknesses.&lt;/p&gt;

&lt;p&gt;I wanted to share this. So, here is the story.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is a Professional certification question?
&lt;/h1&gt;

&lt;p&gt;First, let's see what is a Pro Cert question.&lt;/p&gt;

&lt;p&gt;Professional Certifications are different from Associate Certifications on several aspects. They come with a combination of 4/5 services (instead one 1/2 service(s) for associate exams) which makes the questions longer and more complex. Moreover, more than one proposition can make sense sometimes, but you have to identify the less expensive solution to tick the correct answer.&lt;/p&gt;

&lt;h3&gt;
  
  
  A certification question example
&lt;/h3&gt;

&lt;p&gt;You can find &lt;strong&gt;solutions architect sample questions&lt;/strong&gt; here: &lt;a href="https://d1.awsstatic.com/training-and-certification/docs-sa-pro/AWS-Certified-Solutions-Architect-Professional_Sample-Questions.pdf" rel="noopener noreferrer"&gt;https://d1.awsstatic.com/training-and-certification/docs-sa-pro/AWS-Certified-Solutions-Architect-Professional_Sample-Questions.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's extract one of them (question 4):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;4) &lt;em&gt;A company runs a serverless mobile app that uses Amazon API Gateway, AWS Lambda functions, Amazon Cognito, and Amazon DynamoDB. During large surges in traffic, users report intermittent system failures. The API Gateway API endpoint is returning HTTP status code 502 (Bad Gateway) errors to valid&lt;br&gt;
requests.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Which solution will resolve this issue?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A)&lt;/strong&gt; Increase the concurrency quota for the Lambda functions. Configure Amazon CloudWatch to send notification alerts when the Concurrent Executions metric approaches the quota.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B)&lt;/strong&gt; Configure notification alerts for the quota of transactions per second on the API Gateway API endpoint. Create a Lambda function that will increase the quota when the quota is reached.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C)&lt;/strong&gt; Shard users to Amazon Cognito user pools in multiple AWS Regions to reduce user authentication latency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D)&lt;/strong&gt; Use DynamoDB strongly consistent reads to ensure that the client application always receives the most recent data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  One technique to answer a certification question
&lt;/h3&gt;

&lt;p&gt;Here is one technique to answer the question (N.B. I sometimes use other techniques, depending on the question, but I won't explain them here in order to keep this part short enough). &lt;/p&gt;

&lt;p&gt;So, as you may see, the question involves multiple services (4 in this case) so you have to spot the issue with the most certainty.&lt;/p&gt;

&lt;p&gt;What I do when I see this kind of question is to try to visualize things in a "pattern" (in this case a multi-tier application pattern with authentication). &lt;br&gt;
N.B.: I heavily draw diagrams when I'm preparing for a certification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmayfm4etof54dbxg9cvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmayfm4etof54dbxg9cvd.png" alt=" " width="800" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, I try to think of one possible answer without looking at the propositions. In this case I know that the bad gateway error (502) is probably an issue with the backend behind the API gateway. Probably a Lambda function issue, but I'm not completely sure at this stage.&lt;/p&gt;

&lt;p&gt;Then, I read the answers, looking for inconsistencies or non-relevant answers that sound weird to me, like this one:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;D)&lt;/strong&gt; Use DynamoDB strongly consistent reads to ensure that the client application always receives the most recent data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which says the issue is due to the lack of freshness of data (that sounds weird for a 502 error).&lt;/p&gt;

&lt;p&gt;The Cognito answer sounds weird as well&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;C)&lt;/strong&gt; Shard users to Amazon Cognito user pools in multiple AWS Regions to reduce user authentication latency.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It does not seem to be a latency issue (I would better expect a timeout in this case).&lt;/p&gt;

&lt;p&gt;So, I eliminated 2 answers, I can now make my choice among the remaining 2. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A)&lt;/strong&gt; Increase the concurrency quota for the Lambda functions. Configure Amazon CloudWatch to send notification alerts when the Concurrent Executions metric approaches the quota.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B)&lt;/strong&gt; Configure notification alerts for the quota of transactions per second on the API Gateway API endpoint. Create a Lambda function that will increase the quota when the quota is reached.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They both propose to increase a quota: should I increase the number of concurrent lambda functions or the number of API calls per second?&lt;/p&gt;

&lt;p&gt;But, if the number of PAI calls per second was reached I wouldn't get this 502 response, but rather a 429 error code. Moreover, as I explained earlier, a 502 error is an issue behind the API gateway. Therefore that confirms the issue must happen due to lambda functions, therefore I choose answer &lt;strong&gt;A)&lt;/strong&gt; with a bit of confidence.&lt;/p&gt;
&lt;h3&gt;
  
  
  Let's verify the answer to the previous question
&lt;/h3&gt;

&lt;p&gt;Let's see what the answer and explanation are from the sample questions document:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;4) &lt;strong&gt;A –&lt;/strong&gt; Amazon API Gateway will intermittently return HTTP status code 502 (Bad Gateway) errors if the AWS Lambda function exceeds its concurrency quota. &lt;strong&gt;Option B is incorrect&lt;/strong&gt; because, in this case, API Gateway would&lt;br&gt;
return a status code 429 error for too many requests. &lt;strong&gt;Option C is incorrect&lt;/strong&gt; because the errors occur during calls to the API Gateway API endpoint, not during the authentication process. &lt;strong&gt;Option D is incorrect&lt;/strong&gt; because stale data would not cause a Bad Gateway error.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ok, my reasoning wasn't too bad, even though I rarely found myself in the exact situation described in the question.&lt;/p&gt;

&lt;p&gt;N.B. : You make think that I could follow my first intuition with lambda functions and answer &lt;strong&gt;A)&lt;/strong&gt; right away, but some questions can be quite subtle and I would advise to make sure you can eliminate other responses. &lt;/p&gt;

&lt;p&gt;Of course, knowing the services (like DynamoDB) + HTTP and having some experience with those helps a lot. However, the way you read the question will also help, like identifying important words and elements that will confirm the right answers and/or discard others.&lt;/p&gt;
&lt;h3&gt;
  
  
  Can you find questions tailored to your needs?
&lt;/h3&gt;

&lt;p&gt;Of course, I don't have experience with all the services covered in the certification, and maybe I want to focus on them when I'm preparing for it (that's also a way to improve my skills in general).&lt;/p&gt;

&lt;p&gt;So, I asked myself, can I generate bespoke questions on specific services where I feel weak and answer them within an application that would look like a certification application?&lt;/p&gt;

&lt;p&gt;Then I thought, let's try to develop this with GenAI and Kiro (the new name for Amazon Q Developer)...&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 1 - Generate a GUI for the certification questions
&lt;/h1&gt;

&lt;p&gt;We can surely generate certification questions with LLMs, but first I wanted to create a little app that allows me to answer questions with something that resembles exam conditions.&lt;/p&gt;
&lt;h3&gt;
  
  
  Let's do it with Kiro... in Spec Driven Mode
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;I want a simple web application that can work locally (a web page in an IDE) that asks one certification question with 4 possible answers&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyoit0akxi0e3z4tgiq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmyoit0akxi0e3z4tgiq8.png" alt=" " width="800" height="639"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First I get a requirements.txt file containing 4 requirements that I can inspect and modify.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F626mi8wrcg32fiae6cus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F626mi8wrcg32fiae6cus.png" alt=" " width="800" height="617"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, let's keep these requirements as is, and accept them all. Then move to the design phase.&lt;/p&gt;

&lt;p&gt;The design phase gives you a document containing the application architecture and the design of the GUI components (like the HTML structure of the web page for this single page application). It's a bit like a readme for the developers of the application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e8qgx4pefbcdynacrth.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e8qgx4pefbcdynacrth.png" alt=" " width="800" height="826"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again, I can modify that and change a few things, but in this case let's directly move to the implementation phase.&lt;/p&gt;

&lt;p&gt;In the implementation phase, Kiro will generate a list of tasks. Then, I can click on "Start Task" to generate the related code (e.g. 1.1 create the index.html with container, question, 4 answer options (A-D), submit button, ...)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fti2tqmu1ixfcmopriv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fti2tqmu1ixfcmopriv.png" alt=" " width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result (that I can watch thanks to &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.live-server" rel="noopener noreferrer"&gt;Live Preview VS Code extension&lt;/a&gt;) is quite basic, but that's exactly what I want.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cgymailrkrbb0lomgp2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cgymailrkrbb0lomgp2.png" alt=" " width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now what is *&lt;em&gt;important *&lt;/em&gt; from there is to initiate a git repo so I can save the result and roll back if the next step fails or does not produce what I expect.&lt;/p&gt;

&lt;p&gt;These 3 commands in the terminal are enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "create index.html page"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I continue with the next task (CSS formatting), and in a matter of seconds I get this rendering:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadjjygnwpff52wo5likr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadjjygnwpff52wo5likr.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's nice for someone like me who is not an everyday front end developer 😊    &lt;/p&gt;

&lt;p&gt;Now, if I'm satisfied, I can commit this, or if I want to change something, I can reject it, modify the task description and regenerate.&lt;/p&gt;

&lt;p&gt;Actually, I kept it as it was, and continued to iterate this way through all tasks.&lt;/p&gt;

&lt;p&gt;After a 20 minutes or so, I got a working quiz with 4 possible answers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7ii5p9yjhsjq6aa579a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7ii5p9yjhsjq6aa579a.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which is very nice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's switch to vibe mode now...
&lt;/h3&gt;

&lt;p&gt;Now, I want to quickly improve this first result and I have 2 options: carry on with the Spec Mode or Vibe Mode.&lt;/p&gt;

&lt;p&gt;I chose Vibe mode, because my goal isn't to share this application with a team of developers, but to prototype a solution that suits my needs only.&lt;/p&gt;

&lt;p&gt;So, I asked for some improvements in vibe coding mode, like this one:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Create a questionData with 2 questions (update the logic consequently)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Again, what is important is that I can test a modification, then accept or reject it (i.e. rollback if I'm not satisfied). If I reject, I can reformulate my demand; otherwise I can commit the generated code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwzlezaammr1jyyrmc6kt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwzlezaammr1jyyrmc6kt.png" alt=" " width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a few iterations, I have an interesting application structure that accepts a list of questions and a score at the end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjypthy1b6jadfi7wa4si.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjypthy1b6jadfi7wa4si.png" alt=" " width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgza36fcrggd41er2mksl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgza36fcrggd41er2mksl.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvfkww5gplu0jom05cgf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvfkww5gplu0jom05cgf.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is exactly what I wanted to achieve first.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 2 - Populate the Quiz App with sample questions
&lt;/h1&gt;

&lt;p&gt;Now let's populate this with more interesting (professional) questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feed the quiz app using the sample question document
&lt;/h3&gt;

&lt;p&gt;For this I extracted the text from &lt;a href="https://d1.awsstatic.com/training-and-certification/docs-sa-pro/AWS-Certified-Solutions-Architect-Professional_Sample-Questions.pdf" rel="noopener noreferrer"&gt;the solutions architect professional sample questions pdf&lt;/a&gt; because Kiro doesn't read pdf directly yet.&lt;/p&gt;

&lt;p&gt;Then I asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;From #Solutions-Architect-Professional-Sample-Questions.txt create a new questionData.js (update quiz logic if necessary)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj08v1kpotwxpyy6rwt1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj08v1kpotwxpyy6rwt1c.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer questions in the generated quiz app
&lt;/h3&gt;

&lt;p&gt;That worked quite well (it even noticed when questions needed multiple answers and updated the quiz logic consequently).&lt;/p&gt;

&lt;p&gt;Here is, below, the question I took as an example in the first paragraph of this blog post:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycowwpdy22xuqlrdx4bc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycowwpdy22xuqlrdx4bc.png" alt=" " width="800" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 3 - Generate new certification questions
&lt;/h1&gt;

&lt;p&gt;This is where it becomes interesting😊.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create new questions, tailored to you needs
&lt;/h3&gt;

&lt;p&gt;Now that I have my application and data structure, let's generate/invent new questions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;replace existing questions with 5 questions having #Solutions-Architect-Professional-Sample-Questions.txt style related to api gateway, lambda, dynamoDB&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And that works. I get questions pretty close to real exam questions for a first try (I also get explanations to understand why a response is good and not the others).&lt;/p&gt;

&lt;p&gt;Maybe the level of difficulty is high here, but again this is a first try and we surely can adjust this, but personally, I like it 😊&lt;/p&gt;

&lt;p&gt;Here are the generated questions if you want to have an idea:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question 1:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fom5mxe9r76rfodklkmkh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fom5mxe9r76rfodklkmkh.png" alt=" " width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question 2:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Falnzxj7vxdvrwes3n764.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Falnzxj7vxdvrwes3n764.png" alt=" " width="800" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question 3:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7gdd4906qjzcvv9k0yd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7gdd4906qjzcvv9k0yd.png" alt=" " width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question 4:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxmvghqewactgo5h3j6hl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxmvghqewactgo5h3j6hl.png" alt=" " width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question 5:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1u4ade3aib09ue6f2bj1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1u4ade3aib09ue6f2bj1.png" alt=" " width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Score:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfb6lhrisjuw6qpwi0gd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfb6lhrisjuw6qpwi0gd.png" alt=" " width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What can we do next
&lt;/h3&gt;

&lt;p&gt;I'm sure I could go much further by specifying more context to Kiro (i.e. using Claude Opus 4.5 LLM model in my case) to generate more questions with my preferences.&lt;/p&gt;

&lt;p&gt;For example, I tried to use the &lt;a href="https://awslabs.github.io/mcp/servers/aws-documentation-mcp-server" rel="noopener noreferrer"&gt;AWS Documentation MCP Server&lt;/a&gt; that reads AWS services documentation. Actually, some certification questions are often related to some part of the documentation.&lt;/p&gt;

&lt;p&gt;But, I believe we can have something even more tailored to our specific needs, in order to make us progress faster with more fun!&lt;/p&gt;

&lt;p&gt;If you ever wanted to add improvements or test this prototype at home, here is a GitHub repo with the Kiro generated code: &lt;a href="https://github.com/welcloud-io/wio-professional-certification-quiz-generator" rel="noopener noreferrer"&gt;https://github.com/welcloud-io/wio-professional-certification-quiz-generator&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Preparing a certification can be a challenge and you need to combine multiple tools to prepare them. Training your mind with exam-like questions can be an important one.&lt;/p&gt;

&lt;p&gt;With today's GenAI we can create application quickly, at the speed of light compared to not so long ago. Kiro IDE, propose 2 approaches, Spec Driven and Vibe Coding mode to achieve this. I don't have a preference yet, even though I think Spec Driven Development might be better suited for large teams already using this kind of workflow. Anyway, what is important for me is to work in small steps whatever the choice.&lt;/p&gt;

&lt;p&gt;And even if I could rapidly create an app and generate bespoke certification questions with Kiro (which was unimaginable just 3 years ago), I have the feeling that I just scratched the surface of this! And that we can do much better! Sometimes I'm wondering if certifications (and exams in general) will still look the same in the near future!&lt;/p&gt;

&lt;p&gt;I hope that will inspire people to create quickly what they are missing in their everyday job (not only a certification quiz app). The kind of idea you thought would have taken days to build would now take a few hours to come to life. And obviously an IDE like Kiro can really help to achieve this.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>certification</category>
      <category>programming</category>
      <category>genai</category>
    </item>
    <item>
      <title>Understand how AI Agents work, with AWS Strands</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Sun, 14 Sep 2025 16:56:38 +0000</pubDate>
      <link>https://forem.com/welcloud-io/understand-how-ai-agents-work-with-aws-strands-51g6</link>
      <guid>https://forem.com/welcloud-io/understand-how-ai-agents-work-with-aws-strands-51g6</guid>
      <description>&lt;p&gt;What are AI Agents? Why are they so popular these days? What's the mechanics behind them? Do we have to learn a lot of new skills to build one?&lt;/p&gt;

&lt;p&gt;I found myself asking these same questions recently.&lt;/p&gt;

&lt;p&gt;Then I discovered Strands Agent (provided by AWS), and I found it so simple and interesting to answer all these questions that I wanted to share my discoveries here.&lt;/p&gt;

&lt;h1&gt;
  
  
  How does the world work without agents?
&lt;/h1&gt;

&lt;p&gt;I was inspired by a simple, but good example in which an agent could be useful: &lt;strong&gt;Booking a table at a restaurant online.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, let's see how you could potentially execute that workflow WITHOUT an AI agent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; You open your browser&lt;br&gt;
&lt;strong&gt;2.&lt;/strong&gt; You look for a restaurant near the place you want to go&lt;br&gt;
&lt;strong&gt;3.&lt;/strong&gt; You select some restaurants and look at the menu&lt;br&gt;
&lt;strong&gt;4.&lt;/strong&gt; You select the restaurant with your food preferences&lt;br&gt;
&lt;strong&gt;5.&lt;/strong&gt; You fill in a form (your name, date &amp;amp; time, ...)&lt;br&gt;
&lt;strong&gt;6.&lt;/strong&gt; You validate your reservation&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqo40nk57c4vzdn5dlwcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqo40nk57c4vzdn5dlwcq.png" alt=" " width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B.: Our job as engineers is to create value (i.e. make users' lives easier), and shortening workflows is a very common way to create value. Actually, AI agents can shorten workflows; that's certainly why they are valuable. So, let's explore this further.&lt;/p&gt;
&lt;h1&gt;
  
  
  What can an AI agent do?
&lt;/h1&gt;
&lt;h3&gt;
  
  
  A Simple conversation example
&lt;/h3&gt;

&lt;p&gt;With an AI agent we could imagine this conversation:&lt;/p&gt;

&lt;p&gt;&lt;u&gt;You&lt;/u&gt;      : &lt;strong&gt;What is the best restaurant serving veggie burgers in Paris?&lt;/strong&gt;&lt;br&gt;
&lt;u&gt;The Agent&lt;/u&gt;: &lt;strong&gt;Green Farmer's is the best veggie burger restaurant in Paris&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;You&lt;/u&gt;      : &lt;strong&gt;Reserve a table at Green Farmer's tomorrow at 7pm please.&lt;/strong&gt;&lt;br&gt;
&lt;u&gt;The Agent&lt;/u&gt;: &lt;strong&gt;ok, table is booked.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How is it possible?&lt;/em&gt; I don't have to make a search on the web, I don't even have to fill in a form or click on a button to validate!&lt;/p&gt;

&lt;p&gt;That's because the agent will take care of that for you.&lt;/p&gt;
&lt;h3&gt;
  
  
  The use of tools behind the scenes
&lt;/h3&gt;

&lt;p&gt;Technically, here is the generic and simplified mechanics of agents (as I understand it)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbmunnzxqa8ztoaiqi1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbmunnzxqa8ztoaiqi1l.png" alt=" " width="800" height="605"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's take a concrete example.&lt;/p&gt;
&lt;h3&gt;
  
  
  A simple addition example
&lt;/h3&gt;

&lt;p&gt;Imagine that you want to create an agent that computes additions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67nof6j9egsbdb44f7sp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67nof6j9egsbdb44f7sp.png" alt=" " width="800" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is what happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After I send my prompt "compute 1 + 1":&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1&lt;/strong&gt; - &lt;strong&gt;The agent sends the prompt to the LLM with the available tools (i.e. my add function), and the LLM answers with the tools to use if necessary (in this case it will ask using the add() tool)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2&lt;/strong&gt; - &lt;strong&gt;The agent calls the tools (in my case add(1+1)) and gets the answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3&lt;/strong&gt; - &lt;strong&gt;The agent sends the context and the tools answer, so it can create the final response (in my case 1 + 1 = 2)&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Of course, this simple addition can be done with the LLM without any tool, but only because the result is obvious and present in the model they are trained with. &lt;/p&gt;

&lt;p&gt;However if you want to compute more complex things (a sinusoidal function for example), I would recommend not to rely too much on the NON deterministic output of the LLMs :)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  A simple table booking example
&lt;/h3&gt;

&lt;p&gt;So, an LLM needs tools to do things they cannot do on their own, like computing complex things, searching the web or writing to a database for example.&lt;/p&gt;

&lt;p&gt;For instance, when we say &lt;strong&gt;"Reserve a table at Green Farmer's tomorrow at 7pm please."&lt;/strong&gt;, here is what could be the mechanic behind the scenes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjnvjdkd55l8kzgnpvug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjnvjdkd55l8kzgnpvug.png" alt=" " width="800" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this case the LLM needs a tool to book the table at the restaurant (it cannot do it on its own), that's why we have a book() tool which is actually a function that executes standard code (e.g. python).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We could also add tools to search the web or tell when is "tomorrow" (which is something an LLM will never know). &lt;/p&gt;

&lt;p&gt;In the example above, the agent process would be this one:&lt;br&gt;
&lt;strong&gt;1 - Send the prompt to the LLM specifying that a book() tool is available&lt;br&gt;
2 - Call the book() tool if the LLM answers to do so&lt;br&gt;
3 - Send the tool answer to the LLM which creates a final response&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it. So far you should have understood the basics of agents.&lt;/p&gt;
&lt;h1&gt;
  
  
  How to build an agent with Strands?
&lt;/h1&gt;

&lt;p&gt;With your new knowledge in mind, you could code your own agents from scratch.&lt;/p&gt;

&lt;p&gt;However, it's best to use a framework to handle the plumbing behind the scenes and actually AWS has it's own framework: &lt;a href="https://strandsagents.com/latest/" rel="noopener noreferrer"&gt;Strands Agents&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's take the table reservation and let's see what would be the components to declare with Strands. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fviuopcl6xowjjpzhbnru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fviuopcl6xowjjpzhbnru.png" alt=" " width="800" height="668"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Actually a Strands agent is a Python class that you initiate with 3 main parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The LLM model that you want to use (Claude4Sonnet for example)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Tool list (added the tool registry) that contains all the tools we can send the the LLM so it can make a choice&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The system prompts which defines the accurate role of the agent. For example "You are a restaurant assistant helping customers reserve a table...", to make sure it won't respond off topic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is what the Python code of a Strands AI agent could contain&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_booking&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ToolUse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ToolResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;system_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You are a restaurant assistant ...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;system_prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;system_prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;create_booking&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;delete_booking&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Reserve a table at Green Farmer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s tomorrow at 7pm please.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Now you know how to build an agent with Strands, and that's not very difficult as you may see. The difficulty resides more in the writing of the system prompt and the writing of the tools code. This is where you should focus on from my point of view.&lt;/p&gt;

&lt;h1&gt;
  
  
  Some more capabilities for agents &amp;amp; Strands
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Call external systems like databases
&lt;/h3&gt;

&lt;p&gt;Previously the "book(...)" tool was supposed to book a table at the restaurant. That could be done by calling an external API or/and writing to a database for instance.&lt;/p&gt;

&lt;p&gt;Here is a representation of a tool calling a database. This database could be any kind of database like DynamoDB, RDS MySQL, ...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk41g8wry0z2omtb4lowz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk41g8wry0z2omtb4lowz.png" alt=" " width="800" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Call remote tools with MCP (Model Context Protocol)
&lt;/h3&gt;

&lt;p&gt;Your tools (i.e your functions) can be called "locally", inside your agent process, but they can be called outside the agent process by calling a server.&lt;/p&gt;

&lt;p&gt;This server can run locally (through stdio protocol) or remotely (through streamable http protocol).&lt;/p&gt;

&lt;p&gt;We can see an MCP server like a classic http server that can communicate with an AI agent. The AI Agent can call this server to list the tools that it provides for example.&lt;/p&gt;

&lt;p&gt;Strands integrate with MCP Servers as we can see below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fll034nu03yeu719vi9ej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fll034nu03yeu719vi9ej.png" alt=" " width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Agent to Agent (A2A) with Strands
&lt;/h3&gt;

&lt;p&gt;We can imagine that an agent not only uses tools, but... other agents.&lt;/p&gt;

&lt;p&gt;These agents actually like tools, but they contain a Strand agent.&lt;/p&gt;

&lt;p&gt;We can imagine specialized agents with their own system prompts that interact with the LLM to achieve a task. For example, I can have an agent to reserve a restaurant, but also an agent to plan a trip:&lt;/p&gt;

&lt;p&gt;&lt;u&gt;You&lt;/u&gt;: &lt;strong&gt;Reserve a table at Green Farmer's tomorrow at 7pm please and show me how to get there from Gare du Nord, Paris.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Agent&lt;/u&gt;: &lt;strong&gt;ok, table is booked. Here is the best way to get there...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below is a representation of this pattern. Note that we need an "orchestrator agent" to take care of the orchestration between agents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpk0wf41sm3m0aukacgx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpk0wf41sm3m0aukacgx.png" alt=" " width="800" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B.: Strands supports the A2A protocol which runs on top of HTTP, exactly like the MCP protocol. We can, by the way, mix A2A and MCP in the same agent depending on the sophistication you need (i.e. MCP is simpler).&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy and expose your AI Agent to the world
&lt;/h3&gt;

&lt;p&gt;When you are happy with an agent, you can deploy it on a server and call it through an API.&lt;/p&gt;

&lt;p&gt;You can run the AI Agent and its tool in a Docker container (using ECS/Fargate for example) or in a Lambda function as we can see below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn43n9mxww49vsyj26kl2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn43n9mxww49vsyj26kl2.png" alt=" " width="800" height="684"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We could also do something more complex, calling tools outside the containers using MCP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpnpevti1wiqrzox2fqgs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpnpevti1wiqrzox2fqgs.png" alt=" " width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  My first AI Agent with Strands
&lt;/h1&gt;

&lt;p&gt;I couldn't resist the idea of generating a Strands agent &lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;from a Drawio Diagram with Amazon Q Developer&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;That wasn't straight forward, it's not easy to reproduce, but that was really fun and full of learnings. So I decided to share this part as well.&lt;/p&gt;

&lt;p&gt;Here is what I wanted to achieve for my first AI agent&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8ar063t95f6mirxxlwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8ar063t95f6mirxxlwe.png" alt=" " width="800" height="795"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a simple Strands AI agent. I want it to... reserve a table at a restaurant :)&lt;/p&gt;

&lt;p&gt;First I drew the diagram above and I created a rule file that I called 'ProfessionalTwin', where I describe what I use as a professional.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- I use python 3.10
- I use AWS CDK V2
- I use AWS Strands SDK for AI Agents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I asked Q developer&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;@diagram.drawio.xml generate application&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It generated the application, but introduced a few errors, and it didn't work right away, so I had to create some more files containing rules for each thing I had put in my Professional Twin file: CDKRules, PythonRules and StrandsRules.&lt;/p&gt;

&lt;p&gt;Here is, for example, what StrandsRules contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When asked to use AWS Strands SDK, here are the rules

- use lambda layer for strands packages
- install strands-agents python module in lambda layer folder
- install strands-agents-tools python module in lambda layer folder
- Strands Agent Class parameters are model, tools, system_prompt
- create rules with @tool decorator
- create a system prompt that describes the role of the agent
- use "anthropic.claude-3-haiku-20240307-v1:0" model
- Allow lambda calling bedrock with stream response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After several trials I reused: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;@diagram.drawio.xml generate application&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That gave me a URL as an output, I clicked on it, and I could start a conversation with my assistant. I then could verify my reservation in my DynamoDB table. And I didn't write or modify a single line of code!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F842uymqplsaona9hrdql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F842uymqplsaona9hrdql.png" alt=" " width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7v82l0do5bwhs6ze3h5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7v82l0do5bwhs6ze3h5w.png" alt=" " width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't get me wrong, I'm not saying we can generate everything from diagrams, but that can help bootstrap ideas.&lt;/p&gt;

&lt;p&gt;For example I had no clue how to design and build the landing page. Amazon Q Developer created this in a few seconds!&lt;/p&gt;

&lt;p&gt;Now I can iterate on this code.&lt;/p&gt;

&lt;p&gt;I shared &lt;a href="https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer/tree/main/tutorials/tutorial-generated-examples/strands-ai-agent-diagram-and-rules" rel="noopener noreferrer"&gt;the code generation result in a GitHub repo&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You can also follow &lt;a href="https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer/blob/main/tutorials/TUTORIALS.md#81-generate-strands-ai-agent-from-diagram" rel="noopener noreferrer"&gt;this little tutorial&lt;/a&gt; and try to make a generation on your side, improve it or just review and deploy the generated result.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Are AI Agents a revolution? Are they great? If so, why?&lt;/p&gt;

&lt;p&gt;From the value creation perspective that seems to offer great perspective and that should shorten many processes. Combined with voice that should be impressive. And I clearly understand the enthusiasm around this.&lt;/p&gt;

&lt;p&gt;From the technical point of view, I tend to think AI agents are traditional servers using the power of LLMs to process a query. That's one more component in the architecture. &lt;/p&gt;

&lt;p&gt;Moreover, it's a NON-deterministic component that can have unexpected behaviors sometimes. That comes with a lot of technical questions and some challenges as well. &lt;/p&gt;

&lt;p&gt;I guess a framework like Strands can really help answer some of them. I'm personally a big fan of its simplicity. That's a great discovery! &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you want to practice and understand more about AI Agents, I warmly recommend this workshop : &lt;a href="https://catalog.us-east-1.prod.workshops.aws/workshops/33f099a6-45a2-47d7-9e3c-a23a6568821e/en-US" rel="noopener noreferrer"&gt;Getting Started with Strands Agents&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>ai</category>
      <category>genai</category>
      <category>aws</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Building and Using MCP Servers in Amazon Q CLI</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Sun, 04 May 2025 17:21:35 +0000</pubDate>
      <link>https://forem.com/welcloud-io/building-and-using-mcp-servers-in-amazon-q-cli-3im</link>
      <guid>https://forem.com/welcloud-io/building-and-using-mcp-servers-in-amazon-q-cli-3im</guid>
      <description>&lt;p&gt;What is an MCP server? Even if you know that MCP stands for Model Context Protocol, that's no that obvious to understand or see the benefits, at least for me.&lt;/p&gt;

&lt;p&gt;I thought the best way to figure this out was to build one. so I started to build the simplest MCP server possible and play with it. After that, I used an existing open source MCP server to understand more.&lt;/p&gt;

&lt;h1&gt;
  
  
  1) The simplest MCP Server
&lt;/h1&gt;

&lt;p&gt;I could ask Amazon Q (or an LLM like Anthropic Claude) to build the simplest MCP server for me, but I didn't get satisfying answers. It was not relevant or too complex already, so I looked for some examples with a web search engine, and I cherry picked some ideas.&lt;/p&gt;

&lt;h2&gt;
  
  
  1.1) Using FastMCP v2 to create the simplest MCP server
&lt;/h2&gt;

&lt;p&gt;I discovered that there was a python library that could handle this protocol: FastMCP v2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Little refresher:&lt;/strong&gt; a protocol is a set of rules defining how data must be formatted, transmitted, received between systems. In our case how the coding assistant based on LLM (e.g. Q Developer) must communicate with the server and how the server should answer it. &lt;/p&gt;

&lt;p&gt;FastMCP can be compared to flask for python or express for node. And like flask or express will handle an HTTP request between a web browser and remote resources (e.g. HTML pages), FastMCP will handle the communication between the LLM and the server tools (e.g. python functions).&lt;/p&gt;

&lt;p&gt;After a little exploration, I took that simple example, that we can find in the FastMCP documentation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# server.py
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastmcp&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastMCP&lt;/span&gt;

&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastMCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Demo 🚀&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@mcp.tool&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Add two numbers&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's very similar to what you would do with a flask server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello, World!&amp;lt;h1&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is that in the first case you will expose functions also called tools (e.g. the 'add' method) to your coding assistant, in the second case you will expose functions to your web browser.&lt;/p&gt;

&lt;p&gt;So, that means I can start this server locally like a flask server &lt;/p&gt;

&lt;p&gt;N.B.: I need 'fastmcp' to be installed with&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pip install fastmcp&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 server.py 
&lt;span class="o"&gt;[&lt;/span&gt;05/04/25 14:39:37] INFO     Starting server &lt;span class="s2"&gt;"Demo 🚀"&lt;/span&gt;...  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That works, but it's not "connected" with Q CLI, which is unaware of this  server.&lt;/p&gt;

&lt;h2&gt;
  
  
  1.2) Integrate the simplest MCP server with Q CLI
&lt;/h2&gt;

&lt;p&gt;Now, I want Q CLI to use my 'simplest_mcp_server', and for that I will need to initiate Q CLI with this server.&lt;/p&gt;

&lt;p&gt;The way we do that is by creating this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;~/.aws/amazonq/mcp.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the content below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"simplest-mcp-server"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"python3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"server.py"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the json file describes how to start the server, like we did above, but this time Q will start it during Q initialization.&lt;/p&gt;

&lt;p&gt;Now I start Q CLI (make sure you are in 1.9.1 version or above), and I get that result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ q
To learn more about MCP safety, see https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-security.html
✓ simplest_mcp_server loaded in 0.59 s
✓ 1 of 1 mcp servers initialized

Welcome to 

 █████╗ ███╗   ███╗ █████╗ ███████╗ ██████╗ ███╗   ██╗     ██████╗ 
██╔══██╗████╗ ████║██╔══██╗╚══███╔╝██╔═══██╗████╗  ██║    ██╔═══██╗
███████║██╔████╔██║███████║  ███╔╝ ██║   ██║██╔██╗ ██║    ██║   ██║
██╔══██║██║╚██╔╝██║██╔══██║ ███╔╝  ██║   ██║██║╚██╗██║    ██║▄▄ ██║
██║  ██║██║ ╚═╝ ██║██║  ██║███████╗╚██████╔╝██║ ╚████║    ╚██████╔╝
╚═╝  ╚═╝╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═══╝     ╚══▀▀═╝ 



╭───────────────────────── Did you know? ─────────────────────────╮
│                                                                 │
│   You can programmatically inject context to your prompts by    │
│           using hooks. Check out /context hooks help            │
│                                                                 │
╰─────────────────────────────────────────────────────────────────╯


/help all commands  •  ctrl + j new lines  •  ctrl + k fuzzy search
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the MCP server initialisation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
✓ simplest_mcp_server loaded in 0.59 s
✓ 1 of 1 mcp servers initialized
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also verify the 'add' function is in the list of tools by typing '/tools' (it's like listing the routes for a flask server)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; /tools

Tool                           Permission
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔simplest_mcp_server (MCP):
- simplest_mcp_server___add    * not trusted

Built-in:
- report_issue                 * trusted
- fs_write                     * not trusted
- execute_bash                 * trust read-only commands
- use_aws                      * trust read-only commands
- fs_read                      * trusted


Trusted tools can be run without confirmation

* Default settings

&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  1.3)Test my simplest MCP server with Q CLI
&lt;/h2&gt;

&lt;p&gt;Now when I ask Q to add 2 numbers, Q will use the 'add' function (i.e. tool):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; add 1 + 1

I'll calculate 1 + 1 for you.


🛠️  Using tool: add from mcp server simplest_mcp_server
 ⋮ 
 ● Running add with the param:
 ⋮  {
 ⋮    "arguments": {
 ⋮      "a": 1,
 ⋮      "b": 1
 ⋮    },
 ⋮    "name": "add"
 ⋮  }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:

&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It shows what it will do (i.e. call the add function) and ask if you want to execute this or not.&lt;/p&gt;

&lt;p&gt;If you are ok, you can type 'y' to trust the tool this time only. Or you can type 't' to trust it all the time (at least until you exit Q CLI).&lt;/p&gt;

&lt;p&gt;I choose 't' and I get the result of the 'add' tool&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:

&amp;gt; t

 ⋮ 
 ● Completed in 0.5s


The result of 1 + 1 is 2.

&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when I list my tools I can see my 'add' function is trusted&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; /tools

Tool                           Permission
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔simplest_mcp_server (MCP):
- simplest_mcp_server___add      trusted
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and when I ask another addition it uses the tool automatically. No question asked as you can see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; add 2 + 2

I'll calculate 2 + 2 for you.


🛠️  Using tool: add (trusted) from mcp server simplest_mcp_server
 ⋮ 
 ● Running add with the param:
 ⋮  {
 ⋮    "arguments": {
 ⋮      "a": 2,
 ⋮      "b": 2
 ⋮    },
 ⋮    "name": "add"
 ⋮  }
 ⋮ 
 ● Completed in 0.12s


The result of 2 + 2 is 4.

&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when I ask Q CLI to subtract 2 numbers it tells me it doesn't have the tool (i.e. the function) for that. Which is true because I only have one add function in my server file. However, Q can make a simple subtraction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; substract 3 - 2

I don't have a direct subtraction function available in my tools, but I can help you with this calculation.

The result of 3 - 2 is 1.

If you'd like me to perform more complex calculations or operations, please let me know!

&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For simple calculation, an MCP server is not necessary, but let see how we can use MCP servers for more specific tasks that the LLM is less good at or need more (up to date) context.&lt;/p&gt;

&lt;h1&gt;
  
  
  2) Using an existing MCP Server
&lt;/h1&gt;

&lt;p&gt;I will now use a trusted MCP server that has been developed by AWS here &lt;a href="https://github.com/awslabs/mcp/blob/main/src/aws-diagram-mcp-server/README.md" rel="noopener noreferrer"&gt;https://github.com/awslabs/mcp/blob/main/src/aws-diagram-mcp-server/README.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This MCP server will help generating diagrams with the python Diagram library. It's diagram as code, but unlike mermaid which uses static code, Diagram uses python imperative code.&lt;/p&gt;

&lt;p&gt;Then, I just follow the documentation here: &lt;a href="https://awslabs.github.io/mcp/servers/aws-diagram-mcp-server/" rel="noopener noreferrer"&gt;https://awslabs.github.io/mcp/servers/aws-diagram-mcp-server/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I update my :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.aws/amazonq/mcp.json 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"awslabs.aws-diagram-mcp-server"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"uvx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"awslabs.aws-diagram-mcp-server"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time I need 'uvx' to be installed with&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;pip install uv&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;I start q and list the tools&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;q
To learn more about MCP safety, see https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-security.html
✓ awslabsaws_diagram_mcp_server loaded &lt;span class="k"&gt;in &lt;/span&gt;2.34 s
✓ 1 of 1 mcp servers initialized

Welcome to 

 █████╗ ███╗   ███╗ █████╗ ███████╗ ██████╗ ███╗   ██╗     ██████╗ 
██╔══██╗████╗ ████║██╔══██╗╚══███╔╝██╔═══██╗████╗  ██║    ██╔═══██╗
███████║██╔████╔██║███████║  ███╔╝ ██║   ██║██╔██╗ ██║    ██║   ██║
██╔══██║██║╚██╔╝██║██╔══██║ ███╔╝  ██║   ██║██║╚██╗██║    ██║▄▄ ██║
██║  ██║██║ ╚═╝ ██║██║  ██║███████╗╚██████╔╝██║ ╚████║    ╚██████╔╝
╚═╝  ╚═╝╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═══╝     ╚══▀▀═╝ 



╭───────────────────────── Did you know? ─────────────────────────╮
│                                                                 │
│        You can use /compact to replace the conversation         │
│      &lt;span class="nb"&gt;history &lt;/span&gt;with its summary to free up the context space      │
│                                                                 │
╰─────────────────────────────────────────────────────────────────╯


/help all commands  •  ctrl + j new lines  •  ctrl + k fuzzy search
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tools

Tool                                                      Permission
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔Built-in:
- fs_write                                                &lt;span class="k"&gt;*&lt;/span&gt; not trusted
- report_issue                                            &lt;span class="k"&gt;*&lt;/span&gt; trusted
- execute_bash                                            &lt;span class="k"&gt;*&lt;/span&gt; trust read-only commands
- fs_read                                                 &lt;span class="k"&gt;*&lt;/span&gt; trusted
- use_aws                                                 &lt;span class="k"&gt;*&lt;/span&gt; trust read-only commands

awslabsaws_diagram_mcp_server &lt;span class="o"&gt;(&lt;/span&gt;MCP&lt;span class="o"&gt;)&lt;/span&gt;:
- awslabsaws_diagram_mcp_server___list_icons              &lt;span class="k"&gt;*&lt;/span&gt; not trusted
- awslabsaws_diagram_mcp_server___get_diagram_examples    &lt;span class="k"&gt;*&lt;/span&gt; not trusted
- awslabsaws_diagram_mcp_server___generate_diagram        &lt;span class="k"&gt;*&lt;/span&gt; not trusted


Trusted tools can be run without confirmation

&lt;span class="k"&gt;*&lt;/span&gt; Default settings

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I can see 3 new tools, that can be used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;list_icons&lt;/li&gt;
&lt;li&gt;get_diagram_examples&lt;/li&gt;
&lt;li&gt;generate_diagram&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then I ask&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;create a diagram from the code in this folder&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And it starts using the list_icons tool&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Now that I understand the architecture, I'll create a diagram that represents this serverless application. Based on the SAM template, we have:

1. A landing page function that serves an HTML page
2. A feedback function that records feedback in DynamoDB and sends notifications via SNS
3. A DynamoDB table for storing feedback
4. An SNS topic for email notifications


🛠️  Using tool: list_icons from mcp server awslabsaws_diagram_mcp_server
 ⋮ 
 ● Running list_icons with the param:
 ⋮  {
 ⋮    "arguments": {},
 ⋮    "name": "list_icons"
 ⋮  }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:

&amp;gt; y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, it uses the generate_diagram tool. The input argument is the Diagram python code that Q as generated. Here generate diagram means executing the python code so it creates a diagram in png format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🛠️  Using tool: generate_diagram from mcp server awslabsaws_diagram_mcp_server
 ⋮ 
 ● Running generate_diagram with the param:
 ⋮  {
 ⋮    "arguments": {
 ⋮      "code": "from diagrams import Diagram, Edge\nfrom diagrams.aws.compute import Lambda\nfrom diagrams.aws.database import Dynamodb\nfrom diagrams.aws.integration import SimpleNotificationServiceSnsTopic\nfrom diagrams.aws.network import APIGateway\nfrom diagrams.aws.general import Users\n\nwith Diagram(\"Serverless Feedback Application\", show=False, direction=\"LR\"):\n    # Define components\n    users = Users(\"Users\")\n    api = APIGateway(\"API Gateway\")\n    \n    # Lambda functions\n    landing_page = Lambda(\"Landing Page\\nFunction\")\n    feedback_function = Lambda(\"Record &amp;amp; Confirm\\nFeedback Function\")\n    \n    # Backend services\n    dynamodb = Dynamodb(\"Feedback\\nTable\")\n    sns = SimpleNotificationServiceSnsTopic(\"SNS Topic\\n(Email Notifications)\")\n    \n    # Define relationships\n    users &amp;gt;&amp;gt; api\n    api &amp;gt;&amp;gt; landing_page\n    api &amp;gt;&amp;gt; feedback_function\n    \n    feedback_function &amp;gt;&amp;gt; dynamodb\n    feedback_function &amp;gt;&amp;gt; sns",
 ⋮      "filename": "serverless_feedback_app_diagram.png",
 ⋮      "workspace_dir": "/home/olivier/wio-from-diagram-to-code-with-amazon-q-developer/_playground/vscode-app-folder"
 ⋮    },
 ⋮    "name": "generate_diagram"
 ⋮  }
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:

&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I receive that result, which is not bad.&lt;/p&gt;

&lt;p&gt;The tools (the python functions) created a new folder 'generated_diagram' and created the png file containing the diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvpsu8yzrk0k739f6xv9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvpsu8yzrk0k739f6xv9a.png" alt="Image description" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I thought, can we get a similar result WITHOUT an MCP server? And I removed my Diagram MCP server and asked&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;create a diagram with python Diagram package from the code in this folder&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I receive a quite similar result&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrt5074wok9vm5rk5nlx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrt5074wok9vm5rk5nlx.png" alt="Image description" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The difference it that it generates the python file and execute it locally (not on the server).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fpn2g8kr9yw81q2iu32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fpn2g8kr9yw81q2iu32.png" alt="Image description" width="800" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which means that, as for a simple calculation, an MCP server is not always necessary to draw a simple diagram.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to reproduce this at home
&lt;/h1&gt;

&lt;p&gt;I've created a GitHub repo with multiple starting points you can use to quickly test what I explained and more. Here are the commands to execute in VS Code.&lt;/p&gt;

&lt;h5&gt;
  
  
  Start tutorial environment
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$&amp;gt; git clone git@github.com:welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer.git

$&amp;gt; cd wio-from-diagram-to-code-with-amazon-q-developer
$&amp;gt; ./install-mcp-utils.sh # Installs uv + fatsmcp if not installed yet
$&amp;gt; ./install-q-cli.sh # Installs q cli (&amp;gt;=19.1) if not installed yet

$&amp;gt; ./start-vscode-tutorial-window.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Test simplest MCP server
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$&amp;gt; ../init-playground.sh --with-simplest-mcp-server
...
Where do you want to start from ?: 0 #Empty folder
...

$&amp;gt; cat ./simplest-mcp-server.py # Displays MCP server content
...

$&amp;gt; cat ~/.aws/amazonq/mcp.json # Displays MCP configuration
...

$&amp;gt; q
...
✓ simplest_mcp_server loaded in 1.34 s
✓ 1 of 1 mcp servers initialized
...

&amp;gt; add 1 + 1
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Test diagram MCP server
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$&amp;gt; ../init-playground.sh --with-diagram-mcp-server
...
Where do you want to start from ?: 1 #Folder with code
...

$&amp;gt; cat ~/.aws/amazonq/mcp.json # Displays MCP configuration
...

$&amp;gt; q
...
✓ awslabsaws_diagram_mcp_server loaded in 4.79 s
✓ 1 of 1 mcp servers initialized
...

&amp;gt; create a diagram from the code in this folder
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Finally, creating an MCP server that works with Q CLI is not very difficult. Using an existing MCP server is not that hard either. But, I note that we the in-house functionalities of the coding assistant can be sufficient for basic tasks. Therefore, my opinion is that MCP servers should be built or used for hard tasks that the LLM cannot deal with.&lt;/p&gt;

</description>
      <category>amazonqdeveloper</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Diagram As Prompt (or how to write less text with Amazon Q Developer CLI)</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Mon, 07 Apr 2025 17:07:39 +0000</pubDate>
      <link>https://forem.com/welcloud-io/diagram-as-prompt-or-how-to-write-less-text-with-amazon-q-developer-cli-3ca7</link>
      <guid>https://forem.com/welcloud-io/diagram-as-prompt-or-how-to-write-less-text-with-amazon-q-developer-cli-3ca7</guid>
      <description>&lt;p&gt;As an architect in the software industry, you have to first to understand the problem you have to solve (don't forget this 😉) and then find a solution.&lt;/p&gt;

&lt;p&gt;In many situations, you may have to prototype these solutions. To see if it fits well with the problem at hand or to create modules that can be used by others for example.&lt;/p&gt;

&lt;p&gt;Implementing and testing can take time, but today coding assistants based on LLM (Large Language Models) can help to generate the code you need, which is a big step forward. &lt;/p&gt;

&lt;p&gt;But still, writing good prompts with all the characteristics of your architecture isn't that intuitive and not very flexible in an exploratory phase. At least less intuitive and flexible than an architecture diagram.&lt;/p&gt;

&lt;p&gt;So, what if we could directly use a diagram to express our architecture intents, iterate on it and leave the LLM deals with the implementation?&lt;/p&gt;

&lt;p&gt;This is something I already tried, somehow, but I pushed this a bit further with Amazon Q Developer CLI. And that's what I explain in this blog post.&lt;/p&gt;

&lt;h1&gt;
  
  
  The prerequisites
&lt;/h1&gt;

&lt;p&gt;You will need VS Code with Amazon Q Developer, some extensions and &lt;strong&gt;Amazon Q CLI 1.7.2 or above&lt;/strong&gt; to make this work (Other combination of tools should be possible, but I didn't try them).&lt;/p&gt;

&lt;p&gt;You can find how to configure and use Amazon Q Developer Desktop with diagrams in this blog post: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also find how to install Amazon Q Developer CLI here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are working with Ubuntu 22.04, you can find some installation scripts &amp;amp; tutorials in this repo:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer" rel="noopener noreferrer"&gt;https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's begin this journey!&lt;/p&gt;

&lt;h1&gt;
  
  
  1) Create a simple diagram
&lt;/h1&gt;

&lt;p&gt;As explained in the introduction, the technique I describe can be useful to explore solutions to a problem.&lt;/p&gt;

&lt;p&gt;As an example here, I will explore some solutions to protect my APIs calls.&lt;/p&gt;

&lt;p&gt;So, let's first create a blank diagram &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4cxxewy7h4ti0gq0e2jo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4cxxewy7h4ti0gq0e2jo.png" alt="Image description" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then let's add the Amazon API Gateway service icon to the diagram.&lt;/p&gt;

&lt;p&gt;And since I don't need a backend to test this, let's represent a mock integration which means the API will always return the same answer.&lt;/p&gt;

&lt;p&gt;That's simple and perfect for testing purpose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gk03yl8zevd6ylom39a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gk03yl8zevd6ylom39a.png" alt="Image description" width="800" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  2) Generate code from diagram
&lt;/h1&gt;

&lt;p&gt;That's already possible with Q Desktop &amp;amp; Q CLI as shown in this 2 blog posts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/welcloud-io/talk-to-your-diagrams-with-amazon-q-developer-cli-13bc"&gt;https://dev.to/welcloud-io/talk-to-your-diagrams-with-amazon-q-developer-cli-13bc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In both blog posts, I use the same prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;can you generate application from the drawio diagram (I want the code of the lambdas to be written in python and the infrastructure as code with the python cdk v2)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, I always have to search for this prompt and then copy/paste it in the Q chat interface. And the reason why I always use the same prompt is because it gives good results, but also because python for lambdas and python CDK v2 for infrastructure is what I use at the moment.&lt;/p&gt;

&lt;p&gt;Why should I repeat that information each time? Can Q Developer simply know my preferences? &lt;/p&gt;

&lt;p&gt;And the answer is... yes! Since recently, it's possible with Amazon Q Developer Desktop and CLI (version 1.7.2)!&lt;/p&gt;

&lt;p&gt;So let's create a "Professional Twin", who will work with my habits!&lt;/p&gt;

&lt;h1&gt;
  
  
  3) Create your "Professional Twin"
&lt;/h1&gt;

&lt;p&gt;This capability is really simple to put in place, but very powerful in my opinion.&lt;/p&gt;

&lt;p&gt;At the root of your folder, you can create a specific folder (.amazonq/rules) where you can create your markdown files (.md) containing your rules.&lt;/p&gt;

&lt;p&gt;And that's what I did:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create rule folder&lt;/span&gt;
&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; .amazonq/rules

&lt;span class="c"&gt;# Create rule file&lt;/span&gt;
&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;touch&lt;/span&gt; .amazonq/rules/FROM_DIAGRAM_TO_CODE_RULES.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I edited my file, and I wrote this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When asked to generate application:
- search for the drawio diagram
- use python 3.9 for lambda code
- use python CDK V2 for infrastructure as code

If the folder contains code already, keep this code in sync with the diagram
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbasyxyf2bqyxr6npenp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbasyxyf2bqyxr6npenp.png" alt="Image description" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As usual, I express this very naively to show that it's really easy to get interesting results quickly. That was my first try by the way.&lt;/p&gt;

&lt;p&gt;However, I encourage you to tailor this kind of file carefully, and experiment your rules in order to make sure you get the best results for your use cases each time.&lt;/p&gt;

&lt;h1&gt;
  
  
  4) Generate Code from Diagram iteratively
&lt;/h1&gt;

&lt;p&gt;This is where it's becoming very interesting. &lt;/p&gt;

&lt;p&gt;Now that my rule file is created. I will iterate on my diagram while always using the same prompt in Q CLI Chat:&lt;/p&gt;

&lt;p&gt;| &lt;strong&gt;&amp;gt; generate application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's go!&lt;/p&gt;

&lt;h3&gt;
  
  
  Iteration 1: Generate code from scratch
&lt;/h3&gt;

&lt;p&gt;My folder is almost empty and only contains my diagram and my rules.&lt;/p&gt;

&lt;p&gt;In my terminal, I type&lt;/p&gt;

&lt;p&gt;| $&amp;gt; q chat&lt;/p&gt;

&lt;p&gt;And then I start to ask a first generation using the below prompt:&lt;/p&gt;

&lt;p&gt;| &lt;strong&gt;&amp;gt; generate application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhswapl06kwauhnuon717.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhswapl06kwauhnuon717.png" alt="Image description" width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the screenshot, Q takes my rules into account (my "professional twin" is working 😊)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd989tucud4yla3xc82sc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd989tucud4yla3xc82sc.png" alt="Image description" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I enter 'y' (yes) to all the Q CLI proposals, and at the end I get a folder full of files ready to be deployed!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqy0ajo0b062g4ygt0je.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqy0ajo0b062g4ygt0je.png" alt="Image description" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's what I did, I deployed the app without quitting Q chat (I use the exclamation mark '!' for this)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhvx13hny4t606cs30hn6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhvx13hny4t606cs30hn6.png" alt="Image description" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59l6ahy82nent5wsx9qu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59l6ahy82nent5wsx9qu.png" alt="Image description" width="800" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once deployed, I go to my browser and test the API URL (that was output  by Q in my CDK template)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuudy308iveqjsigxnts9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuudy308iveqjsigxnts9.png" alt="Image description" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I get this response (once again created by Q in my CDK template)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d8i1qkrbtdd04sapaye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d8i1qkrbtdd04sapaye.png" alt="Image description" width="800" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B. I didn't have to check or modify my CDK code at this point!&lt;/p&gt;

&lt;h3&gt;
  
  
  Iteration 2: Test the API Lambda Authorizer Solution
&lt;/h3&gt;

&lt;p&gt;Now, I want to test a lambda authorizer (that means something that will validate a custom API key) to protect my API.&lt;/p&gt;

&lt;p&gt;Let's start from the previous diagram...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1a1vfak5tmv83is8aq2q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1a1vfak5tmv83is8aq2q.png" alt="Image description" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and add a lambda labeled "Lambda Authorizer".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjotn6kapd5wzw304giam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjotn6kapd5wzw304giam.png" alt="Image description" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And now, let's reuse the exact same prompt&lt;/p&gt;

&lt;p&gt;| &lt;strong&gt;&amp;gt; generate application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, Q CLI proposes to keep the code in sync with the diagram&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxf8ooy4t03ci7s4pjv22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxf8ooy4t03ci7s4pjv22.png" alt="Image description" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Second, it detects that there is a difference between the diagram and the code (The lambda authorizer)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80550k1idkbyptej357k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80550k1idkbyptej357k.png" alt="Image description" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In fact, this is the behavior I expect from my "professional twin".&lt;/p&gt;

&lt;p&gt;I don't know if you have noticed earlier in my rule file, but I specified that I wanted to keep my code in sync with my diagram, here is the rule file again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;When asked to generate application:
&lt;span class="p"&gt;-&lt;/span&gt; search for the drawio diagram
&lt;span class="p"&gt;-&lt;/span&gt; use python 3.9 for lambda code
&lt;span class="p"&gt;-&lt;/span&gt; use python CDK V2 for infrastructure as code

If the folder contains code already, keep this code in sync with the diagram
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's deploy the changes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbc5eyg8jqvtg1gz9ye9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbc5eyg8jqvtg1gz9ye9i.png" alt="Image description" width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's test the url again, and this time we are not authorized because we haven't used an API key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fawnu1v9lnik78hxl7uvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fawnu1v9lnik78hxl7uvy.png" alt="Image description" width="800" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To completely verify it works, I also test this from the command line (without leaving Q CLI and using '!'). These curl commands were proposed by Q CLI chat and I just copy/pasted them.&lt;/p&gt;

&lt;p&gt;Then I can verify that I can get an API answer with a valid token, otherwise I cannot. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifj53vlyq9yebycw97ad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifj53vlyq9yebycw97ad.png" alt="Image description" width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B. I didn't have to read or change the CDK code, or the lambda code so far!&lt;/p&gt;

&lt;h3&gt;
  
  
  Iteration 3: Test a Captcha Solution
&lt;/h3&gt;

&lt;p&gt;Now let's say that I changed my mind, and I want to test a Captcha.&lt;/p&gt;

&lt;p&gt;A Captcha is another way to protect my API and make sure only humans can call it.&lt;/p&gt;

&lt;p&gt;Creating a Captcha for your API is possible with AWS WAF (Web Application Firewall) where you can configure a Captcha Rule.&lt;/p&gt;

&lt;p&gt;So, let's first let's add a WAF icon on the diagram with a label set to 'WAF with Captcha Rule"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7uc3s4mb5znvy5z54ho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7uc3s4mb5znvy5z54ho.png" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also want to remove the lambda authorizer, because for the moment I don't want to mix these protections and stay focused on Captcha only.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9x5chhs0x6yc5zcxn8i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9x5chhs0x6yc5zcxn8i.png" alt="Image description" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Moreover, I was curious to see how Q would react to this suppression...&lt;/p&gt;

&lt;p&gt;So, I used the exact same prompt again:&lt;/p&gt;

&lt;p&gt;| &lt;strong&gt;&amp;gt; generate application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihshezjz80ppfum4va4v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihshezjz80ppfum4va4v.png" alt="Image description" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And as you can see, it detects that the lambda authorizer has been removed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqsfwdsvki4v4l64063b8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqsfwdsvki4v4l64063b8.png" alt="Image description" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I deploy the code and I see that my lambda authorizer is removed as expected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpblih9s4h0oti0xqj3qe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpblih9s4h0oti0xqj3qe.png" alt="Image description" width="800" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let see if my Captcha is working by reloading my API URL.&lt;/p&gt;

&lt;p&gt;First, I can see a web page telling me it wants me to verify I am human and ask me to select a group of similar pictures.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77zndj9pexdlk1dh2yrq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77zndj9pexdlk1dh2yrq.png" alt="Image description" width="800" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then if I select the correct group it displays my API message&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feg764x4jjwaru9p225m9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feg764x4jjwaru9p225m9.png" alt="Image description" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B. I had to make a small modification of the CDK code to trigger the Captcha right away (not after n calls over 5 minutes). This is where I am thinking, that I should update my rule to "always take the simplest solution" for example. The goal is to build this professional twin bit by bit until I get the best result each time.&lt;/p&gt;

&lt;p&gt;From there, I let you imagine, that I could carry on exploring other solutions or go deeper into one of these.&lt;/p&gt;

&lt;h2&gt;
  
  
  But wait... what if I trigger Q automatically on each diagram updates?
&lt;/h2&gt;

&lt;p&gt;After all, I can generate code from diagrams, and I always use the same prompt to generate a new version of my code with &lt;code&gt;q chat&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;| &lt;strong&gt;&amp;gt; generate application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But if I wish, I can use inline prompts with &lt;code&gt;q chat&lt;/code&gt;, and accept all the proposals like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;q chat &lt;span class="nt"&gt;--accept-all&lt;/span&gt; &lt;span class="s2"&gt;"generate application"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's automate this each time I save my diagram!&lt;/p&gt;

&lt;p&gt;For that I install a watcher on my machine...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;inotify-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...and I create a watcher script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;while &lt;/span&gt;inotifywait &lt;span class="nt"&gt;-e&lt;/span&gt; modify diagram.drawio&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"File changed, executing command..."&lt;/span&gt;
    q chat &lt;span class="nt"&gt;--accept-all&lt;/span&gt; &lt;span class="s2"&gt;"generate application"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's modify my diagram, and...that works!&lt;/p&gt;

&lt;p&gt;Each time I modify my diagram I get a new version of my code, all I have to do is a 'Ctrl-S' to save my diagram.&lt;/p&gt;

&lt;p&gt;There is a little constraint though. My &lt;code&gt;q chat&lt;/code&gt; command doesn't exit at the end. So I have to do a 'Ctr-C' or 'Ctrl-D' to exit the chat and have my watcher ready to detect file changes again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxhcoeuudchja045lzof.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxhcoeuudchja045lzof.png" alt="Image description" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I thought this would be an issue, but if true in some situations, you might also want to execute some commands like &lt;code&gt;! cdk deploy&lt;/code&gt; in the chat, that can be handy then.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Expressing an architectures with diagrams is actually easier (at least for me) compared to using text. But a diagram alone is not always enough (at least for me again) to evaluate a solution.&lt;/p&gt;

&lt;p&gt;Today, I think we are approaching something very interesting with the new Amazon Q Developer features and LLM capabilities.&lt;/p&gt;

&lt;p&gt;I also still think I just scratched the surface. I know I can go much further with my "professional twin" for instance. I tried, for example, to ask Q to generate unit tests, which worked quite well, because it has also the capability to verify if these tests are working...and correct them if they aren't. I could put this in my rules as well, so it creates/updates these tests each time, because having automated tests is something important for me.&lt;/p&gt;

&lt;p&gt;Finally, I am wondering if diagrams could be the future of prompting? At least for cloud architects?&lt;/p&gt;

&lt;p&gt;It's too soon to answer, but what I'm sure of, is that this technique is useful for exploring and prototyping things quickly, create reusable components like CDK constructs, and probably more...&lt;/p&gt;

</description>
      <category>genai</category>
      <category>amazonqdeveloper</category>
      <category>diagram</category>
      <category>architecture</category>
    </item>
    <item>
      <title>q developer</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Tue, 01 Apr 2025 16:09:49 +0000</pubDate>
      <link>https://forem.com/welcloud-io/q-developer-2ea0</link>
      <guid>https://forem.com/welcloud-io/q-developer-2ea0</guid>
      <description></description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Talk to your diagrams with Amazon Q Developer CLI</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Tue, 11 Mar 2025 11:00:41 +0000</pubDate>
      <link>https://forem.com/welcloud-io/talk-to-your-diagrams-with-amazon-q-developer-cli-13bc</link>
      <guid>https://forem.com/welcloud-io/talk-to-your-diagrams-with-amazon-q-developer-cli-13bc</guid>
      <description>&lt;p&gt;CLI (Command Line Interface) is something I have been using a lot, and I prefer this to using GUI (Graphical User Interface) because it's way more flexible and powerful.&lt;/p&gt;

&lt;p&gt;For decades, when you were working in a terminal you could already start a "conversation" with your computer by typing some commands that it would respond to (with the aws cli for example). That is so true that sometimes, non technical people seeing me working like that, have the feeling that I'm talking to the computer. However, traditional CLI is quite limited if you don't give the right inputs and it has a very low intelligence when it answers.&lt;/p&gt;

&lt;p&gt;But today, with Amazon Q, you can combine the standard CLI with GenAI, which is super powerful and that's what I discovered while testing the new capabilities of Amazon Q Developer CLI agent with architecture diagrams.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Prerequisites
&lt;/h1&gt;

&lt;p&gt;There are already a lot on how to configure Amazon Q Developer desktop (not Q Developer CLI) for diagrams in this blog post: &lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But you can now add a new companion called Amazon Q for command line (Q CLI for simplicity here), which can be installed on Mac or Linux. Here is the procedure you can follow to install it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;N.B. : My installation did not integrate well right away with my VS Code terminal, so I had to use Q CLI in a separate shell window. I believe it's quite a challenge to build a solution that works everywhere and maybe my environment configuration is not standard.&lt;/p&gt;

&lt;p&gt;If you encounter any issue you can also use these blog post:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/aws/the-essential-guide-to-installing-amazon-q-developer-cli-on-linux-headless-and-desktop-3bo7"&gt;https://dev.to/aws/the-essential-guide-to-installing-amazon-q-developer-cli-on-linux-headless-and-desktop-3bo7&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/aws/the-essential-guide-to-installing-amazon-q-developer-cli-on-windows-lmh"&gt;https://dev.to/aws/the-essential-guide-to-installing-amazon-q-developer-cli-on-windows-lmh&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once installed, open a terminal, and type: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;q chat&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;then you are good to go!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9uycgwj9qhq0wbqin9q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9uycgwj9qhq0wbqin9q.png" alt="Image description" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The sample application
&lt;/h1&gt;

&lt;p&gt;I always use the same simple feedback application. This simple application records feedbacks and acknowledge they have been recorded by sending an email back to the user. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqg8envkpubw73bwmjxvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqg8envkpubw73bwmjxvv.png" alt="Image description" width="800" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code of this application is right there: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer/tree/main/tutorials-starting-points/feedback-app-code" rel="noopener noreferrer"&gt;https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer/tree/main/tutorials-starting-points/feedback-app-code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The drawio diagram of this application is right there:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer/tree/main/tutorials-starting-points/feedback-app-diagram" rel="noopener noreferrer"&gt;https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer/tree/main/tutorials-starting-points/feedback-app-diagram&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Using the code and the diagram, you can reproduce what I explained in this blog post :)&lt;/p&gt;

&lt;p&gt;N.B. This is generative AI, and results can be slightly different on your side.&lt;/p&gt;

&lt;h1&gt;
  
  
  1- Extract diagram from code
&lt;/h1&gt;

&lt;p&gt;My first idea with the Q CLI was to extract an architecture diagram of the application from the code. So, I gave the prompt below to Amazon Q CLI: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;create a file containing a mermaid diagram of this application&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And not surprisingly (even if I am always surprised it works right away :)) it generates code, ask me to approve and creates a markdown (.md) file in my folder containing a mermaid diagram (diagram as code) that I can preview!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8z96k9j8fv3sc3qeops.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8z96k9j8fv3sc3qeops.png" alt="Image description" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  2- Update the diagram
&lt;/h1&gt;

&lt;p&gt;Now that I have my application diagram I would like to change it and instead of sending an email, I want to send an SMS to the user.&lt;/p&gt;

&lt;p&gt;So I ask Q CLI: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;update this diagram so now I send an sms instead of an email&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And it proposes an update, that I can accept or not.&lt;/p&gt;

&lt;p&gt;Of course I accepted it by typing 'y' (i.e. yes) in the CLI and here  is the result: it replaces the 'Email' by 'SMS' and the 'User Email' by 'User Phone'.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxrt435fiiwyqubosozye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxrt435fiiwyqubosozye.png" alt="Image description" width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  3- Generate code from diagram
&lt;/h1&gt;

&lt;p&gt;Now I would like to generate code from a diagram. Even though it's quite common to sketch an architecture diagram before implementing it, the difference now, with GenAI, is that we can ask the generation of the infrastructure and application code from this diagram.&lt;/p&gt;

&lt;p&gt;So I started with my (always the same) draw.io diagram in a folder and I gave Q CLI my (always the same) prompt.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;can you generate application from the drawio diagram (I want the code of the lambdas to be written in python and the infrastructure as code with the python cdk v2)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I obtained complete folder structure with all I need to deploy this app!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F781a36ivayshvs6kg9wk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F781a36ivayshvs6kg9wk.png" alt="Image description" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that I say "always the same", because this is exactly the prompt I used in a previous blog post (&lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4&lt;/a&gt;) about generating code from diagrams. &lt;/p&gt;

&lt;p&gt;But, at the time, that was with Amazon Q Desktop with VS Code extension where I used the Q /dev agent or Q &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What I think is nice here, is that Q CLI combines, from my point of view, advantages of both /dev agent and the use of &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt; in VS Code Q chat extension. &lt;/p&gt;

&lt;p&gt;Actually, /dev can create or update files in your folder (what Q Desktop + &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt; doesn't do) which reduces copy/paste work.&lt;/p&gt;

&lt;p&gt;However, using &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;, which also knows about your files in the folder, streams the response in the chat and you get an answer much faster the /dev.&lt;/p&gt;

&lt;p&gt;In brief, Q CLI knows about the files in your folder (like /dev and &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;), it will write/update files in your folder (no copy/pasting needed) and it will split and stream the response (faster answers with more interactions). &lt;/p&gt;

&lt;p&gt;Note that I didn't test what was generated at this point, I made the assumption that it was working, let see later if I was too confident😊&lt;/p&gt;

&lt;h1&gt;
  
  
  4- Update and Improve my architecture
&lt;/h1&gt;

&lt;p&gt;My architecture diagram is quite simple, and everything is contained into one single CDK app with CDK Level 2 "technical" Constructs like DynamoDB, SNS, ...&lt;/p&gt;

&lt;p&gt;The Construct concept is very important in the CDK and the beauty is that you can create your own Constructs (let's say more business domain oriented, autonomous, Constructs).&lt;/p&gt;

&lt;p&gt;So I will ask Q CLI to redraw my diagram with higher abstraction Constructs (this is where I have the feeling that I can talk to my diagram through Q CLI 😊), and I wrote this prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;can you update the drawio diagram file with well defined cdk constructs?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt; &lt;em&gt;I discovered later that it's not the best prompt if you want to repeat that. Check the 'Epilogue' section at the end of this blog post to find a better one. I keep this one though, for the sake of the story.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Then it proposes some modifications, and I typed 'y' (yes) to accept them...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhqj1gv0i5hk6qllia14x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhqj1gv0i5hk6qllia14x.png" alt="Image description" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;... and the result is quite impressive to me!&lt;/p&gt;

&lt;p&gt;I obtained a new diagram with CDK Constructs tied into colored boxes and a diagram legend as you can see below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi7rqled7lmrws71pyyvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi7rqled7lmrws71pyyvq.png" alt="Image description" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that I didn't have to specify the color and legend stuff in my prompt, but I found it was a very good idea. &lt;/p&gt;

&lt;p&gt;And, by the way, when you look at the result I guess you can better understand what I mean by a CDK Constructs 😊&lt;/p&gt;

&lt;p&gt;But even better...&lt;/p&gt;

&lt;p&gt;...Q CLI naturally proposed me to change my code with these CDK Constructs, so my code and diagram are in sync!&lt;/p&gt;

&lt;p&gt;Of course, I accepted this proposal, and I got some new code proposed, what I also accepted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0esdon7tidiolotyeui.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0esdon7tidiolotyeui.png" alt="Image description" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Does this work when I deploy?
&lt;/h1&gt;

&lt;p&gt;This is an important question to me, and I was worried that, with all the stuff that had been generated, I would find a lot of errors. After all, I generated code and changed it without testing it yet (what I wouldn't recommend as a professional, but I wanted to see how far we could go 😊)&lt;/p&gt;

&lt;p&gt;So I deployed the CDK code and... I still cannot get used to it... it worked right away!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffh5v35x5qmroj1po1i7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffh5v35x5qmroj1po1i7z.png" alt="Image description" width="800" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And when I clicked on the landing page link of my application here is what I got:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6q95a2xb6nt1ir5ndy93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6q95a2xb6nt1ir5ndy93.png" alt="Image description" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did I ask for all this in my prompt? No, but the diagram contains enough information for Q to understand what the landing page could look like. That's crazy!&lt;/p&gt;

&lt;p&gt;The infrastructure code worked right away, but to be honest, with this prompt I always get a little issue. When I click on the "Submit feedback" button once deployed for the fist time, the "record feedback" URL is not accessible. The reason is this URL is missing the api stage (i.e. /prod in my case), so I have one line of code to change in the landing page HTML code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbl28y8dd41sbduaffpyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbl28y8dd41sbduaffpyl.png" alt="Image description" width="664" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, that's it... When I change that, and I submit feedback, I get this message below (again I didn't have to specify this in my prompt)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxhopp9e6rtlbh2a8r8t1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxhopp9e6rtlbh2a8r8t1.png" alt="Image description" width="800" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;... and the feed back is recorded in my DynamoDB table!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffuegpf18gc1m01oo34od.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffuegpf18gc1m01oo34od.png" alt="Image description" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Does it improve the quality of my architecture?
&lt;/h1&gt;

&lt;p&gt;As I previously wrote, CDK Constructs can help you build better abstractions of your architecture, but this might not be something obvious to do. That's where, I believe, GenAI can give you ideas.&lt;/p&gt;

&lt;p&gt;If I look at the structure of my resources with the first generation (with only technical Constructs), I get something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9bnpcyplfntn09hr19em.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9bnpcyplfntn09hr19em.png" alt="Image description" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I look at the structure of my resource with the updated generation (with abstracted Constructs), I get more something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0937lqljakxeumrperdh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0937lqljakxeumrperdh.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see a difference (even thought it's not big). In the second hierarchy, our lambda functions are grouped together in their own Construct. The other components live in their own Construct.&lt;/p&gt;

&lt;p&gt;Of course, it's far from perfect, that could be discussed, but it's a very good start with such a little effort (just one simple update prompt!).&lt;/p&gt;

&lt;p&gt;We can start to see the power of constructs however. &lt;/p&gt;

&lt;p&gt;For example, I can see there is a "FeedbackNotifications" Construct that was generated. That isolates this part (let's say this domain) of this architecture into it's own Construct. &lt;/p&gt;

&lt;p&gt;I find this interesting and more explicit than "FeedbackTopic" from the first generation, which is specifically related to Amazon SNS (Simple Notification Service).&lt;/p&gt;

&lt;p&gt;So now I can make this Construct evolve independently.&lt;/p&gt;

&lt;p&gt;For example, I can find a better way to send the feedback confirmation to my user (while keeping SNS as the point of contact with the rest of the architecture). And I could extend this Construct with another type of notification, like an SMS notification with Amazon SNS, or use an even more sophisticated services like Amazon SES or Amazon Pinpoint.&lt;/p&gt;

&lt;p&gt;I feel like I have (or more honestly Q CLI has) abstracted away this notification part and now, as it is decoupled, it can have it's own life, be tested independently, etc as explained in the Q CLI summary 😊&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcy87bmvikzdxekock4vi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcy87bmvikzdxekock4vi.png" alt="Image description" width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I could carry on talking to my diagram, and maybe ask more things. That was possible with /dev or VS Code Q extension + &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;, however I feel like we could go a step further with the Q CLI, and I am keen to carry on the experimentation and use it in my every day job!&lt;/p&gt;

&lt;p&gt;The only thing I regret, which is a detail, but however important, is that it does not integrate well with my VS Code terminal yet (probably due to my VS Code &amp;amp; O.S. configuration) so I have to use an external terminal to execute the Q CLI. But, once this will be solved, I feel like it will be a terrific tool!&lt;/p&gt;

&lt;h1&gt;
  
  
  Epilogue
&lt;/h1&gt;

&lt;p&gt;I wanted to write this epilogue, because a few days later I could easily configure my VS Code terminal with Q CLI, and that works well😊&lt;/p&gt;

&lt;p&gt;But, I retried my prompts and I didn't get always the same kind of response and behavior. Basically, GenAI is build on probability and I think that, for my first try with Q CLI, I was lucky😊&lt;/p&gt;

&lt;p&gt;Anyway, I modified one prompt and now I get very similar results each time (even if, again, GenAI is still not deterministic). And by the way, after a lot of trials I haven't reached my BuilderId free tier yet. The free tier seems quite generous so far!&lt;/p&gt;

&lt;p&gt;So, if you want to try what is in this blog post, you should first ask (and I didn't change that):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;can you generate application from the drawio diagram (I want the code of the lambdas to be written in python and the infrastructure as code with the python cdk v2)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;...and then ask (this is the prompt I changed):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;modify the drawio diagram to split the architecture diagram into well defined cdk construts (use colors and legend)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That proves prompt engineering is an important part with GenAI!&lt;/p&gt;

&lt;p&gt;Here is also a YouTube video that shows this in action 👉&lt;a href="https://www.youtube.com/watch?v=D6cYFDoX1Es" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=D6cYFDoX1Es&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Document, Test &amp; Review your code with Amazon Q Developer</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Tue, 31 Dec 2024 10:49:56 +0000</pubDate>
      <link>https://forem.com/welcloud-io/test-review-document-your-code-with-amazon-q-developer-19cf</link>
      <guid>https://forem.com/welcloud-io/test-review-document-your-code-with-amazon-q-developer-19cf</guid>
      <description>&lt;p&gt;This year, at re:Invent 2024, there were a few announcements about Amazon Q developer. Among these announcements, three new agents looked interesting to me.&lt;/p&gt;

&lt;p&gt;The first agent generates your documentation (/doc), the second agent generates your unit tests (/test) and the third agent review your code vulnerabilities (/review).&lt;/p&gt;

&lt;p&gt;They look interesting because, even if crucial in software projects, these tasks are often overlooked. And I guess you would agree that writing documentation can be tedious, writing unit tests can be discouraging, and reviewing vulnerabilities can require too much expertise... &lt;/p&gt;

&lt;p&gt;So, in this blog post, I evaluated those agents.&lt;/p&gt;

&lt;p&gt;For that, I used this simple feedback application, which records feedbacks and acknowledge they have been received by sending an email. Here is its architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhnoe2ftfvpf6o0ut018.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhnoe2ftfvpf6o0ut018.png" alt="Image description" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code I used is right there: &lt;a href="https://github.com/welcloud-io/wio-doc-test-review-with-amazon-q-developer" rel="noopener noreferrer"&gt;https://github.com/welcloud-io/wio-doc-test-review-with-amazon-q-developer&lt;/a&gt;. Everything I demo here can be reproduced from it.&lt;/p&gt;

&lt;p&gt;N.B. This is generative AI and results can be slightly different on your side.&lt;/p&gt;

&lt;h1&gt;
  
  
  /doc to document your application
&lt;/h1&gt;

&lt;p&gt;I started by creating a README.md file that wasn't existing yet in my folder.&lt;/p&gt;

&lt;p&gt;I first choose the /doc agent in the Amazon Q Chat in my IDE (you can also see the project tree that I want to document in the terminal)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0slix8i2udp6to0gizco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0slix8i2udp6to0gizco.png" alt="Image description" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then I click on "Create a Readme" button&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlh2ct4xaxp93qtscyrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlh2ct4xaxp93qtscyrb.png" alt="Image description" width="800" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Q inspect your project and once done, I accept the generated README.md, which will be created in my folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2aj47y7qtmx2l805k944.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2aj47y7qtmx2l805k944.png" alt="Image description" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result is not bad, and when I verify what has been generated... that seems correct. I don't really see any correction to apply. At least, these are very small, like adding more arguments to the CDK commands. However compared to the time I saved compared to writing this documentation on my own, it's negligible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7gfpz72px3acbge3ghg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7gfpz72px3acbge3ghg.png" alt="Image description" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, I am a bit disappointed with the diagrams and I would like to add more of them.&lt;/p&gt;

&lt;p&gt;Lets start a new documentation task:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi102p8vm4aicxpp3408s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi102p8vm4aicxpp3408s.png" alt="Image description" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, I don't create, but update the existing readme file...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxxdvbb366qq6mzr44o0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxxdvbb366qq6mzr44o0.png" alt="Image description" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...with a specific change&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk0hyw753s5z6jm3dprl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk0hyw753s5z6jm3dprl.png" alt="Image description" width="800" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I ask Q&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;add sequence diagram&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2kpfuwkhj5xj1b6g6uap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2kpfuwkhj5xj1b6g6uap.png" alt="Image description" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it naturally adds a mermaid sequence diagram, after the right section (the Data Flow section)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkquyxj3n5pmxuhnk2jbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkquyxj3n5pmxuhnk2jbw.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I accept this update, and I preview the diagram. The result is not bad at all once again, at least better than the original data flow for me.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsazbxxh6tsxd36n5scmz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsazbxxh6tsxd36n5scmz.png" alt="Image description" width="800" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I think I could add more things, but so far I understand that this agent has to be used in an iterative process. The documentation will not be generated in one go.&lt;/p&gt;

&lt;h1&gt;
  
  
  /test to test your code
&lt;/h1&gt;

&lt;p&gt;Now I want to add unit tests to my code, so I will use the new /test agent.&lt;/p&gt;

&lt;p&gt;For that I must open the file which contains the code I want to test, in my case the 'send_feedback.py'.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fnit4ywe92j8rd313h3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fnit4ywe92j8rd313h3.png" alt="Image description" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It proposes to specify a function, but since I just have only one function...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7g4solp4pz7vbu5rwl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7g4solp4pz7vbu5rwl5.png" alt="Image description" width="800" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...I directly press enter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26eav9thlxq4kz4msjw3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26eav9thlxq4kz4msjw3.png" alt="Image description" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a few seconds I can see the test suite, that will be placed in a new generated test file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fejsfm7e4xw9fdd88sgn1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fejsfm7e4xw9fdd88sgn1.png" alt="Image description" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I accept the tests...and I run them.&lt;/p&gt;

&lt;p&gt;Very quickly, after just a few modifications, they are all running (7 tests, 130 lines of code). Again, the time to fix things, compared to the time I would have needed to write these tests on my own is negligible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81hx5ke2tzjm67x2p75i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81hx5ke2tzjm67x2p75i.png" alt="Image description" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I will intentionally introduce an error and see if it's covered (therefore detected) by my new test suite. So, I select the feedback field in my table update instruction...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2m17xvoymw6jxyqkn5ln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2m17xvoymw6jxyqkn5ln.png" alt="Image description" width="800" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and remove it from the code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgm8vp8c141kjj8hvjm0k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgm8vp8c141kjj8hvjm0k.png" alt="Image description" width="800" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I run my test suite again, and here is the result: the missing field has been detected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmiq33rtqabp6v1ea8nga.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmiq33rtqabp6v1ea8nga.png" alt="Image description" width="800" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now I should be able to refactor my code safely. Pretty interesting!&lt;/p&gt;

&lt;p&gt;N.B. I tried to use /test agent on my CDK code, but the result was not as good as when I generate it with my own prompt in the chat.&lt;/p&gt;

&lt;h1&gt;
  
  
  /review to detect code issues
&lt;/h1&gt;

&lt;p&gt;Then, before committing I want to review my code, so I will use the /review agent&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2dlluwv1o153q3atb2g0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2dlluwv1o153q3atb2g0.png" alt="Image description" width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will choose review workspace to scan all my files&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd80gob567s1ig2i75qyd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd80gob567s1ig2i75qyd.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quickly, I get all the issues of my code. There is no critical issue, but one High level issue in my CDK code.&lt;/p&gt;

&lt;p&gt;It detected there is no encryption of my DynamoDB database, and spots the lines of code that are involved&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi2lm794o3bli3eskvhj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi2lm794o3bli3eskvhj.png" alt="Image description" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By clicking on the search icon of the issue, I can view the details of this weakness (CWE).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5culi3j2i4ccbadbrb0i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5culi3j2i4ccbadbrb0i.png" alt="Image description" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can also ignore this issue, or ask Q to fix it.&lt;/p&gt;

&lt;p&gt;I want to fix it. I click on the "Generate Fix" button, I take a look at the suggested code, and accept it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyo3tz3h50sh73gf1nbm5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyo3tz3h50sh73gf1nbm5.png" alt="Image description" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My code is updated, and the issue disappears from my list :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34jp6ulha6kpoqus1t0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34jp6ulha6kpoqus1t0z.png" alt="Image description" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm now more confident about deploying my code.&lt;/p&gt;

&lt;p&gt;As a next step, I can rerun the tests previously generated by /test agent, or update my test suite with new tests. I can also use /doc agent to update my readme file with what was added since last generation. That could be part of a workflow, that will increase the quality of my project :)&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Personally, I am not really looking for more agents with Amazon Q Developer. I believe we can manage a lot of things with what exists already. I don't want to feel overwhelmed, not knowing what to choose.&lt;/p&gt;

&lt;p&gt;However, I think that specialized, well defined agents like /doc, /test, /review, can incredibly increase the quality of your work and save time.&lt;/p&gt;

&lt;p&gt;They can be part of a software design workflow that you will create or re-invent :)&lt;/p&gt;

</description>
      <category>reinvent2024</category>
      <category>amazonqdeveloper</category>
      <category>development</category>
      <category>codeassistant</category>
    </item>
    <item>
      <title>Overcome startup challenges with Amazon Q Developer</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Wed, 27 Nov 2024 23:57:24 +0000</pubDate>
      <link>https://forem.com/welcloud-io/overcome-startup-challenges-with-amazon-q-developer-45j8</link>
      <guid>https://forem.com/welcloud-io/overcome-startup-challenges-with-amazon-q-developer-45j8</guid>
      <description>&lt;p&gt;I like working for startups. The main reason it that you create new things. Things that haven't been created before. The other reason is that you have a lot of freedom in your technical choices and you can choose the tools that are the most appropriate for the situation (which is not always the case in big companies).&lt;/p&gt;

&lt;p&gt;However, working for startups brings many challenges. The main one is that you want to move fast. In software that often means you have to reduce code quality. That will slow you down over time, but...you have to move fast. &lt;/p&gt;

&lt;p&gt;Another challenge is that you don't know your domain well and the problem to solve. Actually, you want to solve a problem, but you can discover that your users want to solve another problem with your product. Therefore, you might have to redesign things.&lt;/p&gt;

&lt;h1&gt;
  
  
  How Amazon Q Developer can help?
&lt;/h1&gt;

&lt;p&gt;Amazon Q Developer is a GenAI Coding assistant, provided by AWS, which generates code from a natural language description, but it's also used for code explanation, refactoring, optimizing, securing, ...&lt;/p&gt;

&lt;p&gt;As an architect, it's also a very good "architecting" assistant. It can generate code from a diagram but also a diagram from the code, which for me is a great new capability.&lt;/p&gt;

&lt;p&gt;As of today, my intuition makes me feel it's a super powerful tool to increase code quality and ease software design evolution.&lt;/p&gt;

&lt;p&gt;That's what I try to demonstrate in this article.&lt;/p&gt;

&lt;h1&gt;
  
  
  The context
&lt;/h1&gt;

&lt;p&gt;I recently worked for a very small startup, which needed to analyse videos and especially audios from these videos.&lt;/p&gt;

&lt;p&gt;This doesn't sound difficult today, but it's not trivial to implement. Especially when you start from scratch and when the application will be used by real users one week later!&lt;/p&gt;

&lt;p&gt;By chance the front end was already developed with a No Code solution, however a complete backend had to be built on AWS.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Architecture starting point
&lt;/h1&gt;

&lt;p&gt;When you start a project, people often come with a design of the solution and we can have the feeling that if you follow that solution, everything will be working well.&lt;/p&gt;

&lt;p&gt;That never happens in software!&lt;/p&gt;

&lt;p&gt;Here a simplified representation of the AWS solution that I was proposed before I started the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzgimckoma2s84je27fhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzgimckoma2s84je27fhf.png" alt="Image description" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That does not look very complicated, but I did not want to fall into a too early design trap, I decided to start with a very simple AWS backend using: serverless technologies, a lambda-lith and the AWS CDK.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fno1ilayb3ocv22p410px.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fno1ilayb3ocv22p410px.png" alt="Image description" width="780" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The Foundational Architectural Decisions
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Why serverless?
&lt;/h3&gt;

&lt;p&gt;AWS pioneered serverless technologies, and it's not only lambda functions. For instance, Amazon S3 (the AWS object storage service) is considered as serverless, because you do not manage any server. &lt;/p&gt;

&lt;p&gt;Not only you manage less servers, but you also manage less availability, less security, less scalability, less network, ... all these things are AWS's problems.&lt;/p&gt;

&lt;p&gt;That makes it an ideal choice for startups which want to move fast.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why a lambda-lith?
&lt;/h3&gt;

&lt;p&gt;Building a distributed architecture based on events can be hard, but also difficult to maintain, debug and evolve.&lt;/p&gt;

&lt;p&gt;I like the idea of "Monolith First", popularized by Martin Fowler, and I wanted to apply this to my serverless architecture, because I think it brings the same benefits.&lt;/p&gt;

&lt;p&gt;So, I started to write the algorithm in one lambda only, instead of multiple lambdas.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the AWS CDK?
&lt;/h3&gt;

&lt;p&gt;The CDK (Cloud Development Kit), is a library that helps you build infrastructure as code with imperative/Turing complete languages like python, java,... instead of declarative languages like Yaml, Json, ...&lt;/p&gt;

&lt;p&gt;That brings more possibilities, and you can build things much faster with more safety because CDK components "encapsulate" multiple low level components and best practices.&lt;/p&gt;

&lt;p&gt;Among many CDK benefits, I do not have the feeling that I spend more time playing with IAM Policies to apply least privilege principle than building my architecture.&lt;/p&gt;

&lt;p&gt;For example, when I write&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;grant_read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s3_bucket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple line of code will handle all the policy generation with just enough privileges. That saves a lot of time and brings more serenity.&lt;/p&gt;

&lt;h1&gt;
  
  
  The quick and dirty phase
&lt;/h1&gt;

&lt;p&gt;The main architecture constraint was the performance of the analysis. Therefore, I first needed to create a workflow that would be realistic enough to prove the choices were the best regarding performance. I didn't want to discover the wrong choices were made after one week of work!&lt;/p&gt;

&lt;p&gt;That's where lambda-lith is interesting because you don't focus on distribution first, you just concentrate an measure what is interesting for you. I know that distribution can increase performance, but do we need it now? I think that the old adage: "Premature performance is the root of all evil" is still relevant in the cloud!&lt;/p&gt;

&lt;p&gt;This is where I started to use Q, and asked it to help me create my Infrastructure with the CDK V2. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt; generate CDK v2 template from the draw.io diagram&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fab7oh76eiq8oe9yxldcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fab7oh76eiq8oe9yxldcq.png" alt="Image description" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I chose to use a draw.io diagram for that, because it is less text to write and give to Amazon Q. More on that in my previous article: &lt;a href="https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4"&gt;https://dev.to/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since I had a bit of algorithm to develop inside the lambdalith, I asked Amazon Q to help me.&lt;/p&gt;

&lt;p&gt;Then I tested the entire workflow and I proved we were under the expected duration.&lt;/p&gt;

&lt;h1&gt;
  
  
  Rewrite almost all code!
&lt;/h1&gt;

&lt;p&gt;When the quick and dirty phase was finished and that I could prove performance was not an issue with this architecture I decided to rewrite most of my lambda code!!!&lt;/p&gt;

&lt;p&gt;Remember I produced quick and dirty code, and leaving this code as is, was risky. After a just few days, it could have been more and more difficult to maintain or change because it's hard to code fast and keep good quality (at least it's hard for me).&lt;/p&gt;

&lt;p&gt;But actually... I didn't rewrite the code myself... I asked Q to rewrite it!&lt;/p&gt;

&lt;p&gt;I did it in 3 steps: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generate the sequence diagram from existing code&lt;/li&gt;
&lt;li&gt;Generate new code from the diagram &lt;/li&gt;
&lt;li&gt;Generate unit tests from code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Generate the sequence diagram from existing code
&lt;/h4&gt;

&lt;p&gt;First, I asked Q to create sequence diagram from my quick &amp;amp; dirty code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsg37nfju9mqno0q2lro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsg37nfju9mqno0q2lro.png" alt="Image description" width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was not perfect I had to change a few things to the sequence, but not that much.&lt;/p&gt;

&lt;p&gt;The diagram can primarily be used as a documentation. But, it can also be used for generating new things... like code and unit tests.&lt;/p&gt;

&lt;p&gt;So, let's do it!&lt;/p&gt;

&lt;h4&gt;
  
  
  Generate new code from sequence diagram
&lt;/h4&gt;

&lt;p&gt;It's not very complicated to do, you just asked Q:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate code from that mermaid diagram&lt;br&gt;
[mermaid diagram as code]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxeh8flcsbbc1q6f3c65p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxeh8flcsbbc1q6f3c65p.png" alt="Image description" width="800" height="1155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The benefit for me is that Amazon Q is a better developer than I am, and I can see a better written and a better organized code very quickly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Generate unit tests from code
&lt;/h4&gt;

&lt;p&gt;Unit tests are a simple concept, they are automated tests that you execute to make sure your code is still working after you change it.&lt;/p&gt;

&lt;p&gt;This is often something we wish we had. However, behind an apparent simplicity it's not easy to write them or to master techniques like TDD (Test Driven Development). Therefore, these tests are often overlooked.&lt;/p&gt;

&lt;p&gt;But with GenAI, you have no excuse. Generating them is easy with Q:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;write unit tests for that code&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F329hz5mc1kybvpxrq3vl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F329hz5mc1kybvpxrq3vl.png" alt="Image description" width="800" height="962"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And Q generated a lot of tests &lt;strong&gt;(4 files in total and ~ 250 lines of tests)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then I executed the generated tests. Not every test was working right away, but it took less than 1/2 h to do the fixes and make them all pass!&lt;/p&gt;

&lt;p&gt;Some tests are very interesting, for example I had to poll a third party provider, and Q generated a test to evaluate the timeout case, when after a certain number of polls you stop calling the third party provider and raise an error. &lt;/p&gt;

&lt;p&gt;That's something I wouldn't have thought about, or at least it would have taken me more time to write. And it's important because if you do not have a timeout mechanism you will consume lots of resources for probably nothing.&lt;/p&gt;

&lt;p&gt;Another interesting test is the high level test (the lambda handler test), which execute my entire workflow to detect general errors.&lt;/p&gt;

&lt;p&gt;I also completed manually this test suite with a simple integration "end to end" test, where I could put an audio file in my input bucket and verify the analysis in the output bucket, again with Amazon Q's help.&lt;/p&gt;

&lt;p&gt;So, now, my architecture looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmro7ia48a6sfgzdmgko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmro7ia48a6sfgzdmgko.png" alt="Image description" width="800" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The feedback loop &amp;amp; code refactoring
&lt;/h1&gt;

&lt;p&gt;With test harnesses you can put in place a very short feedback loop. Therefore, every change that breaks something in the workflow will be detected immediately and you can roll it back right away. &lt;/p&gt;

&lt;p&gt;What's the advantage? &lt;/p&gt;

&lt;p&gt;First, in the software development process, when you discover that something is broken one day or even one hour after the mistake was made, it's often much harder to fix it compared to fixing it when it was just introduced. Unit tests are a way to move faster.&lt;/p&gt;

&lt;p&gt;Second, without test harnesses, even simple things like renaming objects in your code, and that can happen quite often when you don't know your domain well, can become very difficult, because you fear the application will break. So you don't take the risk and leave inconsistent names, making your production harder to understand and maintain. Unit tests are a way to redesign things with more confidence.&lt;/p&gt;

&lt;h4&gt;
  
  
  Setting up your environment for a short feedback loop
&lt;/h4&gt;

&lt;p&gt;One trick I use is, each time I save a file, all my test suite is executed. With pytest I just had to install this plugin:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;pip install pytest-xdist&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, now each time I modify a file, it runs all my tests automatically, each time I make a mistake I roll back immediately.&lt;/p&gt;

&lt;p&gt;Here is an example of my test suite running when everything is green:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sojohqtcpa2biod13f7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sojohqtcpa2biod13f7.png" alt="Image description" width="800" height="655"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example when it breaks, and how it spots the issue:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foljjd2hm4iuos4opg00r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foljjd2hm4iuos4opg00r.png" alt="Image description" width="800" height="692"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The feedback is very quick, and that's very comfortable.&lt;/p&gt;

&lt;h4&gt;
  
  
  Ask Amazon Q Inline chat to refactor your code
&lt;/h4&gt;

&lt;p&gt;From my point of you, refactoring is at the heart of software development. It's very important, but almost never practiced.&lt;/p&gt;

&lt;p&gt;Refactoring is a technique where you improve the quality/evolvability of your code, without changing its behavior.&lt;/p&gt;

&lt;p&gt;Refactoring is not trivial, it takes time and requires reflection, but today you have a very good friend to help you out: Amazon Q Developer!&lt;/p&gt;

&lt;p&gt;Q Developer has an impressive feature that I use to refactor my code: Q Inline Chat.&lt;/p&gt;

&lt;p&gt;For example, I simply select the chunk of my code I want to refactor, then I press Ctrl-I, and type "refactor" in the dialog box:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe7wmaoysd3krv9382k3c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe7wmaoysd3krv9382k3c.png" alt="Image description" width="800" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It proposes a refactoring that I can accept or reject. In this screenshot below, what is in green is the new code, what is in red if the code that will be removed!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ym6w5gcn1wmaxie63hz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ym6w5gcn1wmaxie63hz.png" alt="Image description" width="800" height="977"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's what I like with refactoring, your code becomes much clearer, easier to understand and maintain.&lt;/p&gt;

&lt;p&gt;Now that the code is refactored I can check if my tests are still passing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sojohqtcpa2biod13f7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sojohqtcpa2biod13f7.png" alt="Image description" width="800" height="655"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I am satisfied, I commit the update and even deploy it into production if I want.&lt;/p&gt;

&lt;p&gt;Amazon Q and test harnesses is a good combination to refactor your code within minutes, but I experimented another technique using Q and tests I found very interesting. Let's explain it.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solve issues with Amazon Q test generation
&lt;/h1&gt;

&lt;p&gt;During this project, I had an issue that was hard to fix for me.&lt;/p&gt;

&lt;p&gt;I had two pieces of code that were supposed to do the same thing, but one was working and the other wasn't. And I couldn't see the differences.&lt;/p&gt;

&lt;p&gt;This was a new piece of code that was not covered previous tests.&lt;/p&gt;

&lt;p&gt;So, I first created a test for the function that was working using Q:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkaai0hynckjlir24p412.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkaai0hynckjlir24p412.png" alt="Image description" width="757" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, I launched the tests against my working code (the one I gave to Q), to make sure the test was green.&lt;/p&gt;

&lt;p&gt;Then, I replaced my working code with the non working code in my function, and I ran the test again. &lt;/p&gt;

&lt;p&gt;The test was red as expected, and it showed me differences in an input data format! In fact, this input data format was slightly different between the two versions of the code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frpn7wfb5i1b4f4i8o6yj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frpn7wfb5i1b4f4i8o6yj.png" alt="Image description" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, I fixed it, and... here we are... this error will never happen again! Or at least it will be detected very soon.&lt;/p&gt;

&lt;h1&gt;
  
  
  The final architecture
&lt;/h1&gt;

&lt;p&gt;After a few iterations and many modifications (safeguarded by tests), I landed with a final architecture.&lt;/p&gt;

&lt;p&gt;Here is the (too early) solution architecture I was proposed first:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzgimckoma2s84je27fhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzgimckoma2s84je27fhf.png" alt="Image description" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is what I really started with:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdgtnbe82uy50jd2upxe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdgtnbe82uy50jd2upxe.png" alt="Image description" width="800" height="594"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From there, I used Q to generate the infrastructure, the code and the unit tests. Then I refactored the code, solved issues, still using Q.&lt;/p&gt;

&lt;p&gt;By the way, we discovered the frontend could not extract audios as expected (which was not in the 'too early' architecture).&lt;/p&gt;

&lt;p&gt;So I introduced AWS Media converter (another serverless service) in the architecture, and here is what I ended up with:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ukd1wlbzgyefyt5wgo4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ukd1wlbzgyefyt5wgo4.png" alt="Image description" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This architecture was built on time, it was production ready and has been used by real users! &lt;/p&gt;

&lt;p&gt;That was a challenge I could overcome while keeping a good quality and evolvability thanks to my developing/architecting assistant. Maybe that will be normality in the near future, but today... it blows my mind! &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This project was ideal to demonstrate the benefits of Amazon Q Developer to kickstart new and innovative projects with good practices.&lt;/p&gt;

&lt;p&gt;With Amazon Q Developer, I could rewrite dirty code, add unit tests and  put in place a short feedback loop. I also used it to refactor my code in order to keep a good quality and allow evolutionary design. I don't think that would have been possible without it in such a short amount of time.&lt;/p&gt;

&lt;p&gt;Of course, I don't think we can overcome all startup challenges with Amazon Q Developer, there are many other dimensions. I am also wondering if that could apply each time or to bigger projects. I don't have enough experience with it yet. But again, that looks very promising!&lt;/p&gt;

&lt;p&gt;Links&lt;br&gt;
&lt;a href="https://martinfowler.com/bliki/MonolithFirst.html" rel="noopener noreferrer"&gt;https://martinfowler.com/bliki/MonolithFirst.html&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>From Diagram to Code with Amazon Q Developer</title>
      <dc:creator>Olivier Lemaitre</dc:creator>
      <pubDate>Thu, 31 Oct 2024 12:58:41 +0000</pubDate>
      <link>https://forem.com/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4</link>
      <guid>https://forem.com/welcloud-io/from-diagram-to-code-with-amazon-q-developer-2da4</guid>
      <description>&lt;p&gt;Architecting a solution is not easy, and we need multiple tools to do it right. Among these tools, diagrams is an important one.&lt;/p&gt;

&lt;p&gt;Diagrams can be used to understand something that has been built or to envision what will be built.&lt;/p&gt;

&lt;p&gt;Whatever the situation, drawing them is a difficult exercise that takes time.&lt;/p&gt;

&lt;p&gt;The good news is that today, with GenAI, it becomes easier to build a diagram from the code, but much more impressive, we can generate an application from a simple diagram.&lt;/p&gt;

&lt;p&gt;In this blog post I demonstrate how to do this with a small project, and the result is already very promising. &lt;/p&gt;

&lt;p&gt;You can replay this example on your side by following the steps below. &lt;u&gt;Note that since it's GenAI, the result might look a bit different on your side and you might not get the same fixes to apply.&lt;/u&gt; But, give it a try, it really worth it if you like software design and architecture.&lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisites if you want to try it
&lt;/h1&gt;

&lt;p&gt;Install VS Code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;https://code.visualstudio.com/download&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install Amazon Q Developer in VS Code: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/q-in-IDE-setup.html#setup-vscode" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/q-in-IDE-setup.html#setup-vscode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enable workspace with Q:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/workspace-context.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/workspace-context.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install mermaid extension in VS Code: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install Draw.io Integration extension in VS Code&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install AWS CDK (not necessary if you don't want to deploy the application, but only see how to generate code from a diagram):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install AWS SAM (not necessary, only if you want to to test the original application)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  GitHub repository &amp;amp; Videos
&lt;/h1&gt;

&lt;p&gt;This repo contains the code and diagram you can start with. The first step will be to extract a diagram from this application code and later recreate a new application code from the diagram.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git clone &lt;a href="https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer" rel="noopener noreferrer"&gt;https://github.com/welcloud-io/wio-from-diagram-to-code-with-amazon-q-developer&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The purpose of this application is to record feedbacks from a user and send feedback acknowledgement to the user mailbox.&lt;/p&gt;

&lt;p&gt;The Infrastructure as Code is built with AWS SAM here, so you can test it by executing &lt;code&gt;_deploy.sh&lt;/code&gt; in the &lt;code&gt;feedback-app-project-original&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;You can also find some demos I created in these videos: &lt;a href="https://www.youtube.com/playlist?list=PL7uUliWSzuvF0GS9jpaFGQxLKGC0CC2vq" rel="noopener noreferrer"&gt;https://www.youtube.com/playlist?list=PL7uUliWSzuvF0GS9jpaFGQxLKGC0CC2vq&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Amazon Q, From Code to Diagram
&lt;/h1&gt;

&lt;p&gt;So, the first step will be to generate a diagram from the code (I mean from all the files in my project). To do this you need Amazon Q to be aware of all the existing files in your folder. This is why you have to activate &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;, which will index all your files so they can be retrieved when you ask a question in the chat.&lt;/p&gt;

&lt;p&gt;The secret is that Q will not draw a diagram (like we would do on a piece of paper), I will ask Q to generate a diagram with the &lt;a href="https://mermaid.js.org/" rel="noopener noreferrer"&gt;mermaid&lt;/a&gt; diagram as code language. So, my diagram will be a text that I can modify in a code editor and that I can reuse as a source for multiple tools. In this case I will use it later to rebuild my project.&lt;/p&gt;

&lt;p&gt;I tested multiple types of diagram generation, but I guess we can do much more, and better with more crafted prompts.&lt;/p&gt;

&lt;p&gt;So, open the &lt;code&gt;feedback-app-project-original&lt;/code&gt; folder in VS Code (File/Open Folder... menu) and follow the prompts...&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 1: Application Diagram
&lt;/h3&gt;

&lt;p&gt;Here is the prompt I used in Amazon Q developer VS Code Chat:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;&lt;/strong&gt; can you generate a mermaid diagram of my application&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8dcon4qz1cvn1upffgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8dcon4qz1cvn1upffgi.png" alt="Image description" width="800" height="1015"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It took less than a minute to generate the diagram of the application. &lt;/p&gt;

&lt;p&gt;Then I use the mermaid viewer in VS Code and... here is the result, which is correct right away.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97djndb2i59uddo9jnwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97djndb2i59uddo9jnwd.png" alt="Image description" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 2: UML Sequence Diagram
&lt;/h3&gt;

&lt;p&gt;Here is the prompt I used in Amazon Q developer VS Code Chat:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;&lt;/strong&gt; can you generate a mermaid sequence diagram of the application&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1uwwrrzxl15oibmj1ux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1uwwrrzxl15oibmj1ux.png" alt="Image description" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 3: UML Class Diagram
&lt;/h3&gt;

&lt;p&gt;Here is the prompt I used in Amazon Q developer VS Code Chat:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;&lt;/strong&gt; can you generate a mermaid class diagram of this application&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frymphne7odlbmhg6ajz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frymphne7odlbmhg6ajz3.png" alt="Image description" width="800" height="752"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Amazon Q, from Diagram to Code
&lt;/h1&gt;

&lt;p&gt;The most impressive part is to build the entire application from the diagram itself.&lt;/p&gt;

&lt;p&gt;I decided to start from an empty folder in VS code, so please create a new folder and open it using 'File/Open folder...' menu if you want to reproduce the example, so Q is not influenced by any context.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Code Generation
&lt;/h2&gt;

&lt;p&gt;Here is the prompt I used in Amazon Q developer VS Code Chat:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;/dev&lt;/strong&gt; can you generate application files from this mermaid diagram (I want the code of the lambdas to be written in python and the infrastructure as code with the python cdk v2)&lt;br&gt;
graph TD&lt;br&gt;
    A[User] --&amp;gt;|HTTP GET /| B[API Gateway]&lt;br&gt;
    B --&amp;gt;|Invoke| C[Landing Page Function]&lt;br&gt;
    C --&amp;gt;|Return HTML| B&lt;br&gt;
    B --&amp;gt;|Return HTML| A&lt;br&gt;
    A --&amp;gt;|HTTP POST /feedbacks| B&lt;br&gt;
    B --&amp;gt;|Invoke| D[Send Feedback Function]&lt;br&gt;
    D --&amp;gt;|Write| E[(DynamoDB Table)]&lt;br&gt;
    D --&amp;gt;|Publish| F[SNS Topic]&lt;br&gt;
    F --&amp;gt;|Send Email| G[User Email]&lt;br&gt;
    subgraph AWS Cloud&lt;br&gt;
        B&lt;br&gt;
        C&lt;br&gt;
        D&lt;br&gt;
        E&lt;br&gt;
        F&lt;br&gt;
    end&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I use the &lt;strong&gt;/dev&lt;/strong&gt; agent which is an Amazon Q agent that will analyse the existing files and update them (but we have none in our case) or generate new files in our folder (that's what we want).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note that the prompt is very short compared to what will be generated, this is where I am the most amazed, I can still not believe it worked!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Q starts generating code and validates that it fits the diagrams that was specified in the prompt (I guess it does a reverse engineering of its own generated code for that).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fha9mkg7bhwvys9wt5hp8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fha9mkg7bhwvys9wt5hp8.png" alt="Image description" width="638" height="1391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I now get code suggestions containing five new files in a folder tree, but these are not placed in my empty folder yet, I have to accept the suggestions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8ec1djkdts275wxar2d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8ec1djkdts275wxar2d.png" alt="Image description" width="725" height="858"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It took one minute or so to get to this result, and when I click on 'Accept code' it takes about one second to create the file structure in my former empty folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsas2l01iwl6f1z2llx5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsas2l01iwl6f1z2llx5i.png" alt="Image description" width="775" height="358"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 2: Test and Fix
&lt;/h1&gt;

&lt;p&gt;I start first to install the requirements and make the cdk deployment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$&amp;gt; pip install -r requirements.txt 
$&amp;gt; cdk deploy --app "python3 app.py"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it starts to deploy 22 resources...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frshz8uecjknc6i56d45x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frshz8uecjknc6i56d45x.png" alt="Image description" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I thought I would have had to fix something here, but it worked &lt;strong&gt;RIGHT AWAY!!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So let's go to Amazon API Gateway and copy paste my landing page endpoint in my web browser address bar to see if it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6uhk4e2fpfmexmj9kckm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6uhk4e2fpfmexmj9kckm.png" alt="Image description" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And this is what I get, and it works right away as well!!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fboid2rqe8seqwdkbubeo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fboid2rqe8seqwdkbubeo.png" alt="Image description" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, let's submit a first feedback now...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbg3xqbsk0vkf4lejhif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbg3xqbsk0vkf4lejhif.png" alt="Image description" width="598" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But this time I have a 403 error (the url access is not allowed, a common error when in fact the url does not exist in API Gateway)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjwe3snqe59dd03bdi1wz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjwe3snqe59dd03bdi1wz.png" alt="Image description" width="800" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Obviously the stage name (/prod in my case) is missing in the url, so let's add it, and redeploy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferk570f3drlapt5tl4en.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferk570f3drlapt5tl4en.png" alt="Image description" width="569" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I do another test, that solved my problem, but now I have a 500 error (a server side error), with this message as a response:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo4263tyjpwuoi4hm60n4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo4263tyjpwuoi4hm60n4.png" alt="Image description" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It turns out that the lambda function is supposed to receive an event, and this event should be in a json format.&lt;/p&gt;

&lt;p&gt;So I ask Q to change the code of my landing page in order to send a json document instead of an HTML Form format with a new prompt in VS Code Chat. I update my code, redeploy and make a new test.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I want my feedback data to be sent as a json document to the '/prod/feebacks' endpoint with a field called "feedback" containing the feedback value typed into the html form&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffvi3lmd291e8j31e4nen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffvi3lmd291e8j31e4nen.png" alt="Image description" width="743" height="480"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Ok, that works now!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have NO error when I send some feedback, and the API call returns a 200 status&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pahov16iz7zbbq0pixl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pahov16iz7zbbq0pixl.png" alt="Image description" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, let's got to the DynamoDB (which has been created by the CDK code) to see if my feedback has been recorded&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And boom! It is there!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F164sp5ghfzhkl2c2ph28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F164sp5ghfzhkl2c2ph28.png" alt="Image description" width="800" height="709"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am also supposed to receive a email to acknowledge the feedback has been recorded, so I will change the destination email which contains a default value in the CDK template (again generated earlier) and I redeploy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhxlvv3hmilp74clph28d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhxlvv3hmilp74clph28d.png" alt="Image description" width="800" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My user has been added and is now pending for confirmation&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2lc6kbb7j8ami92p3ss6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2lc6kbb7j8ami92p3ss6.png" alt="Image description" width="800" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I confirm my subscription in my mailbox and I send a new feedback&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqoq14erzlpkrejdsk841.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqoq14erzlpkrejdsk841.png" alt="Image description" width="800" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And here is what I get straight away in my mail box!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faeycym0vxlc6gu4ly2qc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faeycym0vxlc6gu4ly2qc.png" alt="Image description" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am really impressed so far, but...&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Let's push it a bit further
&lt;/h2&gt;

&lt;p&gt;Mermaid is nice, but maybe we want to draw our diagram with a mouse and then generate the associated code...&lt;/p&gt;

&lt;p&gt;So, I tested the idea, I took a draw.io diagram of my application, that I exported in an XML format (and a png format to display it in my IDE).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbytjuv23yal1rx4err82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbytjuv23yal1rx4err82.png" alt="Image description" width="779" height="1030"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I created an empty folder where I put my app.drawio.xml file and I ask Q:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;/dev&lt;/strong&gt; generate application (code+infrastructure)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And, that's amazing, it has enough information to generate my application, and &lt;strong&gt;this time it works right away, no need to fix anything!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvf0a5h75nw214wvfiqnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvf0a5h75nw214wvfiqnb.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that since I do not specify anything more, Amazon Q chooses the tools, in this case python and SAM. Not sure it would choose the same for you if you try this :)&lt;/p&gt;

&lt;p&gt;But wait..., can I generate a draw.io diagram from my code?&lt;/p&gt;

&lt;p&gt;Let's try it...&lt;/p&gt;

&lt;p&gt;First I remove the app.drawio.xml file to avoid Q to be influenced by it in the context and then I type:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt;&lt;/strong&gt; can you generate a draw.io diagram in an xml format of this application (I want to use AWS 2024 Icons, lines should be orthogonal, dataflow from up to bottom)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpnns96e27ke510runav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgpnns96e27ke510runav.png" alt="Image description" width="800" height="722"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I copy/paste the generated XML document in draw.io (&lt;a href="https://app.diagrams.net/" rel="noopener noreferrer"&gt;https://app.diagrams.net/&lt;/a&gt;), and again almost nothing to change!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj39u75v2io05gxwcoyua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj39u75v2io05gxwcoyua.png" alt="Generated diagram by Amazon Q developer" width="799" height="673"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Integrate Draw.io in VS Code
&lt;/h2&gt;

&lt;p&gt;Finally I asked myself, does it exist a draw.io extension in VS Code, so I can directly edit my diagrams in my IDE, and...that exits!&lt;/p&gt;

&lt;p&gt;It's called '&lt;a href="https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio" rel="noopener noreferrer"&gt;Draw.io Integration&lt;/a&gt;' and it seems to work quite well. So, I redrew my diagram in VS Code directly.&lt;/p&gt;

&lt;p&gt;The only trick that I had to apply was to change the editor file extension association, by default '.drawio', to 'drawio.&lt;strong&gt;xml&lt;/strong&gt;'. &lt;/p&gt;

&lt;p&gt;That's because Amazon Q &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt; doesn't take the '.drawio' extension into account, but only the well known text base file extensions like .xml, .yaml, .py, ....&lt;/p&gt;

&lt;p&gt;To make this work, go to 'File &amp;gt; Preferences &amp;gt; Settings', search for 'editorasso' setting and add the association item (*.drawio.xml =&amp;gt; hediet.vscode-drawio-text)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faunra23r226tenfn5uzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faunra23r226tenfn5uzy.png" alt="Image description" width="799" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I can create my diagrams directly in VS Code using 'drawio' and then ask Q to generate my application :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdj1ekthrhmcrxekt7rsb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdj1ekthrhmcrxekt7rsb.png" alt="Image description" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it, but I think I could carry on this blog post with many other stuff I have in mind although it's already amazing to me!&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Diagrams can be a powerful tool to convey a vision, document and understand the structure of your software architecture.&lt;/p&gt;

&lt;p&gt;With today GenAI tools, this is made easier, and Amazon Q coding assistant can really help you.&lt;/p&gt;

&lt;p&gt;But, what is really new and powerful to me is that you can scaffold an entire project from your diagram.&lt;/p&gt;

&lt;p&gt;I am not sure it's MDA (Model Driven Architecture) reshaped yet, because the problem I guess, is that if you want to make a change to your project you will have to change the diagram and regenerate things, I don't think GenAI is deterministic enough for that today (but I will try).&lt;/p&gt;

&lt;p&gt;However, I think, it's already good for prototyping or rewriting the same small project with different technologies. For example, here I ask to use python in my code and the CDK for the IaC, but I could change my mind and use javascript and pulumi to see the differences and make my choice from there.&lt;/p&gt;

&lt;p&gt;There would be a lot more to say about this experience, and I think it is a very simple trial with many things that would need to be improved in order to be production ready, but it's already very promising.&lt;/p&gt;

&lt;p&gt;I think we can do much better with more crafted prompts, and that's surely what I will try to do in the next couple of weeks. It was so much fun!&lt;/p&gt;

</description>
      <category>amazonqdeveloper</category>
      <category>architecture</category>
      <category>diagram</category>
      <category>genai</category>
    </item>
  </channel>
</rss>
