<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saeed Ghanavat on Medium]]></title>
        <description><![CDATA[Stories by Saeed Ghanavat on Medium]]></description>
        <link>https://medium.com/@GhanavatSaeed?source=rss-7ed67d5113b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6Cgfm5zmMqboCBE3.jpg</url>
            <title>Stories by Saeed Ghanavat on Medium</title>
            <link>https://medium.com/@GhanavatSaeed?source=rss-7ed67d5113b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:40:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@GhanavatSaeed/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Nobody Knows What We’re Building, But Everyone Knows the Deadline]]></title>
            <link>https://medium.com/@GhanavatSaeed/nobody-knows-what-were-building-but-everyone-knows-the-deadline-2a7e27e43430?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a7e27e43430</guid>
            <category><![CDATA[agile-methodology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 13:01:03 GMT</pubDate>
            <atom:updated>2026-11-02T13:01:03.427Z</atom:updated>
            <content:encoded><![CDATA[<h4>We’re Agile when it comes to Sprints. Not so much when engineers discover something needs to change.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*73ZZoM5wBwL8Qk8N.png" /></figure><p>If you’re a software engineer, when was the last time you were handed a software project with the requirements, architecture and deadline already decided, and managed not to go mad?</p><p>Tell me, have you ever watched the non-engineers in your team disappear into a meeting room without you, only to find out later that the decisions they made now dictate what you’re expected to build?</p><p>And they call this Agile?</p><p>If you answered yes to all that, we have a lot in common, my friend.</p><h3>When We Decide Everything Before Writing a Line of Code</h3><p>I call it the great gathering. All the engineers, BAs and stakeholders spent hours in a room going through absolutely every requirement that had already been grouped into features and assigning each a confidence rating.</p><p>Confidence rating?</p><p>I must admit, this was the first time I’d heard of it.</p><p>We used a Low/Medium/High confidence rating system that measured how confident the engineering team was in understanding the requirements and delivering them on time.</p><p>On paper, the exercise sounded reasonable. What happened afterwards was another matter.</p><p>We were questioned about the low confidence ratings. Apparently, admitting that we weren’t confident about meeting the deadline was itself becoming a problem.</p><p>We were even warned that giving requirements low confidence ratings could put our jobs at risk and that the project could be handed over to a third party.</p><p>The back-and-forth discussions began and we were in and out of meeting rooms trying to turn low confidence ratings into high ones. Everyone was exhausted. Requirements were all over the place. A mountain of questions and uncertainties. It was difficult to come away with anything meaningful that engineers could use.</p><p>And guess what, engineers were out of the loop when those features were baked in the oven by BAs and stakeholders in the first place. This exclusion led us to other problems.</p><p>You might assume engineers had agreed to these requirements. We hadn’t. Requirements were agreed among BAs, stakeholders and the architects. Engineers were only involved in assessing them!</p><p>After revising our proof of concept, we became more confident that the solution was technically feasible. But we were still unclear about many of the requirements we were supposed to deliver.</p><p>Fine, it is what it is. But doing all this with a fixed deadline, while the business still wants every requested feature delivered makes absolutely no sense to me.</p><p>When you know little about the technical challenges ahead, how can you assess delivery confidence from vague feature titles and half-baked descriptions?</p><p>We had spent all that time rating our confidence. Now came the user stories that were supposed to turn those requirements into something we could actually build.</p><h3>When Sprint 1 Needs Sprint 5</h3><p>The team discovered that some important technical and business requirements for Feature A had been placed in Feature H, which was planned to be addressed in Sprint 5.</p><p>When Feature A was delivered, it was delivered as per the original acceptance criteria. When the team arrived at Sprint 5 and picked up a story for Feature H, we opened a can of worms. At least three of Feature H’s five acceptance criteria should have belonged to Feature A in Sprint 1.</p><p>It turned out that the BAs had placed those acceptance criteria under Feature H because they used terminology similar to that feature’s business requirements. Engineers hadn’t been involved when the features were originally prepared.</p><p>I don’t expect BAs to write technical implementation details into every story. But when engineers aren’t involved early in refining the requirements, important relationships between features can easily be missed.</p><p>Stories were created well ahead of development. Apparently, the idea was to have <strong>everything</strong> ready before engineers started building. There’s nothing inherently wrong with preparing stories in advance. My frustration comes from poorly understood requirements and stories treated as fixed commitments.</p><p>In my team, the BA makes the decisions about backlog ordering because we don’t have a Product Owner. Scrum makes the Product Owner accountable for the backlog, but nobody has formally taken that responsibility for product priorities and value.</p><p>We had to carve out the requirements misplaced under Feature H and create new stories for Feature A. Although we’d met Feature A’s original acceptance criteria, we now knew the feature was incomplete from the business’s perspective. Not ideal.</p><p>After all those workshops, refinement sessions and confidence ratings, why were we still discovering misplaced requirements five sprints into development?</p><p>I believe the problem arose partly because stories were developed without engineering involvement. Not only that. The stories were treated as settled commitments. Reopening them meant going back to the stakeholders and having the same discussions again. Expensive!</p><h3>We Can Challenge the Design. Good Luck Changing It.</h3><p>A new problem arose and the search for a solution began. The architects began designing the solution behind closed doors. Despite some managers’ efforts to involve engineers, they continued working on it without us.</p><p>They took it through the required approval stages. Once they’d obtained all the required approvals, they opened the doors and announced, ‘It’s done!’</p><p>By the time engineers saw the architecture, it had already passed several approval stages. Challenging it was technically possible, but getting anything changed was another matter.</p><p>Yes, I was told, “Oh, of course you can challenge it. Go ahead!” Good luck changing it, though! It’s already <strong>APPROVED</strong>.</p><p>We studied the architecture design from beginning to end. I had many questions and several back-and-forth discussions with the architect. The architecture document stated that a particular technology was well suited to the solution. At that stage, there seemed to be no room for reconsideration.</p><p>We discovered that one architectural decision involving Azure Blob Storage didn’t appear to account for the implementation effort. The proposed design involved storing hundreds of thousands of records in large files in Azure Blob Storage. Our concern was how the application would retrieve and update individual records without repeatedly processing those files. We proposed Azure Table Storage as an alternative, but struggled to get the trade-offs properly reviewed.</p><p>From our discussions, it appeared that the original design hadn’t fully accounted for the volume of records or how the application needed to access and update them. Later conversations with stakeholders reinforced that concern. However, the architect still didn’t reconsider the design.</p><p>This delayed us by almost two weeks. We had to pause part of the implementation and agree on a temporary workaround so we could continue developing: storing the data on disk while waiting for the architect to reconsider.</p><p>While we were waiting for the decision, Sprint Planning and refinement continued. We were still expected to plan around a design we believed needed reconsideration.</p><p>Eventually, we escalated the issue to senior managers. It took the architect half a day to reconsider and update their documentation in our favour. Victory!</p><p>I don’t actually have a problem with architects doing architecture, BAs documenting requirements, or business stakeholders making commercial decisions.</p><p>I have a problem when those decisions are made upfront, the development team discovers something wrong, and correcting the problem becomes a negotiation rather than a normal part of building software.</p><p>I want engineers involved much earlier in the process. We should shape the architecture together, considering both the design and the practical implementation.</p><p>I am not claiming engineers should make every business decision or have unlimited technical freedom.</p><p>What engineers learn during implementation can reveal reasons to revisit the architecture.</p><blockquote><em>Scrum Guide: Inspection without adaptation is considered pointless. </em><a href="https://scrumguides.org/scrum-guide.html"><em>2020 Scrum Guide</em></a></blockquote><p>We were allowed to challenge the design. What we struggled to do was change it without escalating the issue to senior management.</p><h3>We Have Sprints. We Also Have a Fixed Plan.</h3><p>Now, having sprints and an upfront plan isn’t inherently contradictory. Scrum doesn’t prohibit long-term planning. The issue has never been the delivery methodology, but the execution malarkey.</p><p>I’ve worked in Scrum teams where we negotiated scope when new technical challenges emerged, rather than pretending the original plan was still achievable.</p><p>But, working in a team where Scrum is poorly implemented, especially one dealing with all the shenanigans I’ve mentioned above, isn’t something many want to have to deal with. In my team, engineers are often left implementing decisions made elsewhere instead of helping shape the solution.</p><p>My team works in two-week sprints, but the overall plan assumes decisions made months earlier will remain valid. Dependencies and design problems emerge after development begins. The company struggles when new information challenges those decisions.</p><p>Things become difficult when the delivery deadline remains fixed despite uncertainty about the work. When new information emerges, the scope might need changing to protect the delivery. Failing to do so puts the project’s deadline at risk.</p><p>Don’t get me started with Sprint Goals. In almost every Sprint, we struggled to define Sprint Goals. They should connect the team’s work to a coherent objective. Instead, in our case the goals were little more than reworded user stories on the sprint board. Especially the meaty stories!</p><p>Imagine a Sprint Goal that amounts to:</p><blockquote><em>Complete User Story A, which involves implementing monthly calculations; Story B, which involves storing the results in Azure Table Storage; and Story C, which involves building a results dashboard.</em></blockquote><p>That’s not necessarily a useful Sprint Goal. It doesn’t tell the team what outcome those stories are meant to achieve.</p><p>Compare that with a goal such as:</p><blockquote><em>Make monthly calculation results available to users through a dashboard.</em></blockquote><p>Even when stories supported the same outcome, our Sprint Goals often became task lists. In other Sprints, the selected stories had so little in common that identifying one meaningful goal became difficult.</p><p>The company wants the certainty of a fixed plan while expecting engineers to deal with the uncertainty that the plan failed to address.</p><h3>Final Words</h3><p>If we’re going to inspect our work every two weeks, but changing problematic decisions requires weeks of arguments and escalation, what exactly are we trying to achieve with Scrum?</p><p>An organisation might appear to have documented an enormous amount of what it intends to build. It has requirements, feature lists, confidence ratings, user stories, architecture documents and formal approvals.</p><p>You might argue that all these documents prove we know exactly what we’re building.</p><p>Knowing what you want the software to do isn’t the same as understanding what it will take to build it.</p><figure><a href="https://landing.ghanavats.tech/dotnet-aws-pro?utm_content=iam_auth_medium"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kWLaspOTmFSWJEhad9uuw.png" /></a></figure><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-10-13-way_of_working/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a7e27e43430" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IAM Authorization on API Gateway: Why I Chose It and What I Got Wrong]]></title>
            <link>https://medium.com/@GhanavatSaeed/iam-authorization-on-api-gateway-why-i-chose-it-and-what-i-got-wrong-837066911975?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/837066911975</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 00:41:30 GMT</pubDate>
            <atom:updated>2026-10-05T00:41:30.993Z</atom:updated>
            <content:encoded><![CDATA[<h4>Should every API be protected by machine-to-machine authentication? Building my AWS Starter Kit forced me to question that assumption. The mistake wasn’t choosing the wrong authentication mechanism. It was choosing one too early.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1ZW9g5dX6d6H98WOierkw.png" /></figure><p>I used to think about API authorization too early. I would start choosing how to secure an API before properly asking who was going to call it.</p><p>Some of the options I considered to secure my starter kit were:</p><ul><li>Cognito User Pool (M2M)</li><li>Lambda authorizer</li><li>Just use API keys</li></ul><p>All the above are valid options and none are necessarily wrong approaches, except for API keys.</p><p>However, should every API have M2M authentication by default?</p><p>Or, should all backend systems have a dedicated authorizer?</p><p>Convention shouldn’t choose the authentication model before you know the caller.</p><p>I had fallen into a habit of treating M2M authentication as the default starting point for APIs. While working on my <a href="https://ghanavats.tech/projects/dotnet-on-aws-starter-kit/">.NET on AWS Starter Kit</a>, I went up and down trying to force it in.</p><h3>Ask The Right Question First</h3><p>Before getting too excited about techs such as AWS Cognito, Lambda authorizer or even Azure App Registration, you must ask <strong>who would call my API</strong> before you commit to an authentication model. If you cannot answer this question ahead of time, you must go back to your drawing board.</p><p>Boring? Unexciting? It’s the right question and a defining one that can change how you need to protect the API.</p><p>Would you choose M2M as the default authentication model for requests being made on behalf of interactive users simply because the system happens to have an API?</p><p>Would you implement a simple API key for an API whose endpoints must be protected by roles?</p><p>What about BFF? Would you implement one for an API that is only used internally by other APIs? I mean, how would you even implement it? The last F stands for <strong>Frontend</strong>! Is there one?</p><p>I realised I was choosing the authentication model before properly defining who would call the API.</p><h3>Picking the Technology Too Early</h3><p>Adding an authentication and authorization module to my .NET on AWS Starter Kit was one of the features I wanted to get done properly. And I was aiming to do so before closing the doors on any additional features to prevent the repo growing too big.</p><p>Funny enough, over-engineering is sometimes part of my game. Achieving and appreciating simplicity does not come so easily for me without over-engineering first.</p><p>My over-engineering journey began with the dilemma between AWS Cognito User Pool and Identity Pool.</p><p>I could not effectively choose either. I didn’t yet have an identity model that justified introducing Cognito, such as human users, external machine clients, AWS workloads or something else.</p><p>I delved a bit deeper and studied AWS API Gateway documentation and ways of securing it. Guess what? I stumbled across another interesting approach; Lambda authorizer. I reached for a Lambda authorizer before I had a requirement that justified custom authorization logic. A Lambda authorizer is useful when you need custom authorization logic or control over how the decision is made.</p><p>What about API keys? I did think about it to make life easier. However, in API Gateway, API keys have their own place. They mustn’t be used for authentication or authorization mechanism.</p><p>No matter how many other mechanisms or approaches you find, you cannot effectively pick one if you don’t know how your system is going to be consumed.</p><h3>Why I Chose IAM Authorization</h3><p>My starter kit already assumes AWS. It already uses CDK and deploys AWS resources. Therefore, supporting an AWS-native caller identity as the <strong>default</strong> access model avoids introducing a separate user directory or OAuth server when the kit knows nothing about the final application’s users. So it’s a win. And no one is going to use my kit to deploy to Azure!</p><p>Implementing IAM Authorization in CDK is not exceptionally hard, although it does require careful implementation.</p><blockquote><em>Note: IAM is my Starter Kit’s default. It is not my answer for every API built from the Starter Kit.</em></blockquote><h3>The IAM and SigV4 Details That Matter</h3><p>Let’s start with this line:</p><blockquote><em>SigV4 signs a request, not merely a user’s AWS credentials.</em></blockquote><p>Path, HTTP method, query string, signed headers and other canonical-request details matter.</p><p>Possessing AWS credentials and producing a SigV4 signature doesn’t guarantee you could call the IAM-protected API. You must understand what identity is actually making the request, what permissions that identity has, and why assuming the role changes that identity. The source user’s credentials are not sufficient when execute-api:Invoke belongs to the dedicated invocation role.</p><p>Let’s take a look at some examples:</p><p><strong>Example 1:</strong></p><p>The role’s policy statement in which the permissions are defined will look something like the following. It will say what the resulting role session can do. The following policy grants execute-api:Invoke on the specified API Gateway resource ARN:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: &quot;execute-api:Invoke&quot;,<br>            &quot;Resource&quot;: &quot;arn:{aws_partition}:execute-api:{aws_region}:{aws_accountId}:{api_id}/{stage}/{HttpMethod}/resource_path/*&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Sid&quot;: &quot;AllowGetPersonDetails&quot;<br>        }<br>    ]<br>}</pre><p>PS. This statement is inside the invocation role’s permissions policy. Described blow.</p><p>And the role trust policy will look something like the following. The role’s trust policy (as shown below) defines who — Principal - can assume it while its permissions policy (above) defines what can be done with it:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;arn:aws:iam::{aws_accountId}:user/{username}&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>        }<br>    ]<br>}</pre><p>Once the role is successfully assumed by a principal, STS returns a new temporary credential set. These new credentials represent the assumed-role session. AWS credentials identify a principal. They don’t grant AWS access universally.</p><p><strong>Example 2:</strong></p><p>Below is a simplified version of the code you need to get the assume role response and to sign the request:</p><pre>//Create STS client<br>using var stsClient = new AmazonSecurityTokenServiceClient(<br>    sourceCredentials,<br>    RegionEndpoint.EUWest1);<br><br>//Assume Role request/response<br>var assumeRoleResponse = await stsClient.AssumeRoleAsync(<br>    new AssumeRoleRequest<br>    {<br>        RoleArn = &quot;role_arn&quot;,<br>        RoleSessionName = &quot;an_id_for_this_session&quot;<br>    },<br>    CancellationToken.None);<br><br>//SigV4 signing request/result<br>var awsSigningResult = await AWSSigV4Signer.SignAsync(new AWSSigningRequest<br>{<br>    HttpMethod = HttpMethod.Get,<br>    RequestUri = endpointUri,<br>    Headers =<br>    {<br>        { &quot;x-api-key&quot;, &quot;api_key&quot; }<br>    }<br>}, new AWSSigV4Parameters<br>{<br>    Credentials = assumeRoleResponse.Credentials,<br>    Region = RegionEndpoint.EUWest1,<br>    Service = &quot;execute-api&quot;<br>}, CancellationToken.None);</pre><p><strong>What is the </strong><strong>x-api-key header doing there?</strong> My Starter Kit happens to use and configure usage plans for throttling requests. The API key is used to identify usage for that plan and apply its throttling/quota settings. It&#39;s not designed for authentication or authorization. The x-api-key header has to be in the request because the API method (should it be configured to require an API key) requires it as part of the usage plan.</p><blockquote><em>Note: </em><em>AssumeRoleAsync changes which AWS identity the request will represent. </em><em>SignAsync then proves that identity for one specific HTTP request.</em></blockquote><p>The mental model is like this:</p><ul><li>AssumeRoleAsync: who am I acting as?</li><li>AWSSigV4Signer.SignAsync: Can I cryptographically prove that this identity signed this exact request?</li><li>Then API Gateway/IAM answers the third question: Is this identity allowed to invoke this API resource?</li></ul><p>The new credential set consists of Access Key Id, Secret Access Key, and Session Token. The Session Token is an opaque value issued by STS that belongs to that temporary AWS session. It is part of AWS’s temporary-session credential set, and it must travel with the access key and secret key returned by STS. The SigV4 signer includes that token when it signs using the temporary credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*RGniCJu_DIZDF2U0.png" /><figcaption>Temporary credentials returned by STS AssumeRole</figcaption></figure><blockquote><em>Note: Do not assume role, sign the request in .NET, and then copy the </em><em>AWSSigningResult details into the Postman request. SigV4 signs the actual HTTP request, so signing one request and sending a materially different one can cause </em><em>SignatureDoesNotMatch. Let Postman sign the request Postman is actually going to send; </em><strong><em>Authorization</em></strong><em> tab -&gt; </em><strong><em>AWS Signature</em></strong><em> from Auth type dropdown.</em></blockquote><h3>What I’d Do Differently Now</h3><p>From now on, I would define the callers and trust boundaries first. Then I’d choose the simplest mechanism that satisfies those requirements. IAM happened to be that mechanism for the default AWS-native scenario in my Starter Kit. It might not be for the application someone builds with it.</p><p>Take a look at the implementation in the <a href="https://github.com/ghanavat/dotnet-aws-starter-kit">GitHub Repo</a>.</p><p>The documentation related to IAM Authorization <a href="https://github.com/ghanavat/dotnet-aws-starter-kit/tree/main/content/DotNetAws.StarterKit#iam-authorization-with-aws-signature-version-4">is here</a>.</p><figure><a href="https://landing.ghanavats.tech/dotnet-aws-pro?utm_content=iam_auth_medium"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kWLaspOTmFSWJEhad9uuw.png" /></a></figure><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-09-30-iam_authorization_with_signature_v4/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=837066911975" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Turned 4 .NET Templates Into 1 With symbols and sources]]></title>
            <link>https://medium.com/@GhanavatSaeed/how-i-turned-4-net-templates-into-1-with-symbols-and-sources-e8079892d9d1?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8079892d9d1</guid>
            <category><![CDATA[dotnet-template]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[vertical-slice]]></category>
            <category><![CDATA[template-engine]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 13:46:01 GMT</pubDate>
            <atom:updated>2026-10-04T17:32:09.500Z</atom:updated>
            <content:encoded><![CDATA[<p>A confession about over-engineering four separate .NET templates — and the .NET Template Engine feature that let me collapse them into one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NiZ_yKugTUENffX6.png" /></figure><p>In my previous article, <a href="https://medium.com/@GhanavatSaeed/stop-recreating-net-solutions-from-scratch-10f81e3bab63">Stop Recreating .NET Solutions From Scratch</a>, I introduced and showed how easy it was to create your own template and generate projects and solutions from it over and over again. Taking away a lot of the pain and repetitive setup.</p><p>I want to make a confession. I went ahead and created a few .NET templates, one for Clean Architecture, one for Vertical Slice (why not, it’s a trend now!!), and one with DDD primitives, and I went crazy further and created another but with Repository Pattern stuff configured in it. How many templates? Four. Four templates. Four reasons to come back to every single one of them. Four reasons to touch and fiddle with every single one of them and try to find a way to fix the OpenAPI package vulnerability that happened to all the developers on the entire universe no more than a few weeks ago. 😁</p><p>I did need them all to be fair. I needed the one specifically with Repository Pattern, and the others without so I could do some other research on whether I should stick with Repository Pattern, or if it’s just not worth it. Another article for another time.</p><p>I made a YouTube video after the first article. <a href="https://youtu.be/oSwfae3H4DU">You can watch it here.</a> And I did mention in there, yeah why not make multiple templates and maintain them all until you go officially insane?</p><p>You can tell that it may feel like I was cursed or coerced to just go mad with .NET template engine. Just because it’s there and available, I thought yep let’s get it used for EVERYTHING.</p><p>Wouldn’t it be so cool if it was possible to configure, in a logical way, the behaviour of your .NET template? To have one .NET template that changes based on user input. I mean like it doesn’t matter what architectural style, what third-party libraries, what solution folder structure, naming conventions etc etc. All the configurations would be handled by the template engine based on what the users want. Perhaps it would be. Wouldn’t it?</p><h3>One Template To Rule Them All (Yes, Really)</h3><p>Please don’t let your inner self make you feel comfortable with the basics of templating. It will not give you the ultimate benefit you deserve.</p><p>I began researching this a bit further and found out how much I was missing out on. The .NET Template Engine is much more mature than I was able to imagine. The ‘dotnet new’ command is amazingly flexible and works very well with custom templates. I mean, a really custom, configurable way to build templates. 😉</p><h3>Four Templates Was Never the Answer</h3><p>I hope that I have your attention by now. Trust me, you don’t want to pile up .NET templates. It’s a bad practice, hard to maintain, still easy for things to go out of control. Yes, even though you fixed the first problem of creating .NET solutions from scratch by copying and pasting your previous ones. You just created a new problem. 🤔</p><p>Remember: A useful template should not be a dumping ground for every idea you have ever had. It should be what you really need.</p><h3>How I Rescued Myself With symbols and sources</h3><p>Thanks to the maturity of the .NET Template Engine, I have researched and learned how to configure the template.json to accept inputs from users using symbols and sources.</p><p>This is not a hack. It’s a proper, official way to construct a template that can generate different outputs based on symbols and custom parameters. The content of the symbols in the template.json file is then used in the sources to define the conditional statements based on the user inputs with those custom parameters, so then the appropriate action can be taken.</p><p>Read on if you are keen to learn how I put everything together.</p><h3>Step 1: Teaching the Template to Ask Questions</h3><p>The template.json file was amended with the following addition first - the parameters I want to get from users.</p><pre>&quot;symbols&quot;: {<br>    &quot;architecture&quot;: {<br>      &quot;type&quot;: &quot;parameter&quot;,<br>      &quot;datatype&quot;: &quot;choice&quot;,<br>      &quot;allowMultipleValues&quot;: false,<br>      &quot;description&quot;: &quot;The architecture of the project&quot;,<br>      &quot;choices&quot;: [<br>        {<br>          &quot;choice&quot;: &quot;clean-architecture&quot;,<br>          &quot;description&quot;: &quot;Clean Architecture with multiple projects&quot;<br>        },<br>        {<br>          &quot;choice&quot;: &quot;vertical-slice&quot;,<br>          &quot;description&quot;: &quot;Vertical Slice Architecture&quot;<br>        }<br>      ],<br>      &quot;defaultValue&quot;: &quot;clean-architecture&quot;<br>    },<br>    &quot;include-opentelemetry&quot;: {<br>      &quot;type&quot;: &quot;parameter&quot;,<br>      &quot;datatype&quot;: &quot;bool&quot;,<br>      &quot;description&quot;: &quot;Whether to include OpenTelemetry support in the project&quot;,<br>      &quot;defaultValue&quot;: &quot;true&quot;<br>    }<br>}</pre><p>This was added at the top level of the file. Make sure you don’t put it by mistake inside any of the nested sections in the file.</p><p>The above snippet allowed me to do this:</p><pre>dotnet new simple_template -n MyCompany.VerticalSlice --architecture vertical-slice --include-opentelemetry false</pre><blockquote><em>I was buzzing at this stage. 🐝</em></blockquote><p>The next snippet was like glue. Wired everything together and made everything work — sort of!</p><p>The following, as I briefly touched on, consists of the conditions and the behaviours I was hoping for:</p><pre>  &quot;sources&quot;: [<br>    {<br>      &quot;modifiers&quot;: [<br>        {<br>          &quot;condition&quot;: &quot;(architecture == &#39;clean-architecture&#39;)&quot;,<br>          &quot;exclude&quot;: [<br>            &quot;Simple.Template.Api/Features/**&quot;<br>          ]<br>        },<br>        {<br>          &quot;condition&quot;: &quot;(architecture == &#39;vertical-slice&#39;)&quot;,<br>          &quot;exclude&quot;: [<br>            &quot;Simple.Template.Core/**&quot;,<br>            &quot;Simple.Template.UseCases/**&quot;,<br>            &quot;Simple.Template.Infrastructure/**&quot;<br>          ]<br>        }<br>      ]<br>    }<br>]</pre><p>It worked when I executed the dotnet new command I wrote above. A new .NET solution was created, with only one API project in it - MyCompany.VerticalSlice.Api. Including the folder structure I designed in the template suitable for Vertical Slice architecture style. Excluding all the Clean Architecture related projects.</p><p>My problem was solved — sort of!</p><p>Getting the project structure to switch based on architecture was the easy part. The harder question was: what about features that aren’t a whole architecture style, just a switch — like whether to include OpenTelemetry at all?</p><h3>Step 2: Making OpenTelemetry Optional</h3><p>I was not 100% satisfied. If you scroll back up and study the first JSON snippet you will see what I mean. Yes, OpenTelemetry. I wanted to configure what NuGet package, what configuration code in the Program.cs, and what project to be referenced in the solution file (the .sln file).</p><p>The include-opentelemetry is a boolean parameter. I wanted to include and exclude the whole OpenTelemetry when I needed to. Some of you may have done this before, where you can use #if along with the DEBUG symbol to ensure a block of code only runs during a debug build. I think it&#39;s called conditional compilation directives or preprocessor directives. In Rider I had to do it slightly differently. I wrapped the OpenTelemetry configuration block in Program.cs and did exactly the same in the .csproj with the #if along with the condition:</p><pre>//#if(include-opentelemetry)<br>builder.Logging.AddOpenTelemetry(options =&gt;<br>{<br>    // whatever config you want...<br>});<br>//#endif</pre><p>And in the .csproj:</p><pre>&lt;!--#if(include-opentelemetry)--&gt;<br>&lt;PackageReference Include=&quot;OpenTelemetry.Extensions.Hosting&quot; Version=&quot;1.16.0&quot; /&gt;<br>&lt;PackageReference Include=&quot;OpenTelemetry.Instrumentation.AspNetCore&quot; Version=&quot;1.16.0&quot; /&gt;<br>&lt;!--#endif--&gt;</pre><p>With the C# and .csproj conditions wired up, the template felt complete. It wasn&#39;t. The .sln file had one more surprise waiting for me.</p><h3>One Last Landmine: The Projects That Wouldn’t Die</h3><p>At this stage I genuinely realised that there is often room to get the best out of a solution you have. I found a solution to my original problem, but then created more problems from that solution. I stopped, went back to basics, and realised there was more I could get out of it — and that’s how I found the gem.</p><p>When the first Vertical Slice solution was created from the new template engine configuration, I noticed a weird behaviour in the solution. All the Clean Architecture projects that were successfully excluded by the conditions in the config file were still being unsuccessfully loaded, staying in the solution with a <em>failed to load</em> message next to each. I got a bit panicked and thought excluding the projects doesn’t work very well. I was wrong. In the template solution, I took the same approach as I did in the .csproj file and applied it to the .sln file, using the same conditions on the projects I wanted included or excluded.</p><p>Below is how I did it — simplified:</p><pre>#if(architecture == &quot;clean-architecture&quot;)<br>Project(&quot;{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&quot;) = &quot;Simple.Template.Core&quot;, &quot;Simple.Template.Core\Simple.Template.Core.csproj&quot;, &quot;{6A0090C7-B8F3-4CF9-959D-A423695234D8}&quot;<br>EndProject<br>#endif</pre><blockquote><em>Note: Did not need to do </em><em>\\ in the </em><em>.sln file before the </em><em>#if.</em></blockquote><p>That’s it — one template, four architectural personalities, and zero extra repos to maintain. What took me four separate templates (and four separate headaches every time a NuGet package needed a security patch) now lives in a single, configurable source of truth.</p><p>If you’re maintaining more than one .NET template for what is essentially the same solution shape with different flavours, this is worth the afternoon it takes to set up. I’ll drop the full template.json and the consolidated template repo in a follow-up so you can see the whole thing end to end — and if you try this yourself, let me know what conditions you end up building.</p><p>You can watch me doing it in the YouTube video:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLTA39h8vQb4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLTA39h8vQb4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLTA39h8vQb4%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f6c5c22b0766e4b81a34217ef5d4378/href">https://medium.com/media/2f6c5c22b0766e4b81a34217ef5d4378/href</a></iframe><p>And, if you want a quick tutorial video about how to pack your .NET template into a NuGet package to complete the whole cooking session, the one below is for you:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxvHjZvArjF0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxvHjZvArjF0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxvHjZvArjF0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0454ca848e95a5126e6fc835898a246d/href">https://medium.com/media/0454ca848e95a5126e6fc835898a246d/href</a></iframe><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-07-24-one_dotnet_template_for_many_configurations/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8079892d9d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lambda Cold Starts Are Not the Whole Story: How I Took a .NET API from ~2s to <1s with SnapStart]]></title>
            <link>https://medium.com/@GhanavatSaeed/lambda-cold-starts-are-not-the-whole-story-how-i-took-a-net-api-from-2s-to-1s-with-snapstart-482521483ce0?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/482521483ce0</guid>
            <category><![CDATA[cold-start]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[snapstart]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Mon, 29 Jun 2026 10:31:01 GMT</pubDate>
            <atom:updated>2026-06-29T10:31:07.890Z</atom:updated>
            <content:encoded><![CDATA[<h4>A practical breakdown of Lambda cold starts, SnapStart, DynamoDB latency, and the tuning that actually moved the needle.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQCWhBc2maWEla12dA2uiw.png" /></figure><p>With APIs gaining popularity on a daily basis, and with countless ways to host them, the cost of running APIs remains tightly coupled to how you design the architecture of your application.</p><p>If cost is a factor you want to get right, then you need to revisit the architecture of your application and understand the trade-offs you are making. One of my favourite cloud architecture approaches is serverless architecture.</p><p>There are many serverless or serverless-style services on AWS. Some examples are:</p><ul><li>API Gateway</li><li>Lambda</li><li>DynamoDB</li><li>S3</li><li>SQS</li><li>Fargate</li></ul><p>And many more.</p><p>Serverless does <strong>not</strong> mean there are no servers. Come on 😁. It means there are no servers for <strong>you</strong> to provision, patch, operate, or babysit. There are obviously servers under the hood. They are just managed by AWS.</p><p>In this article, I am going to focus on a real problem I encountered while building my <a href="https://ghanavats.tech/projects/aws-clean-architecture-starter-kit">AWS Clean Architecture Starter Kit</a>: <strong>latency with Lambda APIs after inactivity</strong>.</p><p>This is not theory. I tested it, broke it down, got misled by some numbers, corrected the measurements, and eventually got the API below 1 second after inactivity.</p><h3>ECS</h3><p>One of the best ways to host your application backend is containerisation. I am not going to go deep into how to deploy to ECS in this article. That is not the point here.</p><p>The point is to compare the architectural trade-off between running an API continuously in containers versus running it on demand with Lambda.</p><p>ECS supports two common ways to run containers:</p><ul><li>ECS on EC2</li><li>ECS on Fargate</li></ul><p>Let’s not argue about EC2. We all know EC2 is not serverless. But what about Fargate?</p><p>AWS calls Fargate a serverless compute engine for containers. Fair enough. You do not provision or manage the underlying compute infrastructure. However, from an application architecture point of view, I still do not treat ECS/Fargate as the same kind of serverless experience as Lambda.</p><p>Why?</p><p>Because with ECS/Fargate, you still manage important parts of the container architecture:</p><ul><li>task definitions</li><li>ECS services</li><li>desired task count</li><li>deployment behaviour</li><li>scaling policies</li><li>container health checks</li><li>networking</li><li>load balancing</li></ul><p>That is not a bad thing. It is just a different trade-off.</p><p>Applications running in ECS/Fargate generally continue running while your service maintains running tasks. You pay for those running tasks, even if the API is sitting there doing nothing. That may be perfectly acceptable for latency-sensitive APIs, but it is not the same cost model as Lambda.</p><p>And that is as much as I want to say about ECS in this article.</p><h3>Lambda</h3><p>On the other side, we have Lambda.</p><p>Lambda is much closer to the serverless model most people think about. You do not provision servers, you do not manage the runtime host, and you do not manually scale EC2 instances. Lambda handles the execution environment and scales horizontally as requests come in.</p><p>In my <a href="https://ghanavats.tech/projects/aws-clean-architecture-starter-kit">AWS Clean Architecture Starter Kit</a>, I chose Lambda for the API hosting model. It is easy to deploy, easy to configure, and easy to connect to API Gateway using CDK.</p><p>But in architecture, nothing is free.</p><p>You always pay somewhere.</p><p>With Lambda, one of the things you need to understand properly is cold start latency.</p><h3>Lambda Cold Starts</h3><p>One of the important aspects of serverless architecture is how the service behaves when it has not been used for a while.</p><p>With Lambda, AWS may reuse an existing execution environment for later invocations. But after a period of inactivity, or when Lambda needs to scale out, there may be no warm execution environment ready for your request. In that case, Lambda has to prepare one.</p><p>That extra preparation time is what we call a <strong>cold start</strong>.</p><p>For a normal non-SnapStart Lambda cold start, the rough shape is:</p><pre>Cold start path = Init Duration + Duration</pre><p>For a SnapStart-restored Lambda invocation, the rough shape is:</p><pre>SnapStart restored path = Restore Duration + Duration</pre><p>Those fields matter. Client-side tools such as Postman or curl are useful, but they do not tell the full Lambda story on their own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JgJzjq0gZ3DPk2mX.png" /><figcaption>Response time in Cold Start</figcaption></figure><p>Cold starts also happen when a function is invoked for the first time or when Lambda has to create a new execution environment during scale-out.</p><p>This is the part you need to understand as an architect:</p><blockquote><em>Can your API tolerate that first-request latency?</em></blockquote><p>There is no universal answer. It depends on the workload.</p><p>For internal tools, admin APIs, low-traffic apps, event-driven workloads, and async workloads, Lambda can be an excellent fit.</p><p>For APIs that need consistently low p99 latency, especially after idle periods or during scale-out, you need to be more careful.</p><p>In my case, the endpoint was simple. It was a /api/people/{id} endpoint reading a record from DynamoDB. Nothing crazy. No heavy computation. No massive payload.</p><p>And yet, after inactivity, I was seeing responses around 2 seconds.</p><p>That was not acceptable enough for me to ignore.</p><p>So I investigated.</p><h3>Lambda SnapStart</h3><p>Lambda SnapStart is designed to improve startup performance by taking a snapshot of the initialised execution environment and restoring from that snapshot later.</p><p>In simple terms:</p><ul><li>Lambda initialises your function.</li><li>Lambda takes a snapshot of memory and disk state.</li><li>Later, instead of doing a normal initialisation from scratch, Lambda restores from that snapshot.</li></ul><p>That sounds like magic. It is not. It is engineering. And it still has trade-offs.</p><p>SnapStart applies to published versions. This part is critical.</p><p>If you enable SnapStart but keep invoking $LATEST, you are not testing SnapStart properly. You need to publish a version and invoke that version, usually through an alias such as dev, test, or prod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E3addQqkxcHE6V3U.png" /><figcaption>SnapStart is enabled and will be on when next version published</figcaption></figure><p>Once a new version is published and SnapStart optimisation is complete, SnapStart shows as On for the published version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gPlu-wfFTnTJNk5s.png" /><figcaption>SnapStart is on</figcaption></figure><p>But here is the mistake I nearly made:</p><blockquote><em>Enabling SnapStart is not the same as optimising for SnapStart.</em></blockquote><p>That distinction matters.</p><h3>Measuring the Right Thing</h3><p>At first, I tested with Postman. That was useful, but it was also misleading.</p><p>Postman response time includes more than the backend execution time. It can include:</p><ul><li>socket initialisation</li><li>DNS lookup</li><li>TCP handshake</li><li>TLS handshake</li><li>waiting for first byte</li><li>download time</li><li>client-side processing</li></ul><p>So I moved to curl to get cleaner timing breakdowns.</p><p>This is the command I used:</p><pre>curl -s -H &quot;x-api-key: your_api_key&quot; -o /dev/null \<br>  -w &quot;namelookup: %{time_namelookup}s\nconnect: %{time_connect}s\nappconnect: %{time_appconnect}s\npretransfer: %{time_pretransfer}s\nstarttransfer_ttfb: %{time_starttransfer}s\ntotal: %{time_total}s\n&quot; \<br>  &quot;https://apigatewayid.execute-api.eu-west-1.amazonaws.com/dev/api/people/person_id&quot;</pre><p>The key field was:</p><pre>curl backend wait = starttransfer_ttfb - pretransfer</pre><p>That gave me a better view of how long the client waited after the connection was ready.</p><p>But even curl was not enough on its own.</p><p>I also checked:</p><ul><li>API Gateway Latency</li><li>API Gateway IntegrationLatency</li><li>Lambda Init Duration</li><li>Lambda Restore Duration</li><li>Lambda Duration</li><li>DynamoDB SuccessfulRequestLatency</li></ul><p>That last one was important.</p><p>DynamoDB was not the problem.</p><p>Across the tests, DynamoDB SuccessfulRequestLatency stayed low: around 6-14 ms. The slow part was not the DynamoDB table. The slow part was the first SDK/network/runtime path from the restored Lambda environment.</p><h3>Prepare your application for SnapStart</h3><p>This is the part most people will miss.</p><p>I enabled SnapStart, published the version, wired the alias correctly, waited 5–6 minutes, tested again, and the response was still poor.</p><p>In fact, it was worse in one test.</p><p>That was annoying, but it was also useful.</p><p>It forced me to stop assuming and start measuring properly.</p><h4>Memory Was a Bottleneck</h4><p>My Lambda initially had 1024 MB memory.</p><p>That was not enough for this .NET Lambda API path.</p><p>I increased memory gradually:</p><ul><li>1024 MB</li><li>1800 MB</li><li>2048 MB</li></ul><p>The first jump made a meaningful difference, 1390 ms down from 2230 ms. The jump from 1800 MB to 2048 MB was smaller, but still worth testing. This time slight improvement down to 1200 ms.</p><p>This matters because Lambda memory is tied to CPU allocation. More memory gives your function more CPU capacity, which can help with .NET runtime work, JSON serialisation, AWS SDK work, TLS/signing, and framework overhead.</p><h4>Hello World Warm-Up Was Not Enough</h4><p>I found out that for .Net applications the JIT compilation and assembly loading time can also be a bottleneck. This was when I learned about runtime hooks, in particular RegisterBeforeSnapshot().</p><p>I then tried warming a hello-world endpoint before the snapshot.</p><p>That helped a bit, but it did not solve the real problem.</p><p>Why?</p><p>Because hello-world warmed the wrong path.</p><p>My real endpoint was:</p><pre>/api/people/{id}</pre><p>That endpoint exercised:</p><ul><li>ASP.NET Core routing</li><li>minimal API path</li><li>handler resolution</li><li>repository logic</li><li>DynamoDB SDK</li><li>response mapping</li></ul><p>A hello-world endpoint does not warm all of that.</p><p>So I changed the warm-up to target the real endpoint path.</p><pre>builder.Services.AddAWSLambdaBeforeSnapshotRequest(<br>    new HttpRequestMessage(HttpMethod.Get, &quot;api/people/00000000-0000-0000-0000-000000000001&quot;));</pre><p>I used a fixed diagnostic ID. Do not use random production data for this. Create a harmless diagnostic record that exists only to warm the path.</p><p>Also, do not warm endpoints that write data. That is asking for trouble.</p><p>The point is not to run business logic for its own sake. The point is to warm deterministic and reusable startup paths before Lambda creates the snapshot.</p><h3>Important SnapStart Warning: Uniqueness</h3><p>SnapStart snapshots initialised state.</p><p>That means you must be careful with anything generated during initialization.</p><p>Do not generate these before the snapshot if they must be unique after restore:</p><ul><li>request IDs</li><li>unique runtime IDs</li><li>secrets</li><li>random seeds</li><li>entropy used for security-sensitive randomness</li><li>per-request timestamps</li></ul><p>If a value must be unique per request, generate it during the request.</p><p>If a value must be unique per restored execution environment, regenerate it after restore.</p><p>This is not a theoretical concern. It is part of using SnapStart correctly.</p><h3>The Tests</h3><p>I tested the same endpoint:</p><pre>GET /api/people/{id}</pre><p>I used three scenarios:</p><ol><li>No SnapStart, no warm-up</li><li>SnapStart enabled, no warm-up</li><li>SnapStart enabled, with real-path warm-up</li></ol><p>All timings below are normalised to milliseconds.</p><h3>Test #1 — No SnapStart, No Warm-Up</h3><p>This test gave me the baseline for a normal Lambda cold start without SnapStart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*rhIi3upIBI1JtBc0J6dzpg.png" /></figure><p>The important number here is the Lambda-side total:</p><pre>Init Duration + REPORT Duration = 1125.48 ms</pre><p>So the backend cold path was already above 1 second before adding client-side/network overhead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HhZ_sYqZnpp5TvPa.png" /><figcaption>No SnapStart enabled and no warmup mechanism configured</figcaption></figure><h3>Test #2 — SnapStart Enabled, No Warm-Up</h3><p>This was the annoying one.</p><p>SnapStart was enabled. The function was published. The alias was pointing to the published version. CloudWatch showed Restore Duration.</p><p>So SnapStart was working.</p><p>But the API was not faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*MqAhBIeWYsvAvQ8oO-WoiA.png" /></figure><p>The key calculation:</p><pre>Restore Duration + REPORT Duration = 1,573.11 ms</pre><p>This was worse than the normal non-SnapStart cold start.</p><p>That is the part people need to understand.</p><p>SnapStart was technically working, but the application was not prepared properly for SnapStart. The first restored request still paid expensive first-use costs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5lCLUZNJGWsjs-r_.png" /><figcaption>SnapStart enabled and no warmup mechanism configured</figcaption></figure><h3>Test #3 — SnapStart Enabled, Real-Path Warm-Up</h3><p>This is where the result finally became useful.</p><p>I kept SnapStart enabled, but added warm-up for the actual /api/people/{id} path before snapshot creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*Yi7R-oyYPjW7SbUX_4Q6Ug.png" /></figure><p>The key calculation:</p><pre>Restore Duration + REPORT Duration = 621.82 ms</pre><p>This was the result I was looking for.</p><p>The API response after inactivity dropped below 1 second from curl.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w37ci5BCEqc4JwAr.png" /><figcaption>SnapStart enabled and with warmup mechanism configured</figcaption></figure><h3>All tests aggregated</h3><p>Here is the full comparison — a bit simplified to help with readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*86r1J3YuOopgp8aRLxvd6w.png" /></figure><p>The numbers are gathered from CloudWatch logs and API calls results via curl (last three).</p><h3>Lessons learned</h3><p>The biggest lesson was this:</p><blockquote><em>SnapStart alone was not enough.</em></blockquote><p>In my test, SnapStart without warm-up was worse than the normal non-SnapStart cold start.</p><p>That does not mean SnapStart is bad. It means I had not prepared the application properly.</p><p>The meaningful improvement came when I warmed the actual request path before the snapshot.</p><p>The latency was mainly coming from the Lambda cold/restore path, first-use application code, SDK/network setup, and framework/runtime costs.</p><h3>Conclusion</h3><p>Using Lambda to host APIs is exciting, cost-effective, and massively scalable. But it can be a poor choice if you use it blindly and ignore the cold start behaviour.</p><p>The lazy take is:</p><blockquote><em>Lambda is bad for latency-sensitive APIs because after idle it can take 2 seconds.</em></blockquote><p>That statement is incomplete.</p><p>In my opinion and after all my investigations:</p><blockquote><em>Lambda can be poor for latency-sensitive APIs if you do not understand and optimise the cold/restore path.</em></blockquote><p>In my case, the API did show around 2 seconds after inactivity. But the cause was not simply “Lambda is slow”.</p><p>The real causes were:</p><ul><li>cold/restore startup cost</li><li>low memory allocation</li><li>first-use .NET/runtime costs</li><li>first-use AWS SDK/network path</li><li>warming the wrong endpoint path</li><li>measuring with client-side tools without separating backend time properly</li></ul><p>After enabling SnapStart correctly, increasing memory, and warming the real /api/people/{id} path before snapshot creation, I got the response to sub-second after inactivity.</p><p>That is the real architectural takeaway.</p><p>Lambda is not the answer for every API. ECS/Fargate is still a very strong option, especially when you need consistently low latency and always-running services.</p><p>But Lambda is also not weak just because cold starts exist.</p><p>The truth is more boring and more useful:</p><blockquote><em>You need to understand the trade-off, measure properly, and optimise the actual path your users hit.</em></blockquote><p>No magic. No marketing fluff. Just architecture.</p><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-06-23-lambda_coldstarts/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=482521483ce0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DynamoDB Broke My Architecture]]></title>
            <link>https://medium.com/@GhanavatSaeed/when-clean-architecture-meets-dynamodb-5718b2452c45?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5718b2452c45</guid>
            <category><![CDATA[aws-dynamodb]]></category>
            <category><![CDATA[repository-pattern]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 19:33:59 GMT</pubDate>
            <atom:updated>2026-07-12T12:22:23.961Z</atom:updated>
            <content:encoded><![CDATA[<h4>A practical look at integrating DynamoDB into a Clean Architecture solution, the challenges of preserving repository abstractions, and why introducing a dedicated persistence model turned out to be the simpler solution.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TTUysD3TpeuYZ0QCdXaDKw.png" /></figure><p>I thought integrating DynamoDB into my Clean Architecture solution would take an afternoon.</p><p>I already had repository abstractions.</p><p>I already had an EF Core implementation.</p><p>Surely I could swap the persistence layer and keep the rest of the architecture unchanged.</p><p>I was wrong.</p><p>Over the next two days I discovered that the hardest part wasn’t learning DynamoDB.</p><p>It was realising that my existing abstractions were built around assumptions that no longer held true.</p><p>I wanted to build a Clean Architecture solution hosted on AWS Lambda, deployed with CDK, and backed by DynamoDB.</p><h3><strong>Original architecture</strong></h3><p>What I expected to be a straightforward persistence change turned into a much larger architectural challenge.</p><p>What I had in mind was a focused and opinionated Clean Architecture solution built around serverless AWS services.</p><p>The architecture consisted of:</p><ul><li>AWS Lambda hosting the API</li><li>API Gateway routing requests</li><li>DynamoDB providing persistence</li><li>AWS CDK managing infrastructure*</li></ul><p>The codebase itself was intended to remain relatively simple:</p><ul><li>Core containing entities and business rules</li><li>Infrastructure handling persistence concerns</li><li>IaC isolated in a dedicated CDK project</li></ul><p>At this point I assumed the persistence technology could be swapped without affecting the architecture significantly.</p><p>It was also planned to use my small Repository Pattern package, <a href="https://github.com/ghanavat/Repository">Ghanavats.Repository</a>, which I originally created to centralise common persistence functionality and hide implementation details behind simple abstractions.</p><h3><strong>Repository package</strong></h3><p>The purpose of the package was simple.</p><p>Hide persistence concerns behind common abstractions so the rest of the application remains unaware of the underlying database implementation.</p><p>The package currently provides implementations built around EF Core’s DbContext.</p><p>In theory, this should have made swapping persistence technologies easier.</p><p>In practice, it did not.</p><h3><strong>Why I thought it would work</strong></h3><p>My first instinct was to extend the existing Repository package and add DynamoDB support behind the same abstractions.</p><p>The idea seemed reasonable.</p><p>I already had abstractions such as:</p><pre>public interface IRepository&lt;T&gt; : IReadRepository&lt;T&gt; where T : class</pre><p>Why not provide another implementation?</p><p>The problem was that the abstractions had been designed around EF Core’s way of querying and working with data.</p><p>I spent a lot of time trying to force the existing abstractions to work.</p><p>The more I pushed in that direction, the more friction I created.</p><p>Some repository methods simply did not map cleanly to DynamoDB operations.</p><p>What looked like a generic abstraction was actually carrying assumptions from EF Core.</p><h3><strong>IAmazonDynamoDB vs DynamoDBContext</strong></h3><p>This was another point of confusion.</p><p>AWS provides multiple ways to interact with DynamoDB.</p><p>The two options I spent most of my time evaluating were:</p><ul><li>IAmazonDynamoDB</li><li>DynamoDBContext</li></ul><p>The low-level interface is exposed through IAmazonDynamoDB.</p><p>This API maps very closely to DynamoDB’s underlying operations and gives complete control over requests and responses.</p><p>A simplified example looks like this:</p><pre>internal sealed class PeopleRepository : IPeopleRepository<br>{<br>    private readonly IAmazonDynamoDB _dynamoDb;<br><br>    public PeopleRepository(IAmazonDynamoDB dynamoDb)<br>    {<br>        _dynamoDb = dynamoDb;<br>    }<br><br>    public async Task&lt;Person&gt; GetPersonById(Guid personId)<br>    {<br>        var getItemRequest = new GetItemRequest<br>        {<br>            TableName = &quot;Person&quot;,<br>            Key = new Dictionary&lt;string, AttributeValue&gt;<br>            {<br>                { &quot;PersonId&quot;, new AttributeValue { S = personId.ToString(&quot;D&quot;) } }<br>            }<br>        };<br><br>        var result = await _dynamoDb.GetItemAsync(getItemRequest);<br><br>        var personIdMapped = result.Item[&quot;PersonId&quot;].S;<br>        var somePropertyMapped = result.Item[&quot;SomeProperty&quot;].S;<br><br>        var person = Person.Create(personIdMapped, somePropertyMapped);<br><br>        return person;<br>    }<br>}</pre><p>While powerful, this approach introduces a lot of manual mapping code.</p><p>The alternative is DynamoDBContext.</p><p>This high-level interface acts as a wrapper around IAmazonDynamoDB and handles much of the mapping logic automatically.</p><p>A simplified example:</p><pre>internal sealed class PeopleRepository : IPeopleRepository<br>{<br>    private readonly DynamoDBContext _dbContext;<br><br>    public PeopleRepository()<br>    {<br>        var clientConfig = new AmazonDynamoDBConfig<br>        {<br>            RegionEndpoint = RegionEndpoint.EUWest1<br>        };<br><br>        var client = new AmazonDynamoDBClient(clientConfig);<br><br>        _dbContext = new DynamoDBContextBuilder()<br>            .WithDynamoDBClient(() =&gt; client)<br>            .Build();<br>    }<br><br>    public async Task&lt;Person&gt; GetPersonById(Guid personId)<br>    {<br>        var result = await _dbContext.LoadAsync&lt;DynamoDbPerson&gt;(personId.ToString(&quot;D&quot;));<br>        return result.ToDomain();<br>    }<br>}</pre><p>After experimenting with both approaches, DynamoDBContext felt like the better fit for the starter kit.</p><h3><strong>Mapping challenge</strong></h3><p>This is where things became interesting.</p><p>With EF Core, I typically keep persistence concerns out of the domain and configure mappings through the Fluent API inside DbContext.</p><p>DynamoDBContext takes a different approach.</p><p>Entities need to be decorated with attributes so DynamoDB knows how to map them correctly.</p><p>Examples include:</p><ul><li>DynamoDBTable</li><li>DynamoDBHashKey</li><li>DynamoDBProperty</li></ul><p>Adding these attributes directly to my domain entities would have introduced a dependency from the Core layer to the AWS SDK.</p><p>That would violate one of the design principles I wanted the template to enforce.</p><p>The challenge was no longer DynamoDB itself.</p><h3><strong>Persistence model solution</strong></h3><p>The challenge was introducing DynamoDB without leaking AWS-specific concerns into the <em>Core</em> layer.</p><p>Eventually I stopped fighting the SDK.</p><p>I decided to:</p><ul><li>Use DynamoDBContext</li><li>Implement a dedicated repository in <em>Infrastructure</em></li><li>Keep the domain model unchanged</li><li>Introduce a dedicated persistence model for DynamoDB mapping</li></ul><p>Rather than forcing DynamoDB to fit my existing Repository package, I introduced a DynamoDB-specific persistence model.</p><p>Example:</p><pre>[DynamoDBTable(&quot;People&quot;)]<br>internal sealed class DynamoDbPerson<br>{<br>    [DynamoDBHashKey]<br>    public string PersonId { get; init; } = string.Empty;<br><br>    [DynamoDBProperty]<br>    public string Name { get; init; } = string.Empty;<br><br>    [DynamoDBProperty]<br>    public string Email { get; init; } = string.Empty;<br><br>    [DynamoDBProperty]<br>    public string Phone { get; init; } = string.Empty;<br><br>    [DynamoDBProperty]<br>    public string DateOfBirth { get; init; } = string.Empty;<br>}</pre><p>This allowed the <em>Infrastructure</em> layer to own all DynamoDB-specific concerns while keeping the <em>Core</em> project free from AWS dependencies.</p><p>To recreate domain entities from persistence models, I introduced a hydration factory:</p><pre>public static Person Rehydrate(<br>    Guid id,<br>    string name,<br>    string email,<br>    string phone,<br>    string dateOfBirth)<br>{<br>    return new Person(id, name, email, phone, dateOfBirth);<br>}</pre><p>And a mapper:</p><pre>internal static class PersonMapper<br>{<br>    extension(DynamoDbPerson? source)<br>    {<br>        public Person? ToDomain()<br>        {<br>            if (source is null)<br>            {<br>                return null;<br>            }<br><br>            return Person.Rehydrate(<br>                Guid.Parse(source.PersonId),<br>                source.Name,<br>                source.Email,<br>                source.Phone,<br>                source.DateOfBirth);<br>        }<br>    }<br>}</pre><p>The final design ended up being much simpler than my original approach.</p><p>Instead of introducing AWS-specific dependencies into the Core layer, I created a dedicated persistence model in Infrastructure and mapped it to the domain entity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*lSbaazE93-Skq5mF.gif" /></figure><p>This implementation is now part of the <a href="https://ghanavats.tech/projects/aws-clean-architecture-starter-kit">AWS Clean Architecture Starter Kit</a> and will likely evolve as I gain more experience with DynamoDB.</p><h3><strong>Lessons learned</strong></h3><p>Not every abstraction survives a change in persistence technology.</p><p>I expected my repository package to hide DynamoDB in the same way it hid EF Core. In reality, DynamoDB introduces different access patterns and assumptions.</p><p>Clean Architecture is more about dependency direction than specific technologies.</p><p>The biggest challenge was not DynamoDB itself. It was preventing AWS-specific concerns from leaking into the Core layer.</p><p>Sometimes a dedicated implementation is simpler than a generic abstraction.</p><p>I spent a considerable amount of time extending an existing repository package before realising a small, focused DynamoDB implementation was easier to understand and maintain.</p><p>Persistence models and domain models do not always have to be the same thing.</p><p>Introducing a DynamoDB-specific persistence model allowed me to keep the domain clean while still benefiting from DynamoDBContext and its attribute-based mapping.</p><h3><strong>Conclusion</strong></h3><p>If I were starting this implementation again today, I would still choose DynamoDBContext and a dedicated persistence model.</p><p>The solution ended up being much simpler than the repository abstraction I originally tried to preserve.</p><p>Sometimes the best architectural decision is not finding a way to keep an abstraction alive.</p><p>Sometimes it is recognising when it no longer fits the problem you are trying to solve.</p><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-06-18-dynamodb_integration_into_clean_architecture/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5718b2452c45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Recreating .NET Solutions From Scratch]]></title>
            <link>https://medium.com/@GhanavatSaeed/stop-recreating-net-solutions-from-scratch-10f81e3bab63?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/10f81e3bab63</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[template-engine]]></category>
            <category><![CDATA[nuget]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Sun, 14 Jun 2026 23:25:56 GMT</pubDate>
            <atom:updated>2026-08-01T21:28:36.442Z</atom:updated>
            <content:encoded><![CDATA[<h4>Use Microsoft Template Engine Before Copy-Paste Becomes Your Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lB_v7B3GdnnU29jE.png" /></figure><p>I have been there myself, so I am not preaching to you.</p><p>I have spent far too much time building new .NET solutions from scratch. Actually, that is not completely true. Most of the time, I was not starting from scratch. I was copying from the first solution I built, or the second one, or the third one, then modifying it again for the fourth or fifth project.</p><p>It worked, but it was painful.</p><p>The worse part is that when you get used to a painful method, it starts to feel normal. Then normal becomes a habit. Then the habit becomes stubborn. Before you know it, you are defending a bad workflow just because you have repeated it enough times.</p><p>That was my mistake.</p><p>Every time I wanted to start a new API or SaaS-style project, I would spend time thinking about the same things again:</p><ul><li>project structure</li><li>configuration</li><li>OpenAPI</li><li>health checks</li><li>authentication and authorisation</li><li>logging</li><li>testing setup</li><li>architecture tests</li><li>maybe .NET Aspire</li><li>all the other boring but important moving parts</li></ul><p>None of these things are useless. They matter. A good solution needs structure.</p><p>But doing the same setup manually again and again is not engineering. It is waste.</p><h3>Copy and paste is not a real template</h3><p>There is nothing wrong with learning by manually creating a few solutions. In fact, you probably should do that at the beginning. It helps you understand what is actually inside your application.</p><p>The problem starts when you already know your preferred setup, but you still keep copying old projects and cleaning them up by hand.</p><p>That’s why I wrote this article. Believe me, things will go messy if you don’t change your approach.</p><p>You copy an old solution. Then you rename projects. Then you fix namespaces. Then you remove old features. Then you update package versions. Then you change configuration files. Then you realise you forgot something. Then you discover some random leftover name from the previous project.</p><p>That is not a clean starting point. That is a recycled accident.</p><p>A proper template gives you a repeatable way to generate a clean starting point. The .NET CLI uses the Microsoft Template Engine behind dotnet new to create projects and artifacts based on templates and options.</p><h3>Microsoft already gave us the tool</h3><p>Microsoft Template Engine is not some obscure trick. It is the system behind dotnet new.</p><p>You can use existing templates, install template packages, create your own templates, and generate projects from them. Microsoft’s documentation explains that .NET templates can generate projects, files, and resources, and template packages can be installed from NuGet, a NuGet package file, or a file system directory.</p><p>How cool is that?</p><p>That means your standard API setup does not need to live as a half-forgotten GitHub repository that you copy every few months.</p><p>It can become a template.</p><p>For example, instead of manually rebuilding the same solution structure, you could have something like:</p><pre>dotnet new install MySolution.Templates<br>dotnet new mysolution-api -n MyNewApi</pre><p>Then your solution is generated with the structure and defaults you already decided are useful.</p><h3>What should go into a good .NET template?</h3><p>A useful template should not be a dumping ground for every idea you have ever had.</p><p>That is another mistake.</p><p>The goal is not to create a “perfect enterprise solution” before the project even starts. That usually leads to over-engineering. The goal is to create a sensible baseline that saves time without forcing unnecessary complexity.</p><p>For an API template, I would consider including:</p><ul><li>a clean solution and project structure</li><li>sensible naming</li><li>OpenAPI setup</li><li>health checks</li><li>logging configuration</li><li>basic validation setup</li><li>test projects</li><li>architecture test project</li><li>common configuration files</li><li>optional authentication setup</li><li>optional .NET Aspire support, if it genuinely helps</li></ul><p>Microsoft’s template system supports replacing values, including and excluding files, and custom processing during template generation, so you can make templates flexible instead of hard-coding everything.</p><h3>The real benefit is not speed</h3><p>When you create projects manually, every solution slowly becomes different. One has health checks. One does not. One has better logging. One has outdated package references. One has tests in a different structure. One has old naming conventions.</p><p>That inconsistency becomes expensive later.</p><p>A template forces you to make decisions once, improve them over time, and reuse them properly.</p><p>That is how you turn experience into a tool.</p><h3>Honest tip</h3><p>Don’t do this too early.</p><p>If you have only built one solution, you probably do not have a template yet. You have an experiment.</p><p>Build manually a few times. Learn what repeats. Learn what is actually useful. Learn what you keep deleting. Then create a template from the parts that survive.</p><h3>How to create a simple .NET solution template</h3><p>Here is the part that confused me at first.</p><p>Microsoft’s documentation explains custom templates, but the examples are mostly based around item templates, project templates, and packaging templates. That is useful, but it can make the process look more complicated than it needs to be when your actual goal is simple:</p><blockquote><em>I already have a full .NET solution structure I like. I want to reuse it.</em></blockquote><p>You do not need to start with a strange folder structure such as working, content, and separate test folders just because a tutorial uses that approach.</p><p>You can start with a real solution.</p><p>Build the solution the way you actually want future projects to look.</p><p>For example:</p><pre>TemplateSolution/<br>│<br>├── TemplateSolution.sln<br>│<br>├── src/<br>│   ├── TemplateSolution.Api/<br>│   ├── TemplateSolution.Application/<br>│   ├── TemplateSolution.Domain/<br>│   └── TemplateSolution.Infrastructure/<br>│<br>├── tests/<br>│   ├── TemplateSolution.UnitTests/<br>│   └── TemplateSolution.ArchitectureTests/<br>│<br>└── .template.config/<br>    └── template.json</pre><p>The important part is this:</p><pre>.template.config/template.json</pre><p>That folder should sit at the root of your template, next to the .sln file.</p><p>Microsoft’s documentation confirms that the template.json file belongs inside a .template.config folder at the root of the template, and that the template source files can be whatever files and folders you want the template engine to use.</p><h3>Step 1: Create your normal solution</h3><p>Create your solution exactly how you like it.</p><p>But be careful.</p><p>A template should include repeatable foundations, not every random idea you once thought was clever.</p><p>Also remove junk before turning it into a template, or use .gitignore. Do not include secrets. Do not include real connection strings. Do not include environment-specific rubbish. That mistake is not “template engineering”; it is negligence.</p><h3>Step 2: Use a clear placeholder name</h3><p>Pick a source name that appears everywhere in the solution.</p><p>For example TemplateSolution. Then use it in:</p><pre>TemplateSolution.sln<br>TemplateSolution.Api<br>TemplateSolution.Application<br>TemplateSolution.Domain<br>TemplateSolution.Infrastructure</pre><p>This matters because the template engine can replace the configured sourceName with the name provided by the user when they run dotnet new. Microsoft documents sourceName as the value the template engine searches for in file names and file contents, replacing it with the name passed through -n or --name.</p><p>So later, when someone runs this:</p><pre>dotnet new my-api -n Orders</pre><p>The template engine can replace TemplateSolution with Orders.</p><p>That is the bit that saves you from painful renaming.</p><h3>Step 3: Add .template.config/template.json</h3><p>At the root of the solution, create this folder:</p><pre>.template.config</pre><p>Inside it, create this file:</p><pre>template.json</pre><p>Put the following in as a starting point. This is more complicated than the one in Microsoft documentation. I needed a few more salt and pepper such as the ability to restore NuGet packages, language name and template type:</p><pre>{<br>    {<br>      &quot;$schema&quot;: &quot;http://json.schemastore.org/template&quot;,<br>      &quot;author&quot;: &quot;Saeed Ghanavat&quot;,<br>      &quot;classifications&quot;: [<br>        &quot;Common&quot;,<br>        &quot;WebApi&quot;,<br>        &quot;ClassLibrary&quot;,<br>        &quot;Clean Architecture&quot;<br>      ],<br>      &quot;name&quot;: &quot;YourCompany API Solution&quot;,<br>      &quot;description&quot;: &quot;Whatever description you want.&quot;,<br>      &quot;identity&quot;: &quot;YourCompany.ApiSolution.Templates&quot;,<br>      &quot;shortName&quot;: &quot;my-api-template&quot;,<br>      &quot;tags&quot;: {<br>        &quot;language&quot;: &quot;C#&quot;,<br>        &quot;type&quot;: &quot;solution&quot;<br>      },<br>      &quot;sourceName&quot;: &quot;TemplateSolution&quot;,<br>      &quot;preferNameDirectory&quot;: true,<br>      &quot;primaryOutputs&quot;: [<br>        {<br>          &quot;path&quot;: &quot;YouSolution.Templates.sln&quot;<br>        }<br>      ],<br>      &quot;postActions&quot;: [<br>        {<br>          &quot;actionId&quot;: &quot;210D431B-A78B-4D2F-B762-4ED3E3EA9025&quot;,<br>          &quot;description&quot;: &quot;Restore NuGet packages required by this project.&quot;,<br>          &quot;condition&quot;: &quot;(!skipRestore)&quot;,<br>          &quot;continueOnError&quot;: true,<br>          &quot;manualInstructions&quot;: [<br>            {<br>              &quot;text&quot;: &quot;Run &#39;dotnet restore&#39;&quot;<br>            }<br>         ]<br>      }<br>    ]<br>  }<br>}</pre><p>The $schema value is useful because editors that support JSON schemas can provide validation and IntelliSense. This helped me a lot because I was not guessing every property manually. Microsoft also documents this schema field and explains that the full schema is available through JSON Schema Store.</p><p>The most important values are:</p><pre>shortName<br>sourceName<br>identity<br>name</pre><p>shortName is what you type in the CLI.</p><pre>dotnet new my-api-template</pre><p>sourceName is the placeholder name that gets replaced:</p><pre>TemplateSolution</pre><p>identity should be unique.</p><p>name is the friendly display name.</p><h3>Step 4: Install the template locally</h3><p>Open a terminal at the root of your solution, where the .sln file and .template.config folder are.</p><p>Then run:</p><pre>dotnet new install ./</pre><p>The dotnet new install command installs a template package from a path or NuGet package ID. For local development, installing from the current folder is enough.</p><p>Then check that your template is available:</p><pre>dotnet new list</pre><p>You should see your template listed with the short name you configured.</p><h3>Step 5: Generate a new solution from your template</h3><p>Now test it properly.</p><p>Go to a different folder and run:</p><pre>dotnet new my-api-template -n OrdersService</pre><p>That should generate a new solution based on your template.</p><p>Then build it, please. You don’t want a broken code generated off of your template.</p><pre>dotnet build</pre><h3>Step 6: Improve the template over time</h3><p>Your first version will probably not be perfect.</p><p>That is fine.</p><p>Use it. Find what feels wrong. Remove unnecessary things. Add missing things. Keep improving the baseline. This is exactly what I did.</p><p>When you change the template and need to reinstall it, you can uninstall and install it again:</p><pre>dotnet new uninstall ./<br>dotnet new install ./</pre><p>This is where the value starts to show.</p><p>Instead of improving one project and forgetting to copy the improvement elsewhere, you improve the template. Then every new project starts from a better place.</p><p>That is it.</p><p>The hard part is not the tooling. The hard part is deciding what your standard solution should look like.</p><p>And that is exactly why templates are useful. They force you to stop rebuilding the same foundation again and again, and they turn your repeated decisions into something reusable.</p><p>If you like to take this further and learn more advanced setup, this article — <a href="https://medium.com/@GhanavatSaeed/how-i-turned-4-net-templates-into-1-with-symbols-and-sources-e8079892d9d1">How I Turned 4 .NET Templates Into 1</a> is for you:</p><p>You can watch me doing it in this YouTube video:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FoSwfae3H4DU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DoSwfae3H4DU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoSwfae3H4DU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0169f24ee85b7fa8aae4193a507cf7ab/href">https://medium.com/media/0169f24ee85b7fa8aae4193a507cf7ab/href</a></iframe><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-06-14-pack_you_dotnet_project_as_template/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10f81e3bab63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a Free AWS Clean Architecture Starter Kit for .NET Developers]]></title>
            <link>https://medium.com/@GhanavatSaeed/i-built-a-free-aws-clean-architecture-starter-kit-for-net-developers-6262d381b7b3?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6262d381b7b3</guid>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Sat, 13 Jun 2026 16:07:32 GMT</pubDate>
            <atom:updated>2026-06-13T16:07:32.767Z</atom:updated>
            <content:encoded><![CDATA[<h4>A practical V1 template for .NET developers who want to start a SaaS-style backend on AWS without spending weeks fighting infrastructure 🚀</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/0*F9z-umgJVWhb1V4g.png" /></figure><p>Most .NET AWS starter projects I have seen usually fall into one of two camps.</p><p>They are either too basic to be useful beyond a demo, or they are so over-engineered that you need half a DevOps team just to understand what is going on.</p><p>When .NET developers move from local development to AWS, the problem is rarely writing code.</p><p>I wanted something closer to how I would actually start a real SaaS backend.</p><p>Not perfect. Not enterprise-grade. Not pretending to solve every problem.</p><p>Just a practical starting point for a .NET developer or small team that wants to build something properly and deploy it to AWS without spending weeks stuck in infrastructure decisions.</p><h3>The problem I keep seeing</h3><p>Building the application is often not the hardest part.</p><p>The painful part starts when you need to answer questions like:</p><ul><li>How should the solution be structured?</li><li>Where should the infrastructure live?</li><li>How do I deploy this without creating a mess?</li><li>Should I use Terraform, CloudFormation, CDK, or something else?</li><li>How do I keep this simple enough for a small team?</li><li>How do I avoid building a toy project that falls apart after the first few real features?</li></ul><p>I have seen teams spend a huge amount of time on infrastructure before the actual SaaS product has even proved itself.</p><p>That feels backwards to me.</p><p>Infrastructure matters, but early on it should help you ship faster, not become the main project.</p><p>How cool would it be if you could deploy/release daily when you have a proper system built that build the infrastructure you software needs?</p><h3>Why I chose AWS CDK instead of Terraform</h3><p>I decided not to use Terraform for this version.</p><p>Not because Terraform is bad. It clearly works and plenty of teams use it successfully.</p><p>But for this starter kit, I wanted something that feels more natural for .NET developers. AWS CDK lets me define infrastructure using C#, which means the infrastructure code sits closer to the way many .NET engineers already think and work.</p><p>That was the main reason.</p><p>The goal is not to start a Terraform vs CDK debate. So, don’t send me your fire balls on this matter 😀. The goal is to make deployment feel less painful for developers (oh man including myself) who are already comfortable in C#.</p><h3>What I built</h3><p>I built a Clean Architecture starter template for .NET developers who want to deploy a SaaS-style backend to AWS.</p><p>Yes, another Clean Architecture template. Why not? 🤣</p><p>But this one is not just about folder structure.</p><p>The point of this project is to combine the application foundation with the first version of the AWS deployment setup.</p><p>So instead of just giving you a .NET solution and leaving you to figure out the cloud side yourself, the repository includes the early deployment stacks using AWS CDK.</p><p>The idea is simple 💡:</p><blockquote>Give developers a cleaner starting point so they can move faster without creating a mess from day one.</blockquote><h3>What is inside?</h3><p>The repository currently includes:</p><ul><li>Clean Architecture multi-project template using Microsoft Template Engine</li><li>Minimal API</li><li>A basic end-to-end feature implementation</li><li>Some DDD-style thinking, kept intentionally simple</li><li>Unit tests using xUnit</li><li>AWS CDK deployment stacks</li><li>Multi-stack deployment approach</li><li>Serverless architecture direction</li><li>Documentation to help you try it</li></ul><p>High level solution structure looks like this:</p><pre>├── Application<br>│   └── Ghanavats.CleanArchitecture.UseCases<br>├── Core<br>│   └── Ghanavats.CleanArchitecture.Core<br>├── Framework<br>│   ├── Ghanavats.CleanArchitecture.IaC.AWS<br>│   └── Ghanavats.CleanArchitecture.Infrastructure<br>├── Presentation<br>│   └── Ghanavats.CleanArchitecture.Api<br>└── Shared<br>    └── Ghanavats.CleanArchitecture.Shared</pre><p>The IaC project structure looks like this:</p><pre>├── ApiGatewayStack<br>│   └── ApiGatewayDeploymentStack.cs<br>├── ApplicationStage.cs<br>├── AwsEnvironmentCreator.cs<br>├── DynamoDbStack<br>│   └── DynamoDbDeploymentStack.cs<br>├── LambdaStack<br>│   └── LambdaDeploymentStack.cs<br>└── StackInitializer.cs</pre><p>This is V1, so I am not pretending it is complete.</p><p>There are things missing. There are probably things that should be improved. And honestly, I do not know yet whether developers will find it useful enough.</p><p>That is partly why I am sharing it.</p><h3>Who is this for?</h3><p>This starter kit may be useful if you are:</p><ul><li>A .NET developer trying to get more comfortable with AWS</li><li>Building a SaaS-style backend and want a cleaner starting point</li><li>Interested in Clean Architecture but want something more practical than theory</li><li>Tired of tutorials that stop before real deployment starts</li><li>A small team that wants a simple foundation</li></ul><h3>What this is not</h3><p>This is not a complete SaaS boilerplate.</p><p>It does not solve everything.</p><p>It is not trying to be the perfect production-ready platform from day one.</p><p>It is a starting point.</p><p>My goal with V1 is to test whether this direction is useful, get feedback from real developers, and then improve it based on what people actually need.</p><h3>I need feedback</h3><p>I am specifically looking for feedback from:</p><ul><li>.NET developers</li><li>AWS engineers</li><li>startup builders</li><li>people who have deployed real systems</li><li>anyone who has struggled with SaaS deployment decisions</li></ul><p>The areas I care about most:</p><ul><li>Is the project structure useful?</li><li>Does the AWS CDK approach make sense?</li><li>Is the deployment setup simple enough?</li><li>What is missing?</li><li>Would this help you start a real project faster?</li></ul><p>You can check the starter kit here:</p><p><a href="https://ghanavats.tech/projects/aws-clean-architecture-starter-kit/?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=aws_clean_arc_v1">[Ghanavats project page]</a><br> GitHub repo: <a href="https://github.com/ghanavat/aws-clean-architecture-starter-kit">[repo link]</a></p><p>I am not looking for likes.</p><p>I am looking for honest feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6262d381b7b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate from AWS WorkMail to Microsoft Exchange and take your emails with you!]]></title>
            <link>https://medium.com/@GhanavatSaeed/migrate-from-aws-workmail-to-microsoft-exchange-and-take-your-emails-with-you-349b12fcfcc0?source=rss-7ed67d5113b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/349b12fcfcc0</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Saeed Ghanavat]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 23:34:32 GMT</pubDate>
            <atom:updated>2026-06-12T23:34:32.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQtpKi7QdY9g2prBvRPw_Q.png" /></figure><p>AWS WorkMail is being retired, with end of support scheduled for <strong>31 March 2027</strong>. I have been using it as my personal mail server since I began my AWS journey, so this was not something I wanted to ignore until the last minute.</p><p>This article is specific to <strong>AWS WorkMail</strong>, not Amazon SES. That is a separate service and, at the time of writing, this retirement announcement is about WorkMail only.</p><p>The main reason is obvious: WorkMail is being retired, so I needed to move away from it.</p><p>I also had another reason. In my opinion, AWS WorkMail had a basic UI with basic capabilities. To be fair, that was mostly all I needed. But for my personal setup it was not particularly cheap. I was paying for the WorkMail organisation and each mailbox had its own monthly cost. In total, I was paying around <strong>$30 per month</strong>.</p><p>When AWS announced the retirement, I wanted to act early. I did not want to leave it until the last minute and then rush the migration under pressure. It also gave me a good reason to review whether I could run my personal email setup in a cheaper and cleaner way.</p><p>The first thing I needed was an alternative.</p><p>After some investigation and comparing the pros and cons of a few options, I decided to use <strong>Microsoft Exchange Online</strong>. Some may say it is overkill for a personal email setup. I would say it is sustainable, affordable for my use case, feature rich, and easy enough to set up.</p><p>Below is the list I used to plan the migration:</p><ul><li>Domain ownership verification</li><li>MX record reconfiguration</li><li>Email migration from AWS WorkMail to Exchange Online</li><li>How to reduce cost when creating mailboxes</li><li>How many licensed mailboxes I actually needed</li><li>User downtime risk and how to minimise it</li><li>What to test before and after the cutover</li></ul><p>I decided to keep my domain in <strong>AWS Route 53</strong>. I also avoided removing any existing DNS records too early because I did not want to risk losing emails in flight.</p><p>After setting up the new Microsoft Exchange Online subscription, I was able to verify ownership of my domain fairly quickly. This gave me room to manoeuvre. I could create the mailboxes, aliases, and shared mailboxes I needed before touching the MX records.</p><p>At the beginning, the DNS and domain side was straightforward. I only had to revisit it properly once I was ready to complete the cutover and point the MX records to Exchange Online.</p><p>I decided to use only two licensed users: my account and my wife’s account. Only the two of us needed separate personal mailboxes.</p><p>For everything else, I used <strong>aliases</strong> and <strong>shared mailboxes</strong>.</p><p>I created a handful of aliases under my own user mailbox. I like doing this because it gives me a meaningful separation of email addresses without creating unnecessary paid mailboxes.</p><p>For emails that both of us need to manage, I created a few shared mailboxes and gave both of us access to read and manage them. When you create shared mailboxes in Exchange Online, Microsoft 365 creates the necessary underlying account objects. In my case, that was not an issue because the shared mailboxes were tied to the main licensed accounts for access and management.</p><p>To give a better picture of what I ended up with, this is a simplified version:</p><ul><li>My licensed account<br><em>Alias 1<br>Alias 2<br>Alias 3<br>Access to all shared mailboxes</em></li><li>My wife’s licensed account<br><em>Shared mailbox 1<br>Shared mailbox 2<br>Shared mailbox 3<br>Access to all shared mailboxes</em></li></ul><p>This reduced the number of paid accounts and made the setup easier to manage.</p><p>The best approach I could think of was to set up all the mailboxes, shared mailboxes, and aliases I needed first, then leave AWS WorkMail in place until the end of the process. I wanted to continue receiving emails for as long as possible before changing the MX records.</p><p>I then investigated how to migrate my existing emails from AWS WorkMail to Exchange Online. After around two hours of reading, testing, and trial and error, I landed on the migration tool inside the <strong>Exchange Admin Center</strong>. The migration type I needed was <strong>IMAP migration</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/0*gPdK3CWCyJmSud8D.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*MUwAFjrAPaDUpm7O.png" /></figure><p>The Exchange Admin Center has a migration batch tool that lets you migrate mailboxes from different sources. In my case, I only needed IMAP migration.</p><p>Setting up access to my AWS WorkMail mailboxes from the Exchange IMAP migration tool took longer than I first expected. The tool requires a CSV file with the mailbox details. Yes, this includes passwords in plain text. It is what it is, but treat that file carefully and delete it when you no longer need it.</p><p>To save time and reduce pain, the CSV format must look like this:</p><blockquote><em>Note that the values under </em><strong><em>EmailAddress</em></strong><em> and </em><strong><em>UserName</em></strong><em> are the same in this example. AWS WorkMail did not like me using only the username. It expected the full email address as the username.</em></blockquote><p>After uploading the CSV file with all the source mailboxes listed, I was able to migrate and sync the emails from AWS WorkMail into the new Exchange Online mailboxes. The migration report showed the number of synced emails from the source. The migration brought across the inbox, sent items, and my custom folders.</p><p>Shared mailboxes can be added to the Outlook client app and appear under the main account. For Mac users, I had to add the shared mailbox through the legacy Outlook UI first, then switch back to the new UI. Adding the shared mailbox directly from the new Outlook UI did not work for me.</p><blockquote><em>At this stage I had not reconfigured the MX records with the new Exchange Online details. Everything was still untouched in AWS WorkMail.</em></blockquote><p>Once the migration was done, I went back to the Exchange Admin Center and continued the email setup. Microsoft gave me the DNS records I needed to add, including the new MX record.</p><p>In AWS Route 53, I had to delete the existing MX record because editing it directly did not work cleanly for me. I did this quickly and carefully. In less than 10 minutes, the new records were in place and AWS WorkMail was no longer receiving new inbound email for the domain.</p><p>I then logged into my own mailbox and did a sanity check against the migrated data. To my surprise, because I had never done this before, things looked accurate. The migrated emails were there and the folders looked right.</p><p>For testing, I would recommend checking at least the following:</p><ul><li>Send an email from an external address to the new mailbox</li><li>Send an email from Exchange Online to an external address</li><li>Test replies, not just new messages</li><li>Check aliases</li><li>Check shared mailboxes</li><li>Check Outlook desktop/mobile client access</li><li>Check that old WorkMail mailboxes are no longer receiving new messages after the MX cutover</li></ul><p>I made a funny and expensive mistake when I first set up my email server in AWS WorkMail. I created a separate user account and a completely separate mailbox for almost every purpose.</p><p>I had my personal one, then another one for my wife, then another for family stuff, then another for something else, and then repeated that a few more times.</p><p>That approach is fine for millionaires who are not bothered about spending an extra $15 or $20 per month for a personal email server. For me, however, it was expensive. I am not financially free yet!</p><p>I did not make the same mistake again in my new Exchange Online subscription. I became best friends with aliases, shared mailboxes, and Outlook rules to move emails into the right folders. It is cheaper, easier to maintain, and has less configuration overhead.</p><p>Another risk is treating the migration like it is just a technical copy job. It is not. Email is boring until it breaks. If you are doing this for a business, even a small one, you need to think about downtime, DNS propagation, user access, shared mailboxes, and rollback options.</p><p>An IMAP migration is best understood as a controlled mailbox copy.</p><p>Exchange Online does not magically <em>move</em> the mailbox from the source server. Instead, Microsoft 365 connects to the source mail server using IMAP, authenticates against each mailbox, reads the available mail folders, pulls the messages from those folders, and then writes them into the target Exchange Online mailbox.</p><p>For this to work, the target users and mailboxes must already exist in Microsoft 365 before the migration starts. The migration endpoint stores the source IMAP server connection details, and the migration batch uses the CSV mapping file to know which source mailbox maps to which target mailbox.</p><p>It is a simple and direct server-to-server copy process.</p><blockquote><em>One important limitation: IMAP migration is mainly about email messages and mail folders. It does not migrate everything that exists in a full groupware mailbox. Contacts, calendar items, and tasks are not migrated through IMAP, so those need to be handled separately if they matter to you. This is easy to overlook because users often think of a mailbox as email, calendar, contacts, and settings all together. IMAP does not cover all of that.</em></blockquote><figure><img alt="Ghanavats Tech article — Migrate from AWS WorkMail to Exchange" src="https://cdn-images-1.medium.com/max/1024/1*YYCCGFHlli2Hf2VebmXaVw.png" /></figure><p>I found the process fairly straightforward, apart from the trial and error around the mailbox CSV file. If I had known the correct CSV format earlier, the whole process would have been much simpler.</p><p>For my small personal setup, I did not need a separate archive or backup workflow. I also avoided adding anything unnecessary around SES archiving or journaling because it would have added cost and complexity I did not need.</p><p>The key point is this: <strong>IMAP migration is not just a button-click task</strong>. It is a staged copy-and-cutover process. The mailbox data copy, DNS changes, user communication, Outlook reconfiguration, and final verification all need to be planned together.</p><p>The technical migration may be IMAP, but the real success factor is controlling disruption for the users.</p><p>If you encounter issues during the sync process, take a look at the <a href="https://learn.microsoft.com/en-us/troubleshoot/exchange/move-or-migrate-mailboxes/troubleshoot-issues-with-imap-mailbox-migration">Microsoft troubleshooting guide for IMAP mailbox migration</a>.</p><p>Next time, I would prepare the CSV file earlier and test it with one mailbox first. That would have saved me time and removed most of the guesswork.</p><p>I would also create a simple mailbox inventory before starting. Nothing complicated, just a small table showing each source mailbox, the target mailbox, whether it is licensed or shared, and whether it has aliases. For a personal migration this may feel unnecessary, but even a small checklist helps when DNS, passwords, mailboxes, and clients are all involved.</p><p>I would reduce the DNS TTL in advance where possible, then wait before doing the MX cutover. That gives you a better chance of a quicker and cleaner switch when you are ready.</p><p>For a larger or business-critical migration, I would also keep the migration batch running a little longer after the MX cutover and perform a final sync/validation before fully shutting down the old system. I got away with a simple process because my setup was small. I would not treat a business migration casually.</p><p>The biggest lesson is simple: do the boring preparation properly. The migration tool does the copy, but planning avoids the panic.</p><p><em>Originally published at </em><a href="https://ghanavats.tech/blog/2026-06-03-migrate-from-aws-workmail-to-microsoft-exchange/"><em>https://ghanavats.tech</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=349b12fcfcc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>