<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Cloud with Alon</title><link href="https://cloudwithalon.com/" rel="alternate"/><link href="https://cloudwithalon.com/feeds/all.atom.xml" rel="self"/><id>https://cloudwithalon.com/</id><updated>2026-06-28T19:17:00+00:00</updated><subtitle>Growing into a better cloud architect</subtitle><entry><title>EP15: Migrating from NAT Instances to AWS NAT Gateway</title><link href="https://cloudwithalon.com/writing/ep15-migrating-nat-instances-to-aws-nat-gateway/" rel="alternate"/><published>2026-06-28T19:17:00+00:00</published><updated>2026-06-28T19:17:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-06-28:/writing/ep15-migrating-nat-instances-to-aws-nat-gateway/</id><summary type="html">&lt;p&gt;I led a migration of critical production traffic from old NAT instances to NAT Gateway, reduced internal AWS traffic with VPC endpoints, preserved whitelisted Elastic IPs, and learned that even simple cloud changes become serious when the whole region depends on them.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I recently led a production migration that sounds simple from the outside but took a lot of planning to execute.&lt;/p&gt;
&lt;p&gt;The task was simple: replace the default internet route from an EC2 NAT instance to a NAT Gateway.&lt;/p&gt;
&lt;p&gt;That is it. Just update the route table.&lt;/p&gt;
&lt;p&gt;But this was not a small test VPC. This was a production VPC in &lt;code&gt;us-east-1&lt;/code&gt;, and a large part of the environment depended on those NAT instances for outbound traffic.&lt;/p&gt;
&lt;p&gt;Once I understood that, the project stopped looking simple.&lt;/p&gt;
&lt;p&gt;And because I was leading it, I had to think beyond the technical change and plan around risk, cost, downtime, and communication.&lt;/p&gt;
&lt;h2 id="how-we-got-here"&gt;How We Got Here&lt;/h2&gt;
&lt;p&gt;Back in 2021, two NAT instances were created to save cost.&lt;/p&gt;
&lt;p&gt;At that time, the product was still growing slowly. Traffic was small, downtime during maintenance was acceptable, and using EC2 instances as NAT made sense from a cost point of view.&lt;/p&gt;
&lt;p&gt;The setup was simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;two EC2 NAT instances running Amazon Linux 2&lt;/li&gt;
&lt;li&gt;a few route tables using those NAT instances&lt;/li&gt;
&lt;li&gt;one route table set as the default&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For that stage of the product, it worked.&lt;/p&gt;
&lt;p&gt;But systems do not stay the same. And honestly, that is one reason I find this job interesting.&lt;/p&gt;
&lt;p&gt;Over time, the product grew. Monthly traffic moved from GiBs to TiBs. More resources were added, more dependencies were created, and some were documented while many were not.&lt;/p&gt;
&lt;p&gt;By 2023, those NAT instances had become too critical to reboot casually.&lt;/p&gt;
&lt;p&gt;&lt;img alt="NAT Running for long time" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/2.webp"&gt;&lt;/p&gt;
&lt;p&gt;That meant no easy maintenance, no easy patching, and no simple replacement.&lt;/p&gt;
&lt;p&gt;And because they were still running Amazon Linux 2 with no patching, the security risk kept increasing over time.&lt;/p&gt;
&lt;h2 id="the-risk-became-visible"&gt;The Risk Became Visible&lt;/h2&gt;
&lt;p&gt;In 2025, we started noticing bottlenecks during heavy business days.&lt;/p&gt;
&lt;p&gt;One NAT instance was &lt;code&gt;a1.large&lt;/code&gt;, and the other was &lt;code&gt;t3.medium&lt;/code&gt;. These were not designed to become long-term regional traffic gateways for a growing production environment.&lt;/p&gt;
&lt;p&gt;During architecture discussions, we started listing them as a single point of failure and a critical resource.&lt;/p&gt;
&lt;p&gt;Everyone agreed it was risky. But agreement is not the same as migration.&lt;/p&gt;
&lt;p&gt;The organization had grown, and changing a critical shared component was no longer easy. Many systems depended on it, and some dependencies were unknown. So the risk stayed there for a while.&lt;/p&gt;
&lt;p&gt;Then in 2026, another project created the right timing: migrating Amazon Linux 2 because it was approaching end of life.&lt;/p&gt;
&lt;p&gt;I was also leading that project, and while planning the work, my attention kept coming back to these two NAT instances.&lt;/p&gt;
&lt;p&gt;I knew we had two options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;replace them with new EC2 NAT instances on a different OS&lt;/li&gt;
&lt;li&gt;move to AWS NAT Gateway&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The second option was better operationally, but it came with a hard conversation.&lt;/p&gt;
&lt;p&gt;Cost.&lt;/p&gt;
&lt;h2 id="the-cost-conversation"&gt;The Cost Conversation&lt;/h2&gt;
&lt;p&gt;When I first shared the risk, everyone understood why we needed to move.&lt;/p&gt;
&lt;p&gt;The NAT instances were old, critical, hard to patch, and difficult to maintain. We were lucky they had been stable for so long, but luck is not an architecture strategy.&lt;/p&gt;
&lt;p&gt;Then I shared the estimated cost increase of moving to NAT Gateway. It was almost double what we were paying.&lt;/p&gt;
&lt;p&gt;The room became quiet.&lt;/p&gt;
&lt;p&gt;That was the real tradeoff.&lt;/p&gt;
&lt;p&gt;NAT Gateway gives better availability, scaling, and lower operational overhead. But it can become expensive, especially when a lot of traffic flows through it.&lt;/p&gt;
&lt;p&gt;So before asking the business to accept the cost, I needed to understand the traffic and bring a stronger migration plan.&lt;/p&gt;
&lt;p&gt;I started collecting traffic flow data to answer three questions.&lt;/p&gt;
&lt;p&gt;Where was the traffic going?&lt;/p&gt;
&lt;p&gt;Which resources were generating it?&lt;/p&gt;
&lt;p&gt;Could we reduce it before migration?&lt;/p&gt;
&lt;p&gt;Another critical thing I found was route table imbalance. Because one route table had become the default pattern, many subnets were associated with it, and traffic was not distributed equally.&lt;/p&gt;
&lt;p&gt;One NAT instance was handling around 500 GB per month, while the other had grown close to 40 TB per month.&lt;/p&gt;
&lt;p&gt;That showed how much technical debt had built up quietly.&lt;/p&gt;
&lt;p&gt;I did not focus on fixing that immediately. I treated it as the next phase after migration.&lt;/p&gt;
&lt;h2 id="understanding-the-traffic"&gt;Understanding the Traffic&lt;/h2&gt;
&lt;p&gt;At first, I enabled VPC Flow Logs for a few days.&lt;/p&gt;
&lt;p&gt;That helped, but not enough. I mostly got source and destination IPs, and mapping those IPs back to real services was difficult. It could also get expensive if we kept collecting logs for a long time.&lt;/p&gt;
&lt;p&gt;Then I found a better source of information.&lt;/p&gt;
&lt;p&gt;Because the NAT servers were Linux EC2 instances, I could inspect connection tracking from:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/proc/net/nf_conntrack
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That gave me much richer detail about active connections, including the private source IP generating traffic and the destination IP.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Traffic Log" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/3.webp"&gt;&lt;/p&gt;
&lt;p&gt;But this is a kernel-managed connection tracking file, and it changes constantly. So I had to collect the data carefully.&lt;/p&gt;
&lt;p&gt;I attached an additional disk to avoid filling the root volume, then captured connection tracking data there so the NAT instance itself would not crash because of storage exhaustion.&lt;/p&gt;
&lt;p&gt;I monitored it for around two weeks and collected around 30 GB of logs.&lt;/p&gt;
&lt;p&gt;After that, I worked on a script to analyze where the traffic was going. For AWS destinations, I used the public &lt;a href="https://ip-ranges.amazonaws.com/ip-ranges.json" rel="nofollow" target="_blank"&gt;AWS IP range file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The script checked whether destination IPs belonged to AWS or outside the AWS.&lt;/p&gt;
&lt;p&gt;It was not perfect. Many IPs still appeared only as &lt;code&gt;AMAZON&lt;/code&gt;, not a specific service name. But it was enough to reveal the important pattern.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Traffic Analysus" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/4.webp"&gt;&lt;/p&gt;
&lt;p&gt;Around 90% of the traffic was going back into AWS.&lt;/p&gt;
&lt;p&gt;That was the turning point.&lt;/p&gt;
&lt;h2 id="reducing-traffic-before-migrating"&gt;Reducing Traffic Before Migrating&lt;/h2&gt;
&lt;p&gt;If we moved everything directly to NAT Gateway, that internal AWS traffic would become expensive.&lt;/p&gt;
&lt;p&gt;So before migration, I started reducing the NAT traffic.&lt;/p&gt;
&lt;p&gt;We added VPC endpoints for services like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;S3&lt;/li&gt;
&lt;li&gt;DynamoDB&lt;/li&gt;
&lt;li&gt;CloudWatch&lt;/li&gt;
&lt;li&gt;SSM&lt;/li&gt;
&lt;li&gt;and more&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This allowed private resources to reach AWS services through private paths instead of sending everything through the NAT layer.&lt;/p&gt;
&lt;p&gt;After that change, we reduced the NAT traffic significantly, almost by half compared to the earlier EC2 NAT instance traffic.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Reducing NAT Instance Network Traffic" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/8.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Reducing NAT Instance Network Traffic" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/1.webp"&gt;&lt;/p&gt;
&lt;p&gt;Now I had a stronger story for the migration.&lt;/p&gt;
&lt;p&gt;We were not just saying, "NAT Gateway is better."&lt;/p&gt;
&lt;p&gt;We were saying:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We analyzed the traffic, reduced unnecessary NAT usage, lowered the cost risk, and now the remaining traffic should move to a managed, more reliable service.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That made the decision much easier to defend.&lt;/p&gt;
&lt;h2 id="the-elastic-ip-problem"&gt;The Elastic IP Problem&lt;/h2&gt;
&lt;p&gt;The next major question was whether to preserve the existing Elastic IPs.&lt;/p&gt;
&lt;p&gt;This became more serious than expected.&lt;/p&gt;
&lt;p&gt;We realized some clients had whitelisted our outbound IPs, but the list of who had whitelisted what was not fully documented.&lt;/p&gt;
&lt;p&gt;Changing the Elastic IPs could break client integrations.&lt;/p&gt;
&lt;p&gt;So we decided to preserve them and that created another challenge.&lt;/p&gt;
&lt;p&gt;To reuse an Elastic IP from a NAT instance, we needed to detach it from the EC2 instance and attach it to the new NAT Gateway. That takes time, and in our environment even a few minutes of outage was a big deal.&lt;/p&gt;
&lt;p&gt;So we looked for a safer migration path.&lt;/p&gt;
&lt;h2 id="the-migration-plan"&gt;The Migration Plan&lt;/h2&gt;
&lt;p&gt;The idea was to use a temporary NAT Gateway.&lt;/p&gt;
&lt;p&gt;Instead of moving the route directly from the NAT instance to the final NAT Gateway, we would first point the route table to a temporary NAT Gateway.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Change NAT Routes" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/5.webp"&gt;&lt;/p&gt;
&lt;p&gt;Then we could detach the Elastic IP from the NAT instance, create the final NAT Gateway with the preserved Elastic IP, wait for it to become available, and finally move the route again.&lt;/p&gt;
&lt;p&gt;The goal was to keep general outbound traffic working while we prepared the final NAT Gateway.&lt;/p&gt;
&lt;p&gt;Clients that had whitelisted the old Elastic IP might see a short interruption during the switch. But other outbound traffic should continue working through the temporary NAT Gateway.&lt;/p&gt;
&lt;p&gt;We tested this in a sandbox account first.&lt;/p&gt;
&lt;p&gt;I also wrote a small script that continuously ran &lt;code&gt;curl&lt;/code&gt; every second to check whether outbound connectivity dropped during the route changes.&lt;/p&gt;
&lt;p&gt;In sandbox, the migration looked clean. No visible network drop.&lt;/p&gt;
&lt;p&gt;&lt;img alt="NAT Route Change Testing and Validation" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/6.webp"&gt;&lt;/p&gt;
&lt;p&gt;That gave us confidence.&lt;/p&gt;
&lt;h2 id="production-migration"&gt;Production Migration&lt;/h2&gt;
&lt;p&gt;Since there were two NAT instances, we decided to migrate them separately.&lt;/p&gt;
&lt;p&gt;First, we chose the lower traffic NAT instance.&lt;/p&gt;
&lt;p&gt;During the migration, we saw around 3 seconds of downtime when shifting to the new NAT Gateway. It was unexpected because the sandbox test did not behave that way, but we had already requested a 5-minute maintenance window, so it stayed within the planned window.&lt;/p&gt;
&lt;p&gt;At first, we thought there might be an issue with the script.&lt;/p&gt;
&lt;p&gt;So we tested again in sandbox and it worked fine there.&lt;/p&gt;
&lt;p&gt;The next week, we migrated the higher traffic NAT instance.&lt;/p&gt;
&lt;p&gt;This one was much more important because it was handling far more traffic. &lt;/p&gt;
&lt;p&gt;During the second migration, the temporary NAT Gateway route change still worked fine. But when shifting to the final NAT Gateway, we saw around 30 seconds of downtime.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Production NAT Route Change Validation" src="/images/post/ep15-migrating-nat-instances-to-aws-nat-gateway/7.webp"&gt;&lt;/p&gt;
&lt;p&gt;Again, sandbox did not reproduce the same behavior.&lt;/p&gt;
&lt;p&gt;I still do not know the exact reason.&lt;/p&gt;
&lt;p&gt;My current assumption is that a fresh NAT Gateway receiving large traffic suddenly from many resources may take a short time to fully settle or scale behind the scenes. But that is only an assumption, and in engineering assumptions are not enough.&lt;/p&gt;
&lt;p&gt;I may dig deeper into this someday.&lt;/p&gt;
&lt;h2 id="what-changed"&gt;What Changed&lt;/h2&gt;
&lt;p&gt;The most critical NAT path is now moved from self-managed EC2 NAT instances to AWS NAT Gateway.&lt;/p&gt;
&lt;p&gt;That means:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;less operational maintenance&lt;/li&gt;
&lt;li&gt;no EC2 patching burden for NAT&lt;/li&gt;
&lt;li&gt;better managed availability and scaling&lt;/li&gt;
&lt;li&gt;a cleaner architecture for future growth&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We are still monitoring traffic and cost closely.&lt;/p&gt;
&lt;p&gt;I hope the final cost stays close to what I estimated. 🤞&lt;/p&gt;
&lt;h2 id="what-i-learned"&gt;What I Learned&lt;/h2&gt;
&lt;p&gt;This project reminded me that cloud migration is not always about changing resources.&lt;/p&gt;
&lt;p&gt;The hard part is understanding what depends on that migration and explaining risk to leadership.&lt;/p&gt;
&lt;p&gt;The hard part is reducing cost before making the architecture better.&lt;/p&gt;
&lt;p&gt;The hard part is dealing with undocumented dependencies, old decisions, and production traffic that grew slowly over years.&lt;/p&gt;
&lt;p&gt;From the outside, this was just a migration from NAT instances to NAT Gateway.&lt;/p&gt;
&lt;p&gt;For me, it was a real architecture lesson.&lt;/p&gt;
&lt;p&gt;Cost matters. Reliability matters. Documentation matters.&lt;/p&gt;
&lt;p&gt;And technical debt does not always appear as broken systems. Sometimes it appears as a server nobody wants to reboot.&lt;/p&gt;
&lt;p&gt;More soon,&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP14: AWS KMS Was Faster Than bcrypt on Lambda</title><link href="https://cloudwithalon.com/writing/ep14-kms-was-faster-than-bcrypt-on-lambda/" rel="alternate"/><published>2026-06-24T21:13:00+00:00</published><updated>2026-06-24T21:13:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-06-24:/writing/ep14-kms-was-faster-than-bcrypt-on-lambda/</id><summary type="html">&lt;p&gt;SFTP auth stored encrypted passwords with KMS. Login was slow, so I benchmarked bcrypt. It was 20x slower on Lambda. I stayed on KMS — latency won, with tradeoffs.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I’ve been deep into building an SFTP project lately.&lt;/p&gt;
&lt;p&gt;I’ll share the full story later, but this part is just about authentication and the tradeoffs I ran into.&lt;/p&gt;
&lt;p&gt;Here’s the setup.&lt;/p&gt;
&lt;p&gt;I’m using AWS Transfer Family for SFTP, with a Lambda function handling authentication. User passwords are stored in DynamoDB, encrypted using KMS. On login, Lambda fetches the password, decrypts it with KMS, and compares it with what the user provides.&lt;/p&gt;
&lt;p&gt;Even saying that feels a bit off.&lt;/p&gt;
&lt;p&gt;Passwords are supposed to be hashed, not decrypted.&lt;/p&gt;
&lt;p&gt;But this system is made of multiple services talking over the network:&lt;/p&gt;
&lt;p&gt;&lt;img alt="SFTP authentication flow across Transfer Family, Lambda, DynamoDB, and KMS" src="/images/post/ep14-kms-was-faster-than-bcrypt-on-lambda/1.webp"&gt;&lt;/p&gt;
&lt;p&gt;When I first built it, login took &lt;strong&gt;7–9 seconds&lt;/strong&gt;. Way too slow!&lt;/p&gt;
&lt;p&gt;Then I started optimizing. I added VPC endpoints and reduced some hops, but it was still above &lt;strong&gt;5 seconds&lt;/strong&gt;. Not acceptable for something users interact with directly.&lt;/p&gt;
&lt;p&gt;So I looked at Lambda.&lt;/p&gt;
&lt;p&gt;While checking Lambda logs, I noticed KMS calls adding latency and assumed the network was the main issue. So I tried bcrypt, the “correct” approach for passwords, hoping it would reduce that overhead.&lt;/p&gt;
&lt;p&gt;At that point, I was using 128MB memory. &lt;/p&gt;
&lt;p&gt;I thought switching to bcrypt would help. But it didn’t.&lt;/p&gt;
&lt;p&gt;I know KMS and bcrypt aren’t the same tool. But for my situation, I had to compare them.&lt;/p&gt;
&lt;p&gt;At 128MB the latency was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;KMS: around 200ms&lt;/li&gt;
&lt;li&gt;bcrypt: around 4000ms+&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That was unexpected.&lt;/p&gt;
&lt;p&gt;bcrypt wasn’t just slower, it was dramatically slower. It turned out to be CPU heavy, and Lambda at low memory just doesn’t have enough power for it.&lt;/p&gt;
&lt;p&gt;Then I tried scaling memory:&lt;br&gt;
128MB → 1024MB → 2000MB → 5000MB&lt;/p&gt;
&lt;p&gt;&lt;img alt="KMS vs bcrypt latency across Lambda memory tiers" src="/images/post/ep14-kms-was-faster-than-bcrypt-on-lambda/2.webp"&gt;&lt;/p&gt;
&lt;p&gt;bcrypt improved, but it still stayed higher than I wanted unless I kept increasing memory and cost.&lt;/p&gt;
&lt;p&gt;But KMS behaved differently.&lt;/p&gt;
&lt;p&gt;Since it runs outside Lambda, it depends more on network than CPU. At higher memory, I started seeing &lt;strong&gt;sub-50ms responses&lt;/strong&gt; quite often.&lt;/p&gt;
&lt;p&gt;So I had a choice.&lt;/p&gt;
&lt;p&gt;Use proper one-way hashing like bcrypt, accept more tuning, more CPU usage, and higher cost.&lt;/p&gt;
&lt;p&gt;Or use KMS, accept some security tradeoff, but meet latency and keep the system simple.&lt;/p&gt;
&lt;p&gt;I chose KMS.&lt;/p&gt;
&lt;p&gt;Not because it is better, but because it fit the constraints I had.&lt;/p&gt;
&lt;p&gt;It gave me acceptable latency, simpler setup, and less operational overhead.&lt;/p&gt;
&lt;p&gt;I did not have to worry much about tuning hashing cost or dealing with CPU limits. Access could be controlled with IAM using least privilege.&lt;/p&gt;
&lt;p&gt;But it is still a compromise. Hashing is the right model for passwords. It is one-way and safer by design.&lt;/p&gt;
&lt;p&gt;There were other options I could tune and make work, but they would need more effort and still come with tradeoffs.&lt;/p&gt;
&lt;p&gt;In my case, performance and simplicity mattered more. And that is really the point of this.&lt;/p&gt;
&lt;p&gt;Not that KMS is the right choice, but that real systems force tradeoffs.&lt;/p&gt;
&lt;p&gt;The biggest lesson for me was simple. Measure everything. Do not assume.&lt;/p&gt;
&lt;p&gt;I assumed network would be the bottleneck. But it turned out CPU inside Lambda was the bigger one.&lt;/p&gt;
&lt;p&gt;That is where I landed.&lt;/p&gt;
&lt;p&gt;More soon&lt;br&gt;
-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP13: AWS 28-Hour Outage - Not a Code Bug or Bad Deployment</title><link href="https://cloudwithalon.com/writing/ep13-aws-28-hour-outage-not-a-code/" rel="alternate"/><published>2026-05-09T17:09:00+00:00</published><updated>2026-05-09T17:09:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-05-09:/writing/ep13-aws-28-hour-outage-not-a-code/</id><summary type="html">&lt;p&gt;A cooling system failed and AWS went dark for 28 hours.&lt;/p&gt;</summary><content type="html">&lt;p&gt;If your cloud region is AWS us-east-1, maybe this week was painful for you too.&lt;/p&gt;
&lt;p&gt;It was for us.&lt;/p&gt;
&lt;p&gt;We got affected by the recent AWS incident. Not completely down, but enough to hurt operations badly. &lt;/p&gt;
&lt;p&gt;One of our critical client-facing SFTP applications stopped working and we had to rebuild the server from backup because there was no other recovery option left.&lt;/p&gt;
&lt;p&gt;That pushed us almost 12 hours back and the impact was significant. We had to reach out to each client individually to communicate the situation.&lt;/p&gt;
&lt;p&gt;We manage around 1500+ servers. Many of them recovered because of autoscaling, but this one system was in bad situation.&lt;/p&gt;
&lt;p&gt;And honestly, I never expected the reason behind all this.&lt;/p&gt;
&lt;p&gt;The cooling system failed. That’s it.&lt;/p&gt;
&lt;p&gt;Not bad code.&lt;/p&gt;
&lt;p&gt;Not wrong deployment.&lt;/p&gt;
&lt;p&gt;Not database migration.&lt;/p&gt;
&lt;p&gt;Not hacker attack.&lt;/p&gt;
&lt;p&gt;A cooling system inside one AWS availability zone failed and temperature became too high. Servers started shutting down to protect hardware. Then services got impacted for 28 hours. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This might be the longest single-AZ outage in AWS history.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But this incident reminded me of something important.&lt;/p&gt;
&lt;p&gt;Sometimes infrastructure fails because the physical world fails first. &lt;/p&gt;
&lt;p&gt;And cloud is still physical.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Your servers are still machines.&lt;br&gt;
Machines are inside racks.&lt;br&gt;
Racks are inside buildings.&lt;br&gt;
Buildings need electricity and cooling.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I think many teams are not really prepared for this type of failure because cloud feels like magic sometimes. We think AWS will always recover automatically.&lt;/p&gt;
&lt;p&gt;But when this happened, many people were stuck for a long time. &lt;/p&gt;
&lt;p&gt;AWS acknowledged the failure and said it would take longer to resolve, so they asked customers to recover from backups if they needed immediate recovery. This happens rarely.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS outage timeline" src="/images/post/ep13-aws-28-hour-outage-not-a-code/1b5048ad-570c-49db-ae51-acacf9241aa3_2490x250.webp"&gt;&lt;/p&gt;
&lt;p&gt;If your systems were running only in one availability zone, that’s a problem.&lt;br&gt;
If backups were old, that’s a problem too.&lt;br&gt;
If you never tested restore from snapshot, that’s a big problem.&lt;/p&gt;
&lt;p&gt;This is the kind of failure we don’t prepare for because it feels unlikely. But it happened. And it lasted longer than most software outages ever do.&lt;/p&gt;
&lt;p&gt;The lesson is simple: Don’t assume the cloud is magic. Design for reality. Test for failure.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; I wrote a detailed breakdown of the full incident—the timeline, root cause, affected services, and my own takeaways. &lt;/p&gt;
&lt;p&gt;You can read it here: [&lt;strong&gt;&lt;a href="https://builder.aws.com/content/3DTtGltSalD4IteiZ7bEKQ8Tj4E/the-28-hour-meltdown-what-happened-when-aws-us-east-1-overheated"&gt;The 28-Hour Meltdown: What Happened When AWS US-EAST-1 Overheated&lt;/a&gt;&lt;/strong&gt;]&lt;/p&gt;</content><category term="misc"/></entry><entry><title>How HDD Architecture Creates Physical Limits on Storage and Throughput</title><link href="https://cloudwithalon.com/writing/hdd-architecture-physical-limits-storage-throughput/" rel="alternate"/><published>2026-04-18T23:14:00+00:00</published><updated>2026-04-18T23:14:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-04-18:/writing/hdd-architecture-physical-limits-storage-throughput/</id><summary type="html">&lt;p&gt;A beginner-friendly breakdown of HDD internals, how platters, arms, and sectors work, and why physics puts a hard ceiling on storage speed and size.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Technology keeps moving faster. Every year CPUs become more powerful, networks get faster, and AI keeps pushing what we think is possible.&lt;/p&gt;
&lt;p&gt;But storage is different. It has stayed stubbornly limited.&lt;/p&gt;
&lt;p&gt;When I say storage, I mean the disks that hold our data. And we mainly have two types: HDD and SSD.&lt;/p&gt;
&lt;p&gt;Both have limits. But here I’ll mainly focus on HDDs (Hard Disk Drives).&lt;/p&gt;
&lt;p&gt;Not just limits on how much data they can hold (capacity), but on how fast they can move that data (throughput and IOPS).&lt;/p&gt;
&lt;p&gt;And these aren’t soft limits you can fix by throwing money at. They’re real, physical walls.&lt;/p&gt;
&lt;p&gt;Look at AWS. Their EBS HDD volumes have a service limit of 16 TB storage with a max throughput of 500 MiB/s. SSDs go higher, up to 64 TB and 4,000 MiB/s, but even those have a ceiling.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why can’t they just make it faster and bigger?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;That’s what this article is about.&lt;/p&gt;
&lt;h2 id="how-an-hdd-works-from-a-beginners-pov"&gt;How an HDD works from a beginner’s POV&lt;/h2&gt;
&lt;p&gt;Inside every HDD, there is a motor attached to a spindle that spins magnetic platters. The platters are stacked on top of each other, like a stack of CDs. Each platter has two surfaces (top and bottom), and each surface has its own head.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Hard Disk Drive Architecture" src="/images/post/hdd-architecture-physical-limits-storage-throughput/1.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.expertsmind.com/CMSImages/689_Hard%20Disk%20Technology.png" rel="nofollow" target="_blank"&gt;Image Source&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Think of it like a record player. The arm swings across the platter, and the head at the tip reads the data. But unlike a record player, the head doesn’t touch the platter. It floats just nanometers above the surface.&lt;/p&gt;
&lt;p&gt;Two things move inside an HDD to read/write data:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The arm swings left and right (inner edge to outer edge of the platter).&lt;/li&gt;
&lt;li&gt;The platter spins in a circle underneath the head.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Together, these two movements let the head reach any spot on the platter to read or write data.&lt;/p&gt;
&lt;h3 id="how-a-readwrite-actually-happens"&gt;How a Read/Write Actually Happens&lt;/h3&gt;
&lt;p&gt;The platter surface is organized into thousands of concentric circles called tracks. Each track is divided into smaller chunks called sectors. A sector is the smallest unit of data the drive can read or write.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Hard Disk Drive Platter Architecture" src="/images/post/hdd-architecture-physical-limits-storage-throughput/2.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.pctechguide.com/wp-content/uploads/2011/09/31format.jpg" rel="nofollow" target="_blank"&gt;Image Source&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When the drive needs to read/write data, it goes through these steps:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1 — Seek.&lt;/strong&gt; The actuator swings the arm to position the head over the correct track. This movement is called &lt;strong&gt;seek time&lt;/strong&gt;. On a typical consumer drive, this takes about 5 to 10 milliseconds.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2 — Wait for rotation.&lt;/strong&gt; The head is now on the right track, but the exact sector it needs might not be under the head yet. The platter is spinning, so the head waits for the right sector to rotate underneath it. This wait is called &lt;strong&gt;rotational latency&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;An average disk spins at 7,200 RPM (revolutions per minute). One full rotation takes about 8.3 ms. On average, the head waits for half a rotation (~4.15 ms) for the right sector to come under it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3 — What if it misses?&lt;/strong&gt; If the head arrives just slightly too late and the sector has already passed, it has to wait for the platter to come all the way back around. That's a full rotation, another 8.3ms wasted. This is called a &lt;strong&gt;rotational miss&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4 — Transfer.&lt;/strong&gt; Once the sector is under the head, the actual read or write happens. The platter is magnetically coated. For a read, the head detects the direction of the magnetic field of each bit. For a write, it changes the direction to store new 0s and 1s.&lt;/p&gt;
&lt;p&gt;The platter keeps spinning as this happens, and the time it takes to transfer the data is called &lt;strong&gt;transfer time&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Each sector is typically 4KB, which is the smallest unit the disk reads/writes at a time. If the next sectors are sequential, the head doesn’t need to move, it just keeps going.&lt;/p&gt;
&lt;p&gt;But if the next sectors are on different tracks (because of fragmentation), the arm has to reposition, which adds more seek time. Tools like disk defragmenters try to fix this by placing related data closer together so reads become sequential again.&lt;/p&gt;
&lt;h2 id="how-fast-can-an-hdd-actually-go-iops-and-throughput"&gt;How Fast Can an HDD Actually Go (IOPS and Throughput)&lt;/h2&gt;
&lt;p&gt;There are two ways data gets accessed on a disk: random and sequential.&lt;/p&gt;
&lt;p&gt;Let’s calculate both.&lt;/p&gt;
&lt;h3 id="random"&gt;Random&lt;/h3&gt;
&lt;p&gt;Before the head can read or write anything, it has to get to the right spot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Seek time (~5-10ms) + rotational latency (~4.15ms) = ~9 to 14ms just to get into position.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each sector is 4KB, and the actual read/write takes microseconds. So almost all the time is spent on physical movement, not data transfer. This is called &lt;strong&gt;mechanical overhead&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Now the math: if each random operation takes about 9 to 14 ms, you can fit roughly 70 to 110 operations per second. That number is called IOPS (Input/Output Operations Per Second).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Throughput = IOPS × Block Size&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Random throughput: 70-110 IOPS × 4KB = 280KB/s to 440KB/s. That's less than half a MB per second.&lt;/p&gt;
&lt;h3 id="sequential"&gt;Sequential&lt;/h3&gt;
&lt;p&gt;Here, the head only needs to seek once. After that, data is in consecutive sectors, so the head just keeps reading or writing as the platter spins.&lt;/p&gt;
&lt;p&gt;Sequential throughput depends on rotational speed and how densely data is packed on the tracks. A typical 7,200 RPM consumer HDD does around 100–200 MB/s sequential.&lt;/p&gt;
&lt;p&gt;That’s the gap: ~0.4 MB/s random vs ~150 MB/s sequential. Same disk, same hardware. The difference is purely mechanical overhead.&lt;/p&gt;
&lt;h2 id="why-hdd-cant-get-faster-or-bigger"&gt;Why HDD Can't Get Faster or Bigger&lt;/h2&gt;
&lt;p&gt;Looking at the architecture, HDDs are slow because of physical movement. The obvious question is: why not just make things move faster?&lt;/p&gt;
&lt;p&gt;Because physics says &lt;strong&gt;NO&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id="speed"&gt;Speed&lt;/h3&gt;
&lt;p&gt;The arm movement (seek time) has a ceiling. Move it faster and you get more vibration, more heat, and less accuracy when reading data.&lt;/p&gt;
&lt;p&gt;Rotational speed has a ceiling too. The fastest enterprise drives go up to 15,000 RPM, and even that comes with serious trade-offs: more heat, more vibration, and more wear. At some point, pushing speed just makes the drive unreliable.&lt;/p&gt;
&lt;p&gt;Then there's latency. In desktops, HDDs connect through SATA which is a direct cable to the motherboard. In the cloud, there's an actual network between compute and storage, which adds extra latency on top of the mechanical overhead.&lt;/p&gt;
&lt;h3 id="storage"&gt;Storage&lt;/h3&gt;
&lt;p&gt;This is where engineers are still making progress, but slowly. The largest HDD today is around 36TB.&lt;/p&gt;
&lt;p&gt;Data is stored on platters, and a typical drive can have around 5 of them. Adding more platters means more weight, more heat, and more vibration. Physics gets in the way again.&lt;/p&gt;
&lt;p&gt;The other approach is packing bits closer together so they take up less space. This increases capacity, but only up to a point. If bits are packed too tightly, their magnetic fields start interfering with each other. This can flip neighboring bits and corrupt data. This limit is known as the &lt;strong&gt;superparamagnetic limit&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="how-big-systems-work-around-these-limits"&gt;How Big Systems Work Around These Limits&lt;/h2&gt;
&lt;p&gt;Even with all these physical limits, massive systems (AI workloads, streaming platforms, large databases) still rely on HDDs. So how do they make it work?&lt;/p&gt;
&lt;p&gt;A single disk is slow. There’s no way around that.&lt;/p&gt;
&lt;p&gt;Instead of trying to make one disk faster, they use many disks together. This is called &lt;strong&gt;distributed storage&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For example, AWS offers EBS HDD volumes with throughput of up to 500 MiB/s, which is far beyond what a single disk can deliver. When you create a 100 GB EBS volume, your data isn’t stored on just one disk. Behind the scenes, AWS spreads it across multiple drives, allowing them to achieve throughput that no single HDD could reach on its own.&lt;/p&gt;
&lt;p&gt;That’s how these systems push throughput far beyond the limits of a single HDD.&lt;/p&gt;
&lt;p&gt;In the end, they’re not breaking the physical limits. They’re working around them by scaling out.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP12: Learning System Design | URL Shortener | Part 4 API Design</title><link href="https://cloudwithalon.com/writing/ep12-learning-system-design-url-shortener/" rel="alternate"/><published>2026-04-12T05:06:00+00:00</published><updated>2026-04-12T05:06:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-04-12:/writing/ep12-learning-system-design-url-shortener/</id><summary type="html">&lt;p&gt;Designing APIs, understanding HTTP, and building the redirect flow&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy ppl,&lt;/p&gt;
&lt;p&gt;It’s been a month since I last wrote anything. I got busy and couldn’t really manage the time to write. But now I’m back.&lt;/p&gt;
&lt;p&gt;In the &lt;a href="/writing/ep11-learning-system-design-url-shortener/"&gt;last post&lt;/a&gt;, I talked about how I designed the database using NoSQL for the URL shortener.&lt;/p&gt;
&lt;p&gt;Now it’s time for part 4, designing the API.&lt;/p&gt;
&lt;p&gt;I’m not from a core development background, but I do have a basic foundation in programming. And honestly, for now, that’s enough. My goal here isn’t to build the most perfect solution, but to think in the right direction.&lt;/p&gt;
&lt;p&gt;So if I had to design an API, how would I approach it?&lt;/p&gt;
&lt;p&gt;Before jumping into the design, I want to quickly explain what an API is, in the way I understand it. &lt;/p&gt;
&lt;blockquote class="twitter-tweet" data-theme="light" data-dnt="true" align="center"&gt;
    &lt;a href="https://x.com/alonshrestha/status/2037158546232807534"&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;script async src="https://platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;
&lt;p&gt;That’s the simple idea. Now let’s dive deeper into the design part.&lt;/p&gt;
&lt;p&gt;The first thing I would think about is who my clients are. A client is anyone or anything that calls the API. It’s not just a person using a browser.&lt;/p&gt;
&lt;p&gt;For a URL shortener, possible clients could be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A browser running a frontend app&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A mobile app&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The application itself, where one service talks to another&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A CLI tool or script someone wrote..&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Basically, we are building an API that should not care who is calling it. We only care about receiving a request, validating it, and processing it correctly.&lt;/p&gt;
&lt;p&gt;Now the next part is how these clients talk to our API. In this case, the API is HTTP based, and an HTTP request usually has a few important parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Method&lt;/strong&gt;: what the client wants to do, such as GET, POST, DELETE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;URL or path&lt;/strong&gt;: what resource the client is targeting, for example /api/url or /abc123&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Headers&lt;/strong&gt;: metadata such as content type or authorization details&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Body&lt;/strong&gt;: the actual data the client is sending, which is usually used with methods like POST or PUT.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this in mind, let’s start designing the API by deciding what we actually want to allow clients to do. We’ll start small and keep it simple.&lt;/p&gt;
&lt;p&gt;For a URL shortener, the most basic functionality we need is:&lt;/p&gt;
&lt;p&gt;Create a short URL&lt;/p&gt;
&lt;p&gt;Redirect users when they use that short URL&lt;/p&gt;
&lt;p&gt;So the API pattern looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;POST /api/urls → Create a short URL
GET /{shortCode} → Redirect the user to the original URL
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now let’s walk through what actually happens when a client wants to create a short URL.&lt;/p&gt;
&lt;p&gt;Imagine a user enters a long URL into an input field in a web form. From the user’s point of view, they are just typing something like:&lt;/p&gt;
&lt;p&gt;https://gogl.com/helloworld.html&lt;/p&gt;
&lt;p&gt;But when the client sends this to the server, the request looks more like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nf"&gt;POST&lt;/span&gt; &lt;span class="nn"&gt;/api/urls&lt;/span&gt; &lt;span class="kr"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="l"&gt;myurlshort.com&lt;/span&gt;
&lt;span class="na"&gt;Content-Type&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="l"&gt;application/json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;originalUrl&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;https://gogl.com/helloworld.html&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Here the client is sending the original URL in the request body as JSON. The server receives this, validates the URL, generates a unique short code, saves it in the database, and returns a response.&lt;/p&gt;
&lt;p&gt;If everything goes well, the server returns a success response like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kr"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt; &lt;span class="m"&gt;201&lt;/span&gt; &lt;span class="ne"&gt;Created&lt;/span&gt;
&lt;span class="na"&gt;Content-Type&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="l"&gt;application/json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;shortUrl&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;https://myurlshort.com/zs19d&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;originalUrl&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;https://gogl.com/helloworld.html&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;createdAt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;2026-04-12T10:30:00Z&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Few things to notice here,&lt;/p&gt;
&lt;p&gt;Client sends only the &lt;strong&gt;originalUrl&lt;/strong&gt;, that’s all the server needs from them.&lt;/p&gt;
&lt;p&gt;Server does the work and generates &lt;strong&gt;zs19d&lt;/strong&gt; using counter + base62, stores it in DynamoDB.&lt;/p&gt;
&lt;p&gt;Server sends back the result, the short URL, when it’s created.&lt;/p&gt;
&lt;p&gt;Now let’s look at what happens when user actually clicks the short URL they received.&lt;/p&gt;
&lt;p&gt;Here’s the redirection flow in simple.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;User clicks: https://myurlshort.com/zs19d
    │
    ▼
Browser → GET /zs19d → Our URL ShortApp Server
    │                      │
    │                      │ (looks up zs19d in DB)
    │                      │
    │     301/302 Redirect │
    │  Location: gogl.com  │
    ◄──────────────────────┘
    │
    │ (browser automatically follows Location header)
    ▼
Browser → GET https://gogl.com/helloworld.html → Origin Server
    │                              │
    │       200 OK + HTML page     │
    ◄──────────────────────────────┘
    │
    ▼
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;User sees Original pageNow here’s an important part. There are two common types of redirects we can use: &lt;strong&gt;301 and 302&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;301 means permanent redirect. &lt;/p&gt;
&lt;p&gt;When we use this, the browser caches the redirect. So the next time the user clicks the same short link, the browser doesn’t even hit our server. It goes straight to the original URL. This makes things faster for the user and reduces load on our system.&lt;/p&gt;
&lt;p&gt;302 means temporary redirect. &lt;/p&gt;
&lt;p&gt;In this case, the browser does not cache the redirect. Every time the short link is clicked, the browser will come to our server first. This is slower compared to 301 and adds more load to our system.&lt;/p&gt;
&lt;p&gt;For our basic version, we’ll use 301 because it’s faster and more efficient. But later we can add more features, for example for premium users. If we want to collect analytics such as click counts or location data, we’ll need the request to always hit our server. In that case, using 302 makes sense.&lt;/p&gt;
&lt;p&gt;Now the next part is building this in real, which I’m excited about. I’ll share updates as I make progress.&lt;/p&gt;
&lt;p&gt;Till then, thanks for reading.&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP11: Learning System Design | URL Shortener | Part 3 Database Engineering</title><link href="https://cloudwithalon.com/writing/ep11-learning-system-design-url-shortener/" rel="alternate"/><published>2026-03-07T14:17:00+00:00</published><updated>2026-03-07T14:17:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-03-07:/writing/ep11-learning-system-design-url-shortener/</id><summary type="html">&lt;p&gt;Building a scalable DynamoDB schema and preventing race conditions in a distributed system.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy friends,&lt;/p&gt;
&lt;p&gt;Time for part 3.&lt;/p&gt;
&lt;p&gt;In &lt;a href="/writing/ep10-learning-system-design-url-shortener/"&gt;part 2&lt;/a&gt; of learning system design using a URL shortener application, I showed how I engineered a short URL application that could scale to billions of users.&lt;/p&gt;
&lt;p&gt;In this episode, I will focus on the &lt;strong&gt;database&lt;/strong&gt; side.&lt;/p&gt;
&lt;p&gt;The first question was which database to choose.&lt;/p&gt;
&lt;p&gt;For a URL shortener, the access pattern is simple: a short URL maps → to a long URL.&lt;/p&gt;
&lt;p&gt;Therefore, I didn’t need relational features like joins or complex relationships, so a key-value database felt like a natural fit.&lt;/p&gt;
&lt;p&gt;I chose DynamoDB because it’s a managed service and can handle simple lookups at massive scale.&lt;/p&gt;
&lt;p&gt;Next came the schema. &lt;/p&gt;
&lt;p&gt;Our application supports both auto-generated URLs and custom URLs. At first, I thought about using two separate tables, but a single table works fine because every URL has a &lt;strong&gt;unique&lt;/strong&gt; &lt;strong&gt;short ID&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;DynamoDB gives a &lt;strong&gt;partition key&lt;/strong&gt; and a &lt;strong&gt;sort key&lt;/strong&gt;. Since each short URL ID is unique, a partition key is enough for now. If a short URL could map to multiple values, we need sort key as well.&lt;/p&gt;
&lt;p&gt;Here’s what the table looks like:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Table:&lt;/strong&gt; url_mappings&lt;br&gt;
&lt;strong&gt;Partition Key:&lt;/strong&gt; short_code (string)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;{
  “short_code”: “abc123”,
  “original_url”: “https://google.com”,
  “created_at”: “2024-01-15T10:30:45Z”,
  “is_custom”: false,
  “user_id”: “user_123”
}We also keep a counter row in the same table
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;{
  “short_code”: “counter_number”,
  “counter_value”: 123
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The main table stores URL metadata. We will have other tables for client information and additional metadata.&lt;/p&gt;
&lt;p&gt;The counter row is important because we generate short URLs using a &lt;strong&gt;counter increment + Base64 encoding&lt;/strong&gt;. The application needs this counter to create new URLs, so storing it in the same table works for now.&lt;/p&gt;
&lt;p&gt;For now, the DynamoDB table is configured as:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Writes&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Provision&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WCU&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Reads&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;350&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Provision&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RCU&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Alternative&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Demand&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;unpredictable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;traffic&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The table is currently configured for &lt;strong&gt;read-heavy&lt;/strong&gt; traffic. In the future, we might need more write capacity, since writes for URLs and the counter happen in the same table, which could limit scaling. &lt;/p&gt;
&lt;p&gt;To handle this, we can move the counter to its own table and split the URL mappings across multiple tables. This can be done easily as the system grows.&lt;/p&gt;
&lt;p&gt;The main goal in designing this application is to start small but make it easy to scale. Keeping the schema simple now allows growth without major changes later.&lt;/p&gt;
&lt;p&gt;Now we have a single-table database, but the application will be running distributed for high availability, with at least two servers from the start. Once the application is distributed, some issues can appear, and the main one is &lt;strong&gt;race conditions&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;A race condition happens when multiple requests try to update the same value in the database at the same time. In our case, the value is the “&lt;strong&gt;&lt;em&gt;counter_number”&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;If two servers read the same counter and generate a URL simultaneously, they could create duplicates, which would break the application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Server A gets counter: 12345 → converts to “dnh” [short url id]
Server B gets counter: 12345 → converts to “dnh” [short url id]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Both try to write “dnh” → COLLISION!To prevent this, we use a kind of auto-increment logic in DynamoDB. Unlike MySQL, DynamoDB does not have built-in auto-increment, but we can achieve the same effect using the “&lt;strong&gt;&lt;em&gt;update_item”&lt;/em&gt;&lt;/strong&gt; operation with “&lt;strong&gt;&lt;em&gt;ADD”&lt;/em&gt;&lt;/strong&gt; expression:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;response = dynamodb.update_item(
        TableName=&amp;#39;url_mappings&amp;#39;,
        Key={&amp;#39;short_code&amp;#39;: {&amp;#39;S&amp;#39;: &amp;#39;counter_number&amp;#39;}},
        UpdateExpression=&amp;#39;ADD counter_value :inc&amp;#39;,  # DynamoDB: read + increment + store
        ExpressionAttributeValues={&amp;#39;:inc&amp;#39;: {&amp;#39;N&amp;#39;: &amp;#39;1&amp;#39;}},
        ReturnValues=&amp;#39;UPDATED_NEW&amp;#39;  # Return the new incremented value
    )This will auto-increment the **counter_number** for each new URL.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Even though DynamoDB is a NoSQL database, it supports &lt;strong&gt;atomic operations&lt;/strong&gt;. This means when a write request hits an item, DynamoDB locks it, performs the operation, and only unlocks it if the operation succeeds or fails. Essentially, &lt;strong&gt;it’s all-or-nothing&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;So even if multiple requests happen at the same time, they are executed sequentially under the hood:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;00.001&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;calls&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ADD&lt;/span&gt;
&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;00.001&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;calls&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ADD&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;same&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;millisecond&lt;/span&gt;&lt;span class="o"&gt;!)&lt;/span&gt;

&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LOCK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;increment&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="mi"&gt;124&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UNLOCK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;returns&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;124&lt;/span&gt;
&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WAIT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LOCK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;increment&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;124&lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="mi"&gt;125&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UNLOCK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;returns&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;125&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;From the outside, it looks like the requests happened concurrently, but each server receives a &lt;strong&gt;unique counter value&lt;/strong&gt;, avoiding collisions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Concurrent Requests:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Time T1: Server A calls atomic ADD → DynamoDB returns: 124
Time T1: Server B calls atomic ADD → DynamoDB returns: 125  
Time T1: Server C calls atomic ADD → DynamoDB returns: 126

All servers get DIFFERENT numbers!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;All servers get different numbers, keeping the system consistent even under concurrent access.&lt;/p&gt;
&lt;p&gt;With this, we have covered the major database design decisions for the system. &lt;/p&gt;
&lt;p&gt;Next, we will move to the API design and discuss how the application will expose endpoints for creating and resolving short URLs in the next episode.&lt;/p&gt;
&lt;p&gt;Till then, happy learning.&lt;/p&gt;
&lt;p&gt;Growing into a better cloud architect every day,&lt;br&gt;
Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP10: Learning System Design | URL Shortener | Part 2 Engineering for Scale</title><link href="https://cloudwithalon.com/writing/ep10-learning-system-design-url-shortener/" rel="alternate"/><published>2026-02-21T17:15:00+00:00</published><updated>2026-02-21T17:15:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-02-21:/writing/ep10-learning-system-design-url-shortener/</id><summary type="html">&lt;p&gt;Designing URL ID Generation That Scales to Billions&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy friends,&lt;/p&gt;
&lt;p&gt;Time for part 2.&lt;/p&gt;
&lt;p&gt;&lt;a href="/writing/ep9-learning-system-design-url-shortener/"&gt;From part 1&lt;/a&gt;, I was learning system design with Amazon Q using a URL shortener problem. Part 1 was about something invisible but very important. Learning how to ask better questions before jumping into architecture.&lt;/p&gt;
&lt;p&gt;Now we move into the engineering side.&lt;/p&gt;
&lt;p&gt;I am still using Amazon Q like an interviewer. I answer as a candidate. I give my solution. If my thinking is weak, it corrects me. If something is missing, it pushes me to think deeper. We go back and forth until the idea becomes stronger.&lt;/p&gt;
&lt;blockquote class="twitter-tweet" data-theme="light" data-dnt="true" align="center"&gt;
    &lt;a href="https://x.com/alonshrestha/status/2021243893032112336?s=20"&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;script async src="https://platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;
&lt;p&gt;Today’s main focus is:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How do we generate short URLs that can scale to billions of users?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If we design this wrong now, later we might need heavy changes in application logic. So I want something that works long term.&lt;/p&gt;
&lt;p&gt;There are two types of short URLs in our design.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom URL.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Auto generated URL.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let me start with custom.&lt;/p&gt;
&lt;p&gt;Custom URL is mostly for premium users. For example someone wants short.url/google or short.url/cloudwithalon.&lt;/p&gt;
&lt;p&gt;But here I realized something. Anyone can try to create popular names and redirect them to any site. That can create misuse and brand problems.&lt;/p&gt;
&lt;p&gt;So I suggested maybe we can use an open source dataset if one exists, or maintain our own reserved keywords list, starting small and growing it over time.&lt;/p&gt;
&lt;p&gt;Then we moved to auto generated URLs.&lt;/p&gt;
&lt;p&gt;This is where I got stuck for a long time.&lt;/p&gt;
&lt;p&gt;The big question was how do we generate unique short IDs that scale to billions with no collision.&lt;/p&gt;
&lt;p&gt;My first thoughts were random string generators or hashing the original URL. But I remembered collisions can happen.&lt;/p&gt;
&lt;p&gt;Even if rare, at billion scale rare is not rare anymore.&lt;/p&gt;
&lt;p&gt;I was not fully confident in my answer. Then Amazon Q introduced counter based string generation.&lt;/p&gt;
&lt;p&gt;Instead of random, we use a counter and then encode it.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Counter-based URL ID generation with Base62 encoding" src="/images/post/ep10-learning-system-design-url-shortener/8c654d96-25c0-4046-8dde-c701c10f273e_2146x1276.webp"&gt;&lt;/p&gt;
&lt;p&gt;That means we use increasing numbers like 12, 13, 14 for each auto generated URL and then convert them into Base64.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;12 encoded in Base64 becomes MTIK&lt;/p&gt;
&lt;p&gt;13 encoded in Base64 becomes MTMK&lt;/p&gt;
&lt;p&gt;And so on.&lt;/p&gt;
&lt;p&gt;10,000,000,000 encoded in Base64 becomes MTAwMDAwMDAwMDAK&lt;/p&gt;
&lt;p&gt;Even if we reach ten billion URLs, the encoded value is still 16 characters, which is compact and unique.&lt;/p&gt;
&lt;p&gt;That was a shift for me.&lt;/p&gt;
&lt;p&gt;Instead of hoping values do not collide, we guarantee uniqueness because each number is unique.&lt;/p&gt;
&lt;p&gt;But then new questions came.&lt;/p&gt;
&lt;p&gt;Where does this counter live?&lt;/p&gt;
&lt;p&gt;What type of database do we need?&lt;/p&gt;
&lt;p&gt;What should the API look like?&lt;/p&gt;
&lt;p&gt;If we have multiple servers, how do they coordinate?&lt;/p&gt;
&lt;p&gt;At this point, I realized generating the short URL is not the real problem.&lt;/p&gt;
&lt;p&gt;Making it work in a distributed environment is the real challenge.&lt;/p&gt;
&lt;p&gt;Now we move into application and database scaling.&lt;/p&gt;
&lt;p&gt;I am still thinking through this part and discussing it with Amazon Q. I will continue this in the next part once I feel more clear.&lt;/p&gt;
&lt;p&gt;Growing into a better cloud architect everyday.&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP9: Learning System Design | URL Shortener | Part 1 Asking Better Questions</title><link href="https://cloudwithalon.com/writing/ep9-learning-system-design-url-shortener/" rel="alternate"/><published>2026-02-14T18:22:00+00:00</published><updated>2026-02-14T18:22:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-02-14:/writing/ep9-learning-system-design-url-shortener/</id><summary type="html">&lt;p&gt;Using the FUNCS framework to gather requirements before system design&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy friends,&lt;/p&gt;
&lt;p&gt;This week I did not build anything.&lt;/p&gt;
&lt;p&gt;But I learned how to think.&lt;/p&gt;
&lt;p&gt;From my recent posts and tweets you might have seen that I have been learning system design using Amazon Q. I asked it to act like an interviewer while I act like the candidate, and we started with a simple problem: build a URL shortener.&lt;/p&gt;
&lt;p&gt;I have not built the application yet. Building will come later. First I wanted to learn how to design.&lt;/p&gt;
&lt;p&gt;And the first lesson surprised me.&lt;/p&gt;
&lt;p&gt;The interviewer said, “Design a URL shortener.”&lt;/p&gt;
&lt;p&gt;Earlier I would immediately start drawing architecture. Database, cache, load balancer, done.&lt;/p&gt;
&lt;p&gt;But now I realized something important. The question is incomplete.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Good system design does not start with architecture. It starts with questions.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I struggled here.&lt;/p&gt;
&lt;p&gt;I did not know what to ask or how to ask. That is when I learned a simple framework that changed my thinking.&lt;/p&gt;
&lt;blockquote class="twitter-tweet" data-theme="light" data-dnt="true" align="center"&gt;
    &lt;a href="https://x.com/alonshrestha/status/2016541318428893636"&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;script async src="https://platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;
&lt;h2 id="f-u-n-c-s-framework"&gt;F U N C S Framework&lt;/h2&gt;
&lt;p&gt;A simple structure for gathering requirements before designing anything.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;F — Features&lt;/strong&gt;&lt;br&gt;
What exactly are we building&lt;br&gt;
Should the short link expire&lt;br&gt;
Should we support analytics&lt;br&gt;
Should users create custom URLs&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;U — Users and Scale&lt;/strong&gt;&lt;br&gt;
How big is the system&lt;br&gt;
Millions of users or billions&lt;br&gt;
Is the system read heavy or write heavy&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;N — Non functional requirements&lt;br&gt;
&lt;/strong&gt;How good should the system be&lt;br&gt;
Latency, availability, durability, security&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C — Constraints&lt;/strong&gt;&lt;br&gt;
What limits us&lt;br&gt;
Budget, technology, compliance, timeline&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;S — Success metrics&lt;/strong&gt;&lt;br&gt;
How do we know the system is good&lt;br&gt;
Latency, uptime, cost, growth&lt;/p&gt;
&lt;p&gt;At first, questions did not come naturally. But once I started thinking through this framework, better questions started appearing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For example, under Features&lt;/strong&gt;&lt;br&gt;
A URL shortener creates a short link and redirects to the original URL. But should we track how many people clicked the link. Should we provide analytics. Should links expire.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Similarly, under Users and Scale&lt;/strong&gt;&lt;br&gt;
After estimating some rough numbers, I was able to do quick back of the envelope calculations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Writes around 35 per second so we provision for 50 with buffer.&lt;br&gt;
Reads around 350 per second so we provision for 400 with buffer.&lt;/p&gt;
&lt;p&gt;This small exercise helped me understand system size, capacity planning, and early design decisions.&lt;/p&gt;
&lt;p&gt;I was genuinely happy that I could think this way. Asking better questions started shaping the design naturally.&lt;/p&gt;
&lt;p&gt;This week was about learning how to ask before learning how to build.&lt;/p&gt;
&lt;p&gt;In the next part, we will explore the real engineering challenge. &lt;/p&gt;
&lt;p&gt;How do we generate short URLs that scale to billions of users.&lt;/p&gt;
&lt;p&gt;Growing into a better cloud architect everyday.&lt;/p&gt;
&lt;p&gt;Hope this was helpful. See you in the next episode.&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP8: My System Design Foundations Journey</title><link href="https://cloudwithalon.com/writing/ep8-my-system-design-foundations/" rel="alternate"/><published>2026-02-07T17:07:00+00:00</published><updated>2026-02-07T17:07:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-02-07:/writing/ep8-my-system-design-foundations/</id><summary type="html">&lt;p&gt;Learning system design with AI as my mentor. Not as an expert, but as a student.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy Friends,&lt;/p&gt;
&lt;p&gt;If you have been following me, you know I have been working as a cloud engineer. To create real impact in my work and grow in my career, I am now on a journey to become a better cloud architect.&lt;/p&gt;
&lt;p&gt;While searching for that path, one thing became very clear to me.&lt;/p&gt;
&lt;p&gt;System design is the foundation you must have to become a better architect.&lt;/p&gt;
&lt;p&gt;It teaches you how to think about scale, tradeoffs, constraints, and decisions. So I decided to begin my cloud architect journey by learning system design from the ground up.&lt;/p&gt;
&lt;p&gt;Even though I had some experience designing systems as a cloud engineer, learning system design deeply felt like entering a new world.&lt;/p&gt;
&lt;p&gt;I realized that making decisions sometimes is very different from understanding why those decisions exist. That deeper level of reasoning is what I wanted to build.&lt;/p&gt;
&lt;p&gt;I started with popular system design books and blogs. But very quickly I found myself full of questions. Too many unknowns. Too many gaps.&lt;/p&gt;
&lt;p&gt;So instead of rushing through books, I chose a different path. I decided to learn by building and thinking with AI as my mentor. I explored different tools, but since Amazon Q is already part of my daily workflow inside my IDE, I chose it as my learning partner.&lt;/p&gt;
&lt;p&gt;Then I realized that before understanding complex systems, I first needed to learn basic estimation and how to ask better questions. To think from first principles and truly understand requirements.&lt;/p&gt;
&lt;p&gt;I created a small repository called second brain where I write all my thoughts, questions, and learnings. Amazon Q helps me refine my notes, guide my thinking, and act like a mentor.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Second brain repository for system design notes" src="/images/post/ep8-my-system-design-foundations/62c0d79d-553a-4ff9-831f-b1da6f82b001_562x848.webp" style="max-width: 300px"&gt;&lt;/p&gt;
&lt;p&gt;I asked it to treat me like a beginner and design a learning path for me. It created a simple structured plan, and every day I spend one hour continuing from where I left off.&lt;/p&gt;
&lt;p&gt;I began with simple back of the envelope calculations. Converting monthly requests into requests per second. Estimating traffic and storage. Understanding scale. I also realized that asking deeper questions is a fundamental skill. The better I understand the requirements, the better I can understand the system.&lt;/p&gt;
&lt;p&gt;I also wrote an article &lt;strong&gt;&lt;a href="https://cloudwithalon.com/writing/back-of-the-envelope-every-architect-must-master/"&gt;explaining back of the envelope&lt;/a&gt;&lt;/strong&gt; in a simple way. Feel free to read it.&lt;/p&gt;
&lt;p&gt;Slowly the fog started to clear. From there I moved into actual design using a simple system, a URL shortener. I am still learning through the same example, but now with much stronger fundamentals.&lt;/p&gt;
&lt;blockquote class="twitter-tweet" data-theme="light" data-dnt="true" align="center"&gt;
    &lt;a href="https://x.com/alonshrestha/status/2016895405481705493"&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;script async src="https://platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;
&lt;p&gt;It has only been some weeks, yet the shift in my thinking feels real. I am no longer just thinking in services. I am beginning to think in systems.&lt;/p&gt;
&lt;p&gt;Some days are confusing. Some days everything clicks. But showing up every day is changing how I understand architecture.&lt;/p&gt;
&lt;p&gt;This newsletter is where I document my journey. The questions, the struggles, the small insights, and my gradual transition from cloud engineer to someone learning to think like a cloud architect.&lt;/p&gt;
&lt;p&gt;If you are also walking this path, maybe this journey will resonate with you.&lt;/p&gt;
&lt;p&gt;I will share more about my learning in the next episode.&lt;/p&gt;
&lt;p&gt;Until then, happy weekend and keep learning.&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP7: What Remote Work Really Feels Like on the Road</title><link href="https://cloudwithalon.com/writing/ep7-what-remote-work-really-feels/" rel="alternate"/><published>2026-01-31T08:38:00+00:00</published><updated>2026-01-31T08:38:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-01-31:/writing/ep7-what-remote-work-really-feels/</id><summary type="html">&lt;p&gt;Balancing work, learning, and movement during an unplanned remote work trip&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy friends,&lt;/p&gt;
&lt;p&gt;Welcome back.&lt;/p&gt;
&lt;p&gt;Over the past couple of weeks, if you follow me on &lt;a href="https://x.com/alonshrestha/"&gt;X&lt;/a&gt;, you probably noticed that I was working remotely while traveling across eastern Nepal with my colleagues.&lt;/p&gt;
&lt;p&gt;Relax, this post is not about travel tips.&lt;/p&gt;
&lt;p&gt;It is about what actually happens when you try to balance work, learning, and movement at the same time.&lt;/p&gt;
&lt;p&gt;The trip itself was unplanned.&lt;/p&gt;
&lt;p&gt;During the third week of January, from the 19th to the 23rd, we had a work from home rotation. If we were going to try working while roaming, this window felt like the right moment.&lt;/p&gt;
&lt;p&gt;Here is how it went, what worked, and what I would do differently next time.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Remote work trip route" src="/images/post/ep7-what-remote-work-really-feels/cb04c492-4ee8-4f0b-bbdd-d46d47ba08b1_1608x930.webp"&gt;&lt;/p&gt;
&lt;h3 id="the-setup"&gt;The setup&lt;/h3&gt;
&lt;p&gt;Our main base during the trip was Dharan, my hometown. It is fairly central in the east and allowed us to roam surrounding areas without constantly changing places.&lt;/p&gt;
&lt;p&gt;On Friday, January 16, after finishing our assigned dailies, we left at 2 pm. We drove almost nonstop, stopping briefly in Sindhuli for EV charging, and reached Dharan around midnight.&lt;/p&gt;
&lt;p&gt;The weekend was intentionally slow. We went uphill to places like Dhankuta and Basantapur. &lt;/p&gt;
&lt;p&gt;Devices stayed at home. No work, no planning, just time to chill out.&lt;/p&gt;
&lt;h3 id="monday-reality-check"&gt;Monday reality check&lt;/h3&gt;
&lt;p&gt;&lt;img alt="Monday morning work setup on the road" src="/images/post/ep7-what-remote-work-really-feels/9bf9c91e-20a0-401c-b577-4f25da00f74d_1734x1979.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://maps.app.goo.gl/enBgJnpodG86bd5Y7"&gt;Map Location&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On Monday, January 19, we punched in remotely and joined our regular calls from a viewpoint cafe near my home.&lt;/p&gt;
&lt;p&gt;That same day, we were assigned a security training course that needed to be completed within the week. It was long and heavy, with assessments.&lt;/p&gt;
&lt;p&gt;To free up the rest of the week, we tried to complete most of it on the first day while also handling our regular work. &lt;/p&gt;
&lt;p&gt;We underestimated it. The course was longer than expected and we could not finish it that day.&lt;/p&gt;
&lt;p&gt;Since none of us were on call, after 2 pm we decided to roam towards the lower Terai and the India Nepal border area at Jogbani.&lt;/p&gt;
&lt;p&gt;We had a call at 6 pm, so we crossed into India briefly and returned before the call. We attended the meeting calmly from the vehicle. Being in a city area helped. Mobile data worked well.&lt;/p&gt;
&lt;p&gt;That was one of the moments where remote work actually felt smooth.&lt;/p&gt;
&lt;h3 id="the-hardest-days"&gt;The hardest days&lt;/h3&gt;
&lt;p&gt;The next day was tough.&lt;/p&gt;
&lt;p&gt;We had many meetings and work, so we decided not to roam and stayed home to focus. Meetings stretched late into the night, almost until 11 pm. There was a function at home, but only a few of us could properly enjoy it because work came first.&lt;/p&gt;
&lt;p&gt;The following day started similarly. After covering most of the critical work earlier, we left home around 2 pm and headed further east towards Ilam.&lt;/p&gt;
&lt;p&gt;This turned out to be the most challenging part of the trip.&lt;/p&gt;
&lt;p&gt;Due to maintenance on the highway, our journey was slower than expected. &lt;/p&gt;
&lt;p&gt;As we moved into hilly areas, network reliability dropped sharply. We still had meetings to attend while on the road, and at multiple points we questioned whether choosing this route while working was a good idea.&lt;/p&gt;
&lt;p&gt;We stopped at several places hoping for stable internet. Most could not provide usable connectivity. Even mobile data was unreliable.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Searching for stable internet on the road" src="/images/post/ep7-what-remote-work-really-feels/dbdb4abc-9d8e-43cf-a458-3141bd16b524_1164x1432.webp"&gt;&lt;/p&gt;
&lt;p&gt;Finally, we found a place where we could charge the EV, eat, and unexpectedly get decent internet. We stayed there from around 5 pm to 9 pm and completed all pending meetings and work.&lt;/p&gt;
&lt;p&gt;Only after that did we continue. We reached Shree Antu around 11.30 pm.&lt;/p&gt;
&lt;h3 id="learning-versus-reality"&gt;Learning versus reality&lt;/h3&gt;
&lt;p&gt;The next morning, we woke up around 5.30 am and went for a walk to watch the sunrise. It was calm and refreshing. After that, we returned to the hotel and started work.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Sunrise view during morning walk" src="/images/post/ep7-what-remote-work-really-feels/2bde52ac-312e-46c1-b377-e41ee6ef74aa_1164x956.webp"&gt;&lt;/p&gt;
&lt;p&gt;That day, I finally completed the security course.&lt;/p&gt;
&lt;p&gt;By then, we had learned how to plan better. Where to charge the EV and devices, when to take meetings, and how to complete daily responsibilities. With that clarity, the day went smoothly and we returned to Dharan without trouble.&lt;/p&gt;
&lt;p&gt;Before the trip, I had packed my notebook for system design and AWS AI and ML certification preparation. I imagined using early mornings for focused learning.&lt;/p&gt;
&lt;p&gt;That did not happen.&lt;/p&gt;
&lt;p&gt;I barely took the notebook out of my bag. Some mornings I woke up late. Some days went into breakfast outings and family time. Energy was limited, and context switching was very real.&lt;/p&gt;
&lt;p&gt;This became an important lesson.&lt;/p&gt;
&lt;h3 id="what-i-learned"&gt;What I learned&lt;/h3&gt;
&lt;p&gt;Working while roaming is possible. &lt;/p&gt;
&lt;p&gt;Learning while roaming is much harder.&lt;/p&gt;
&lt;p&gt;This trip would have been extremely difficult if any of us were on call. Remote work during travel only works when responsibilities are predictable.&lt;/p&gt;
&lt;p&gt;Another important thing I realized is how energy draining it can be. Traveling and working remotely for a full week is exhausting. Some days, I genuinely felt low, both mentally and physically.&lt;/p&gt;
&lt;p&gt;Planning matters a lot. Anything can happen, so having backups for electricity and internet is essential. When you are roaming while working, nothing matters more than reliable power and connectivity. Everything else can be managed.&lt;/p&gt;
&lt;p&gt;We were also lucky. No production incidents occurred during this time. If something critical had gone down, the trip could have quickly turned into a stressful experience.&lt;/p&gt;
&lt;p&gt;This is one of the beautiful things about the tech industry. Remote work can support real work life balance, but only if it is managed intentionally.&lt;/p&gt;
&lt;p&gt;I truly enjoyed this trip. Next time, I would be more intentional about choosing locations, limiting movement on work heavy days, and being realistic about learning goals.&lt;/p&gt;
&lt;p&gt;Thanks for reading. More reflections coming soon.&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP6: Taking Back Ownership of CloudwithAlon Using AI</title><link href="https://cloudwithalon.com/writing/ep6-taking-back-ownership-of-cloudwithalon/" rel="alternate"/><published>2026-01-25T16:45:00+00:00</published><updated>2026-01-25T16:45:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-01-25:/writing/ep6-taking-back-ownership-of-cloudwithalon/</id><summary type="html">&lt;p&gt;Learning in public, thinking clearly, and building with AI&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy friends,&lt;/p&gt;
&lt;p&gt;This week I want to share a small but meaningful shift in my journey of growing into a better cloud architect.&lt;/p&gt;
&lt;p&gt;My website &lt;strong&gt;&lt;a href="http://cloudwithalon.com"&gt;cloudwithalon.com&lt;/a&gt;&lt;/strong&gt; is where I log my personal learning and document my journey in public.&lt;/p&gt;
&lt;p&gt;For a long time, it lived on &lt;a href="https://hashnode.com/"&gt;Hashnode&lt;/a&gt;. I chose Hashnode because I did not want the hassle of maintaining a website or getting distracted by constant tweaks. I just wanted to write, learn, and move forward.&lt;/p&gt;
&lt;p&gt;And honestly, it served that purpose really well.&lt;/p&gt;
&lt;p&gt;But recently in 2026, Hashnode updated their theme. After the change, CloudwithAlon started to feel less personal to me and more like a platform page.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Hashnode updated theme that felt less personal" src="/images/post/ep6-taking-back-ownership-of-cloudwithalon/f898a4a8-e5e7-42e3-a996-de1884a0a78f_1160x918.webp"&gt;&lt;/p&gt;
&lt;p&gt;That made me pause.&lt;/p&gt;
&lt;p&gt;I also realized that if I ever wanted to migrate, doing it early would be much easier than doing it later when the site had grown much larger. So I decided this was the right time to take back full ownership.&lt;/p&gt;
&lt;p&gt;I moved CloudwithAlon to a fully self managed website and shaped it the way I wanted it to feel.&lt;/p&gt;
&lt;p&gt;I built the site using Pelican, a Python based static site generator. I chose it because I am comfortable with Python. The site is hosted on GitHub and deployed using Cloudflare.&lt;/p&gt;
&lt;p&gt;&lt;img alt="New CloudwithAlon site built with Pelican" src="/images/post/ep6-taking-back-ownership-of-cloudwithalon/5d8b94d2-fea9-4259-950a-48ea283c9f2c_1450x1592.webp"&gt;&lt;/p&gt;
&lt;p&gt;Now comes the most interesting part.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I did not write a single line of code for this website.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Every part of it, the &lt;a href="https://getpelican.com/"&gt;Pelican&lt;/a&gt; setup, site structure, theme adjustments, content migration, Markdown conversion, and even the automation scripts for adapting posts to the new setup was written entirely by &lt;strong&gt;&lt;a href="https://aws.amazon.com/q/"&gt;Amazon Q&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;My role was just thinking. &lt;/p&gt;
&lt;p&gt;I designed and prompted. Amazon Q translated those ideas into code.&lt;/p&gt;
&lt;p&gt;As I kept thinking, I added one more feature. &lt;/p&gt;
&lt;p&gt;The site now lists not only my articles but also all my Substack posts, including the one you are reading right now. The goal is to make CloudwithAlon a central hub for my entire public learning journey.&lt;/p&gt;
&lt;p&gt;&lt;img alt="CloudwithAlon site showing articles and letters" src="/images/post/ep6-taking-back-ownership-of-cloudwithalon/d52f293f-e714-40cb-9583-55c388c3ee6d_1160x1072.webp"&gt;&lt;/p&gt;
&lt;p&gt;This was done using a simple Python script that generates HTML files during the build process.&lt;/p&gt;
&lt;p&gt;I really wanted to share the full prompt history from Amazon Q, but unfortunately I deleted it.&lt;/p&gt;
&lt;h3 id="what-i-learned"&gt;What I learned&lt;/h3&gt;
&lt;p&gt;This project taught me a lot.&lt;/p&gt;
&lt;p&gt;I have been leveraging AI heavily for some time, but this project helped me understand what prompt engineering really means. It is not about clever prompts. It is about clear thinking and knowing the outcome you want.&lt;/p&gt;
&lt;p&gt;Writing code is not the hardest part. Clear thinking is.&lt;/p&gt;
&lt;p&gt;I also learned that AI works best when you stay at the right abstraction level. Breaking problems down step by step and guiding the flow produces much better results than asking for everything at once.&lt;/p&gt;
&lt;p&gt;Migrating a website is not simple if you want it to be future ready. I had to think about URL structure, redirection, page structure, content organization, and SEO. All of this requires proper planning so the site can grow while staying flexible for future features.&lt;/p&gt;
&lt;p&gt;Most importantly, this project reminded me that even small personal projects can teach real architecture lessons, because you are forced to make every decision yourself.&lt;/p&gt;
&lt;p&gt;This migration was not just a technical move. It was a mindset shift.&lt;/p&gt;
&lt;p&gt;CloudwithAlon will continue to be my personal space on the internet. A place to think clearly, learn in public, and slowly build long term online presence.&lt;/p&gt;
&lt;p&gt;As I move further into 2026, I plan to be more intentional about showing up online, writing more, and sharing what I am learning along the way.&lt;/p&gt;
&lt;p&gt;If you are also building something, I would love to hear your story.&lt;/p&gt;
&lt;p&gt;Until next week,&lt;br&gt;
Alon&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PS — A few quick updates&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I was on a week long remote work trip and will share that experience in the next episode.&lt;/li&gt;
&lt;/ul&gt;</content><category term="misc"/></entry><entry><title>EP5: My Experience On Passing AWS Developer Certification</title><link href="https://cloudwithalon.com/writing/ep5-my-experience-on-passing-aws/" rel="alternate"/><published>2026-01-11T15:39:00+00:00</published><updated>2026-01-11T15:39:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-01-11:/writing/ep5-my-experience-on-passing-aws/</id><summary type="html">&lt;p&gt;A real exam experience, preparation, long questions, self doubt, and practical lessons&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Howdy friends&lt;/strong&gt;,&lt;/p&gt;
&lt;p&gt;Hope this email finds you in good health.&lt;/p&gt;
&lt;p&gt;Today I want to share my experience of attempting the AWS Certified Developer Associate exam. I planned to write this earlier, but I was waiting for my official exam score, which caused a small delay.&lt;/p&gt;
&lt;p&gt;I sat for the exam on December 15, 2025, and overall it was a memorable experience. &lt;/p&gt;
&lt;p&gt;Since English is not my native language, I received extra time. The total duration for me was 170 minutes, while the standard exam time is 130 minutes. To be honest, that extra time helped a lot.&lt;/p&gt;
&lt;h2 id="preparation-journey"&gt;Preparation journey&lt;/h2&gt;
&lt;p&gt;For preparation, I used Stephane Maarek’s course and practice exams from Udemy. I trust his content and have been using his courses since the Cloud Practitioner level. &lt;/p&gt;
&lt;p&gt;I also tried a course on LinkedIn Learning, but personally, I found it not detailed enough for this certification.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Ultimate AWS Certified Developer Associate 2026 DVA-C02 | Udemy" src="/images/post/ep5-my-experience-on-passing-aws/abb493e3-7127-4628-a55e-69e17555ac0c_750x422.webp"&gt;(&lt;a href="https://www.udemy.com/course/aws-certified-developer-associate-dva-c01/"&gt;Course link&lt;/a&gt;) &lt;/p&gt;
&lt;p&gt;Stephane’s Developer Associate course is quite long, around 32 hours. This is because he goes deep into important services like CloudFormation, DynamoDB, CodePipeline and CodeDeploy, Lambda, API Gateway, and more. That depth really helps when you start thinking in real world scenarios instead of just exam questions.&lt;/p&gt;
&lt;p&gt;I prefer writing my notes on paper and getting help from AI to explain topics in more depth.&lt;/p&gt;
&lt;p&gt;This is how I prepared for the exam.&lt;/p&gt;
&lt;p&gt;&lt;img alt="My handwritten exam preparation notes" src="/images/post/ep5-my-experience-on-passing-aws/d1920377-9a2a-4115-8d2e-d14fd119c300_2312x1734.webp"&gt;&lt;/p&gt;
&lt;p&gt;During Dashain and Diwali vacations, I was working from home since I had traveled to my hometown. That period gave me enough time to study, and I completed the entire course in roughly 30 days, mostly throughout October.&lt;/p&gt;
&lt;p&gt;One reason I could finish the course within a month was that this was my third AWS certification. I had already used Stephane’s course for the Solutions Architect Associate exam, so many services and concepts were familiar. That helped me move faster through the content.&lt;/p&gt;
&lt;h2 id="the-long-gap-and-exam-booking"&gt;The long gap and exam booking&lt;/h2&gt;
&lt;p&gt;After completing the course, I completely closed the course materials and my notes and didn’t revise them. I stopped studying for almost a month.&lt;/p&gt;
&lt;p&gt;In November, I was busy with a &lt;a href="/writing/ep2-a-disaster-recovery-reality-check/"&gt;DR event at my office&lt;/a&gt;, which consumed most of my time.&lt;/p&gt;
&lt;p&gt;In the first week of December, I scheduled the exam since some of my colleagues were also planning to take exams. The exam was booked by my office, and although there was a bit of peer pressure, I decided to go ahead with it.&lt;/p&gt;
&lt;p&gt;After exam confirmation, you will receive this from AWS.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS exam confirmation email" src="/images/post/ep5-my-experience-on-passing-aws/621587b1-f80c-45c0-91df-d94ecbfade66_1455x615.webp"&gt;&lt;/p&gt;
&lt;h2 id="a-very-important-note-on-exam-environment"&gt;A very important note on exam environment&lt;/h2&gt;
&lt;p&gt;One important suggestion I want to share is about the exam environment. &lt;/p&gt;
&lt;p&gt;If you have a good setup at home with stable electricity and reliable internet, taking the exam from home is fine. If not, I strongly recommend choosing a good and reputed exam center.&lt;/p&gt;
&lt;p&gt;I am saying this from personal experience. During my Solutions Architect Associate exam, I initially chose an exam center that turned out to be a terrible choice. &lt;/p&gt;
&lt;p&gt;The computers were old, the setup was poorly managed, and they were facing technical issues with Pearson VUE. There were not enough technical staff to fix the problems, and because of this, I had to reschedule my exam four times. Even after multiple reschedules, I still could not sit for the exam at that center.&lt;/p&gt;
&lt;p&gt;Eventually, I changed my exam center, and the difference was huge. The new center was well managed, had proper infrastructure, and the exam experience was smooth. This taught me that the exam environment matters more than we realize.&lt;/p&gt;
&lt;h2 id="final-week-and-practice-tests"&gt;Final week and practice tests&lt;/h2&gt;
&lt;p&gt;There was a one month gap between my continuous study period and the actual exam, and it was difficult to get back into rhythm. I had several social events and commitments at the same time, so in the final week, I focused only on practice tests.&lt;/p&gt;
&lt;p&gt;The practice exams were good and closely matched the structure of the real exam. I attempted all six practice test sets once, and my scores ranged between 72 percent and 84 percent. After that, I reviewed only the incorrect answers and revised my notes based on weak areas.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Practice test scores ranging from 72 to 84 percent" src="/images/post/ep5-my-experience-on-passing-aws/96a1a8f4-a95a-49f8-9170-44c7b112345c_1168x996.webp"&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately, I couldn’t hit 90+, lol.&lt;/p&gt;
&lt;h2 id="exam-day-reality"&gt;Exam day reality&lt;/h2&gt;
&lt;p&gt;With this preparation, I sat for the exam feeling confident. I initially thought it would be easier than the Solutions Architect Associate exam, but it turned out to be the opposite. I personally found the Developer Associate exam more difficult.&lt;/p&gt;
&lt;p&gt;The questions were very long and often covered almost the entire screen. The first 15 questions went smoothly, but after that, things became challenging. I started flagging questions, and by the end, I had more than 20 questions marked for review. At one point, I genuinely felt like I might not clear the exam.&lt;/p&gt;
&lt;p&gt;Because of the lengthy questions, while reaching question’s last line, I sometimes forgot what was mentioned at the beginning. It was mentally exhausting.&lt;/p&gt;
&lt;p&gt;&lt;img alt="a woman sitting in front of a laptop computer" src="https://images.unsplash.com/photo-1698047681465-a75bcf38379e?fm=jpg&amp;amp;q=60&amp;amp;w=3000&amp;amp;ixlib=rb-4.1.0&amp;amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://unsplash.com/photos/a-woman-sitting-in-front-of-a-laptop-computer-f2JMVDnarks"&gt;(image source&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;This was literally my situation during the exam (while solving a long question).  &lt;/p&gt;
&lt;p&gt;Please do not take this in a negative or demotivating way. I am just being honest about my experience. I know I lacked proper revision and also pressured myself at the last moment. I did not sleep well the night before the exam, which affected my focus.&lt;/p&gt;
&lt;p&gt;Despite all this, I managed to pass the exam with a score of &lt;strong&gt;836 out of 1000.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Developer Associate exam pass result with score 836" src="/images/post/ep5-my-experience-on-passing-aws/605f4777-6ee2-42a6-a474-ef3ea50adf19_1302x816.webp"&gt;&lt;/p&gt;
&lt;h2 id="certification-badge"&gt;Certification badge&lt;/h2&gt;
&lt;p&gt;Since my exam was booked using a different email, I had to link that email with my personal email associated with Credly. After linking it, I received my badge.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Developer Associate Credly badge" src="/images/post/ep5-my-experience-on-passing-aws/a7a5d55e-c3a5-4406-80e2-89289f31fd9c_2312x1172.webp"&gt;(&lt;a href="https://www.credly.com/badges/0ccb655a-d855-488c-a4a8-f9ee122f8741"&gt;Badge link&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;If you click the Celebrate button on the badge page, it helps me experience that moment too. I never received a notification for it.&lt;/p&gt;
&lt;h2 id="major-takeaways-from-this-experience"&gt;Major takeaways from this experience&lt;/h2&gt;
&lt;p&gt;Here are my lessons from this journey:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Consistency matters. Long gaps make revision much harder.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Taking notes and using AI during preparation is an effective way to learn.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Practice exams are extremely important.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The exam environment can make or break your experience.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sleep and mental state matter.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You do not need perfect preparation to pass, but you do need honest confidence in yourself.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope you found this experience helpful. I would love to get your feedback on how I can improve these weekly letters. &lt;/p&gt;
&lt;p&gt;If you think this could help someone else, please feel free to share it.&lt;/p&gt;
&lt;p&gt;I will see you next week with another experience.&lt;/p&gt;
&lt;p&gt;Thank you for reading.&lt;/p&gt;
&lt;p&gt;Warm regards,&lt;br&gt;
Alon Shrestha&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP4: My 2026 AWS Cloud Architect Roadmap</title><link href="https://cloudwithalon.com/writing/ep4-my-2026-aws-cloud-architect-roadmap/" rel="alternate"/><published>2026-01-02T11:42:00+00:00</published><updated>2026-01-02T11:42:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2026-01-02:/writing/ep4-my-2026-aws-cloud-architect-roadmap/</id><summary type="html">&lt;p&gt;AWS certifications, system design, and growing in public&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy Friends,&lt;/p&gt;
&lt;p&gt;Happy New Year 🎉&lt;/p&gt;
&lt;p&gt;I hope this year gives you the energy, focus, and courage to work on the things you truly want to achieve.&lt;/p&gt;
&lt;p&gt;I started this year by spending quality time with good people, and that gave me clarity.&lt;/p&gt;
&lt;p&gt;I do not want to try or start anything completely new this year. Instead, I want to continue the work I have already begun.&lt;/p&gt;
&lt;p&gt;Building my personal brand, &lt;strong&gt;CloudWithAlon&lt;/strong&gt;, for better visibility and better opportunities.&lt;/p&gt;
&lt;p&gt;Learn. Share. Repeat. Stay consistent.&lt;/p&gt;
&lt;p&gt;However, I do want to publicly commit to a few goals. Writing this down pushes me to stay accountable and consistent.&lt;/p&gt;
&lt;h2 id="my-2026-goals"&gt;My 2026 Goals&lt;/h2&gt;
&lt;h3 id="aws-certifications"&gt;AWS Certifications&lt;/h3&gt;
&lt;p&gt;So far, I have completed certifications using free vouchers from my office. If I continue to receive these vouchers, I plan to pursue certifications across different AWS levels.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;AWS Certified AI Practitioner&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AWS Certified Machine Learning Engineer Associate&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AWS Certified Security Specialty&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AWS Certified Solutions Architect Professional&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I am purely focused on the AWS cloud. No distractions until I fully learn it, apply it, and truly digest it.&lt;/p&gt;
&lt;h3 id="architecting-and-system-design"&gt;Architecting and System Design&lt;/h3&gt;
&lt;p&gt;This year, I will focus more deeply on real world architecting skills, especially system design and other skills that uplift my overall thinking.&lt;/p&gt;
&lt;p&gt;I will start reading engineering papers, design more architectures, and strengthen my fundamentals. By the end of 2026, I want to be confident in designing systems end to end so that I can learn new topics faster and clearly share and discuss them with others.&lt;/p&gt;
&lt;h3 id="building-in-public-and-personal-branding"&gt;Building in Public and Personal Branding&lt;/h3&gt;
&lt;p&gt;I will continue improving my presence on the internet by sharing what I learn and build. One major step for me this year is speaking on camera. This is a key challenge I want to overcome. The goal is better visibility and better opportunities through consistent personal branding.&lt;/p&gt;
&lt;h3 id="learning-and-building-with-ai"&gt;Learning and Building With AI&lt;/h3&gt;
&lt;p&gt;I will actively learn AI, not just as tools that make daily tasks easier, but from an architect and system design perspective. &lt;/p&gt;
&lt;p&gt;I want to understand workflows, architectural concepts, and how AI systems are designed and scaled.&lt;/p&gt;
&lt;h2 id="what-you-can-expect-from-cloudwithalon-in-2026"&gt;What You Can Expect From CloudwithAlon in 2026&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Practical system design breakdowns&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Real world AWS architecture decisions and tradeoffs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lessons from certifications&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Honest notes from building in public&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I do not want to add more goals and get distracted. Focus and consistency are the priorities this year.&lt;/p&gt;
&lt;p&gt;I feel good documenting this journey and sharing it with you. At the end of the year, we can look back together and celebrate what we have accomplished.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What are you continuing this year instead of starting something new?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let us build, learn, and grow together in 2026.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;br&gt;
&lt;strong&gt;Alon&lt;/strong&gt;&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP3: Wrapping Up 2025 and Choosing the Cloud Architect Path</title><link href="https://cloudwithalon.com/writing/ep3-wrapping-up-2025-and-choosing/" rel="alternate"/><published>2025-12-28T14:54:00+00:00</published><updated>2025-12-28T14:54:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-12-28:/writing/ep3-wrapping-up-2025-and-choosing/</id><summary type="html">&lt;p&gt;Learning in public, building visibility, and small consistent steps that are reshaping my career direction.&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Howdy Friends,&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Do not be surprised to see me again so soon. I missed you.&lt;/p&gt;
&lt;p&gt;This letter is a short pause before the year ends. A moment to wrap up my 2025 and honestly share how my career journey has been so far.&lt;/p&gt;
&lt;p&gt;If I am being real, 2025 felt a bit lost for me in tech. It was a year of unfinished plans, delayed goals, and quiet doubts.&lt;/p&gt;
&lt;p&gt;But that is part of the journey.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This year was the moment I made a clear decision. I wanted to grow from being just a cloud engineer into becoming a cloud architect.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Writing to you here is also part of that journey. Thinking clearly. Explaining ideas simply. Sharing what I learn as I grow.&lt;/p&gt;
&lt;p&gt;Once I made that decision, many things started to change.&lt;/p&gt;
&lt;p&gt;I began building my personal brand on the internet with the name &lt;strong&gt;cloudwithalon&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;I did not have a perfect plan. I still do not. But I knew one thing. Visibility creates opportunity. And the only way to get visible was to start showing up.&lt;/p&gt;
&lt;p&gt;I wrote my first &lt;a href="https://www.linkedin.com/in/alonshrestha"&gt;LinkedIn&lt;/a&gt; post after a long time. Then another. And another.&lt;/p&gt;
&lt;p&gt;I started writing blogs on &lt;a href="https://cloudwithalon.com"&gt;cloudwithalon.com&lt;/a&gt; about the technology I am learning.&lt;/p&gt;
&lt;p&gt;I became active on &lt;a href="https://x.com/alonshrestha"&gt;X&lt;/a&gt;, sharing daily learnings, thoughts, and small lessons from my work.&lt;/p&gt;
&lt;p&gt;I created a &lt;a href="https://www.youtube.com/@cloudwithalon"&gt;YouTube&lt;/a&gt; channel and started making videos focused on cloud architecture concepts and real world thinking.&lt;/p&gt;
&lt;p&gt;And finally, I started this &lt;a href="http://cloudwithalon.substack.com"&gt;letter(Substack)&lt;/a&gt; to document my journey and share it with people walking the same path.&lt;/p&gt;
&lt;p&gt;By being active on these platforms, my only goal is to learn, share, and repeat consistently. Every post, video, and article is just a small step in that same direction.&lt;/p&gt;
&lt;p&gt;I also completed the AWS Developer certification as a wrap up achievement for 2025, even though it should have been done in 2024. Better late than never. In a future episode, I will share how I prepared and what the exam experience was like.&lt;/p&gt;
&lt;p&gt;Talking about my work, I am currently leading one of the biggest projects in the cloud infrastructure department. This project has tested my technical skills, my decision making, and my patience. It started in March 2025 and is expected to complete in Q2 of 2026. If I do not deliver, I might be jobless. Just kidding. Maybe.&lt;/p&gt;
&lt;p&gt;I will definitely share more about this project because it is shaping up to be my biggest achievement and the strongest footprint I will leave in my current organization.&lt;/p&gt;
&lt;p&gt;Looking back at 2025, even though it was not my best year, I achieved a lot. More importantly, I feel like I am on the right path. This journey is about growing with intention and becoming a little better every day.&lt;/p&gt;
&lt;p&gt;For 2026, I will list the achievements I plan to work toward and share them with you soon. This newsletter will be the place where I track progress honestly, share lessons openly, and reflect on what worked and what did not. &lt;/p&gt;
&lt;p&gt;At the end of the year, we will look back together and see how the journey truly went.&lt;/p&gt;
&lt;p&gt;Thank you for being here and walking this journey with me.&lt;/p&gt;
&lt;p&gt;More to come.&lt;/p&gt;
&lt;p&gt;Alon Shrestha&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP2: A Disaster Recovery Reality Check</title><link href="https://cloudwithalon.com/writing/ep2-a-disaster-recovery-reality-check/" rel="alternate"/><published>2025-12-21T14:37:00+00:00</published><updated>2025-12-21T14:37:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-12-21:/writing/ep2-a-disaster-recovery-reality-check/</id><summary type="html">&lt;p&gt;Replicating application infrastructure is easy. Replicating behavior is not.&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Howdy Friends,&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I’m back after a few months away. Hope you haven’t forgotten me!&lt;/p&gt;
&lt;p&gt;After Diwali, I returned to Kathmandu. My team had a compliance Disaster Recovery event scheduled for November 29, and I was fully focused on preparing for it.&lt;/p&gt;
&lt;p&gt;Today, I want to share what I learned from this experience and why it matters beyond just passing a compliance check.&lt;/p&gt;
&lt;h3 id="what-is-a-disaster-recovery-event"&gt;What Is a Disaster Recovery Event&lt;/h3&gt;
&lt;p&gt;Every year, my company runs a Disaster Recovery drill.&lt;/p&gt;
&lt;p&gt;The goal is to spin up the entire infrastructure and applications in a separate AWS account, in a different region (West instead of East). &lt;/p&gt;
&lt;p&gt;We then validate data, calculate RPO and RTO, and prepare a report for the security team and our clients.&lt;/p&gt;
&lt;p&gt;As part of the infrastructure team, we own everything from infrastructure to application deployment. &lt;/p&gt;
&lt;p&gt;I work at a health tech company handling critical health data, so this is not optional. It’s required for compliance and client trust.&lt;/p&gt;
&lt;h3 id="the-real-challenge"&gt;The Real Challenge&lt;/h3&gt;
&lt;p&gt;On paper, this sounds simple.&lt;/p&gt;
&lt;p&gt;If your infrastructure is written as Infrastructure as Code (IaC), you just replicate it and move on, right?&lt;/p&gt;
&lt;p&gt;Well, yes and no.&lt;/p&gt;
&lt;p&gt;Infrastructure spins up perfectly. VPCs, subnets, load balancers, instances. Everything looks green.&lt;/p&gt;
&lt;p&gt;But a green infrastructure does not mean a working system. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The real challenge is data and application behavior.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Even after successful deployment in the West region, applications were still trying to connect to services in the East region. &lt;/p&gt;
&lt;p&gt;This is not the hardest part. The challenge is redirecting application requests to West region resources by changing configurations and related mechanisms.&lt;/p&gt;
&lt;p&gt;These configurations must stay updated as the system evolves. And this is the kind of failure dashboards do not show.&lt;/p&gt;
&lt;h3 id="our-approach-to-dr"&gt;Our Approach to DR&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Before the DR event&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Ensure backups are complete and restorable&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Validate configurations are region-aware&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;During the DR event&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Document every success and failure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Capture what broke, how, and why&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;After the DR event&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Fix issues with the development team&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Improve automation to make the next DR smoother&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="how-we-execute-disaster-recovery"&gt;How We Execute Disaster Recovery&lt;/h3&gt;
&lt;p&gt;We use a third-party tool called Arpio combined with in-house automation. Our stack includes Ansible, CloudFormation, Terraform, Bash, and Python.&lt;/p&gt;
&lt;p&gt;We create a private DNS and configure VPN access so anyone connected is routed only to the DR environment. This prevents accidental access to production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Simple applications&lt;/strong&gt;&lt;br&gt;
Applications with minimal configuration needs are replicated directly using Arpio. Resources are copied from East to West with identical networking and naming.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Complex applications&lt;/strong&gt;&lt;br&gt;
Applications that require config changes are deployed in two steps. First, infrastructure is deployed using IaC. Then we use Ansible to deploy the application with updated configurations.&lt;/p&gt;
&lt;p&gt;Configs that support the West region are stored in S3 and updated through automation. Applications pull these configs at runtime. They include region-specific values like bucket names and service endpoints.&lt;/p&gt;
&lt;p&gt;For APIs, databases, and load balancers, we migrated all endpoints to domain names. During DR, we only update Private Route 53 records. Applications resolve endpoints through DNS and connect to the correct region without code changes.&lt;/p&gt;
&lt;h3 id="testing-is-where-reality-hits"&gt;Testing Is Where Reality Hits&lt;/h3&gt;
&lt;p&gt;Once applications are up, the QA team gets VPN access to the DR environment and begins testing. We allocate several hours for this.&lt;/p&gt;
&lt;p&gt;If issues are found, we try to fix them during the DR window. Otherwise, we create tickets and address them later. &lt;/p&gt;
&lt;p&gt;This phase consistently reveals real gaps in application logic and data replication.&lt;/p&gt;
&lt;p&gt;After testing, we finalize issue tickets and calculate RPO and RTO.&lt;/p&gt;
&lt;h3 id="one-failure-that-surprised-us"&gt;One Failure That Surprised Us&lt;/h3&gt;
&lt;p&gt;A large portion of client data in the West region was stale.&lt;/p&gt;
&lt;p&gt;In 2025, we focused heavily on security and moved many resources to private access, including S3, SQS, SNS, and KMS. These changes were tested thoroughly in production. &lt;/p&gt;
&lt;p&gt;However, they caused severe failures in the DR environment. Due to these security updates, a significant amount of client data was not replicated to the West region.&lt;/p&gt;
&lt;p&gt;The application did not crash. It behaved incorrectly.&lt;/p&gt;
&lt;p&gt;We then created a ticket to add automation that monitors S3 bucket replication and alerts us when replication breaks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Major Issues We Faced This Year&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;IAM and network permissions did not fully replicate&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Security hardening caused S3 replication failures&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;OpenSearch and QuickSight data replication remains difficult&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Large infrastructure changes like OS migrations and AWS SCPs increased complexity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Many hardcoded values in applications were discovered unexpectedly&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="what-we-will-do-differently-next-time"&gt;What We Will Do Differently Next Time&lt;/h3&gt;
&lt;p&gt;Test security changes against DR earlier&lt;/p&gt;
&lt;p&gt;Push harder on removing hardcoded values&lt;/p&gt;
&lt;p&gt;Automate more validation checks before QA starts&lt;/p&gt;
&lt;h3 id="the-takeaway"&gt;The Takeaway&lt;/h3&gt;
&lt;p&gt;Disaster Recovery is not about copying infrastructure. It is about whether your system can operate independently in a new environment.&lt;/p&gt;
&lt;p&gt;Configuration management, DNS strategy, and data replication matter as much as spinning up resources. &lt;/p&gt;
&lt;p&gt;Security improvements can break DR workflows, so every change should be validated against Disaster Recovery.&lt;/p&gt;
&lt;p&gt;The success of the 2025 DR exercise was built on lessons from previous years. Repeated practice creates confidence and maturity. The work we did this year will make the 2026 DR smoother and more predictable.&lt;/p&gt;
&lt;p&gt;If you had to run a DR drill tomorrow, which part of your system would you trust the least? I would love to hear your experience.&lt;/p&gt;
&lt;p&gt;Until next time,&lt;br&gt;
Alon&lt;/p&gt;
&lt;h3 id="postscript"&gt;Postscript&lt;/h3&gt;
&lt;p&gt;I recently earned the &lt;strong&gt;AWS Certified Developer Associate certification&lt;/strong&gt;, my last one of the year. I will share more about this in an upcoming newsletter.&lt;/p&gt;
&lt;p&gt;My company was acquired by a much larger organization. Big changes are happening, and I will share that experience soon.&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Back of the Envelope Every Architect Must Master</title><link href="https://cloudwithalon.com/writing/back-of-the-envelope-every-architect-must-master/" rel="alternate"/><published>2025-12-06T14:28:00+00:00</published><updated>2025-12-06T14:28:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-12-06:/writing/back-of-the-envelope-every-architect-must-master/</id><summary type="html">&lt;p&gt;Learn back of the envelope estimation to quickly assess design feasibility, identify bottlenecks, and make smart decisions under pressure for architects&lt;/p&gt;</summary><content type="html">&lt;p&gt;You're in a system design interview. The interviewer asks: Design WhatsApp for 2 billion users. How many messages per second should it handle?&lt;/p&gt;
&lt;p&gt;No calculator. No Google. Just you, a pen, and paper.&lt;/p&gt;
&lt;p&gt;Your mind goes blank. Two billion users sounds overwhelming.&lt;/p&gt;
&lt;p&gt;But with back-of-the-envelope estimation, you can break this down in minutes using simple math.&lt;/p&gt;
&lt;p&gt;This post shows you how to make quick, practical calculations that tell you if your system design will work or break under load.&lt;/p&gt;
&lt;h2 id="what-is-back-of-the-envelope-estimation"&gt;What Is Back-of-the-Envelope Estimation?&lt;/h2&gt;
&lt;p&gt;Back of the envelope estimation is a quick way to make rough calculations that help you understand the scale, cost, or performance of a system before you build it.&lt;/p&gt;
&lt;p&gt;You already use this kind of thinking in daily life. The name may feel new, but the idea is very simple.&lt;/p&gt;
&lt;p&gt;Think of it like planning a party where you estimate:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;How many guests will come? (Users)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How much food will each person need? (Data per user)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How big should the venue be? (Server capacity)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The goal isn't to have perfect accuracy. It's getting numbers good enough to make smart decisions and avoid obvious disasters.&lt;/p&gt;
&lt;h2 id="where-the-name-comes-from"&gt;&lt;strong&gt;Where the Name Comes From&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;The phrase goes back to the late 1800s and early 1900s.&lt;/p&gt;
&lt;p&gt;Scientists and engineers needed quick calculations on the spot. Envelopes were always nearby in offices and homes, and the blank backside made a convenient surface for rough math.&lt;/p&gt;
&lt;p&gt;Einstein sketched ideas on spare paper. Enrico Fermi estimated the atomic bomb's power using simple math on whatever he had.&lt;/p&gt;
&lt;p&gt;The phrase stuck because it captures the essence: quick, rough calculations using whatever's available.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Back-of-envelope estimation calculation example" src="/images/post/back-of-the-envelope-every-architect-must-master/e2f989c6-c9f1-4f33-a9ea-c831205f1933.webp"&gt;&lt;/p&gt;
&lt;h2 id="why-this-matters-for-system-design"&gt;Why This Matters for System Design&lt;/h2&gt;
&lt;p&gt;As an architect, you can't afford to guess. Every choice affects scale, cost, and reliability.&lt;/p&gt;
&lt;p&gt;A few minutes of rough math tells you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Can your system handle peak traffic?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Will your database keep up?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can your network support the load?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Are your latency targets realistic?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Will your cloud bill explode?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This skill helps you spot problems early, before writing a single line of code.&lt;/p&gt;
&lt;p&gt;The best part? It's simple to learn.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Connect with the author on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://x.com/alonshrestha" rel="nofollow" target="_blank"&gt;&lt;strong&gt;&lt;em&gt;X&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.linkedin.com/in/alonshrestha" rel="nofollow" target="_blank"&gt;&lt;strong&gt;&lt;em&gt;LinkedIn&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;for insights on cloud architecture and system design.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="the-building-blocks"&gt;&lt;strong&gt;The Building Blocks&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img alt="System design capacity planning diagram" src="/images/post/back-of-the-envelope-every-architect-must-master/8f485687-51b4-482f-8d3a-d1c5f7d17ee2.webp"&gt;&lt;/p&gt;
&lt;p&gt;To make quick estimations, you need to understand four fundamental concepts. Let's dive into each one.&lt;/p&gt;
&lt;h2 id="power-of-two"&gt;Power of Two&lt;/h2&gt;
&lt;p&gt;When humans count, we naturally think in tens (10, 100, 1000..).&lt;/p&gt;
&lt;p&gt;But computers don't count like we do. Everything in a computer uses bits and bit holds two states: 0 or 1, nothing else.&lt;/p&gt;
&lt;p&gt;Because of this, computers count in powers of two, which is why it appears everywhere in computing.&lt;/p&gt;
&lt;p&gt;Understanding this pattern makes size estimation much easier.&lt;/p&gt;
&lt;h3 id="how-computers-count"&gt;&lt;strong&gt;How Computers Count&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;At the smallest level, computers store information using bits. Each extra bit doubles the possible values you can represent.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;¹&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;pos&lt;/span&gt;&lt;span class="n"&gt;sible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;val&lt;/span&gt;&lt;span class="n"&gt;ues&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;²&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;pos&lt;/span&gt;&lt;span class="n"&gt;sible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;val&lt;/span&gt;&lt;span class="n"&gt;ues&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;³&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;8&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;pos&lt;/span&gt;&lt;span class="n"&gt;sible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;val&lt;/span&gt;&lt;span class="n"&gt;ues&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;⁴&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;16&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;pos&lt;/span&gt;&lt;span class="n"&gt;sible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;val&lt;/span&gt;&lt;span class="n"&gt;ues&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;⁸&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;256&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;pos&lt;/span&gt;&lt;span class="n"&gt;sible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;val&lt;/span&gt;&lt;span class="n"&gt;ues&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With 256 possibilities, you can represent a character, a color value, or a small piece of data. This is why 8 bits make 1 byte.&lt;/p&gt;
&lt;h3 id="how-computers-measure-size"&gt;&lt;strong&gt;How Computers Measure Size&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The same doubling pattern describes storage size:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;¹⁰&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;024&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;about&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;on&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;thousand&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;KB&lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;²⁰&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;048&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;576&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;about&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;on&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;million&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;³⁰&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;073&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;741&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;824&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;about&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;on&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;billion&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;GB&lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;⁴⁰&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;099&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;511&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;627&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;776&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;about&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;on&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;trillion&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;
&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="n"&gt;⁵⁰&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;125&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;899&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;906&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;842&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;624&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;about&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;on&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quadrillion&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PB&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;These sizes power everything you estimate: storage, memory, bandwidth, cache, file sizes, and network limits.&lt;/p&gt;
&lt;h3 id="the-key-pattern"&gt;The Key Pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Bits describe how many different values something can represent.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bytes describe how much data something can hold or transfer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both follow powers of two.&lt;/p&gt;
&lt;p&gt;Once this clicks, you start thinking like a computer, and estimation becomes natural.&lt;/p&gt;
&lt;h3 id="quick-examples"&gt;Quick Examples&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A network moving 2 MB per second transfers about 2 million bytes every second.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A cache with 64 MB holds about 64 million bytes of frequently accessed data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A 4 MB image contains about 4 million bytes of pixel information.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These mental shortcuts let you reason about size without calculators.&lt;/p&gt;
&lt;h2 id="latency-numbers"&gt;Latency Numbers&lt;/h2&gt;
&lt;p&gt;Latency is how long something takes to respond.&lt;/p&gt;
&lt;p&gt;In a system, that “something” could be a CPU operation, a memory read, a disk access, or a network request. Each takes a different amount of time and some are extremely faster than others.&lt;/p&gt;
&lt;p&gt;Once you understand what’s fast and what’s slow, it becomes much easier to see where your design might fall apart.&lt;/p&gt;
&lt;h3 id="units-of-time"&gt;Units of Time&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;nanosecond (ns) &amp;lt; microsecond (µs) &amp;lt; millisecond (ms) &amp;lt; second

1 second = 1,000 milliseconds
1 millisecond = 1,000 microseconds  
1 microsecond = 1,000 nanoseconds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This scale shows just how big the speed gaps are inside a computer.&lt;/p&gt;
&lt;h3 id="how-fast-are-different-operations"&gt;How Fast Are Different Operations?&lt;/h3&gt;
&lt;p&gt;Here is a simple version of real latency numbers:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;L1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basically&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;instant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;CPU&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;operation&lt;/span&gt;&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mh"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ns&lt;/span&gt;
&lt;span class="n"&gt;Memory&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mh"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ns&lt;/span&gt;
&lt;span class="n"&gt;Same&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mh"&gt;500&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;µ&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="n"&gt;Disk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="w"&gt;                  &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mh"&gt;10&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;
&lt;span class="n"&gt;Cross&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;continent&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mh"&gt;150&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You don't need to memorize exact values. What matters is the pattern.&lt;/p&gt;
&lt;h3 id="the-pattern-that-matters"&gt;The Pattern That Matters&lt;/h3&gt;
&lt;p&gt;&lt;img alt="Storage and bandwidth estimation chart" src="/images/post/back-of-the-envelope-every-architect-must-master/ec8a26b2-952b-4458-99da-7053d0558cda.webp"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CPU is thousands of times faster than memory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Memory is hundreds of times faster than disk&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Disk is much faster than network&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;And global network calls are the slowest of all&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This simple pattern explains why caching works, why databases become bottlenecks, and why smart architecture tries to keep everything as close and local as possible.&lt;/p&gt;
&lt;h3 id="real-design-decisions"&gt;Real Design Decisions&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Example 1: Understanding Request Speed&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Suppose a user request (like loading a profile page) makes three database calls. Each database call takes 5 ms.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;3 DB calls → 15 ms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;App logic → 5 ms&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Total → 20 ms per request&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If one request takes 20 ms, a single server can handle: &lt;strong&gt;1 second / 0.020 = ~50 requests per second (RPS)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But here's the key insight. Each request makes 3 database calls, so: &lt;strong&gt;50 RPS × 3 DB calls = 150 queries per second (QPS) to the database&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Now you can see two potential bottlenecks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Server capacity: 50 RPS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Database capacity: 150 QPS&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your app expects 5000 concurrent user requests, you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Servers needed: 5000 ÷ 50 = 100 servers&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Database QPS needed: 5000 × 3 = 15,000 QPS&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is back-of-the-envelope estimation in action. In two minutes, you know your system needs 100 servers and a database that can handle 15,000 queries per second.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example 2: Why Caching Works&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Since memory (100 ns) is hundreds of times faster than disk (10 ms), certain questions become obvious:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Can I cache this instead of hitting the database every time?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Can I pre-compute this instead of recalculating it on every request?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before understanding latency, these seemed like random optimizations. Now they're natural design choices based on speed differences.&lt;/p&gt;
&lt;h2 id="bandwidth-and-throughput"&gt;Bandwidth and Throughput&lt;/h2&gt;
&lt;p&gt;Bandwidth and throughput both describe how much data moves through your network, but they measure different things.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bandwidth&lt;/strong&gt; = your network's maximum capacity(like pipe width). It's the theoretical limit of how much data can flow.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Throughput&lt;/strong&gt; = is the actual, real-world rate of data transfer (what you actually get). It's usually less than bandwidth due to congestion, packet loss, or other real-world factors.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Real example:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Your internet plan might offer 100 Mbps bandwidth, but during peak hours you might only get 70 Mbps throughput because everyone in your area is streaming video.&lt;/p&gt;
&lt;h3 id="understanding-the-units"&gt;Understanding the Units&lt;/h3&gt;
&lt;p&gt;When you buy internet, companies advertise 100 Mbps speed! But when you download a file, your computer shows 12 MB/s. This isn't misleading, they're measuring differently.&lt;/p&gt;
&lt;p&gt;Networks are measured in bits per second because that's how data travels through cables and routers. Every piece of network equipment thinks in bits.&lt;/p&gt;
&lt;p&gt;But your computer shows file downloads in bytes per second because that's how we measure file sizes. A photo is 2 MB, so downloads naturally show in the same units.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The conversion: 1 byte = 8 bits&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This means:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mbps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;internet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;maximum&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;download&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;speed&lt;/span&gt;
&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mbps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;internet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;maximum&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;download&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mbps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;internet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;maximum&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;download&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;speed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For system design, remember this conversion. If you need to transfer 100 MB/s of data, you actually need 800 Mbps of network capacity.&lt;/p&gt;
&lt;h3 id="common-network-speeds"&gt;Common Network Speeds&lt;/h3&gt;
&lt;p&gt;Here are typical bandwidth numbers you'll encounter when designing systems:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Home internet:     100 Mbps  (12 MB/s maximum transfer)
Office internet:   1 Gbps    (125 MB/s maximum transfer)
Server connection: 10 Gbps   (1.25 GB/s maximum transfer)
CDN backbone:      100 Gbps  (12.5 GB/s maximum transfer)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;These numbers help you understand what's realistic for different connection types. A home user uploading a video will be limited by their 12 MB/s connection, while your servers can handle much higher loads.&lt;/p&gt;
&lt;h3 id="real-design-examples"&gt;Real Design Examples&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Example 1: Photo Upload Service&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You're building an app where users upload 10 MB photos. You expect 1000 uploads per hour during peak time.&lt;/p&gt;
&lt;p&gt;Let's calculate the bandwidth needed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Total data per hour: 1000 photos × 10 MB = 10,000 MB = 10 GB/hour
Data per second: 10 GB ÷ 3600 seconds = 0.00278 GB/s
Convert to MB/s: 0.00278 × 1000 = 2.78 MB/s ≈ 3 MB/s
Convert to Mbps: 3 MB/s × 8 = 24 Mbps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Video Streaming Platform&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You have 10,000 users simultaneously streaming 1080p video at 4 Mbps each during prime time.&lt;/p&gt;
&lt;p&gt;Total bandwidth needed: 10,000 users × 4 Mbps = 40 Gbps&lt;/p&gt;
&lt;p&gt;A single server with a 10 Gbps connection can't handle this load. You need either 4 servers or a Content Delivery Network (CDN) to distribute the load across multiple locations.&lt;/p&gt;
&lt;h3 id="how-bandwidth-and-throughput-work-together"&gt;&lt;strong&gt;How Bandwidth and Throughput Work Together&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Bandwidth and throughput are connected, but they tell different stories about your network performance.&lt;/p&gt;
&lt;p&gt;Your server might have 10 Gbps bandwidth, but the actual data flowing through it right now could be much less.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Throughput can never exceed bandwidth, but it's almost always lower.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The gap between them tells you about network health&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In a healthy network, you typically see throughput reaching 70-90% of your total bandwidth. The remaining 10-30% gets consumed by network overhead, protocol headers, and minor congestion. This is completely normal.&lt;/p&gt;
&lt;p&gt;When throughput drops significantly below bandwidth, something is wrong.&lt;/p&gt;
&lt;h2 id="availability-numbers"&gt;Availability Numbers&lt;/h2&gt;
&lt;p&gt;Availability measures how often a system is actually working.&lt;/p&gt;
&lt;p&gt;It tells you how much of the time your service is up and usable. Usually, it is written as a percentage, and people often describe it using the word nines.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For example: 99%, 99.9%, 99.99%.. and so on.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At first glance, these numbers look almost the same. But in reality, each extra nine makes a big difference in how much downtime is allowed.&lt;/p&gt;
&lt;h3 id="what-the-numbers-mean"&gt;What the Numbers Mean&lt;/h3&gt;
&lt;p&gt;Here's what different availability levels mean over one year:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mf"&gt;99&lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;available&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;~&lt;/span&gt;&lt;span class="mf"&gt;3.65&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;days&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;downtime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;per&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;
&lt;span class="mf"&gt;99.9&lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;available&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;~&lt;/span&gt;&lt;span class="mf"&gt;8.7&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;downtime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;per&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;
&lt;span class="mf"&gt;99.99&lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;available&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;~&lt;/span&gt;&lt;span class="mf"&gt;52&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;downtime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;per&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;
&lt;span class="mf"&gt;99.999&lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;available&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;~&lt;/span&gt;&lt;span class="mf"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;downtime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;per&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When you see it like this, the gap becomes very clear.&lt;/p&gt;
&lt;p&gt;Going from 99.9 to 99.99 can remove entire hours of possible downtime. And each extra nine becomes harder and more expensive to achieve.&lt;/p&gt;
&lt;h3 id="the-math-behind-it"&gt;The Math Behind It&lt;/h3&gt;
&lt;p&gt;Availability is simple to calculate:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Availability (%) = (Total Time - Downtime) / Total Time × 100&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A year has 8,760 hours. If your app was down for 48 hours in that year:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Availability = (8,760 - 48) ÷ 8,760 × 100 = &lt;strong&gt;99.45%&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The availability numbers you see aren't guesses. They come from real measurements of uptime and downtime.&lt;/p&gt;
&lt;h3 id="why-this-matters-for-design"&gt;Why This Matters for Design&lt;/h3&gt;
&lt;p&gt;Availability directly influences your architecture before you write any code.&lt;/p&gt;
&lt;p&gt;As an architect, one of the most important questions you need to ask is how much downtime is acceptable for the application. That is usually a business decision, not a technical one.&lt;/p&gt;
&lt;p&gt;If the business can handle a few days of downtime in a year, then a simple setup might be enough. A single server and a single database could work.&lt;/p&gt;
&lt;p&gt;But if the business can only tolerate a few minutes of downtime, then the design must be very different. You will need multiple servers, replicas, automatic failover, load balancing, and maybe even multiple regions.&lt;/p&gt;
&lt;p&gt;In that way, availability directly influences your architecture, your cost, and your overall complexity before you even start building.&lt;/p&gt;
&lt;p&gt;And once the system is live, availability also helps you understand how healthy it really is.&lt;/p&gt;
&lt;p&gt;You can calculate it monthly, quarterly, or yearly to track trends, see where problems are happening, and improve over time.&lt;/p&gt;
&lt;h2 id="putting-it-all-together"&gt;Putting It All Together&lt;/h2&gt;
&lt;p&gt;Now you understand the four building blocks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Power of Two&lt;/strong&gt; for storage calculations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Latency&lt;/strong&gt; for performance and capacity planning&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bandwidth and Throughput&lt;/strong&gt; for network capacity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Availability&lt;/strong&gt; for reliability requirements&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let's see how they work together in a real example.&lt;/p&gt;
&lt;h3 id="complete-example-designing-a-photo-sharing-app"&gt;Complete Example: Designing a Photo Sharing App&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;10 million daily active users&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Each user uploads 2 photos per day&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Each photo is 2 MB&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Users view 20 photos per day&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Target: 99.9% availability&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Storage Estimation (Power of Two):&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Daily&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;uploads&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;×&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;photos&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;photos&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt;
&lt;span class="n"&gt;Daily&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;photos&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;×&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt;
&lt;span class="n"&gt;Yearly&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;×&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;365&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;≈&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Traffic Estimation (Latency):&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Daily requests: 10M users × 20 photo views = 200M requests/day
Requests per second: 200M ÷ 86,400 seconds ≈ 2,315 RPS
Peak traffic (3x average): ~7,000 RPS
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Bandwidth Estimation (Bandwidth &amp;amp; Throughput):&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bandwidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;photos&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;×&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;÷&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;86&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;≈&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;463&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Convert&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mbps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;463&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;×&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;≈&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Mbps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;≈&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Gbps&lt;/span&gt;

&lt;span class="n"&gt;Download&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bandwidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;×&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TB&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;÷&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;86&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;≈&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;630&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MB&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;≈&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;37&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Gbps&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Peak&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;111&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Gbps&lt;/span&gt;

&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;real&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;throughput&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;145&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Gbps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;needed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Availability Planning:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mf"&gt;99.9&lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;availability&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;8.7&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;downtime&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;allowed&lt;/span&gt;
&lt;span class="n"&gt;This&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;requires&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;Load&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;balancers&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Multiple&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;servers&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;Data&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;replication&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Automated&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;failover&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Monitoring&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;alerts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Decisions You Can Make:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Need CDN for photo delivery (111 Gbps peak is too much for single location)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Need object storage like S3 (15 PB/year is massive)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Need caching layer (memory is 100x faster than disk for popular photos)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Need multiple regions for availability target&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Database will handle 2,315 QPS average, 7,000 QPS peak&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of this from 10 minutes of back-of-the-envelope math.&lt;/p&gt;
&lt;h2 id="final-thoughts"&gt;Final Thoughts&lt;/h2&gt;
&lt;p&gt;With these four building blocks, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Estimate if your design will work before building it&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Spot bottlenecks early&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make informed architecture choices&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Communicate clearly with stakeholders&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Avoid expensive mistakes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Remember two key things:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First, these methods give you rough estimates, not exact numbers. Always add a 20-50% buffer to whatever you calculate. This handles unexpected traffic spikes and real-world conditions.&lt;/p&gt;
&lt;p&gt;Second, the more you practice, the more natural it becomes. Start with simple examples. Work through system design problems. Soon you'll be doing these calculations in your head.&lt;/p&gt;
&lt;p&gt;I hope this guide has provided you valuable information.&lt;/p&gt;
&lt;p&gt;If you enjoyed this article, feel free to connect with me through my &lt;a href="http://links.alonshrestha.com.np" rel="nofollow" target="_blank"&gt;Linktree&lt;/a&gt; 🌳, where you'll find all my social links.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>EP1: My Journey into the Cloud</title><link href="https://cloudwithalon.com/writing/ep1-my-journey-into-the-cloud/" rel="alternate"/><published>2025-10-26T16:42:00+00:00</published><updated>2026-06-13T12:42:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-10-26:/writing/ep1-my-journey-into-the-cloud/</id><summary type="html">&lt;p&gt;How I started, what I learned, and where I’m heading next&lt;/p&gt;</summary><content type="html">&lt;p&gt;Howdy Friends!&lt;/p&gt;
&lt;p&gt;Welcome to the first episode.&lt;/p&gt;
&lt;p&gt;Honestly, I wasn’t sure how to start this.&lt;/p&gt;
&lt;p&gt;Over the years, I've learned a lot from people sharing their experiences. This is my attempt to do the same.&lt;/p&gt;
&lt;p&gt;I’m trying to recall everything from the beginning, so I’ll keep it simple and honest.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;My IT journey began in 2016, when I started my Bachelor’s in Computer Science and Information Technology.&lt;/p&gt;
&lt;p&gt;Before that, I remember studying computers in school up to grade 7, learning basic computer hardware and MS-DOS.&lt;/p&gt;
&lt;p&gt;Even the basic HTML/CSS was entirely new to me, and I had no prior exposure to C programming. I initially felt overwhelmed, especially since many of my friends had already built a foundation in school.&lt;/p&gt;
&lt;p&gt;I struggled during the first year of my bachelor’s with projects and academics, but luckily, the college turned out to be very good for me, as I got a lot of opportunities to learn and grow.&lt;/p&gt;
&lt;p&gt;During my second year, I started a paid internship in the IT department at my college. There, I learned computer hardware, server and networking concepts.&lt;/p&gt;
&lt;p&gt;There were computer labs and a small server room. In lab, many PCs were pretty old and we used to get task of doing maintenance on these computers every week. That was the starting point to build a foundaion for me.&lt;/p&gt;
&lt;p&gt;We replaced disks, RAM, and motherboards from one to another wherever they would fit. Booted OS, installed software from an NFS and also controlled blocking ephemeral devices and internet when required.&lt;/p&gt;
&lt;p&gt;At one point, I felt like a pro at fixing them because I could identify the issue just by turning on the PC.&lt;/p&gt;
&lt;p&gt;Another part was learning networking.&lt;/p&gt;
&lt;p&gt;Using FortiGate and Cisco portal felt privileged and overwhelming at the beginning. We worked on building policies for guardrails, blocking sites, monitoring user activity, building a portal for authentication, limiting internet access, separating VLANs, monitoring bandwidth, and going back and forth with ISPs for internet speed and failover.&lt;/p&gt;
&lt;p&gt;Later, I started deploying college websites to production Linux servers. It was lot of fun because we had many experimental sites built with different technologies. Handling deployments for every small change and fixing issues along the way helped me learn a great deal.&lt;/p&gt;
&lt;p&gt;That was when I learned about hosting services like Apache HTTPD and Tomcat. All the websites and databases ran on a single server, which I now know is called a monolithic setup. It was simple, but I learned a lot from it.&lt;/p&gt;
&lt;p&gt;At that time, I was working on on-premises servers using VMware ESXi. I even built my first public server using a dedicated public IP.&lt;/p&gt;
&lt;p&gt;That experience completely changed how I viewed servers. I became deeply interested in fixing issues, even when I did not fully understand them at first. I learned how to find solutions effectively on the internet. &lt;/p&gt;
&lt;p&gt;That phase really built my confidence as an intern. &lt;/p&gt;
&lt;p&gt;Until then, I was still working with on-prem servers. Later, I was given access to the college AWS account, where I could use EC2 and S3. &lt;/p&gt;
&lt;p&gt;I used to explore the AWS console and had PEM keys to access aws instances, but I was completely blank on how to actually use them.&lt;/p&gt;
&lt;p&gt;Then I got another internship, this time as a Cloud Intern at a real cloud-based tech company.&lt;/p&gt;
&lt;p&gt;Everything I learned in my previous internship started to make sense in a production environment. Although I wasn’t allowed to directly work on production systems, I could understand what was going on. That was when I got my real introduction to AWS.&lt;/p&gt;
&lt;p&gt;For six months, I worked with common AWS services like IAM, EC2, Snapshots, Lambda, S3, ALB, RDS and more. This helped me connect my on-premises knowledge to the cloud.&lt;/p&gt;
&lt;p&gt;Alongside the internship, I received $500 in AWS credits from my college to support my learning, and I used them to practice and experiment on my own.&lt;/p&gt;
&lt;p&gt;After completing my bachelor's, I was hired by the same company as an Associate Cloud Engineer. I started handling production systems and learned how critical change windows, backups, monitoring, and security are. That was a big step for me.&lt;/p&gt;
&lt;p&gt;Later, I got promoted to Cloud Engineer. &lt;/p&gt;
&lt;p&gt;I had a basic understanding of programming in Python and Bash, and my team lacked automation for operational tasks. This was a great opportunity for me to contribute, so I started implementing automation in AWS.&lt;/p&gt;
&lt;p&gt;From there, my programming skills improved, and I began to feel more confident.&lt;/p&gt;
&lt;p&gt;I automated simple operational overhead tasks like starting and stopping resources, generating reports, rotating keys, and managing backups. This focus on automation helped me better understand efficiency.&lt;/p&gt;
&lt;p&gt;During this period, I was more focused on deploying and maintaining cloud resources. By this time, I was confident in creating AWS resources and had gained good knowledge of different AWS services, including how to troubleshoot and manage them. &lt;/p&gt;
&lt;p&gt;Looking back, I consider this phase the golden foundation of my cloud skills, and I feel lucky to have been on this path.&lt;/p&gt;
&lt;p&gt;After a few years, the company grew through an acquisition. Eventually, our Cloud Engineering and DevOps teams combined to form a Platform Team, and I became a Platform Engineer.&lt;/p&gt;
&lt;p&gt;I was introduced to CI/CD, release processes, and DevOps best practices. I enjoyed building pipelines for smooth deployments and worked on several deployments and internal applications using serverless and containers.&lt;/p&gt;
&lt;p&gt;Later, I was promoted again to Senior Platform Engineer, focusing on research and long running tasks to streamline operations.&lt;/p&gt;
&lt;p&gt;My first major research project was automating resource patching across multiple AWS accounts using AWS SSM and Lambda. This greatly reduced operational workload, especially as we were managing around 24 AWS accounts.&lt;/p&gt;
&lt;p&gt;The company acquisition also helped me gain new experience, like bringing multiple accounts into a single organization, handling conflicting network migrations, and adapting to new standards.&lt;/p&gt;
&lt;p&gt;Later, I was assigned to another major project. I worked on an operating system migration project as CentOS 7 was reaching end of life, and we chose Rocky Linux. I led the planning and migration efforts across the organization.&lt;/p&gt;
&lt;p&gt;We also improved our security posture through system hardening and configuration best practices using golden images. This project further boosted my knowledge and confidence.&lt;/p&gt;
&lt;p&gt;In 2024, my office provided me with free vouchers to take AWS certification exams. I completed the AWS Cloud Practitioner and Solutions Architect Associate, which were my first certifications.&lt;/p&gt;
&lt;p&gt;While preparing, I had actually underestimated certifications, but they helped me learn new things about the same services and technologies I had already been using.&lt;/p&gt;
&lt;p&gt;That’s when I realized how much certifications can enhance your knowledge when approached the right way. From that point on, I decided to pursue as many certifications as I could.&lt;/p&gt;
&lt;p&gt;So far, I have achieved &lt;a href="https://www.credly.com/users/alon.shrestha/badges/credly"&gt;5 AWS certifications&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Later in 2025, I was promoted to Principal Platform Engineer. These days, I spend more time researching problems, designing solutions, and working on long-term initiatives across the platform. I enjoy what I do, but I’ve also realized that to go further, I need to go deeper.&lt;/p&gt;
&lt;p&gt;Recently in 2026, I’ve been involved in one of the biggest projects of my career. It involves decommissioning a decade-old architecture and rebuilding it to meet modern requirements. The system primarily handles secure file transfers between clients and the organization.&lt;/p&gt;
&lt;p&gt;Working on this project gave me a lot of insights. I started seeing beyond cloud operations and DevOps. It pushed me toward distributed system, architecture and system design at scale.&lt;/p&gt;
&lt;p&gt;After all these years, I feel like I'm starting to see where I want to go next.&lt;/p&gt;
&lt;p&gt;I don't have all the answers yet, but I've become more interested in how large systems are designed, scaled, and evolved over time.&lt;/p&gt;
&lt;p&gt;So these days, I spend more time reading, learning, and experimenting in that direction.&lt;/p&gt;
&lt;p&gt;We'll see where it takes me.&lt;/p&gt;
&lt;p&gt;For now, my goal is simple: to become a better cloud architect.&lt;/p&gt;
&lt;p&gt;Thank you for reading my first letter.&lt;/p&gt;
&lt;p&gt;Until next time,&lt;br&gt;
Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>The Evolution from Dynamo to DynamoDB</title><link href="https://cloudwithalon.com/writing/the-evolution-from-dynamo-to-dynamodb/" rel="alternate"/><published>2025-10-22T16:23:00+00:00</published><updated>2025-10-22T16:23:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-10-22:/writing/the-evolution-from-dynamo-to-dynamodb/</id><summary type="html">&lt;p&gt;Amazon's Dynamo evolved into DynamoDB, transforming from an outage solution to a high-performance NoSQL database for major tech platforms&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;Before DynamoDB, there was Dynamo.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;More than a decade before DynamoDB powered apps like Zoom, Dropbox, Snapchat, and Tinder, a small team inside Amazon was trying to solve one big problem.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to keep Amazon.com online when everything starts breaking?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It was about survival.&lt;/p&gt;
&lt;p&gt;In the early 2000s, Amazon’s business was growing fast with more customers, more orders, more data, and more stress on its systems.&lt;/p&gt;
&lt;p&gt;When you add something to your shopping cart on Amazon, you expect it to just work.&lt;/p&gt;
&lt;p&gt;But back then, that simple click was a huge engineering challenge.&lt;/p&gt;
&lt;p&gt;Databases that once worked fine were suddenly struggling to keep up.&lt;/p&gt;
&lt;p&gt;On normal days, they were slow.&lt;/p&gt;
&lt;p&gt;During peak shopping seasons, they broke.&lt;/p&gt;
&lt;p&gt;And one winter, they really broke.&lt;/p&gt;
&lt;p&gt;For Amazon, that was not acceptable.&lt;/p&gt;
&lt;p&gt;This article tells the story of how DynamoDB was born.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This post reflects what I have learned from various sources online, primarily AWS official sites. While I have made every effort to ensure accuracy, some information may not be completely precise.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="the-outage-that-started-everything"&gt;&lt;strong&gt;The Outage That Started Everything&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Amazon 2004 holiday outage timeline" src="/images/post/the-evolution-from-dynamo-to-dynamodb/c4f4154d-28f8-4f00-b66d-d9b4593d1580.webp"&gt;&lt;/p&gt;
&lt;p&gt;In December 2004, Amazon.com went down for several hours during the peak holiday shopping season.&lt;/p&gt;
&lt;p&gt;It was not just a technical glitch, but a major business failure.&lt;/p&gt;
&lt;p&gt;For an online store during the busiest time of the year, every minute of downtime meant lost sales, unhappy customers, and broken trust.&lt;/p&gt;
&lt;p&gt;When the outage was finally over and the site was back online, Amazon engineers did something that many companies ignore.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;They sat down and wrote a brutally honest report about what went wrong and why.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="the-investigation-results"&gt;&lt;strong&gt;The Investigation Results&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;They wrote what they called a &lt;strong&gt;Correction of Error (COE)&lt;/strong&gt; document.&lt;/p&gt;
&lt;p&gt;It was a technical postmortem of the failure that used the &lt;strong&gt;five whys&lt;/strong&gt; method, asking why again and again until they found the real reason.&lt;/p&gt;
&lt;p&gt;The shocking discovery was this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;70%&lt;/strong&gt; of database operations were simple single key lookups, like Get user's shopping cart.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;20%&lt;/strong&gt; were multi key operations within the same table, such as Get all items in this order.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;90%&lt;/strong&gt; of all database activity had nothing to do with relational capabilities.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Technically, they were using a Formula One race car to deliver pizza.&lt;/p&gt;
&lt;p&gt;Then they faced a key question:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why are we using a relational database for workloads that do not need relations?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The workloads were simple and repetitive:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Shopping cart operations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Session state management&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Location tracking&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Player state retrieval&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These operations needed fast and reliable key value storage, not complex SQL queries, joins, or multi table transactions.&lt;/p&gt;
&lt;p&gt;But that failure sparked one of the most important database innovations in history.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Connect with the author on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.linkedin.com/in/alonshrestha" rel="nofollow" target="_blank"&gt;&lt;strong&gt;&lt;em&gt;LinkedIn&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;for insights on cloud architecture.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="the-dynamo-paper"&gt;&lt;strong&gt;The Dynamo Paper&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Dynamo paper publication and impact" src="/images/post/the-evolution-from-dynamo-to-dynamodb/a854d122-df15-4ff3-a8d0-e413731aac88.webp"&gt;&lt;/p&gt;
&lt;p&gt;In 2007, Amazon published a white paper called &lt;strong&gt;Dynamo: Amazon’s Highly Available Key-Value Store&lt;/strong&gt; at the SOSP conference.&lt;/p&gt;
&lt;p&gt;It was not just another research paper.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It was real, proven technology that Amazon had already built and used in production for years.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The paper explained how Dynamo kept Amazon’s core services running even when parts of the system failed.&lt;/p&gt;
&lt;p&gt;Dynamo focused on a few simple but powerful ideas:&lt;/p&gt;
&lt;h3 id="high-availability-over-consistency"&gt;High Availability Over Consistency&lt;/h3&gt;
&lt;p&gt;In databases, high availability often comes as a trade-off with consistency. Dynamo chose to focus on availability.&lt;/p&gt;
&lt;p&gt;Dynamo was an eventually consistent key value store designed for availability and fault tolerance rather than strict consistency.&lt;/p&gt;
&lt;p&gt;Each piece of data was stored on three separate servers located in three different data centers to ensure durability and continuous access.&lt;/p&gt;
&lt;p&gt;This design made Amazon’s shopping cart always available, even when some servers were down or disconnected.&lt;/p&gt;
&lt;h3 id="always-writeable"&gt;Always Writeable&lt;/h3&gt;
&lt;p&gt;In traditional databases, a write can fail if part of the system is down. Dynamo was built to be always writeable.&lt;/p&gt;
&lt;p&gt;Every write operation was stored on multiple replicas.&lt;/p&gt;
&lt;p&gt;When a customer added an item to the cart, Dynamo did not wait for all three servers to confirm the update.&lt;/p&gt;
&lt;p&gt;As soon as any two out of three servers acknowledged the write, it was accepted. The third server synced up later in the background, a method known as accept now, fix later(sloppy quorum).&lt;/p&gt;
&lt;p&gt;This approach ensured that customer operations, such as adding or updating a shopping cart, continued to work smoothly even during server or network problems.&lt;/p&gt;
&lt;h3 id="simple-query-model"&gt;Simple Query Model&lt;/h3&gt;
&lt;p&gt;Dynamo kept the query model extremely simple.&lt;/p&gt;
&lt;p&gt;It only supported operations by primary key with no joins or complex SQL queries.&lt;/p&gt;
&lt;p&gt;Each item was stored as a &lt;strong&gt;binary object&lt;/strong&gt; (blob) that could be retrieved using its key.&lt;/p&gt;
&lt;p&gt;This simplicity allowed Dynamo to scale horizontally and deliver predictable performance even under heavy load.&lt;/p&gt;
&lt;h3 id="achieved-results"&gt;Achieved Results&lt;/h3&gt;
&lt;p&gt;All these design choices led to impressive real-world results:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;99.9995%&lt;/strong&gt; successful response rate&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Zero data&lt;/strong&gt; loss events reported&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Shopping Cart Service&lt;/strong&gt;: Tens of millions of requests, 3+ million checkouts in a single day&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scalable&lt;/strong&gt; during busy shopping seasons without downtime&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The system that was born from failure became Amazon’s secret weapon.&lt;/p&gt;
&lt;h2 id="simpledb-aws-first-nosql-database"&gt;SimpleDB: AWS’ First NoSQL Database&lt;/h2&gt;
&lt;p&gt;While Amazon was improving its internal Dynamo system, the team realized something important.&lt;/p&gt;
&lt;p&gt;External customers might be facing the same challenges. Many companies were struggling with complex MySQL setups just to handle simple primary key lookups.&lt;/p&gt;
&lt;p&gt;Amazon had already solved this problem internally.&lt;/p&gt;
&lt;p&gt;So, in the same year the Dynamo paper was published, AWS launched &lt;strong&gt;SimpleDB&lt;/strong&gt;, its first public NoSQL database service.&lt;/p&gt;
&lt;p&gt;It was revolutionary at the time. Customers loved it because there was no need for server management.&lt;/p&gt;
&lt;p&gt;It offered a flexible data model, high availability, and a simple interface.&lt;/p&gt;
&lt;p&gt;However, over time, customers started reporting its limitations.&lt;/p&gt;
&lt;p&gt;Each domain was limited to 10 GB of storage, which forced users to split data across multiple domains.&lt;/p&gt;
&lt;p&gt;Performance was sometimes unpredictable because SimpleDB automatically indexed all attributes, which slowed down writes and increased memory usage.&lt;/p&gt;
&lt;p&gt;Pricing was also complex and difficult to estimate.&lt;/p&gt;
&lt;p&gt;Even with these challenges, SimpleDB was a valuable experiment.&lt;/p&gt;
&lt;p&gt;It helped AWS learn what customers really wanted: simplicity, scalability, and a fully managed service without strict limits.&lt;/p&gt;
&lt;p&gt;Today, SimpleDB is considered deprecated, although AWS has never officially announced it.&lt;/p&gt;
&lt;h2 id="dynamodb-the-next-evolution"&gt;DynamoDB: The Next Evolution&lt;/h2&gt;
&lt;p&gt;&lt;div class="video-container"&gt;
    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/kxW3-k7NXwo" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt; &lt;/p&gt;
&lt;p&gt;After years of running Dynamo inside Amazon and learning from the challenges of SimpleDB, AWS decided to build something new.&lt;/p&gt;
&lt;p&gt;In 2012, AWS launched DynamoDB, a NoSQL database designed for speed, scalability, and zero operational burden.&lt;/p&gt;
&lt;p&gt;It is important to note that Dynamo (2007) and DynamoDB (2012) are completely separate systems.&lt;/p&gt;
&lt;p&gt;They share the same design principles but have very different implementations.&lt;/p&gt;
&lt;p&gt;DynamoDB was built as a distributed hash table with a few key requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Partitionable from the beginning&lt;/strong&gt;: It needed to scale down to individual items without using add-on sharding.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Horizontal scaling&lt;/strong&gt;: Every part of the system had to scale evenly to prevent bottlenecks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi-tenant architecture&lt;/strong&gt;: Resources had to be shared efficiently while keeping data isolated.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Zero downtime&lt;/strong&gt;: The system had to keep running continuously without planned maintenance interruptions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div data-node-type=callout&gt;
&lt;div data-node-type=callout-emoji&gt;💡&lt;/div&gt;
&lt;div data-node-type=callout-text&gt;If this interests you, you may want to check out the &lt;a target=_self rel=noopener noreferrer nofollow href=https://cloudwithalon.com/deep-dive-into-aws-s3-architecture style=pointer-events: none&gt;AWS S3 architecture&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="scaling-and-performance-milestones"&gt;Scaling and Performance Milestones&lt;/h3&gt;
&lt;p&gt;According to AWS documentation, DynamoDB has reached remarkable scale and reliability:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Handles trillions of requests per day&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Used by major companies such as Netflix, Disney Plus, and Samsung&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Tables can scale to petabytes of data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Delivers single-digit millisecond latency for reads and writes&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="recent-inovation"&gt;Recent Inovation&lt;/h3&gt;
&lt;p&gt;AWS has made several improvements to DynamoDB up to 2024.&lt;/p&gt;
&lt;p&gt;The price of on demand capacity mode was reduced by 50 percent. This change reflects DynamoDB’s growing adoption and AWS’s effort to pass those savings back to customers.&lt;/p&gt;
&lt;p&gt;The extra cost for Global Tables regional writes has been removed. Writing to multiple regions now costs the same as a replicated write in one region.&lt;/p&gt;
&lt;p&gt;A new feature called Warm Throughput provides better visibility into how tables use resources. It helps users understand performance more clearly and gives the experience of dedicated capacity even in a shared system.&lt;/p&gt;
&lt;p&gt;Integration has also improved. DynamoDB now supports direct connections with OpenSearch, Redshift, and S3 without complex ETL steps.&lt;/p&gt;
&lt;p&gt;Security has been strengthened with resource based policies, PrivateLink support, and attribute based access control.&lt;/p&gt;
&lt;p&gt;Operationally, DynamoDB Accelerator (DAX) now delivers microsecond latency for even faster response times.&lt;/p&gt;
&lt;p&gt;Now, it serves as a tier zero dependency within Amazon, meaning many other AWS services such as EC2 and Lambda now directly depend on it.&lt;/p&gt;
&lt;p&gt;If DynamoDB fails, several critical AWS services would be affected. For example, &lt;a href="https://aws.amazon.com/message/101925/"&gt;the outage on October 20, 2025&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="key-lessons-from-dynamodbs-evolution"&gt;&lt;strong&gt;Key Lessons from DynamoDB’s Evolution&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Two decades after Amazon’s 2004 holiday outage, DynamoDB’s journey from failure to one of the most reliable databases offers lasting lessons.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Innovation often starts with failure.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When most companies were focused on relational databases, Amazon asked a simple question: why? That question opened the door to a new way of thinking about scale and reliability.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Prove before publishing.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;DynamoDB was tested in production for years before the paper was shared, ensuring it was trusted and practical.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Internal tools can become global standards.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A solution for Amazon’s challenges now powers thousands of systems worldwide.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Simplicity wins.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;DynamoDB’s focus has always been on making complex systems simple, reliable, and easy to use.&lt;/p&gt;
&lt;p&gt;This story shows that tackling real problems with reflection and thoughtful engineering can turn failure into lasting innovation.&lt;/p&gt;
&lt;p&gt;If you enjoyed this story, feel free to connect with me through my &lt;a href="https://links.alonshrestha.com.np/"&gt;&lt;strong&gt;Linktree&lt;/strong&gt;&lt;/a&gt; 🌳, where you’ll find all my social links.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Deep Dive into AWS S3 Architecture</title><link href="https://cloudwithalon.com/writing/deep-dive-into-aws-s3-architecture/" rel="alternate"/><published>2025-10-04T05:07:00+00:00</published><updated>2025-10-04T05:07:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-10-04:/writing/deep-dive-into-aws-s3-architecture/</id><summary type="html">&lt;p&gt;Explore AWS S3's architecture, uncovering its frontend, indexing, and storage layers for durability and performance in cloud computing environments&lt;/p&gt;</summary><content type="html">&lt;blockquote&gt;
&lt;p&gt;Connect with me on &lt;a href="https://x.com/alonshrestha" rel="nofollow" target="_blank"&gt;&lt;strong&gt;&lt;em&gt;X&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.linkedin.com/in/alonshrestha" rel="nofollow" target="_blank"&gt;&lt;strong&gt;&lt;em&gt;LinkedIn&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; for insights on Cloud Architecture.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;AWS S3 (Simple Storage Service) is one of the most widely used services and a critical building block of the cloud.&lt;/p&gt;
&lt;p&gt;It powers everything from startups storing simple files to enterprises running complex data lakes and AI driven workflows.&lt;/p&gt;
&lt;p&gt;On first look, S3 might look like a simple bucket where you can put and get files.&lt;/p&gt;
&lt;p&gt;But here’s the catch. Behind that simplicity lies one of the most massive and sophisticated distributed storage systems ever designed to deliver:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;11 nines (99.999999999%) durability&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;99.99% availability&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;storage of over 350 trillion objects&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;handling 100 million+ requests per second&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;serving 1 PB of data per second&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;cost effective cold storage&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Impressive, right? So how does S3 actually pull this off?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The answer lies in its layered architecture built for durability, availability, and performance with built in risk mitigation at every step.&lt;/p&gt;
&lt;p&gt;In this blog we will break down S3’s architecture into three main layers: Frontend, Indexing, and Storage and explore how each layer works.&lt;/p&gt;
&lt;h2 id="high-level-s3-architecture"&gt;High-Level S3 Architecture&lt;/h2&gt;
&lt;p&gt;&lt;img alt="AWS S3 Architecture - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/7a3b1f9c-34b9-48c8-914a-b782c7190e34.webp"&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Disclaimer: In this post, I’ve shared what I’ve learned about AWS S3 Architecture in simple terms. Please note, AWS has not fully disclosed its architecture publicly. While I’ve made every effort to ensure accuracy, the information may not be entirely precise.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;S3 has over 350 microservices deployed in each region, making it a highly complex system. For AWS engineers, building this ecosystem was not easy.&lt;/p&gt;
&lt;p&gt;It has been a journey of learning from failures and continuously improving from 2006 until today.&lt;/p&gt;
&lt;p&gt;In the early days AWS operated in a reactive mode where issues were fixed only after customers experienced them.&lt;/p&gt;
&lt;p&gt;But as usage grew from gigabytes to exabytes this approach was no longer sustainable.&lt;/p&gt;
&lt;p&gt;This led to a cultural shift toward threat modeling which means anticipating what could go wrong and building safeguards before problems ever occur.&lt;/p&gt;
&lt;p&gt;With this foundation in place, the diagram above shows a simple architecture of S3, highlighting its key components and how they work together.&lt;/p&gt;
&lt;h2 id="frontend-layer-entry-point"&gt;Frontend Layer (Entry Point)&lt;/h2&gt;
&lt;p&gt;When you upload or download a file from S3, the very first component you interact with is the frontend layer.&lt;/p&gt;
&lt;p&gt;This layer is responsible for authenticating incoming requests, balancing traffic, and routing them to the right backend systems.&lt;/p&gt;
&lt;p&gt;Think of this as the entry gate where every request checks in.&lt;/p&gt;
&lt;p&gt;At a high level, the frontend is made of three pieces:&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS S3 Architecture - Front Layer -Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/5469a779-bcfd-45c5-9310-bd1fbf70a460.webp"&gt;&lt;/p&gt;
&lt;h3 id="multi-value-dns"&gt;&lt;strong&gt;Multi-value DNS&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;When you type in &lt;code&gt;s3.amazonaws.com&lt;/code&gt;, DNS doesn’t just hand you one IP address. Instead, it gives back several IPs, each pointing to a different S3 frontend server.&lt;/p&gt;
&lt;p&gt;Your client (AWS SDK, CLI) can pick from these addresses, which automatically spreads requests across multiple servers.&lt;/p&gt;
&lt;p&gt;This way, no single machine becomes a bottleneck and traffic stays balanced.&lt;/p&gt;
&lt;h3 id="rest-api-servers"&gt;&lt;strong&gt;REST API Servers&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;These are the machines that actually speak the S3 API language handling your &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;LIST&lt;/code&gt;, and &lt;code&gt;DELETE&lt;/code&gt; calls.&lt;/p&gt;
&lt;p&gt;Each server has limited resources (CPU, memory, bandwidth), so AWS encourages clients to use parallelism like multipart upload and range GETs.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS S3 Multipart Upload and Range GET - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/bb603303-a5ed-418f-89b5-0bc4e67724aa.webp"&gt;&lt;/p&gt;
&lt;p&gt;For example, if you’re uploading a huge file(above 100MB), you can split it into parts and send them to different servers at once. If one part fails, you just retry that chunk instead of starting all over again.&lt;/p&gt;
&lt;h3 id="routing-to-backend"&gt;&lt;strong&gt;Routing to Backend&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Once the request is validated at the front-end, it is forwarded deeper into S3 (the index and storage layers).&lt;/p&gt;
&lt;p&gt;This separation allows the frontend to focus purely on API performance and traffic scaling, while the backend ensures durability and persistence of objects.&lt;/p&gt;
&lt;p&gt;Of course, no system is perfect. Here’s what can go wrong and how AWS prevents it.&lt;/p&gt;
&lt;h3 id="threats-and-mitigations-in-frontend-layer"&gt;&lt;strong&gt;Threats and Mitigations in Frontend Layer&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Threat&lt;/strong&gt;: A single server becomes overloaded or fails&lt;br&gt;
&lt;strong&gt;Mitigation&lt;/strong&gt;: Multi-value DNS spreads requests across multiple servers&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Threat&lt;/strong&gt;: Network errors may cause large uploads to fail midway&lt;br&gt;
&lt;strong&gt;Mitigation&lt;/strong&gt;: Multipart uploads retry only the failed parts instead of restarting the whole upload&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Threat&lt;/strong&gt;: Limited throughput on one server&lt;br&gt;
&lt;strong&gt;Mitigation&lt;/strong&gt;: Parallel requests and range GETs distribute load across servers&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All these capabilities are built into an open-source library created and maintained by AWS, called the &lt;a href="https://docs.aws.amazon.com/sdkref/latest/guide/common-runtime.html" rel="nofollow" target="_blank"&gt;Common Runtime&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It includes features such as multipart uploads, range GETs, multi-value DNS, strong checksums, and advanced retry algorithms.&lt;/p&gt;
&lt;p&gt;Moreover, it is bundled with the AWS SDKs and CLI, allowing developers to automatically benefit from these best practices without additional effort.&lt;/p&gt;
&lt;h2 id="index-layer"&gt;Index Layer&lt;/h2&gt;
&lt;p&gt;&lt;img alt="AWS S3 Index Layer - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/31215cdd-c6ae-4a3e-a0dd-6f0051c090a4.webp"&gt;&lt;/p&gt;
&lt;p&gt;Here’s where things get interesting.&lt;/p&gt;
&lt;p&gt;If the frontend is the entry point of S3, then the index layer is its brain.&lt;/p&gt;
&lt;p&gt;This layer plays a crucial role in S3’s performance, and most of the important work is done here.&lt;/p&gt;
&lt;p&gt;It knows where every single object in your bucket lives, no matter how many trillions of objects there are.&lt;/p&gt;
&lt;p&gt;When you upload a file, S3 doesn’t just throw it blindly into storage.&lt;/p&gt;
&lt;p&gt;First, it updates the index with metadata: the object’s name, size, version, permissions, and most importantly where the actual data is stored.&lt;/p&gt;
&lt;p&gt;Later, when you try to download that file, S3 looks it up in the index first, figures out which storage node holds it, and retrieves it for you.&lt;/p&gt;
&lt;p&gt;Think of the index like a massive, distributed catalog. Instead of keeping one giant database (which would be a single point of failure), AWS spreads the index across many systems in multiple availability zones.&lt;/p&gt;
&lt;p&gt;This gives two benefits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Durability&lt;/strong&gt; → even if an entire server or zone fails, the metadata isn’t lost.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt; → lookups stay fast, even when you’re dealing with hundreds of trillions of objects.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="how-it-works"&gt;How it works?&lt;/h3&gt;
&lt;p&gt;No single server can handle index of trillions of objects, so S3 partitions and distributes its index.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Partitioning follows a lexicographical order: objects with certain prefixes go to specific partitions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bucket object keys are hashed, especially the prefix part, to determine which partition stores them.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;System continuously monitors partition load and can migrate hot keys to less loaded partitions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When a partition is overloaded (e.g., popular prefixes), S3 splits it into smaller sub-partitions and redistributes the load.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="threats-and-mitigation-for-indexing-partitioning"&gt;&lt;strong&gt;Threats and mitigation for Indexing &amp;amp; Partitioning&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;img alt="AWS Prefix Partition - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/5e7997f5-7923-486a-937f-325a3e42ac00.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Threat:&lt;/strong&gt; If many objects share similar prefixes, requests pile up in one partition and create hotspots. This can make performance slower or unpredictable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mitigations:&lt;/strong&gt; S3 avoids this giving each prefix its own throughput capacity. User can help by designing keys smartly. This way, requests are evenly balanced across partitions and scale linearly.&lt;/p&gt;
&lt;h2 id="storage-layer-where-your-data-lives"&gt;Storage Layer - Where Your Data Lives&lt;/h2&gt;
&lt;p&gt;&lt;img alt="AWS S3 Storage Layer - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/b6b2e816-4265-442c-9f6e-30e7d9867c17.webp"&gt;&lt;/p&gt;
&lt;p&gt;You can think of the storage layer as the heart of S3.&lt;/p&gt;
&lt;p&gt;This is where your objects actually live, spread across millions of drives and storing exabytes of data.&lt;/p&gt;
&lt;p&gt;When you upload a file&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The file is broken into smaller chunks, also called shards.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;These chunks are distributed across multiple drives.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The data is then replicated across at least three Availability Zones, unless you have chosen a One-Zone storage class.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The locations of these chunks are tracked in the index layer we discussed earlier, so S3 always knows exactly where each piece of your object lives.&lt;/p&gt;
&lt;h3 id="ssds-and-hdds-in-s3"&gt;SSDs and HDDs in S3&lt;/h3&gt;
&lt;p&gt;It is believed that S3 uses a mix of SSDs and HDDs.&lt;/p&gt;
&lt;p&gt;SSDs are used for hot paths such as metadata, indexes, and small objects that require fast IOPS performance. They are also commonly used in storage classes like Standard and Infrequent Access.&lt;/p&gt;
&lt;p&gt;HDDs are used for the bulk of object data since they offer large capacity at a lower cost. They are the foundation for colder storage classes such as Glacier.&lt;/p&gt;
&lt;p&gt;While HDDs provide lower performance(IOPS), S3 overcomes this by using massive parallelism.&lt;/p&gt;
&lt;p&gt;Data is spread across millions of drives, allowing the combined throughput of many HDDs to deliver high performance at scale while keeping costs efficient.&lt;/p&gt;
&lt;p&gt;But here’s the real challenge.&lt;/p&gt;
&lt;p&gt;Storing data at this scale comes with risks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Drives&lt;/strong&gt; → hard drives can fail or silently corrupt bits.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Zones/Buildings&lt;/strong&gt; → entire facilities can be taken down by fire, water, or power failures.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;People/Operations&lt;/strong&gt; → bugs, misconfigurations, and operator mistakes happen.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Yet despite these risks, S3 still promises 11 nines of durability (99.999999999%).&lt;/p&gt;
&lt;h2 id="reasons-behind-s3-11-9s-durability"&gt;Reasons Behind S3 11 9s Durability&lt;/h2&gt;
&lt;h3 id="end-to-end-checksums"&gt;&lt;strong&gt;End-to-End Checksums&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;First, let’s understand how S3 ensures that an uploaded file is safely stored without corruption or unexpected changes.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS S3 End to end integrity Check - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/019de27e-8fc1-4f82-8470-f2964826324a.webp"&gt;&lt;/p&gt;
&lt;p&gt;When you upload a file to S3, it immediately creates a checksum to make sure the data is not changed while moving through the network.&lt;/p&gt;
&lt;p&gt;Once the file reaches storage, S3 calculates another checksum and compares it with the original to confirm nothing was lost or altered.&lt;/p&gt;
&lt;p&gt;S3 uses algorithms like MD5, CRC32, or SHA-256 for these checks. Even later, when you read the file, S3 recalculates the checksum to detect silent issues such as bit rot.&lt;/p&gt;
&lt;p&gt;This way, S3 guarantees that the file you upload is exactly the file you download. Only after all integrity checks pass S3 return a success message.&lt;/p&gt;
&lt;h3 id="erasure-coding"&gt;&lt;strong&gt;Erasure Coding&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;img alt="AWS S3 Using Parity Shards Erasure Coding - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/53833ddc-44e5-461d-8726-460c417bd363.webp"&gt;&lt;/p&gt;
&lt;p&gt;AWS uses erasure coding to save storage space while maintaining high durability.&lt;/p&gt;
&lt;p&gt;Instead of storing multiple full copies of a file, S3 splits the file into smaller data shards and adds redundant parity shards.&lt;/p&gt;
&lt;p&gt;Parity shards are mathematical representations of data shards that can be used to reconstruct any missing data shards.&lt;/p&gt;
&lt;p&gt;For example, a file might be split into 5 data shards + 3 parity shards and spread across different drives. If one or two drives fail, S3 can reconstruct the missing shards from the remaining ones.&lt;/p&gt;
&lt;p&gt;The data and parity shards are distributed across multiple Availability Zones rather than fully replicated.&lt;/p&gt;
&lt;p&gt;This approach is primarily used for cold storage and large files, where storage efficiency and cost savings are critical.&lt;/p&gt;
&lt;h3 id="monitoring-and-replication"&gt;Monitoring and Replication&lt;/h3&gt;
&lt;p&gt;S3 stores data across millions of hard drives. These drives are distributed across different availability zones (AZs) within a region.&lt;/p&gt;
&lt;p&gt;The split shards are either replicated or distributed across these drives, depending on the requirements.&lt;/p&gt;
&lt;p&gt;When you upload a file, the upload isn’t considered complete until all shards are safely written across multiple zones. Only then does S3 return a success message.&lt;/p&gt;
&lt;p&gt;This guarantees reads always return the most recent data which enables strong consistency.&lt;/p&gt;
&lt;p&gt;This wasn't always the case. Before December 2020, S3 had eventual consistency, meaning you could upload a file and immediately get a 404 if you tried to read it. It took AWS 14 years to achieve strong consistency without sacrificing performance, and they did it at no extra cost.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS S3 Automated Drive Auditing and Recovery - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/46457d7a-4aa3-4ac7-a658-497fa320e8b1.webp"&gt;&lt;/p&gt;
&lt;p&gt;One hard truth is that replicating data across zones alone isn’t enough to keep data safe.&lt;/p&gt;
&lt;p&gt;Drives can silently fail over time, so S3 constantly runs background audits and monitoring. It even uses machine learning to predict drive failures and fix issues before they cause any data loss.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Failed or unhealthy drives are detected within seconds.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data is automatically re-replicated to healthy drives, often before users even notice.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Extra “slack capacity” is always kept available so recovery can happen in parallel across thousands of drives.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Silent errors, like bit flips, are caught with checksums and corrected immediately.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="availability-design"&gt;Availability Design&lt;/h3&gt;
&lt;p&gt;&lt;img alt="AWS S3 High Availability and Automatic Failover - Cloud with Alon" src="/images/post/deep-dive-into-aws-s3-architecture/e7dedc5a-47fd-40b6-95d3-a4b3c99e9991.webp"&gt;&lt;/p&gt;
&lt;p&gt;S3 is regional, not global. (don’t get confused)&lt;/p&gt;
&lt;p&gt;Because of this, S3 helps keep latency low and reliability high.&lt;/p&gt;
&lt;p&gt;Within each region:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Data is spread across multiple AZs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If one AZ fails, traffic is automatically routed to healthy ones.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DNS ensures your application only connects to healthy servers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Updates and changes are deployed zone by zone, so one mistake never affects the whole region.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This design is what enables S3 to deliver both high durability and high availability.&lt;/p&gt;
&lt;h3 id="mitigating-human-errors"&gt;Mitigating Human Errors&lt;/h3&gt;
&lt;p&gt;Hardware isn’t the only risk.&lt;/p&gt;
&lt;p&gt;Sometimes the biggest threat is us, the humans.&lt;/p&gt;
&lt;p&gt;Human mistakes and software bugs are also significant threats to data risk.&lt;/p&gt;
&lt;p&gt;AWS S3 offers several features designed to protect against such errors.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Versioning&lt;/strong&gt; ensures that previous versions of objects are retained, allowing for recovery in case of accidental deletions or overwrites.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lifecycle Policies&lt;/strong&gt; help manage older object versions and facilitate transitions to more cost-effective storage solutions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To enhance data protection, &lt;strong&gt;Cross-Region Replication&lt;/strong&gt; allows for automatic copies of data in different regions, providing an extra layer of insurance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Additionally, &lt;strong&gt;Object Lock&lt;/strong&gt; prevents modification or deletion of objects, ensuring compliance and preserving the integrity of important data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="lessons-from-s3s-evolution"&gt;&lt;strong&gt;Lessons from S3’s Evolution&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;S3's architecture didn't emerge overnight.&lt;/p&gt;
&lt;p&gt;Looking back, here are the principles that guided S3’s growth.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start Simple, Scale Slowly:&lt;/strong&gt; S3 began with basic features and added more as needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Accept Failures:&lt;/strong&gt; Instead of avoiding all failures, S3 is built to handle them gracefully.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Measure Everything:&lt;/strong&gt; Constant monitoring helps improve the system continuously.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Automate Recovery:&lt;/strong&gt; Fixing problems should mostly happen without human help.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Limit Damage:&lt;/strong&gt; Design to keep failures small.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="takeaway"&gt;&lt;strong&gt;Takeaway&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;S3's architecture demonstrates how to build systems that are simultaneously simple to use and incredibly robust under the hood.&lt;/p&gt;
&lt;p&gt;Understanding this architecture helps us appreciate not just how S3 works, but how to think about building distributed systems that need to operate reliably at massive scale.&lt;/p&gt;
&lt;p&gt;Next time you upload a file to S3, remember: behind that simple action is a complex, well-designed system working hard to keep your data safe, available, and fast.&lt;/p&gt;
&lt;p&gt;If you enjoyed this breakdown, feel free to connect with me through my &lt;a href="https://links.alonshrestha.com.np"&gt;Linktree&lt;/a&gt; 🌳, where you’ll find all my social links.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>AWS Stateless Network ACL vs. Stateful Security Group</title><link href="https://cloudwithalon.com/writing/aws-stateless-network-acl-vs-stateful-security-group/" rel="alternate"/><published>2025-09-29T09:37:00+00:00</published><updated>2025-09-29T09:37:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-09-29:/writing/aws-stateless-network-acl-vs-stateful-security-group/</id><summary type="html">&lt;p&gt;Explains the key differences between AWS Network ACLs and Security Groups, focusing on stateless and stateful behaviors in cloud computing&lt;/p&gt;</summary><content type="html">&lt;blockquote&gt;
&lt;p&gt;Connect with the author on &lt;a href="https://x.com/alonshrestha" rel="nofollow" target="_blank"&gt;X&lt;/a&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;a href="https://www.linkedin.com/in/alonshrestha" rel="nofollow" target="_blank"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt; for Cloud Architect tips.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This short guide explains one important characteristic of AWS Network ACLs and Security Groups that many beginners miss.&lt;/p&gt;
&lt;p&gt;Often you won't run into a situation that forces you to learn the difference between stateless and stateful.&lt;/p&gt;
&lt;p&gt;You just tweak inbound/outbound rules until traffic works, and that’s fine. Because of that, many beginners never notice the underlying behavior until they hit a tricky networking issue.&lt;/p&gt;
&lt;p&gt;Let's start.&lt;/p&gt;
&lt;p&gt;Video version:&lt;/p&gt;
&lt;p&gt;&lt;div class="video-container"&gt;
    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/OswAweFOTz8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt; &lt;/p&gt;
&lt;h2 id="security-groups-are-stateful"&gt;Security Groups are Stateful&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;What does stateful mean here?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It means a Security Group remembers the connection in memory.&lt;/p&gt;
&lt;p&gt;When you attach a Security Group to an EC2 instance, you usually configure both inbound and outbound rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inbound rule&lt;/strong&gt;: allows traffic from a specific source (e.g., a user’s IP).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Outbound rule&lt;/strong&gt;: allows the EC2 instance to send responses back.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Suppose a user with IP &lt;code&gt;10.0.1.12&lt;/code&gt; wants to access your EC2 instance on port 80. The inbound rule must allow this IP.&lt;/p&gt;
&lt;p&gt;Normally, you might think you also need an outbound rule for the response, which is true for other types of connections.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Security Group stateful behavior diagram" src="/images/post/aws-stateless-network-acl-vs-stateful-security-group/848ce1e3-1aa8-4d99-b8d2-6af0840eda30.webp"&gt;&lt;/p&gt;
&lt;p&gt;But here’s the twist: Security Groups are stateful, so once an inbound rule is allowed, the outbound response traffic is automatically allowed even if no outbound rule is defined, as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Security Group automatic response traffic flow" src="/images/post/aws-stateless-network-acl-vs-stateful-security-group/9b8293ac-319c-47bf-a5f8-e258c85271d0.webp"&gt;&lt;/p&gt;
&lt;p&gt;That’s why the user will still get the response, and your application works as expected.&lt;/p&gt;
&lt;p&gt;The same applies in the other direction, but one side must be accepted first for it to work.&lt;/p&gt;
&lt;div data-node-type=callout&gt;
&lt;div data-node-type=callout-emoji&gt;💡&lt;/div&gt;
&lt;div data-node-type=callout-text&gt;&lt;a target=_self rel=noopener noreferrer nofollow href=https://youtu.be/NbTmboFia5A?si=Ijfr4CxDSYv7hoz7 style=pointer-events: none&gt;AWS Networking Fundamentals explained in under 4 minutes.&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id="network-acls-are-stateless"&gt;Network ACLs are Stateless&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;What does stateless mean here?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It means a Network ACL (NACL) does not remember connections. Every packet is checked individually, whether it’s a request or a response.&lt;/p&gt;
&lt;p&gt;You must explicitly configure both inbound and outbound rules to allow traffic from a specific IP and to send the response back.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Network ACL stateless behavior requiring explicit rules" src="/images/post/aws-stateless-network-acl-vs-stateful-security-group/3c0925f3-fba7-4059-8a4e-3bbc7b1181d7.webp"&gt;&lt;/p&gt;
&lt;p&gt;Unlike Security Groups, if either rule is missing, the request will fail.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>How EC2 Instance in Private Subnet Connects to the Internet in AWS</title><link href="https://cloudwithalon.com/writing/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/" rel="alternate"/><published>2025-09-15T00:00:00+00:00</published><updated>2025-09-15T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-09-15:/writing/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/</id><summary type="html">&lt;p&gt;Understand the traffic flow of EC2 instances in a private subnet as they securely access the internet through a NAT Gateway in AWS&lt;/p&gt;</summary><content type="html">&lt;p&gt;If you’ve ever launched an EC2 instance in a private subnet, you’ll notice it can’t reach the internet.&lt;/p&gt;
&lt;p&gt;But what if your instance needs to connect to external services while still staying private and hidden from the public internet?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;That’s where a NAT Gateway comes in.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A NAT Gateway allows private resources to securely access the internet without being exposed to it.&lt;/p&gt;
&lt;p&gt;It’s simple to set up, but many AWS engineers get confused about how the traffic actually flows. From an EC2 instance, through the NAT Gateway, and out to the internet.&lt;/p&gt;
&lt;p&gt;In this blog, we’ll walk through the step-by-step workflow of how an EC2 instance in a private subnet reaches the internet.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If you prefer a quick visual walkthrough, here’s a short video explanation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class="video-container"&gt;
    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/0ZV37Um91Ho?si=0X8pUCgU6XvBRB1T" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt; &lt;/p&gt;
&lt;h2 id="creating-nat-gateway-in-aws"&gt;&lt;strong&gt;Creating NAT Gateway in AWS&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Before we dive into the workflow, let’s first understand how a NAT Gateway is created.&lt;/p&gt;
&lt;p&gt;The most important thing to know is that a NAT Gateway must be created in a public subnet.&lt;/p&gt;
&lt;p&gt;A public subnet is simply a subnet that has an Internet Gateway (IGW) in its route table.&lt;/p&gt;
&lt;p&gt;&lt;img alt="NAT Gateway creation in public subnet" src="/images/post/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/96e4dac4-92f3-463c-975f-33507c6a6f9c.webp"&gt;&lt;/p&gt;
&lt;p&gt;Without a public subnet you cannot create a NAT Gateway because the NAT Gateway ultimately relies on the Internet Gateway to reach the internet.&lt;/p&gt;
&lt;p&gt;So, when you create a NAT Gateway in a public subnet, AWS automatically provisions an Elastic Network Interface (ENI) with both a private IP and a public IP.&lt;/p&gt;
&lt;p&gt;&lt;img alt="NAT Gateway with private and public IP configuration" src="/images/post/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/bdb90409-7b8d-4cf2-9a8a-d0290039c853.webp"&gt;&lt;/p&gt;
&lt;p&gt;The private IP comes from the CIDR range of the public subnet you selected. This is very similar to how an EC2 instance receive IP address.&lt;/p&gt;
&lt;p&gt;Once the NAT Gateway is created, it can be linked to a route table.&lt;/p&gt;
&lt;p&gt;Any subnet that uses this route table will function as a private subnet, because its traffic will be routed through the NAT Gateway.&lt;/p&gt;
&lt;div data-node-type=callout&gt;
&lt;div data-node-type=callout-emoji&gt;💡&lt;/div&gt;
&lt;div data-node-type=callout-text&gt;&lt;strong&gt;Interested in optimizing AWS costs?&lt;/strong&gt; &lt;a target=_self rel=noopener noreferrer nofollow href=https://cloudwithalon.com/understanding-aws-data-transfer-costs style=pointer-events: none&gt;This article breaks down AWS data transfer pricing.&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id="traffic-flow-from-nat-gateway-to-the-internet"&gt;&lt;strong&gt;Traffic Flow from NAT Gateway to the Internet&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Now let’s understand how traffic flows from an EC2 instance in a private subnet to the internet using the figure below.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Traffic flow from EC2 instance to internet via NAT Gateway" src="/images/post/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/fff53e57-546a-42a4-bc8f-d83fc10ddf96.webp"&gt;&lt;/p&gt;
&lt;p&gt;Suppose a private EC2 instance wants to reach &lt;code&gt;google.com&lt;/code&gt;. The traffic first leaves the EC2, but it can only do so if the Security Group attached to the instance allows outbound traffic.&lt;/p&gt;
&lt;p&gt;After passing through the Security Group, the traffic must also pass through the private subnet’s Network Access Control List (NACL). Just like Security Groups, the NACL must allow outbound traffic to &lt;code&gt;0.0.0.0/0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Since google.com is outside the VPC, the instance uses the private subnet’s route table to determine the path. To reach the internet, the route must send traffic to &lt;code&gt;0.0.0.0/0&lt;/code&gt; via the NAT Gateway.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Private subnet route table configuration" src="/images/post/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/b3f7f03f-48fa-4d67-b896-81a5c7279d00.webp"&gt;&lt;/p&gt;
&lt;p&gt;Once these checks are satisfied, the traffic reaches the NAT Gateway.&lt;/p&gt;
&lt;p&gt;The NAT Gateway translates the private IP of the EC2 instance into its own public IP, hiding the original private address.&lt;/p&gt;
&lt;p&gt;At this point, the traffic moves toward the internet. But the NAT Gateway itself resides in a public subnet, so the request must also pass through the public subnet’s NACL and route table, which must have a route 0.0.0.0/0 → Internet Gateway.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Public subnet route table with Internet Gateway" src="/images/post/how-ec2-instance-in-private-subnet-connects-to-the-internet-in-aws/0a9c83ef-fbb5-48de-9e0b-4d744ed447c7.webp"&gt;&lt;/p&gt;
&lt;p&gt;Only after passing these checks, the request reach the Internet Gateway and go out to the internet.&lt;/p&gt;
&lt;p&gt;📝 &lt;strong&gt;Key point:&lt;/strong&gt; The NAT Gateway depends on the public subnet’s NACL and route table.&lt;/p&gt;
&lt;p&gt;Any changes to these configurations can break internet access not only for resources in the public subnet but also for all private subnets relying on the NAT Gateway.&lt;/p&gt;
&lt;p&gt;I hope this gives you a clear understanding of how traffic flows from a NAT Gateway to the internet.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>AWS Spot Instances: Maximize Savings, Minimize Interruptions</title><link href="https://cloudwithalon.com/writing/aws-spot-instances-maximize-savings-minimize-interruptions/" rel="alternate"/><published>2025-09-04T06:45:00+00:00</published><updated>2025-09-04T06:45:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-09-04:/writing/aws-spot-instances-maximize-savings-minimize-interruptions/</id><summary type="html">&lt;p&gt;Learn the truth about AWS Spot Instances. Discover how pricing works, strategies to maximize savings, and tips to minimize interruptions&lt;/p&gt;</summary><content type="html">&lt;p&gt;AWS claims that Spot Instances can save you up to 90% compared to On-Demand pricing.&lt;/p&gt;
&lt;p&gt;But here’s the real question:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Do you always save 90% with Spot Instances?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not quite. That 90% is the maximum possible discount and not a guaranteed discount.&lt;/p&gt;
&lt;p&gt;In reality, most users save around 50% to 70%, and only a few manage to reach 80% or more. However, with a solid understanding of how Spot Instances work and the right strategies in place, you can get much closer to that 90% mark.&lt;/p&gt;
&lt;p&gt;In this post, we’ll explore:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;What Spot Instances are&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How Spot pricing works and ways to maximize savings&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Strategies to minimize interruptions&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="what-are-spot-instances"&gt;What are Spot Instances?&lt;/h2&gt;
&lt;p&gt;AWS has a large pool of servers for its customers. When demand is low, some of these servers remain unused. These spare servers are offered as AWS Spot Instances. Instead of leaving them idle, AWS makes them available at a much lower price, up to 90% cheaper than On-Demand.&lt;/p&gt;
&lt;p&gt;There’s no difference in how they run. A Spot Instance is the same EC2 instance you’d get with On-Demand.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The only difference is:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If AWS needs that capacity back when demand rises, your Spot Instance gets interrupted and the capacity reassigned to customers paying the regular price.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Then what happens to your EC2 instance?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;By default, AWS will terminate your Spot Instance during an interruption, which means any data stored on the instance will be lost. To control this behavior, you can configure the interruption action to either &lt;strong&gt;stop, hibernate, or terminate&lt;/strong&gt; the instance based on your needs.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/interruption-behavior.html" rel="nofollow" target="_blank"&gt;Learn more about Spot Instance interruption behavior.&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="truth-about-up-to-90-savings"&gt;Truth About “Up to 90%” Savings&lt;/h2&gt;
&lt;p&gt;AWS advertises Spot Instances as &lt;strong&gt;“up to 90% cheaper”&lt;/strong&gt; but that doesn’t mean you will get 90% off on every Spot Instance you launch.&lt;/p&gt;
&lt;p&gt;Spot Instance prices aren’t fixed. They change frequently based on region, instance type, and demand.&lt;/p&gt;
&lt;p&gt;Before launching a spot instance, you can check its potential savings by viewing its price history in the AWS Console:&lt;br&gt;
EC2 &amp;gt; Spot Requests &amp;gt; Pricing History&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;us-east-1a&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;img alt="AWS Spot Instance pricing history for us-east-1a" src="/images/post/aws-spot-instances-maximize-savings-minimize-interruptions/5da53dcb-1b7b-40d3-bc98-4c86711f1908.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;us-east-1d&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;img alt="AWS Spot Instance pricing history for us-east-1d" src="/images/post/aws-spot-instances-maximize-savings-minimize-interruptions/9dcd8b35-a58e-412f-9ddb-8991b558599d.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This shows how Spot prices have changed over the last 3 months, updating every minute. Each instance type and Availability Zone (AZ) may have different prices.&lt;/p&gt;
&lt;p&gt;For example, &lt;strong&gt;us-east-1a vs us-east-1d&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;c5d.18xlarge&lt;/code&gt;: ~57% vs ~64% savings&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;c6gd.2xlarge&lt;/code&gt;: ~83.6% vs ~85% savings&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;m8i.metal-96xlarge&lt;/code&gt;: ~89.99% vs ~89.98% savings&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These differences are driven by supply and demand. You always pay the &lt;em&gt;current&lt;/em&gt; market price for that capacity.&lt;/p&gt;
&lt;p&gt;Also note: Spot pricing today is more predictable than in the past. Before 2017, AWS used a bidding system where prices spiked rapidly, but now Spot follows a smoother demand-based model.&lt;/p&gt;
&lt;p&gt;To get more value out of Spot Instances, try these approaches:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use newer instance generations&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Newer families often have more unused capacity, which translates into higher discounts and fewer interruptions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Spread across multiple Availability Zones (AZs)&lt;/strong&gt;&lt;br&gt;
    The same instance type can have different Spot prices depending on the AZ. By running across multiple zones, you increase your chances of finding cheaper pools.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Setting maximum price&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;While setting maximum price when launching a Spot Instance can help control costs. However, it’s no longer recommended, as it often increases the chance of interruptions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Price capacity optimized allocation strategies&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can choose the price capacity optimized strategy when running a fleet of Spot Instances. AWS automatically identifies instance pools with the highest availability (i.e., lowest chance of interruption) and, among those, selects the one with the lowest price.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="strategies-to-minimize-interruptions"&gt;Strategies to Minimize Interruptions&lt;/h2&gt;
&lt;p&gt;Spot Instances should only be used for applications that can tolerate faults. Even then, frequent interruptions can impact your business.&lt;/p&gt;
&lt;p&gt;Since interruptions occur when AWS needs capacity back, here are strategies to reduce their impact:&lt;/p&gt;
&lt;h3 id="aws-spot-instance-advisor"&gt;AWS Spot Instance Advisor&lt;/h3&gt;
&lt;p&gt;The &lt;a href="https://aws.amazon.com/ec2/spot/instance-advisor/" rel="nofollow" target="_blank"&gt;Spot Instance Advisor&lt;/a&gt; provides the frequency of interruptions for different instance types. A higher frequency indicates a higher chance that your instance will be interrupted, helping you choose instances with fewer disruptions.&lt;/p&gt;
&lt;p&gt;Recommended to use instance type with &amp;lt;5% frequency of interruption.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Spot Instance Advisor interruption frequency chart" src="/images/post/aws-spot-instances-maximize-savings-minimize-interruptions/67dc06b0-f0e8-4711-b340-b48f723bd419.webp"&gt;&lt;/p&gt;
&lt;h3 id="capacity-optimized-allocation-strategy"&gt;Capacity-Optimized Allocation Strategy&lt;/h3&gt;
&lt;p&gt;It's best to use Spot Instances with an Auto Scaling Group or EC2 Fleet. This helps manage interruptions more effectively and keeps your applications running smoothly.&lt;/p&gt;
&lt;p&gt;To improve reliability even further, you can use the Capacity-Optimized Allocation Strategy.&lt;/p&gt;
&lt;p&gt;This AWS feature selects Spot Instance pools that are less likely to be interrupted, giving you better stability.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/blogs/compute/introducing-the-capacity-optimized-allocation-strategy-for-amazon-ec2-spot-instances/" rel="nofollow" target="_blank"&gt;Learn more about Capacity-Optimized Allocation Strategy.&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="spot-instance-interruption-notices"&gt;Spot Instance interruption notices&lt;/h3&gt;
&lt;p&gt;AWS provides a 2-minute interruption notice before reclaiming capacity. You can capture this signal from instance metadata or EventBridge to gracefully stop workloads, checkpoint data, or shift traffic.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-instance-termination-notices.html" rel="nofollow" target="_blank"&gt;Learn more&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With Spot Instances, cost savings and interruption risk are a tradeoff. It is not always easy to achieve both at the same time. The key is to use the right strategies: monitor pricing trends, choose low interruption pools, diversify across instance types and Availability Zones, and design workloads that can tolerate failures.&lt;/p&gt;
&lt;p&gt;When applied correctly, Spot Instances can deliver near maximum savings while still keeping your applications reliable.&lt;/p&gt;
&lt;p&gt;I hope this page has made you clear about AWS Spot Instances.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;- Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>AWS Free Tier (2025): Whats Free &amp; For How Long</title><link href="https://cloudwithalon.com/writing/aws-free-tier-2025-whats-free-and-for-how-long/" rel="alternate"/><published>2025-08-03T00:00:00+00:00</published><updated>2025-08-03T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-08-03:/writing/aws-free-tier-2025-whats-free-and-for-how-long/</id><summary type="html">&lt;p&gt;Learn how AWS Free Tier really works, what's included, how long it lasts, and how to avoid unexpected charges. Perfect for beginners, students, and cost-conscious users&lt;/p&gt;</summary><content type="html">&lt;p&gt;You saw “Free Tier” and spun up a few services. It looked safe and simple.&lt;/p&gt;
&lt;p&gt;But at the end of the month?&lt;/p&gt;
&lt;p&gt;Surprise charges. Confusion. Frustration.&lt;/p&gt;
&lt;p&gt;&lt;blockquote class="twitter-tweet" data-theme="light" data-dnt="true" align="center"&gt;
    &lt;a href="https://twitter.com/alonshrestha/status/1854506750415921294?t=tDmv0KYKmC5O2h-L-l-FUA&amp;amp;s=19"&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;script async src="https://platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt; &lt;/p&gt;
&lt;p&gt;That’s when many realize: maybe AWS Free Tier is just a myth after all.&lt;/p&gt;
&lt;p&gt;But here's the truth, AWS Free Tier isn’t a myth. It has limits, and those limits are often misunderstood.&lt;/p&gt;
&lt;p&gt;Some are time-based and some are usage-based.&lt;/p&gt;
&lt;p&gt;This guide clears up that confusion, so you know exactly what to expect before you get billed.&lt;/p&gt;
&lt;p&gt;Recently, AWS upgraded its Free Tier offerings, introducing changes that took effect after July 15, 2025.&lt;/p&gt;
&lt;p&gt;In this guide, we’ll cover both the previous Free Tier plan (before July 15) and the updated one, so you have a full picture.&lt;/p&gt;
&lt;h2 id="free-tier-plan-before-july-15-2025"&gt;Free Tier Plan &lt;strong&gt;Before&lt;/strong&gt; July 15, 2025&lt;/h2&gt;
&lt;p&gt;&lt;img alt="AWS Free Tier services overview" src="/images/post/aws-free-tier-2025-whats-free-and-for-how-long/539f5eab-0ad9-422a-a40d-5c8d562f26cf.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This image was generated using Google AI Studio.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If your AWS account was created before July 15, 2025, AWS offers three types of Free Tier plans:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;12 Months Free&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Always Free&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Short-Term Trials&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="12-months-free"&gt;12 Months Free&lt;/h3&gt;
&lt;p&gt;This plan gives you access to some of AWS’s most popular services like EC2, S3 for free for the first 12 months after you create your account. After that, standard pay-as-you-go pricing applies.&lt;/p&gt;
&lt;p&gt;Even during the free 12 months, there are limits, and if you go beyond them, you’ll be billed.&lt;/p&gt;
&lt;p&gt;Take EC2, for example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;AWS lets you run a t2.micro or t3.micro EC2 instance for free, up to 750 hours per month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can launch multiple instances, but their total combined usage must not exceed 750 hours in a month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For example, if you run 2 instances, you can only use each one for up to 375 hours (750 ÷ 2) to stay within the free limit.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Also, launching EC2 instance requires:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Amazon Machine Image (AMI): If you choose a paid AMI from the AWS Marketplace, you will be charged for it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;EBS volume. The Free Tier gives you 30 GB of EBS per month. If you exceed that, you will be billed for the extra usage.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After 12 months, the Free Tier ends automatically and your account switches to standard pay-as-you-go billing, even though you may still see the Free Tier label when selecting a t2.micro instance.&lt;/p&gt;
&lt;h3 id="always-free"&gt;Always Free&lt;/h3&gt;
&lt;p&gt;This plan includes services that are free forever, not just for the first 12 months.&lt;/p&gt;
&lt;p&gt;Examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;AWS Lambda: 400,000 GB-seconds of compute time per month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Amazon SQS: 1 million requests per month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;And other more services.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These limits reset at the beginning of each month.&lt;/p&gt;
&lt;p&gt;If you exceed these limits, you'll be charged according to standard pay-as-you-go pricing.&lt;/p&gt;
&lt;h3 id="short-term-trial"&gt;Short Term - Trial&lt;/h3&gt;
&lt;p&gt;This plan is different from the 12 Months Free and Always Free tiers. It usually applies to newly launched services that AWS wants customers to try. These offers are time-bound trials and only start after you activate the service.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Amazon Inspector gives you a 15-days free trial.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After you enable it, the trial starts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once the trial ends, you’ll be charged based on standard pricing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;AWS doesn’t notify you when a trial period ends. To avoid unexpected charges, make sure to stop or terminate any trial-based resources before the period expires.&lt;/p&gt;
&lt;h2 id="free-tier-plan-after-july-15-2025"&gt;Free Tier Plan After July 15, 2025&lt;/h2&gt;
&lt;p&gt;&lt;img alt="AWS Free Tier billing alerts configuration" src="/images/post/aws-free-tier-2025-whats-free-and-for-how-long/8ae0edc1-8c0e-4617-97ac-49da61031389.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This image was generated using Google AI Studio.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;After July 15, 2025, AWS updated its Free Tier offerings. While the Always Free and Short-Term Trial plans remain the same, the previous 12 Months Free plan has been replaced with two new categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Free Plan (New)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Paid Plan (New)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Always Free&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Short-Term Trials&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="free-plan-new"&gt;Free Plan (New)&lt;/h3&gt;
&lt;p&gt;This plan replaces the previous 12 Months Free plan. Instead of giving you monthly usage limits, AWS now provides $200 in free credits.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You get $100 in credits when you create your account.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can earn another $100 by exploring more AWS services.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This plan supports more features but has limited services available. For example, you can launch EC2 instances with types like T3.micro, T3.small, T4g.micro, T4g.small, C7i-flex.large, and M7i-flex.large.&lt;/p&gt;
&lt;p&gt;Even though you're required to enter your payment details when creating the account, you won’t be charged even if you exceed your credits. Instead, AWS will suspend your account while still retaining your data, giving you the option to upgrade to a paid plan later.&lt;/p&gt;
&lt;p&gt;The plan is valid for 6 months or until you use up the $200, whichever comes first. It's ideal for students, startups, and new users who want to try AWS without risk.&lt;/p&gt;
&lt;p&gt;You can switch to the Paid Plan anytime, either after your credits expire or earlier if you're ready to build real production workloads.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;→ Make sure to read the&lt;/em&gt; &lt;a href="https://aws.amazon.com/free/free-tier-faqs/#topic-0" rel="nofollow" target="_blank"&gt;&lt;em&gt;Free Tier FAQ&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. It answers most common questions clearly.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="paid-plan-new"&gt;Paid Plan (New)&lt;/h3&gt;
&lt;p&gt;This plan is similar to the Free Plan but is designed for real production workloads.&lt;/p&gt;
&lt;p&gt;You’ll still receive $200 in free credits and your account will not be suspended when the credits run out or after 6 months.&lt;/p&gt;
&lt;p&gt;Instead, once you exceed the $200 credit limit, you’ll start receiving bills based on standard AWS pricing.&lt;/p&gt;
&lt;p&gt;Think of this as a regular AWS account where you can access all AWS services just like any other paying customer.&lt;/p&gt;
&lt;div data-node-type=callout&gt;
&lt;div data-node-type=callout-emoji&gt;💰&lt;/div&gt;
&lt;div data-node-type=callout-text&gt;Looking to cut AWS costs? Don’t miss this guide: [&lt;a target=_self rel=noopener noreferrer nofollow href=https://cloudwithalon.com/15-aws-native-tools-to-master-cost-optimization style=pointer-events: none&gt;15 AWS Native Tools to Master Cost Optimization&lt;/a&gt;].&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id="ways-to-find-free-tier-plan-for-aws-services"&gt;Ways to Find Free Tier Plan for AWS Services&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h3 id="official-aws-free-tier-page"&gt;Official AWS Free Tier Page&lt;/h3&gt;
&lt;p&gt;Start by visiting the &lt;a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/tracking-free-tier-usage.html#free-tier-services" rel="nofollow" target="_blank"&gt;official AWS Free Tier page&lt;/a&gt;. It gives you a comprehensive overview of all services available under Free Tier, categorized into Always Free, 12-Month Free, and Trials.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3 id="service-specific-documentation"&gt;Service-Specific Documentation&lt;/h3&gt;
&lt;p&gt;Check the pricing section in each service’s documentation. It clearly outlines both standard pricing and Free Tier eligibility, if available.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3 id="aws-console-resource-launch"&gt;AWS Console Resource Launch&lt;/h3&gt;
&lt;p&gt;When creating resources in your AWS account, some services display Free Tier eligibility before launching. This is useful for verifying if the service you’re about to use is covered.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Free Tier usage tracking dashboard" src="/images/post/aws-free-tier-2025-whats-free-and-for-how-long/e30099f5-7fe0-48d4-8e1e-d6653c86cc06.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3 id="free-tier-usage-dashboard"&gt;Free Tier Usage Dashboard&lt;/h3&gt;
&lt;p&gt;Inside your AWS account, go to Billing and Cost Management → Free Tier. This dashboard shows how much Free Tier usage you've consumed per service, including remaining quotas.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Free Tier cost monitoring interface" src="/images/post/aws-free-tier-2025-whats-free-and-for-how-long/4d805689-aa7f-429c-b82c-f79d2c42e4ca.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding how AWS Free Tier works helps you make the most, even for production use. In the end, every business aims to &lt;a href="https://cloudwithalon.com/what-is-finops-and-why-it-matters-in-cloud-era"&gt;reduce cloud costs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For beginners, the Free Tier is a great way to learn AWS. I have been there myself, running small projects using EC2, S3, and Lambda to build real-world applications without spending a single penny.&lt;/p&gt;
&lt;p&gt;I hope this clears up your confusion about the AWS Free Tier.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;- Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>15 AWS Native Tools to Master Cost Optimization</title><link href="https://cloudwithalon.com/writing/15-aws-native-tools-to-master-cost-optimization/" rel="alternate"/><published>2025-07-20T15:35:00+00:00</published><updated>2025-07-20T15:35:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-07-20:/writing/15-aws-native-tools-to-master-cost-optimization/</id><summary type="html">&lt;p&gt;15 essential AWS tools to monitor, optimize, and control cloud costs. Ideal for FinOps beginners and small teams seeking cost visibility and governance&lt;/p&gt;</summary><content type="html">&lt;p&gt;AWS often feels expensive, and it usually is if you don’t know what you're spending on.&lt;/p&gt;
&lt;p&gt;But the top companies like Netflix and Airbnb have shown that with the right visibility and practices, it’s possible to achieve the best ROI on cloud spending.&lt;/p&gt;
&lt;p&gt;This is possible if you have dedicated FinOps teams focused on monitoring and optimizing costs using advanced tools and strategies.&lt;/p&gt;
&lt;p&gt;However, for most organizations, cloud costs are complex, and they may not have the expertise or budget to use advanced tools.&lt;/p&gt;
&lt;p&gt;This post focuses on native AWS tools that can help you gain visibility, optimize, and set controls to manage your cloud spend effectively.&lt;/p&gt;
&lt;p&gt;I’ll list and briefly explain them, categorizing them according to the FinOps phases: Inform, Optimize, and Operate, for better clarity.&lt;/p&gt;
&lt;p&gt;If you're not familiar with the FinOps lifecycle, I recommend reading following first before moving on.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;→&lt;/em&gt; &lt;a href="https://cloudwithalon.com/apply-finops-lifecycle-in-aws-using-built-in-tools"&gt;&lt;em&gt;Understanding FinOps Lifecycle and Implementing it in AWS&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Cost Explorer interface and features" src="/images/post/15-aws-native-tools-to-master-cost-optimization/af1f1a1b-d72f-465e-adb0-0c2134532373.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This image was generated using Google AI Studio.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class="video-container"&gt;
    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/EqgL7GqD_XY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt;&lt;/p&gt;
&lt;h2 id="phase-inform"&gt;Phase: Inform&lt;/h2&gt;
&lt;p&gt;In this phase, we explore AWS tools that offer cost visibility, helping us understand where the spending is happening and how much is being spent.&lt;/p&gt;
&lt;h3 id="cost-explorer"&gt;Cost Explorer&lt;/h3&gt;
&lt;p&gt;&lt;img alt="AWS Budgets alert configuration" src="/images/post/15-aws-native-tools-to-master-cost-optimization/3aef1664-9dfe-417f-a6ee-43544f8e6b68.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/aws-cost-management/aws-cost-explorer/" rel="nofollow" target="_blank"&gt;Cost Explorer&lt;/a&gt; helps you visualize your AWS spending with easy-to-read graphs.&lt;/p&gt;
&lt;p&gt;You can see how much you’re spending, which services cost the most, and spot daily or monthly trends.&lt;/p&gt;
&lt;p&gt;The tool is free, updates daily, and allows you to export data as CSV for further analysis&lt;/p&gt;
&lt;p&gt;Where to find it:&lt;/p&gt;
&lt;p&gt;AWS Console → Billing and Cost Management → Cost Explorer&lt;/p&gt;
&lt;h3 id="cost-and-usage-report-cur-20"&gt;Cost and Usage Report (CUR 2.0)&lt;/h3&gt;
&lt;p&gt;This tool provides all the detailed billing and usage reports you'll ever need.&lt;/p&gt;
&lt;p&gt;The reports are comprehensive and delivered in CSV format, automatically saved to your S3 bucket.&lt;/p&gt;
&lt;p&gt;A key feature is its ability to breaks down costs by time (hourly, daily, monthly), service, resource, and custom tags, giving you full visibility into your AWS usage.&lt;/p&gt;
&lt;p&gt;To access this report, you’ll need to create a job.&lt;/p&gt;
&lt;p&gt;How to create it:&lt;/p&gt;
&lt;p&gt;AWS Console → Billing and Cost Management → Data Exports → Create export&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Trusted Advisor cost optimization recommendations" src="/images/post/15-aws-native-tools-to-master-cost-optimization/b02ef6b1-b854-4862-89ad-21889579a72a.webp"&gt;&lt;/p&gt;
&lt;p&gt;Once the report is available, you can analyze it more effectively using tools like Amazon QuickSight, or query it with Athena or Redshift for deeper insights.&lt;/p&gt;
&lt;h3 id="cost-categories"&gt;Cost Categories&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/aws-cost-management/aws-cost-categories/" rel="nofollow" target="_blank"&gt;AWS Cost Categories&lt;/a&gt; help you organize your cloud spend by grouping costs based on accounts, services, tags, regions, charge types, and more.&lt;/p&gt;
&lt;p&gt;You can define custom rules to group expenses by business units, projects (like tag &lt;code&gt;Project = ProjectA&lt;/code&gt;), or services (like EC2 and S3). This gives you a clear view of where your costs are coming from.&lt;/p&gt;
&lt;p&gt;How to access:&lt;/p&gt;
&lt;p&gt;AWS Console → Billing and Cost Management → Cost Categories&lt;/p&gt;
&lt;h3 id="cost-allocation-tags"&gt;Cost Allocation Tags&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html" rel="nofollow" target="_blank"&gt;Cost Allocation Tags&lt;/a&gt; help you track and organize AWS costs by assigning labels to your resources(EC2, Snapshot, RDS etc).&lt;/p&gt;
&lt;p&gt;These tags can be custom labels that reflect business details such as environment, owner, or project.&lt;/p&gt;
&lt;p&gt;There are two types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;User-defined tags (e.g., &lt;code&gt;Environment=PROD&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AWS-generated tags (like &lt;code&gt;aws:createdBy&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To use these tags in billing and reports, you must activate them so they appear in tools like Cost Explorer or AWS Budgets.&lt;/p&gt;
&lt;p&gt;AWS Console → Billing and Cost Management console → Cost Allocation Tags.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Tag your resources with &lt;code&gt;Environment=DEV&lt;/code&gt;, &lt;code&gt;STAGE&lt;/code&gt;, or &lt;code&gt;PROD&lt;/code&gt;. Once activated, you can filter and analyze costs by environment making it easier to allocate costs to projects or teams and improve visibility.&lt;/p&gt;
&lt;h3 id="aws-budget"&gt;AWS Budget&lt;/h3&gt;
&lt;p&gt;With &lt;a href="https://aws.amazon.com/aws-cost-management/aws-budgets/" rel="nofollow" target="_blank"&gt;AWS Budgets&lt;/a&gt;, you can set custom budget limits for cost utilization. When thresholds are exceeded, you get alerts, and optionally, you can automate actions using Lambda.&lt;/p&gt;
&lt;p&gt;AWS Console → Billing and Cost Management → Budgets&lt;/p&gt;
&lt;p&gt;You can start with pre-built templates or create custom budgets based on your needs.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Cost Anomaly Detection dashboard" src="/images/post/15-aws-native-tools-to-master-cost-optimization/d6ed6503-fd08-476b-877d-4d53f4ab0768.webp"&gt;&lt;/p&gt;
&lt;h4 id="common-use-cases"&gt;Common Use Cases:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Alert when monthly AWS bill exceeds $10,000 (trigger at 80%, 100%, or forecasted).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Notify if EC2 instance hours exceed $1,000 per month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Track cost for resources tagged &lt;code&gt;Environment:Dev&lt;/code&gt;, and alert if over $5,000.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enforce action: Deny &lt;code&gt;ec2:RunInstances&lt;/code&gt; using an IAM policy via SNS + Lambda if cost exceeds $30,000.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="aws-cost-anomaly-detection"&gt;AWS Cost Anomaly Detection&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/aws-cost-management/aws-cost-anomaly-detection/" rel="nofollow" target="_blank"&gt;AWS Cost Anomaly Detection&lt;/a&gt; uses machine learning to automatically detect unusual spikes in your AWS spending, helping you catch unexpected cost increases early.&lt;/p&gt;
&lt;p&gt;When an anomaly is detected, you receive alerts, along with insights into what caused it, where it occurred, and why.&lt;/p&gt;
&lt;p&gt;The system checks for anomalies three times daily, and detection/reporting may take up to 24 hours.&lt;/p&gt;
&lt;h2 id="phase-optimize"&gt;Phase: Optimize&lt;/h2&gt;
&lt;p&gt;In this phase, we’ll explore AWS tools that help optimize compute and storage resources.&lt;/p&gt;
&lt;p&gt;Since optimization is the first step toward achieving cost savings in FinOps, these tools play a critical role in driving meaningful changes.&lt;/p&gt;
&lt;h3 id="saving-planssps-and-reserved-instancesris"&gt;Saving Plans(SPs) and Reserved Instances(RIs)&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/savingsplans/" rel="nofollow" target="_blank"&gt;Savings Plans&lt;/a&gt; offer up to 72% savings on compute services like EC2, Fargate, and Lambda.&lt;/p&gt;
&lt;p&gt;You agree to spend a fixed amount per hour (for example, $75/hour) for 1 or 3 years. In return, AWS gives you lower prices.&lt;/p&gt;
&lt;p&gt;It is flexible because you do not need to commit to a specific instance type, operating system, or region.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;If you usually run EC2 instances that cost $75/hour at On-Demand rates, you can commit to that same $75/hour spend through a Savings Plan. AWS will then charge you less for that usage, often around 30 to 70 percent cheaper, depending on the plan and term.&lt;/p&gt;
&lt;p&gt;But once you commit, you must pay that amount whether you use it fully or not.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/ec2/pricing/reserved-instances/" rel="nofollow" target="_blank"&gt;Reserved Instances&lt;/a&gt; also provide long-term savings similar to Savings Plans, but with less flexibility. You must commit to specific instance attributes (type, OS, region, tenancy).&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;If you run 3 EC2 t3.large instances 24/7 in one region, On-Demand costs about $7,200 per year.&lt;/p&gt;
&lt;p&gt;With Reserved Instances, you commit to those instances for 1 year and pay around $1,800 to $3,600, saving up to 75%.&lt;/p&gt;
&lt;p&gt;But you must stick to the same instance type, region, and OS, and pay whether you use them or not.&lt;/p&gt;
&lt;p&gt;You can buy RI for EC2 instances, RDS, ElastiCache, Redshift and OpenSearch.&lt;/p&gt;
&lt;p&gt;AWS Console → Billing and Cost Management&lt;/p&gt;
&lt;h3 id="spot-instances"&gt;Spot Instances&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html" rel="nofollow" target="_blank"&gt;Spot Instances&lt;/a&gt; let you use EC2 compute capacity at up to 90% discount compared to On-Demand prices.&lt;/p&gt;
&lt;p&gt;This discount is possible because you're using AWS’s unused EC2 capacity.&lt;/p&gt;
&lt;p&gt;However, Spot Instances can be interrupted at any time when AWS needs the capacity back. That's why Spot Instances are ideal for fault-tolerant and flexible workloads.&lt;/p&gt;
&lt;h3 id="aws-ec2-auto-scaling-groups"&gt;AWS EC2 Auto Scaling Groups&lt;/h3&gt;
&lt;p&gt;While &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html" rel="nofollow" target="_blank"&gt;EC2 Auto Scaling&lt;/a&gt; might not appear to be a cost-saving feature at first, it can actually help reduce costs by automatically adjusting your EC2 capacity based on real-time demand.&lt;/p&gt;
&lt;p&gt;You define minimum, desired, and maximum instance counts to match your workload.&lt;/p&gt;
&lt;p&gt;However, poor configuration can lead to over-scaling (higher costs) or under-scaling (performance issues).&lt;/p&gt;
&lt;p&gt;Properly tuned, Auto Scaling ensures you only pay for the compute you actually need avoiding over-provisioning.&lt;/p&gt;
&lt;p&gt;AWS Console → EC2 → Auto Scaling groups&lt;/p&gt;
&lt;h3 id="aws-compute-optimizer-and-trusted-advisor"&gt;AWS Compute Optimizer and Trusted Advisor&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/compute-optimizer/" rel="nofollow" target="_blank"&gt;AWS Compute Optimizer&lt;/a&gt; helps you right-size compute resources like EC2, Auto Scaling groups, EBS, Lambda, RDS, and ECS on Fargate by analyzing historical usage.&lt;/p&gt;
&lt;p&gt;It provides cost and performance recommendations, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Flagging EC2 instances as underutilized, over utilized, or optimized.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Suggesting EBS volume changes in IOPS, throughput, type or storage size.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;AWS Console → AWS Compute Optimizer&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Compute Optimizer recommendations" src="/images/post/15-aws-native-tools-to-master-cost-optimization/c1974089-4f90-4dd4-a702-e883369119f3.webp"&gt;&lt;/p&gt;
&lt;p&gt;AWS Trusted Advisor offers a broader view. It audits your AWS environment for cost, security, performance, fault tolerance, and service limits.&lt;/p&gt;
&lt;p&gt;It helps reduce costs by identifying idle, unassociated, or unused resources that can be safely removed or downsized.&lt;/p&gt;
&lt;p&gt;AWS Console → AWS Trusted Advisor&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Resource Groups and Tag Editor" src="/images/post/15-aws-native-tools-to-master-cost-optimization/b237802a-700b-4484-a220-b1f662dd138b.webp"&gt;&lt;/p&gt;
&lt;h3 id="aws-cost-optimization-hub"&gt;AWS Cost Optimization Hub&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/aws-cost-management/cost-optimization-hub/" rel="nofollow" target="_blank"&gt;AWS Cost Optimization Hub&lt;/a&gt; is a new tool that acts as a centralized dashboard that helps you discover and manage cost-saving opportunities across your entire AWS organization.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Systems Manager Patch Manager" src="/images/post/15-aws-native-tools-to-master-cost-optimization/51e3634d-40c8-4dcb-aa67-383f17c60102.webp"&gt;&lt;/p&gt;
&lt;p&gt;It provides recommendations on cost optimization, such as EC2 rightsizing, Graviton migration, Idle resource cleanup, RDS and Aurora optimization, Reserved Instances and Savings Plan suggestions and more.&lt;/p&gt;
&lt;p&gt;It quickly answers key questions like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;How much can I save by rightsizing resources?&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Which account has the most unused or costly resources?&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;What are the top actions I should take right now to reduce costs?&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;AWS Console → Billing and Cost Management → AWS Cost Optimization Hub&lt;/p&gt;
&lt;h3 id="s3-storage-lens"&gt;S3 Storage Lens&lt;/h3&gt;
&lt;p&gt;It’s a central dashboard that gives you full visibility into your S3 usage and activity across all AWS accounts.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS CloudFormation stack management" src="/images/post/15-aws-native-tools-to-master-cost-optimization/295613f5-f614-4099-8894-c797f9f81bce.webp"&gt;&lt;/p&gt;
&lt;p&gt;With its built-in metrics, you can easily spot issues like incomplete multipart uploads, too many noncurrent versions, missing lifecycle rules, and fast-growing buckets all of which help you save money on S3.&lt;/p&gt;
&lt;h2 id="phase-operate"&gt;Phase: Operate&lt;/h2&gt;
&lt;p&gt;In this phase, we focus on tools and services that help control cloud costs through governance and policy enforcement.&lt;/p&gt;
&lt;h3 id="aws-organization"&gt;AWS Organization&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html" rel="nofollow" target="_blank"&gt;AWS Organizations&lt;/a&gt; is a powerful tool for managing multiple AWS accounts. It lets you consolidate billing across all accounts into a single central account, making it easier to track and pay for usage. You can also apply policies, automate tasks, and manage access centrally across all linked accounts.&lt;/p&gt;
&lt;h3 id="service-control-policies-scps"&gt;&lt;strong&gt;Service Control Policies (SCPs)&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;This tool lets you create rules that apply across all AWS accounts in your organization. These rules help you control what services and actions users can use.&lt;/p&gt;
&lt;p&gt;For cost optimization, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Block expensive instance types like &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt;, or &lt;code&gt;x&lt;/code&gt; families.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prevent users from creating resources in unwanted regions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Allow only Spot Instances in development accounts.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SCPs work like IAM policies, so you can write custom rules to fit your needs.&lt;/p&gt;
&lt;h3 id="tag-policies"&gt;&lt;strong&gt;Tag Policies&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_tag-policies.html" rel="nofollow" target="_blank"&gt;Tag Policies&lt;/a&gt; enforce consistent tagging across AWS resources by requiring specific tags during resource creation. This reduces tag clutter, improves cost visibility, and enables accurate cost allocation and tracking.&lt;/p&gt;
&lt;p&gt;By leveraging these AWS-native tools, even small teams can gain control over their cloud spend.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The first rule is to start simple:&lt;/strong&gt; set up budgets, apply tagging policies, and optimize low-hanging resources.&lt;/p&gt;
&lt;p&gt;There are other helpful tools such as the &lt;a href="https://cloudwithalon.com/aws-free-tier-2025-whats-free-and-for-how-long"&gt;AWS Free Tier&lt;/a&gt;, AWS Cost Calculator, CloudWatch and more, but I’ve kept things brief for now. I’ll cover those in a separate post.&lt;/p&gt;
&lt;p&gt;As we wrap up, I’d love to hear your thoughts or feedback.&lt;/p&gt;
&lt;p&gt;Thanks for reading!&lt;/p&gt;
&lt;p&gt;- Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Apply FinOps Lifecycle in AWS Using Built-in Tools</title><link href="https://cloudwithalon.com/writing/apply-finops-lifecycle-in-aws-using-built-in-tools/" rel="alternate"/><published>2025-07-01T00:00:00+00:00</published><updated>2025-07-01T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-07-01:/writing/apply-finops-lifecycle-in-aws-using-built-in-tools/</id><summary type="html">&lt;p&gt;Learn how to apply the FinOps lifecycle using AWS built-in tools and services. Discover how Inform, Optimize, and Operate phases align with AWS&lt;/p&gt;</summary><content type="html">&lt;p&gt;By now, you may already have some knowledge of &lt;strong&gt;FinOps&lt;/strong&gt;, or perhaps you’ve come across the term somewhere.&lt;/p&gt;
&lt;p&gt;If not, feel free to check out my post: &lt;a href="https://cloudwith.alon.com.np/what-is-finops-and-why-it-matters-in-cloud-era"&gt;&lt;strong&gt;What is FinOps and Why It Really Matters Today?&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now, coming back to this post.&lt;/p&gt;
&lt;p&gt;Progress in any area requires a repeatable process.&lt;/p&gt;
&lt;p&gt;Take growing a plant as an example:&lt;br&gt;
You plant the seed, water it, give it sunlight, and repeat the process. With consistent care, the plant grows over time.&lt;/p&gt;
&lt;p&gt;Similarly, FinOps is an ongoing journey, not a one-time fix. It evolves as your cloud usage and organization grow.&lt;/p&gt;
&lt;p&gt;To see real progress and grow the value of your business through cost optimization, you need to follow a consistent lifecycle.&lt;/p&gt;
&lt;h2 id="finops-framework"&gt;FinOps Framework&lt;/h2&gt;
&lt;p&gt;The FinOps Foundation defines its framework in &lt;a href="https://www.finops.org/framework/phases/" rel="nofollow" target="_blank"&gt;three phases&lt;/a&gt;: Inform, Optimize, and Operate. Each cycle builds momentum by enabling better decisions and greater efficiency.&lt;/p&gt;
&lt;p&gt;&lt;img alt="FinOps Phases" src="https://www.finops.org/wp-content/uploads/2024/03/Overview-Phases-1.91_1-Meta.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Image source: FinOps Foundation&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let’s break down in brief what each phase is all about.&lt;/p&gt;
&lt;h3 id="inform"&gt;Inform&lt;/h3&gt;
&lt;p&gt;The main goal of this phase is to understand your cloud costs.&lt;/p&gt;
&lt;p&gt;It's all about gathering information on what resources you have, how they're being used, who is using them, and how much they're costing, using the right tools and techniques.&lt;/p&gt;
&lt;p&gt;With this data, you gain clear visibility into your cloud spending and understand the business value of that spend. This helps you plan better for optimization, budgeting, and cost allocation.&lt;/p&gt;
&lt;h3 id="optimize"&gt;Optimize&lt;/h3&gt;
&lt;p&gt;Once you understand your cloud spending, this phase is about making improvements.&lt;/p&gt;
&lt;p&gt;Start by sharing cost reports with both technical and finance teams. Identify unused or underutilized resources, rightsize them, and explore pricing options such as commitment-based savings plans.&lt;/p&gt;
&lt;p&gt;If needed, consider re-architecting for long-term efficiency and value as well.&lt;/p&gt;
&lt;p&gt;Collaboration between engineering, finance, and business teams is key to success in this phase. Not just focusing on reducing costs but on maximizing the value of your cloud investment.&lt;/p&gt;
&lt;h3 id="operate"&gt;Operate&lt;/h3&gt;
&lt;p&gt;You have the data, and you've started optimizing. Now it's time to put these practices into daily operations.&lt;/p&gt;
&lt;p&gt;Establish policy rules and governance for cloud usage. Set up monitoring for resource usage and alerts for spending thresholds to ensure compliance.&lt;/p&gt;
&lt;p&gt;Educate teams and individuals about cloud cost ownership. Use insights from the &lt;strong&gt;Inform&lt;/strong&gt; phase and strategies from the &lt;strong&gt;Optimize&lt;/strong&gt; phase to create actionable guidelines.&lt;/p&gt;
&lt;p&gt;Most importantly, leverage automation to improve efficiency and consistency.&lt;/p&gt;
&lt;p&gt;These three phases are ongoing and repeat over time. As your organization grows, the process should evolve to drive continuous improvement and better outcomes.&lt;/p&gt;
&lt;h2 id="aws-cloud-financial-management-framework-cfm"&gt;AWS Cloud Financial Management Framework (CFM)&lt;/h2&gt;
&lt;p&gt;Similar to the FinOps framework, AWS has its own &lt;a href="https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/practice-cloud-financial-management.html" rel="nofollow" target="_blank"&gt;Cloud Financial Management (CFM) Framework&lt;/a&gt;, which includes four key pillars: See, Save, Plan, and Run.&lt;/p&gt;
&lt;p&gt;AWS CFM aligns with the core concepts of FinOps but is designed specifically for the AWS environment, using native tools and services to achieve its goals.&lt;/p&gt;
&lt;p&gt;Its primary goal is to help customers achieve their business outcomes in the most cost-efficient way, accelerating economic and business value while maintaining the right balance between agility and control.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Descriptions of the four CFM pillars see, save, plan, and run." src="https://docs.aws.amazon.com/images/wellarchitected/latest/cost-optimization-pillar/images/cfm-pillars.webp align=left"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Image source: AWS&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="see"&gt;See&lt;/h3&gt;
&lt;p&gt;This pillar focuses on gaining visibility into where your cloud costs are coming from. It enables the finance team to track spending patterns and hold teams accountable for their usage.&lt;/p&gt;
&lt;p&gt;You can get started by implementing a strong AWS tagging strategy and, if using multiple accounts, setting up a structured account hierarchy for achieving cost transparency.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AWS Services&lt;/strong&gt;: AWS Control Tower, AWS Organizations, Cost Allocation Tags, Tag Policies, AWS Resource Groups, AWS Cost Categories, AWS Cost Explorer, AWS Cost and Usage Report, RIs and SPs&lt;/p&gt;
&lt;h3 id="save"&gt;Save&lt;/h3&gt;
&lt;p&gt;This pillar is about &lt;strong&gt;cost optimization&lt;/strong&gt; through strategic use of pricing models and efficient resource management.&lt;br&gt;
Examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Purchasing Reserved Instances or Savings Plans&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Using Spot Instances for fault-tolerant workloads&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Scaling efficiently with Auto Scaling Groups&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rightsizing resources&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Terminating wasteful and idle resources&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;AWS Services&lt;/strong&gt;: RIs and SPs, Amazon EC2 Auto Scaling Groups, Spot Instances, AWS Compute Optimizer, AWS Trusted Advisor, AWS Instance Scheduler&lt;/p&gt;
&lt;h3 id="plan"&gt;Plan&lt;/h3&gt;
&lt;p&gt;Once you gain visibility into spending, the next step is forecasting and budgeting. AWS allows you to build flexible, dynamic budgeting processes that help you monitor if spending aligns with expectations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AWS Services&lt;/strong&gt;: AWS Cost Explorer, AWS Cost and Usage Report, AWS Budgets&lt;/p&gt;
&lt;h3 id="run"&gt;Run&lt;/h3&gt;
&lt;p&gt;The Run pillar is about operational cost control and governance. It includes setting up guardrails, automating policies, and using monitoring tools to stay within budget and detect anomalies.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AWS Services&lt;/strong&gt;: AWS Billing and Cost Management Console, AWS Identity and Access Management, Service Control Policies (SCP), AWS Service Catalog, AWS Cost Anomaly Detection, AWS Budgets&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;→ You may want to know:&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://cloudwithalon.com/15-aws-native-tools-to-master-cost-optimization"&gt;&lt;em&gt;15 AWS Native Tools to Master AWS Cost Optimization&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="mapping-finops-and-aws-cfm-frameworks"&gt;Mapping FinOps and AWS CFM Frameworks&lt;/h2&gt;
&lt;p&gt;To better understand how the FinOps lifecycle aligns with AWS’s Cloud Financial Management (CFM) pillars, I created the following mapping.&lt;/p&gt;
&lt;p&gt;This table illustrates how both frameworks complement each other and highlights the AWS-native tools and services that support each phase.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: ‘See’ and ‘Plan’ align with the Inform phase.&lt;/em&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;FinOps Phase&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;AWS CFM Pillar&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Purpose&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;AWS Services &amp;amp; Tools&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Inform&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;See&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Gain visibility into cloud spend and usage&lt;/td&gt;
&lt;td&gt;AWS Control Tower, AWS Organizations, Cost Allocation Tags, Tag Policies, AWS Resource Groups, AWS Cost Categories, AWS Cost Explorer, AWS Cost and Usage Report, RIs and SPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Plan&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Forecast usage, set budgets, and plan financial goals&lt;/td&gt;
&lt;td&gt;AWS Cost Explorer, AWS Cost and Usage Report, AWS Budgets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Optimize&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Save&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Eliminate waste, rightsize, and apply pricing models&lt;/td&gt;
&lt;td&gt;RIs and SPs, Amazon EC2 Auto Scaling Groups, Spot Instances, AWS Compute Optimizer, AWS Trusted Advisor, AWS Instance Scheduler&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Operate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Run&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Manage costs operationally, enforce governance&lt;/td&gt;
&lt;td&gt;AWS Billing and Cost Management Console, AWS IAM, Service Control Policies (SCP), AWS Service Catalog, AWS Cost Anomaly Detection, AWS Budgets&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I hope you found this information helpful. I'd love to hear your thoughts or experiences in the comments below.&lt;/p&gt;
&lt;p&gt;Thank you for reading,&lt;/p&gt;
&lt;p&gt;– Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>What is FinOps and Why It Matters in Cloud Era?</title><link href="https://cloudwithalon.com/writing/what-is-finops-and-why-it-matters-in-cloud-era/" rel="alternate"/><published>2025-06-16T00:00:00+00:00</published><updated>2025-06-16T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-06-16:/writing/what-is-finops-and-why-it-matters-in-cloud-era/</id><summary type="html">&lt;p&gt;FinOps: a framework for teamwork in cloud cost management to optimize spending and maximize business value&lt;/p&gt;</summary><content type="html">&lt;p&gt;According to Precedence Research, 96% of organizations use at least one cloud service, and the cloud market is projected to surpass $1 trillion by 2028. Organizations are investing heavily in technology, and a significant portion of that spend is going to the cloud.&lt;/p&gt;
&lt;p&gt;For instance, estimates suggest that Netflix pays approximately $115 million annually to AWS, Pinterest spends between $190 million and $225 million per year, and Snapchat allocates around $400 million annually to AWS services.&lt;/p&gt;
&lt;p&gt;These costs are expected to grow each year and that’s where the real challenge lies.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;mark&gt;CLOUD COST MANAGEMENT&lt;/mark&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Cloud spending has become a hot topic. 75% of organizations report that around 32% of their cloud budget goes to waste. This waste can be controlled and optimized, but the bigger issue is that nearly half struggle with it due to a lack of knowledge, tools, or strategy.&lt;/p&gt;
&lt;p&gt;And this is exactly where FinOps comes in.&lt;/p&gt;
&lt;p&gt;FinOps focuses on optimizing cloud resources for efficient usage and implementing governance to gain visibility into spending so costs can be controlled effectively.&lt;/p&gt;
&lt;p&gt;&lt;div class="video-container"&gt;
    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/tBdG3ZYX34Y?si=1u0DDTu5WgsXgQyt" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt;&lt;/p&gt;
&lt;div class="toc"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#what-is-finops"&gt;What is FinOps?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#key-principles-of-finops"&gt;Key Principles of FinOps&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#core-principles-of-finops"&gt;Core Principles of FinOps:&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#why-finops-matters-in-the-cloud-era"&gt;Why FinOps Matters in the Cloud Era?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#getting-started-with-finops"&gt;Getting Started with FinOps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h2 id="what-is-finops"&gt;What is FinOps?&lt;/h2&gt;
&lt;p&gt;Many people mistakenly believe that FinOps is just about cutting costs through resource optimization, but that is not true.&lt;/p&gt;
&lt;p&gt;As per the &lt;a href="https://www.finops.org/" rel="nofollow" target="_blank"&gt;FinOps Foundation&lt;/a&gt;,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;FinOps is an operational framework and cultural practice which maximizes the business value of cloud and technology, enables timely data-driven decision making, and creates financial accountability through collaboration between engineering, finance, and business teams.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;After working in this field for a while, I see it as a set of principles that delivers business value aligned with cloud spending. It involves team collaboration, cost visibility, resource optimization, forecasting, and governance.&lt;/p&gt;
&lt;p&gt;Just like DevOps focuses on development and operations, FinOps focuses on cloud financial operations.&lt;/p&gt;
&lt;p&gt;In the early days, FinOps focused on maximizing business value from cloud provider spending. But today, it’s &lt;a href="https://www.finops.org/topic/scopes/" rel="nofollow" target="_blank"&gt;scope&lt;/a&gt; has extended beyond just cloud and includes AI, SaaS platform, and increasingly, any technology-related spend.&lt;/p&gt;
&lt;h2 id="key-principles-of-finops"&gt;&lt;strong&gt;Key Principles of FinOps&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;FinOps isn't just about saving money. It's about making cloud spend meaningful. Here's how it works in practice:&lt;/p&gt;
&lt;p&gt;Imagine a product engineering team builds a new feature that needs extra cloud resources. During testing, they spin up resources, and the DevOps team adds auto-scaling and CI/CD pipelines to streamline deployment.&lt;/p&gt;
&lt;p&gt;But no one informs finance, and there’s no cost estimate shared.&lt;/p&gt;
&lt;p&gt;By the next billing cycle, the finance team sees a spike in the cloud bill but has no context. They don’t know what caused it, and the engineering team isn’t sure either.&lt;/p&gt;
&lt;p&gt;This disconnect between teams is common in cloud environments, often leading to finger-pointing, delayed responses, and sometimes wasted budget.&lt;/p&gt;
&lt;p&gt;This is where FinOps steps in to bring clarity and alignment.&lt;/p&gt;
&lt;p&gt;By fostering collaboration between engineering, DevOps, and finance, FinOps helps teams understand the financial impact of their decisions.&lt;/p&gt;
&lt;p&gt;It enables them to optimize usage and take ownership of their spending.&lt;/p&gt;
&lt;p&gt;Ultimately, it ensures that every cloud dollar is used with intention and delivers meaningful business value.&lt;/p&gt;
&lt;h3 id="core-principles-of-finops"&gt;Core Principles of FinOps:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Collaborate Early Across Teams&lt;/strong&gt;: Finance, engineering, and operations work together early to plan and estimate cloud costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Own What You Use&lt;/strong&gt;: Each team is responsible for their own cloud usage and understands what they are spending and why.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optimize Continuously&lt;/strong&gt;: Teams reduce waste by rightsizing and automating resources.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Get Timely Insights&lt;/strong&gt;: Regular cost reports help engineering teams adjust quickly and support finance teams in forecasting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set Clear Policies&lt;/strong&gt;: Clear policies and rules keep cloud usage in check and prevent budget surprises.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="why-finops-matters-in-the-cloud-era"&gt;&lt;strong&gt;Why FinOps Matters in the Cloud Era?&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;In traditional IT environments, hosting an application often required overestimating server capacity. Companies would invest significant upfront capital in hardware that frequently went underutilized.&lt;/p&gt;
&lt;p&gt;Cloud computing eliminates this burden. It allows organizations to provision exactly the resources they need, when they need them, using a consumption-based pricing model.&lt;/p&gt;
&lt;p&gt;Although cloud computing simplifies operations, it also introduces new challenges, particularly in cost visibility and control.&lt;/p&gt;
&lt;p&gt;One reason cloud costs are often opaque is the pay-as-you-go pricing model, which fluctuates based on usage. This variability makes it difficult to predict monthly bills and complicates financial planning.&lt;/p&gt;
&lt;p&gt;Many cloud services include hidden costs, such as &lt;a href="https://cloudwith.alon.com.np/understanding-aws-data-transfer-costs"&gt;charges for data transfer,&lt;/a&gt; API requests, software licenses, and managed service fees. These charges often go unnoticed until they appear unexpectedly on the invoice.&lt;/p&gt;
&lt;p&gt;Beyond pricing complexity, many cost-related issues also stem from within the organization. A lack of governance can lead to overspending due to unused resources that continue running.&lt;/p&gt;
&lt;p&gt;Unless there is a dedicated FinOps role focused on cost management, most employees remain focused on their individual tasks and often overlook the broader impact of cloud spending.&lt;/p&gt;
&lt;p&gt;This results in delays in identifying which teams, projects, or services are driving costs, making it challenging to manage expenses effectively.&lt;/p&gt;
&lt;p&gt;Also, missing opportunities to optimize pricing, such as leveraging Reserved Instances, Savings Plans, or right-sizing resources.&lt;/p&gt;
&lt;p&gt;With these issues, business spending on the cloud delivers poor return on investment (ROI).&lt;/p&gt;
&lt;p&gt;FinOps bridges these gaps by enabling shared accountability, real-time insights, and proactive cost management, turning cloud spend into a strategic advantage rather than a blind expense.&lt;/p&gt;
&lt;h2 id="getting-started-with-finops"&gt;&lt;strong&gt;Getting Started with FinOps&lt;/strong&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gain Visibility&lt;/strong&gt;&lt;br&gt;
    Begin by collecting and organizing cloud spending data. Know where every penny goes. Organize data in a way that provides insights from finance, tech, and business views. Use resource tagging, and look for high-cost drivers, usage patterns, and unusual spikes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enable Collaboration and Ownership&lt;/strong&gt;&lt;br&gt;
    Once you have the data, bring finance, engineering, and operations together. Help teams see that cost is a shared responsibility. Work together to build a strategy for optimization and accountability.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set Up Reporting&lt;/strong&gt;&lt;br&gt;
    Transparency is key. Create dashboards and reports to give every stakeholders real-time visibility into cloud costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start Small and Scale&lt;/strong&gt;&lt;br&gt;
    Don’t try to fix everything at once. Start with one team or service. Learn, show results, and scale gradually. FinOps is a journey, not a one-time fix.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Learn and Implement&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Research how other organizations implement FinOps. Study real examples and apply what works to your environment.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Want to dive deeper?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;→ &lt;a href="https://cloudwith.alon.com.np/apply-finops-lifecycle-in-aws-using-built-in-tools"&gt;&lt;em&gt;Learn the FinOps lifecycle and How you can implement it in AWS using its built-in tools.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;→ &lt;a href="https://cloudwithalon.com/15-aws-native-tools-to-master-cost-optimization"&gt;&lt;em&gt;15 AWS Native Tools to Master AWS Cost Optimization&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope you found this post helpful. I'm diving deeper into FinOps and working to grow in this space. This is my first post on the topic, and I'd love your feedback.&lt;/p&gt;
&lt;p&gt;Follow me on my FinOps journey. Let’s learn and grow together!&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Deploying AWS Transfer Family with Lambda, EFS and DynamoDB</title><link href="https://cloudwithalon.com/writing/deploying-aws-transfer-family-with-lambda-efs-and-dynamodb/" rel="alternate"/><published>2025-05-11T00:00:00+00:00</published><updated>2025-05-11T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-05-11:/writing/deploying-aws-transfer-family-with-lambda-efs-and-dynamodb/</id><summary type="html">&lt;p&gt;Migrate your SFTP to AWS using Transfer Family, Lambda, EFS, and DynamoDB for a serverless and fully managed architecture&lt;/p&gt;</summary><content type="html">&lt;p&gt;I previously had SFTP configured on an AWS EC2 instance.&lt;/p&gt;
&lt;p&gt;However, due to increasing operational overhead and maintenance challenges, I decided to migrate the workload to a serverless, fully managed architecture using AWS services.&lt;/p&gt;
&lt;p&gt;In this new setup, I’ll be using:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AWS Transfer Family&lt;/strong&gt; – to provide a managed SFTP server&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AWS Lambda&lt;/strong&gt; – for implementing custom authentication logic&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Amazon DynamoDB&lt;/strong&gt; – to store user credentials&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Amazon EFS&lt;/strong&gt; – as the home directory for SFTP users&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AWS KMS&lt;/strong&gt; – for encrypting credentials&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="setup"&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;I set up an &lt;strong&gt;AWS Transfer Family server&lt;/strong&gt; using the &lt;strong&gt;SFTP protocol&lt;/strong&gt;, deployed across &lt;strong&gt;two subnets&lt;/strong&gt; for high availability. For authentication, I used a &lt;strong&gt;Custom Identity Provider&lt;/strong&gt; with &lt;strong&gt;AWS Lambda&lt;/strong&gt;, enabling support for both &lt;strong&gt;password&lt;/strong&gt; and &lt;strong&gt;public key&lt;/strong&gt; authentication.&lt;/p&gt;
&lt;p&gt;AWS Transfer Family natively supports only public key authentication, but since my use case required password-based access, Lambda allowed me to implement that custom logic.&lt;/p&gt;
&lt;p&gt;For storage, I configured &lt;strong&gt;Amazon EFS&lt;/strong&gt; as the user home directory. This is where clients land after login and where they can upload or download files.&lt;/p&gt;
&lt;p&gt;When a client attempts to connect, &lt;strong&gt;Transfer Family triggers the Lambda function&lt;/strong&gt;. The Lambda function then retrieves the user's credentials from &lt;strong&gt;DynamoDB&lt;/strong&gt; and compares them with the provided information.&lt;/p&gt;
&lt;p&gt;If the credentials match, the function returns a success response, and the client is connected to their EFS directory. If not, it returns an empty response, and the connection is denied.&lt;/p&gt;
&lt;h2 id="workflow"&gt;Workflow&lt;/h2&gt;
&lt;p&gt;&lt;img alt="AWS Transfer Family architecture with Lambda, EFS, and DynamoDB" src="/images/post/deploying-aws-transfer-family-with-lambda-efs-and-dynamodb/975024d0-bd4d-4bd5-9738-ced5a367ee81.webp"&gt;&lt;/p&gt;
&lt;p&gt;When a client attempts to log in to AWS Transfer Family, they can choose either &lt;strong&gt;password-based&lt;/strong&gt; or &lt;strong&gt;SSH key-based&lt;/strong&gt; authentication.&lt;/p&gt;
&lt;p&gt;Once the Transfer Family server receives the request, it triggers the associated &lt;strong&gt;Lambda function&lt;/strong&gt;, passing in connection metadata.&lt;/p&gt;
&lt;p&gt;For password-based authentication, the Lambda function receives details like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;user&lt;/span&gt;&lt;span class="kc"&gt;na&lt;/span&gt;&lt;span class="err"&gt;me&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;_XXX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;sourceIp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;XX.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;XX.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;XX.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;pro&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;ocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;SFTP&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;serverId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="mi"&gt;-598&lt;/span&gt;&lt;span class="err"&gt;XXXXXXXX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;XXXXXX@&lt;/span&gt;&lt;span class="mi"&gt;4321&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This data is used to validate the user against stored credentials in DynamoDB.&lt;/p&gt;
&lt;p&gt;However, when a client uses &lt;strong&gt;SSH key-based authentication&lt;/strong&gt;, the &lt;strong&gt;public key is not included&lt;/strong&gt; in the Lambda payload.&lt;/p&gt;
&lt;h3 id="lambda-authentication-logic"&gt;&lt;strong&gt;Lambda Authentication Logic&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Once triggered, the Lambda function retrieves the client's details from &lt;strong&gt;DynamoDB&lt;/strong&gt;, where both the &lt;strong&gt;password&lt;/strong&gt; and &lt;strong&gt;SSH public key&lt;/strong&gt; are stored in &lt;strong&gt;encrypted format&lt;/strong&gt; using AWS KMS. The Lambda code then determines the authentication method based on the login request.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;If the client provides a password&lt;/strong&gt;:&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lambda decrypts the password stored in DynamoDB.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It compares it with the password from the login request.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If they match, Lambda returns a &lt;strong&gt;success response&lt;/strong&gt; to Transfer Family:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;Role&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;arn:aws:iam::123XXXXXX:role/transfer-access-role&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;PosixProfile&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;Gid&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;65534&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;Uid&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;65534&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;SecondaryGids&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;HomeDirectoryDetails&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;Entry&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;Target&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/fs-fXXXXXXXX/clients/Client_XXXX&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;HomeDirectoryType&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LOGICAL&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If credentials don’t match, Lambda returns an &lt;strong&gt;empty response&lt;/strong&gt;, and the connection is denied.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;If the client uses SSH key authentication&lt;/strong&gt;:&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;password is not included&lt;/strong&gt; in the request.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lambda adds the &lt;strong&gt;public key&lt;/strong&gt; from DynamoDB to the response:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="err"&gt;respo&lt;/span&gt;&lt;span class="kc"&gt;nse&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;PublicKeys&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;ssh&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;rsa&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;abcde&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="mi"&gt;0123456789&lt;/span&gt;&lt;span class="err"&gt;abcde&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="mi"&gt;0123456789&lt;/span&gt;&lt;span class="err"&gt;abcde&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="mi"&gt;0123456789&lt;/span&gt;&lt;span class="err"&gt;abcde&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="mi"&gt;0123456789&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;AWS Transfer Family handles the key validation; Lambda has no control over authenticating the SSH key.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the Lambda response, the &lt;code&gt;Role&lt;/code&gt; field specifies the &lt;strong&gt;IAM role&lt;/strong&gt; that the client will assume upon successful authentication. This role must have the necessary permissions to access &lt;strong&gt;Amazon EFS&lt;/strong&gt;, enabling the client to upload and download files.&lt;/p&gt;
&lt;p&gt;The IAM policy attached to the role should include the following permissions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="err"&gt;Ac&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;io&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;elas&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;ic&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;ilesys&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;Roo&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;Access&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;elas&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;ic&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;ilesys&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;Mou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;elas&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;ic&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;ilesys&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;Wri&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;PosixProfile&lt;/code&gt; and &lt;code&gt;HomeDirectoryDetails&lt;/code&gt; fields, which define the client’s user/group IDs and their logical directory path, are also stored in &lt;strong&gt;DynamoDB&lt;/strong&gt;. These are fetched by Lambda and included in the response to Transfer Family, ensuring the client lands in the correct EFS directory with appropriate file system permissions.&lt;/p&gt;
&lt;h2 id="limitations"&gt;Limitations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Password Exposure:&lt;/strong&gt; Avoid logging the full Lambda event, as it may contain user passwords in plaintext.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Concurrent Sessions:&lt;/strong&gt; Each Transfer Family server supports up to &lt;strong&gt;10,000 concurrent sessions&lt;/strong&gt;. To avoid abuse, consider limiting sessions per user. &lt;a href="https://aws.amazon.com/blogs/storage/enable-session-limits-for-aws-transfer-family/" rel="nofollow" target="_blank"&gt;More details&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Client Lockout:&lt;/strong&gt; Transfer Family doesn’t have built-in lockout policies, so I implemented a separate mechanism using AWS Lambda to track failed login attempts and temporarily block users.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Idle Timeout:&lt;/strong&gt; Connections are automatically closed after &lt;strong&gt;30 minutes of inactivity&lt;/strong&gt;. This timeout is not configurable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;File Size Limit:&lt;/strong&gt; Maximum upload size is &lt;strong&gt;5 TB per file&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unsupported Ciphers:&lt;/strong&gt; Some older ciphers supported in my EC2-based SFTP were not supported by Transfer Family. &lt;a href="https://docs.aws.amazon.com/transfer/latest/userguide/security-policies.html" rel="nofollow" target="_blank"&gt;More details&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Setting Up PrivateLink Between AWS and Snowflake</title><link href="https://cloudwithalon.com/writing/setting-up-privatelink-between-aws-and-snowflake/" rel="alternate"/><published>2025-05-10T06:54:00+00:00</published><updated>2025-05-10T06:54:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-05-10:/writing/setting-up-privatelink-between-aws-and-snowflake/</id><summary type="html">&lt;p&gt;Set up AWS PrivateLink with Snowflake for enhanced cloud security by following detailed integration steps&lt;/p&gt;</summary><content type="html">&lt;p&gt;Recently, my organization decided to migrate to Snowflake. Since security is always a top priority, the first step we took was to create a PrivateLink connection between our AWS VPC and Snowflake.&lt;/p&gt;
&lt;p&gt;Snowflake offers several built-in features that make it easy to integrate with AWS accounts, so setting up a PrivateLink is straightforward.&lt;/p&gt;
&lt;p&gt;This page outlines the steps I followed to set up the PrivateLink.&lt;/p&gt;
&lt;h2 id="step-1-create-an-aws-iam-user"&gt;Step 1: Create an AWS IAM User&lt;/h2&gt;
&lt;p&gt;To create a PrivateLink connection with Snowflake, you'll need an IAM user in the AWS account where the PrivateLink will be set up. This is required because Snowflake uses federated user credentials for the integration, which &lt;strong&gt;cannot&lt;/strong&gt; be obtained through an IAM role or STS session — a dedicated IAM user is necessary.&lt;/p&gt;
&lt;p&gt;If you already have an IAM user with required permission, you can use that. Otherwise, create a new IAM user and ensure it has at least the following permission:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;Versio&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2012-10-17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;S&lt;/span&gt;&lt;span class="kc"&gt;tate&lt;/span&gt;&lt;span class="err"&gt;me&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="err"&gt;E&lt;/span&gt;&lt;span class="kc"&gt;ffe&lt;/span&gt;&lt;span class="err"&gt;c&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="err"&gt;Ac&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;io&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;ts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;Ge&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;Federa&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;io&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;Toke&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="err"&gt;Resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id="step-2-generate-a-federation-token"&gt;Step 2: Generate a Federation Token&lt;/h2&gt;
&lt;p&gt;Once you've created an IAM user with the necessary permissions, configure the user on your local machine using the AWS CLI.&lt;/p&gt;
&lt;p&gt;Then generate a federation token running the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# Replace &amp;#39;svc-snowflake-federated&amp;#39; with your IAM user name&lt;/span&gt;
aws&lt;span class="w"&gt; &lt;/span&gt;sts&lt;span class="w"&gt; &lt;/span&gt;get-federation-token&lt;span class="w"&gt; &lt;/span&gt;--name&lt;span class="w"&gt; &lt;/span&gt;svc-snowflake-federated
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This command returns credentials that Snowflake will use to establish the PrivateLink. The output will look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;Crede&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;ials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;AccessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ASIAVSTBMXXXXXXXXXX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;Secre&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;AccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;RMDMBXXXXXXXXXXXXXXXXXXXXXXXXXX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;Sessio&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;Toke&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;IQoJb&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="err"&gt;JpZ&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;luX&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;VjEOjXXXXXXXXXXXXXXXXXXXXXXXsXXXXXXXXXXXXXXXXXXXXXXXXXXw+&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;YTps&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;Q/JFXXXXXXXXXXXXXXXXXXXXXXXXXXED&lt;/span&gt;&lt;span class="kc"&gt;ft&lt;/span&gt;&lt;span class="err"&gt;y&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="err"&gt;v+LJRMbghcR&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;ouPTg==&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;Expira&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;io&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2025-04-18&lt;/span&gt;&lt;span class="err"&gt;T&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;23+00&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;Federa&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;dUser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;Federa&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;dUserId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="err"&gt;XXXXXXXXX&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;svc&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;ke&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="kc"&gt;fe&lt;/span&gt;&lt;span class="err"&gt;dera&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;Ar&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ar&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;aws&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;ts&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="err"&gt;XXXXXXXXX&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;fe&lt;/span&gt;&lt;span class="err"&gt;dera&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;d&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;user/svc&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;ke&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="kc"&gt;fe&lt;/span&gt;&lt;span class="err"&gt;dera&lt;/span&gt;&lt;span class="kc"&gt;te&lt;/span&gt;&lt;span class="err"&gt;d&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;PackedPolicySize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;These credentials will be used in the next steps to establish the PrivateLink between AWS and Snowflake.&lt;/p&gt;
&lt;h2 id="step-3-enable-privatelink-in-snowflake"&gt;Step 3: Enable PrivateLink in Snowflake&lt;/h2&gt;
&lt;p&gt;Log in to your Snowflake account. The user performing this step must have the &lt;strong&gt;ACCOUNTADMIN&lt;/strong&gt; role to authorize and retrieve PrivateLink configuration details.&lt;/p&gt;
&lt;h3 id="1-open-a-worksheet"&gt;1. Open a Worksheet&lt;/h3&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Projects &amp;gt; Worksheets&lt;/strong&gt; in the Snowflake UI, and execute the following queries:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Switch to the ACCOUNTADMIN role&lt;/span&gt;
&lt;span class="n"&gt;USE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ROLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ACCOUNTADMIN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Authorize PrivateLink using your AWS Account ID and federation token&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SYSTEM&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;AUTHORIZE_PRIVATELINK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;3XXXXXXXXX0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;-- Replace with your AWS Account details&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;{&lt;/span&gt;
&lt;span class="s1"&gt;        Credentials: {&lt;/span&gt;
&lt;span class="s1"&gt;            AccessKeyId: ASIAVSTBMXXXXXXXXXX,&lt;/span&gt;
&lt;span class="s1"&gt;            SecretAccessKey: RMDMBXXXXXXXXXXXXXXXXXXXXXXXXXX,&lt;/span&gt;
&lt;span class="s1"&gt;            SessionToken: IQoJb3JpZ2luX2VjEOjXXXXXXXXXXXXXXXXXXXXXXXsXXXXXXXXXXXXXXXXXXXXXXXXXXw+tYTps1Q/JFXXXXXXXXXXXXXXXXXXXXXXXXXXEDfty8v+LJRMbghcR0ouPTg==,&lt;/span&gt;
&lt;span class="s1"&gt;            Expiration: 2025-04-18T19:18:23+00:00&lt;/span&gt;
&lt;span class="s1"&gt;        },&lt;/span&gt;
&lt;span class="s1"&gt;        FederatedUser: {&lt;/span&gt;
&lt;span class="s1"&gt;            FederatedUserId: 3XXXXXXXXX0:svc-snowflake-federated,&lt;/span&gt;
&lt;span class="s1"&gt;            Arn: arn:aws:sts::3XXXXXXXXX0:federated-user/svc-snowflake-federated&lt;/span&gt;
&lt;span class="s1"&gt;        },&lt;/span&gt;
&lt;span class="s1"&gt;        PackedPolicySize: 0&lt;/span&gt;
&lt;span class="s1"&gt;    }&amp;#39;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If successful, you will see the message: &lt;code&gt;Account is authorized for PrivateLink.&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="2-retrieve-privatelink-configuration"&gt;2. Retrieve PrivateLink Configuration&lt;/h3&gt;
&lt;p&gt;Run the following to retrieve your Snowflake PrivateLink configuration details:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SYSTEM&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;GET_PRIVATELINK_CONFIG&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will return output similar to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;accou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;pri&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;cipal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ar&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;aws&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;iam&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;XXXXXXXXX&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;roo&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;regio&lt;/span&gt;&lt;span class="kc"&gt;nless&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;owsigh&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;app&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;xxxxxxxxxx&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;youraccou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;.priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;accou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="kc"&gt;na&lt;/span&gt;&lt;span class="err"&gt;me&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;xxxxxx.us&lt;/span&gt;&lt;span class="mf"&gt;-e&lt;/span&gt;&lt;span class="err"&gt;as&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mf"&gt;-1.&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;vpce&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;com.amazo&lt;/span&gt;&lt;span class="kc"&gt;na&lt;/span&gt;&lt;span class="err"&gt;ws.vpce.us&lt;/span&gt;&lt;span class="mf"&gt;-e&lt;/span&gt;&lt;span class="err"&gt;as&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mf"&gt;-1.&lt;/span&gt;&lt;span class="err"&gt;vpce&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;svc&lt;/span&gt;&lt;span class="mi"&gt;-0&lt;/span&gt;&lt;span class="err"&gt;dxxxxxxxxxxxxxxx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;owsigh&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;app.us&lt;/span&gt;&lt;span class="mf"&gt;-e&lt;/span&gt;&lt;span class="err"&gt;as&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mf"&gt;-1.&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;regio&lt;/span&gt;&lt;span class="kc"&gt;nless&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;ocsp&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ocsp.xxxxxxxxxx&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;youraccou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;.priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;accou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;xxxxxx.us&lt;/span&gt;&lt;span class="mf"&gt;-e&lt;/span&gt;&lt;span class="err"&gt;as&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mf"&gt;-1.&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;spcs&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;regis&lt;/span&gt;&lt;span class="kc"&gt;tr&lt;/span&gt;&lt;span class="err"&gt;y&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;xxxxxxxxxx&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;youraccou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;.regis&lt;/span&gt;&lt;span class="kc"&gt;tr&lt;/span&gt;&lt;span class="err"&gt;y.priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;app&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;service&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*.yourregio&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;.priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;ke.app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;regio&lt;/span&gt;&lt;span class="kc"&gt;nless&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;accou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;xxxxxxxxxx&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;youraccou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;.priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;spcs&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;au&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;h&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;s&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;c&lt;/span&gt;&lt;span class="mf"&gt;-e&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;dpoi&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;logi&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;.yourregio&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;.priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k_ocsp&lt;/span&gt;&lt;span class="mi"&gt;-&lt;/span&gt;&lt;span class="err"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ocsp.&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="err"&gt;xxxxxx.us&lt;/span&gt;&lt;span class="mf"&gt;-e&lt;/span&gt;&lt;span class="err"&gt;as&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="mf"&gt;-1.&lt;/span&gt;&lt;span class="err"&gt;priva&lt;/span&gt;&lt;span class="kc"&gt;tel&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;k.s&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;ow&lt;/span&gt;&lt;span class="kc"&gt;fla&lt;/span&gt;&lt;span class="err"&gt;kecompu&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;i&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;g.com&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;These values are essential for configuring the AWS side of the PrivateLink connection in the next steps.&lt;/p&gt;
&lt;h2 id="step-4-create-a-vpc-endpoint-interface"&gt;Step 4: Create a VPC Endpoint Interface&lt;/h2&gt;
&lt;p&gt;Create a VPC Endpoint Interface in your AWS account to connect to the Snowflake PrivateLink service by following the steps below.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;“PrivateLink Ready Partner Services”&lt;/strong&gt; as the type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Service name&lt;/strong&gt;, enter the value from Snowflake’s &lt;code&gt;privatelink-vpce-id&lt;/code&gt; (e.g.,&lt;br&gt;
&lt;a href="http://com.amazonaws.vpce.us"&gt;&lt;code&gt;com.amazonaws.vpce.us&lt;/code&gt;&lt;/a&gt;&lt;code&gt;-east-1.vpce-svc-0dxxxxxxxxxxxxxxx&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Disable&lt;/strong&gt; the &lt;strong&gt;Private DNS name&lt;/strong&gt; option.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select your &lt;strong&gt;VPC&lt;/strong&gt; and choose &lt;strong&gt;at least two subnets&lt;/strong&gt; for high availability.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create and attach a &lt;strong&gt;security group&lt;/strong&gt; with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inbound&lt;/strong&gt;: Allow TCP on ports &lt;strong&gt;80&lt;/strong&gt; and &lt;strong&gt;443&lt;/strong&gt; from your VPC CIDR.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Outbound&lt;/strong&gt;: Allow TCP on ports &lt;strong&gt;80&lt;/strong&gt; and &lt;strong&gt;443&lt;/strong&gt; to &lt;code&gt;0.0.0.0/0&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create Endpoint and copy the endpoint DNS name. You'll need this in the next step to configure the Route 53 records.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="step-5-configure-dns-resolution-for-snowflake-privatelink"&gt;Step 5: Configure DNS Resolution for Snowflake PrivateLink&lt;/h2&gt;
&lt;p&gt;To allow your Snowflake Workspace resources to resolve PrivateLink URLs, configure DNS as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a Private Hosted Zone&lt;/strong&gt; in &lt;strong&gt;Route 53&lt;/strong&gt; with the domain name: &lt;code&gt;privatelink.snowflakecomputing.com&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Associate&lt;/strong&gt; the Private Hosted Zone with your &lt;strong&gt;VPC&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create the following CNAME records&lt;/strong&gt; in the hosted zone, pointing each to the appropriate Snowflake PrivateLink DNS (from the &lt;code&gt;SYSTEM$GET_PRIVATELINK_CONFIG()&lt;/code&gt; output):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;regionless-snowsight&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Record Name:&lt;/strong&gt; &lt;code&gt;regionless-snowsight-privatelink-url&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Type:&lt;/strong&gt; CNAME&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt;: VPC Endpoint DNS&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;privatelink-account&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Record Name:&lt;/strong&gt; &lt;code&gt;privatelink-account-url&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Type:&lt;/strong&gt; CNAME&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt;: VPC Endpoint DNS&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;privatelink-ocsp&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Record Name:&lt;/strong&gt; &lt;code&gt;privatelink_ocsp-url&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Type:&lt;/strong&gt; CNAME&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt;: VPC Endpoint DNS&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img alt="Route 53 private hosted zone configuration for Snowflake PrivateLink" src="/images/post/setting-up-privatelink-between-aws-and-snowflake/1e6f221d-6a85-4bdd-ba44-d8329a72dea5.webp"&gt;&lt;/p&gt;
&lt;h2 id="step-6-access-snowflake-using-the-private-url"&gt;Step 6: Access Snowflake Using the Private URL&lt;/h2&gt;
&lt;p&gt;Connect to a machine within your VPC and try logging into Snowflake using the URL from the &lt;code&gt;regionless-snowsight-privatelink-url&lt;/code&gt; value returned by the &lt;code&gt;SYSTEM$GET_PRIVATELINK_CONFIG()&lt;/code&gt; query.&lt;/p&gt;
&lt;p&gt;URL eg: https://app-xxxxxxxxxx-youraccount.privatelink.snowflakecomputing.com&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Optimizing Data Retrieval from DynamoDB Using Boto3</title><link href="https://cloudwithalon.com/writing/optimizing-data-retrieval-from-dynamodb-using-boto3/" rel="alternate"/><published>2025-05-03T00:00:00+00:00</published><updated>2025-05-03T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-05-03:/writing/optimizing-data-retrieval-from-dynamodb-using-boto3/</id><summary type="html">&lt;p&gt;Optimizing DynamoDB data retrieval using Boto3's Client and Resource APIs can improve performance. Discover real-world comparisons with code examples.&lt;/p&gt;</summary><content type="html">&lt;p&gt;While my expertise isn’t in databases, but whenever I have to choose a database for my internal projects, I go with NoSQL solutions like DynamoDB in AWS.&lt;/p&gt;
&lt;p&gt;Recently, I built a project for real clients, which meant performance and efficiency became critical, especially for data retrieval.&lt;/p&gt;
&lt;p&gt;I explored DynamoDB’s documentation, ran some performance tests, and made a few small but impactful changes. These changes led to a noticeable boost in data retrieval speed.&lt;/p&gt;
&lt;p&gt;In this blog, I’ll share what I learned and how I implemented those improvements.&lt;/p&gt;
&lt;h2 id="dynamodb-choosing-the-right-method-for-data-retrieval"&gt;DynamoDB: Choosing the Right Method for Data Retrieval&lt;/h2&gt;
&lt;p&gt;I use the Python &lt;code&gt;Boto3&lt;/code&gt; library to access DynamoDB, which provides three main methods to retrieve data. &lt;code&gt;GetItem&lt;/code&gt;, &lt;code&gt;Query&lt;/code&gt; and &lt;code&gt;Scan&lt;/code&gt;. However, AWS strongly recommends avoiding the use of &lt;code&gt;Scan&lt;/code&gt; whenever possible, as it scans the entire table and is the least efficient option for data retrieval.&lt;/p&gt;
&lt;p&gt;When it comes to choosing between &lt;code&gt;GetItem&lt;/code&gt; and &lt;code&gt;Query&lt;/code&gt;, it largely depends on your specific use case. Here’s a quick breakdown:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;GetItem&lt;/code&gt;: If you know the exact &lt;strong&gt;partition key&lt;/strong&gt; (and &lt;strong&gt;sort key&lt;/strong&gt;, if the table has one) and need to retrieve &lt;strong&gt;a single item&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;clientName(Partition Key)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;clientLocation&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Client_Jun&lt;/td&gt;
&lt;td&gt;Kathmandu, Nepal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client_Gole&lt;/td&gt;
&lt;td&gt;Dhulikhel, Nepal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In this case, if you know the &lt;code&gt;clientName&lt;/code&gt; (e.g., &lt;code&gt;Client_Jun&lt;/code&gt;), you can use &lt;code&gt;GetItem&lt;/code&gt; to retrieve that one specific record.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;📝&lt;/em&gt; &lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;If your table has a sort key, you must provide both the partition key and the sort key when using&lt;/em&gt; &lt;code&gt;GetItem&lt;/code&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;Query&lt;/code&gt;: If you need to retrieve multiple items that share the same partition key (and sort key, if applicable).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;clientName(Partition Key)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;clientId(Sort Key)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;clientLocation&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Client_Jun&lt;/td&gt;
&lt;td&gt;1010&lt;/td&gt;
&lt;td&gt;Kathmandu, Nepal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client_Jun&lt;/td&gt;
&lt;td&gt;1011&lt;/td&gt;
&lt;td&gt;Dhulikhel, Nepal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client_Jun&lt;/td&gt;
&lt;td&gt;1012&lt;/td&gt;
&lt;td&gt;Bhaktapur, Nepal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In this case, you can use &lt;code&gt;Query&lt;/code&gt; to retrieve all entries where &lt;code&gt;clientName = Client_Jun&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;📝&lt;/em&gt; &lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; You can query just by partition key or add conditions on the sort key to filter the results.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="my-experience-from-query-to-getitem"&gt;My Experience: From Query to GetItem&lt;/h2&gt;
&lt;p&gt;In my case, I was initially using &lt;code&gt;Query&lt;/code&gt;, but after reviewing the requirements, I realized that &lt;code&gt;GetItem&lt;/code&gt; was a better fit since I only ever had one item per partition key. So, I updated my table structure by removing the sort key and modified my code to use &lt;code&gt;GetItem&lt;/code&gt; instead.&lt;/p&gt;
&lt;p&gt;This change made a big impact because &lt;code&gt;GetItem&lt;/code&gt; is optimized for retrieving a single item using the partition key, which makes it much faster. Even with this improvement, I still saw opportunities to optimize further.&lt;/p&gt;
&lt;h2 id="two-ways-to-use-getitem"&gt;Two Ways to Use GetItem&lt;/h2&gt;
&lt;p&gt;Boto3 provides two ways to interact with DynamoDB’s &lt;strong&gt;GetItem&lt;/strong&gt; API:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Boto3 Low-Level Client API&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;python
client = boto3.client('dynamodb')&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Boto3 High-Level Resource API&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;python
dynamodb = boto3.resource('dynamodb')&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I was using the &lt;strong&gt;high-level Resource API&lt;/strong&gt;, which is easier to work with because it handles many complexities for you.&lt;/p&gt;
&lt;h3 id="example-retrieving-data-using-both-apis"&gt;Example: Retrieving Data Using Both APIs&lt;/h3&gt;
&lt;p&gt;Here’s how you can retrieve data using both the Client API and Resource API with the same filter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="err"&gt;Key&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;&amp;#39;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;Id&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;#39;N&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="mi"&gt;1001&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="err"&gt;&amp;#39;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;Name&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;#39;S&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;#39;Clie&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="err"&gt;_Ju&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Output from the Client API:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;json
{
    'Item': {
        'ClientPosixProfile': {'M': {'Uid': {'N': '2008'}, 'SecondaryGids': {'L': [{'N': '2000'}]}, 'Gid': {'N': '2000'}}},
        'ClientUserName': {'S': 'Client_Jun'},
        'ClientHomeDirConfigMap': {'M': {'Entry': {'S': '/'}, 'Target': {'S': '/newclients/Client_Jun'}}},
        'ClientPassword': {'S': 'HahaHoHo@1234'}
    }
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This returns raw data with types like &lt;code&gt;S&lt;/code&gt;, &lt;code&gt;N&lt;/code&gt;, &lt;code&gt;M&lt;/code&gt;, etc., which you have to manually process and interpret.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Output from the Resource API:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;json
{
    'Item': {
        'ClientPosixProfile': {'Uid': Decimal('2008'), 'SecondaryGids': [Decimal('2000')], 'Gid': Decimal('2000')},
        'ClientUserName': 'Client_Jun',
        'ClientHomeDirConfigMap': {'Entry': '/', 'Target': '/newclients/Client_Jun'},
        'ClientPassword': 'HahaHoHo@1234'
    }
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This returns clear, simplified data that’s easier to use directly, as it automatically converts data types for you.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While the resource API works well for most use cases, the Low-Level Client API proved to be faster and more efficient for data retrieval in my specific case. You can see the speed comparison in the graph below:&lt;/p&gt;
&lt;p&gt;&lt;img alt="DynamoDB performance comparison between Client and Resource APIs" src="/images/post/optimizing-data-retrieval-from-dynamodb-using-boto3/f50d1f35-6575-42f1-9d89-acf8af059ec9.webp"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;GetItem&lt;/code&gt; using the &lt;strong&gt;Resource API&lt;/strong&gt; took &lt;strong&gt;1.4 seconds&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;GetItem&lt;/code&gt; using the &lt;strong&gt;Client API&lt;/strong&gt; took &lt;strong&gt;1.2 seconds&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Using &lt;code&gt;Query&lt;/code&gt; took &lt;strong&gt;2.6 seconds&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;After switching from &lt;code&gt;Query&lt;/code&gt; to the &lt;code&gt;GetItem&lt;/code&gt; API, I immediately noticed an improvement in performance. But here’s the interesting part: using the low-level &lt;code&gt;Client API&lt;/code&gt; for &lt;code&gt;GetItem&lt;/code&gt; resulted in even faster data retrieval.&lt;/p&gt;
&lt;p&gt;While the &lt;code&gt;Resource API&lt;/code&gt; is easier to use and handles the data retrieval in a more abstract way, it’s inherently slower due to the additional processing overhead. On the other hand, the &lt;code&gt;Client API&lt;/code&gt; gives you raw data, which requires more manipulation, but provides a much faster response time.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Implementing AWS Network Firewall</title><link href="https://cloudwithalon.com/writing/implementing-aws-network-firewall/" rel="alternate"/><published>2025-02-23T00:00:00+00:00</published><updated>2025-02-23T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2025-02-23:/writing/implementing-aws-network-firewall/</id><summary type="html">&lt;p&gt;Learn to implement AWS Network Firewall for enhanced security in your AWS environment, including setup, subnet configuration, and rule creation&lt;/p&gt;</summary><content type="html">&lt;p&gt;Again, this is my another experiment under the security domain. Security is receiving greater attention every day, and we can’t deny its importance.&lt;/p&gt;
&lt;p&gt;This document discusses implementing the AWS Network Firewall to protected AWS resources.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Network Firewall Architecture Diagram" src="/images/post/implementing-aws-network-firewall/5394610b-ab5c-4d40-8430-cca1de8a7a1a.webp"&gt;&lt;/p&gt;
&lt;p&gt;To implement AWS Network Firewall, you need at least one dedicated subnet for the firewall, or one dedicated subnet in each availability zone (AZ) you plan to use.&lt;/p&gt;
&lt;p&gt;In my case, I created two public subnets in AZs us-east-1a and us-east-1b. These subnets are for the firewall only and should not contain the resources you want to protect, as the firewall cannot protect resources within the subnet it's deployed in.&lt;/p&gt;
&lt;h2 id="concept-of-aws-network-firewall"&gt;Concept of AWS Network Firewall&lt;/h2&gt;
&lt;p&gt;First, create a firewall subnet that is public-facing, and set up a firewall in that subnet. This automatically creates a VPC endpoint as a gateway load balancer.&lt;/p&gt;
&lt;p&gt;Next, create a protected subnet where you'll place the resources you want to secure. The gateway for this protected subnet should be the VPC endpoint created earlier.&lt;/p&gt;
&lt;p&gt;When a request comes from the internet, it first passes through the network firewall. If the request matches your defined rules, it is forwarded to the protected subnet. Similarly, when a request is sent from the protected subnet to the internet, it goes through the firewall before reaching the internet&lt;/p&gt;
&lt;h2 id="implementing-aws-network-firewall"&gt;Implementing AWS Network Firewall&lt;/h2&gt;
&lt;h3 id="vpc-and-subnets"&gt;VPC and Subnets&lt;/h3&gt;
&lt;p&gt;First, I created a VPC with the CIDR block 10.24.0.0/16.&lt;/p&gt;
&lt;p&gt;Then, I created an Internet Gateway and two firewall subnets in us-east-1a (10.24.10.0/24) and us-east-1b (10.24.11.0/24), attaching a route table with the Internet Gateway.&lt;/p&gt;
&lt;p&gt;You can use a /28 subnet for the network firewall if no other resources are needed, as it only requires one available IP, and /28 is the smallest subnet size AWS allows.&lt;/p&gt;
&lt;p&gt;Then, I created a network firewall in two subnets I created earlier. This automatically creates Gateway Load Balancer VPC Endpoints in each subnet.&lt;/p&gt;
&lt;p&gt;Next, I created two protected subnets in AZ us-east-1a (10.24.20.0/24) and us-east-1b (10.24.21.0/24).&lt;/p&gt;
&lt;p&gt;Now, we need to update the route table for routing traffic.&lt;/p&gt;
&lt;h3 id="route-table"&gt;Route Table&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Internet Gateway Route Table&lt;/strong&gt;: We need to create a route table for the Internet Gateway to ensure that requests coming from the internet or going to the internet are forwarded to the Gateway Load Balancer VPC Endpoint(Network Firewall).&lt;/p&gt;
&lt;p&gt;Additionally, we need to add the Internet Gateway to the edge association of this route table.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Destination&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Target&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10.24.0.0/16&lt;/td&gt;
&lt;td&gt;local&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.24.20.0/28&lt;/td&gt;
&lt;td&gt;vpce-1a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.24.21.0/28&lt;/td&gt;
&lt;td&gt;vpce-1b&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Public Firewall Subnet Route Table&lt;/strong&gt;: The route table for the public firewall subnet should be similar to the route table for public subnets. The Internet Gateway should be the route used to reach the internet.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Destination&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Target&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10.24.0.0/16&lt;/td&gt;
&lt;td&gt;local&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.0.0.0/0&lt;/td&gt;
&lt;td&gt;igw-xx&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Protected Subnet Route Table&lt;/strong&gt;: The destination for internet-bound traffic in the protected subnets should be the network firewall VPC endpoint, ensuring that all traffic is filtered by the firewall before reaching the internet.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Destination&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Target&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10.24.0.0/16&lt;/td&gt;
&lt;td&gt;local&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.0.0.0/0&lt;/td&gt;
&lt;td&gt;vpce-1a, vpce-1b&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id="network-firewall-rule-creation"&gt;Network Firewall Rule Creation:&lt;/h3&gt;
&lt;p&gt;Let’s go back to setting up the network firewall rules. After creating the network firewall, the next step is to define a policy.&lt;/p&gt;
&lt;p&gt;A policy contains two types of rule groups: &lt;strong&gt;stateless&lt;/strong&gt; and &lt;strong&gt;stateful&lt;/strong&gt;. Within each rule group, you can add specific security rules.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a Policy&lt;/strong&gt;: In my case, I didn’t use stateless rules and only used stateful rules.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For stateless rules, I set the default action to forward to stateful rules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For stateful rules, the default action is to drop all connections and alert on all connections.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Adding Rules in Stateful Rule Group&lt;/strong&gt;: You can add rules with different methods for defining IP CIDRs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rule Variable&lt;/strong&gt;: Create a variable, assign IPs to it, and then use the variable in the rule. This can also be done for port numbers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;IP Set Reference&lt;/strong&gt;: Create a variable, but reference a prefix list instead of adding individual IP CIDRs directly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="AWS Network Firewall Rule Configuration" src="/images/post/implementing-aws-network-firewall/b1c007b2-c275-4cc5-b31f-3e8692475ee3.webp"&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nx"&gt;Directly&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Adding&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;IP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;CIDRs&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;You&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;can&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;also&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;choose&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;directly&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;individual&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;IP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;CIDRs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;without&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;or&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;prefix&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;approach&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;simpler&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;but&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;might&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;less&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;flexible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;need&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;reuse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;same&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;IP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;multiple&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;places&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="AWS Network Firewall IP Set Configuration" src="/images/post/implementing-aws-network-firewall/a8dfe4d3-1931-47e9-89bd-95330492000b.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;📝 &lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;When creating rules, even though there are protocol names like SSH, FTP, and HTTP, these names didn't work for me directly. I had to use the TCP protocol and specify the port numbers.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Rule variables are assigned with a&lt;/em&gt; &lt;code&gt;$&lt;/code&gt;, and IP set references are assigned with an &lt;code&gt;@&lt;/code&gt; in rules.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="limitation"&gt;Limitation:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A firewall policy can have a maximum of 20 rules in each rule group, applicable to both stateless and stateful rules.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A rule group within a policy can have a maximum of 30,000 entries. This total is the combined capacity of all the entries from the individual rules attached to the same rule group. For example, if a rule group has a capacity of 30,000 entries and you create two rules with a capacity of 100 entries each, the total number of entries used will be 200 entries (200/30,000).&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Network Firewall Rule Group Capacity" src="/images/post/implementing-aws-network-firewall/afbd4595-53e4-4f2d-b896-7252957b8c33.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rule Variables: The total value for rule variables (IP addresses) can only be up to 8,192 characters.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prefix List Limit: A prefix list can have a maximum of 1,000 CIDRs per list.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;IP Set Reference Limit: A rule group can reference a maximum of five IP sets(5 prefix list). This means that a single rule group can handle up to 5,000 IPs. To achieve the capability of handling 1,000,000 CIDRs per firewall, multiple rule groups need to be created.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Network Firewall IP Set Reference Limits" src="/images/post/implementing-aws-network-firewall/d45a83a1-c6f9-4d32-aad6-9de1235e9789.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;- Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>How I Automated Cross-Account AWS Access Using STS AssumeRole</title><link href="https://cloudwithalon.com/writing/automate-cross-account-access-using-sts-assume-role/" rel="alternate"/><published>2024-12-14T00:00:00+00:00</published><updated>2024-12-14T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-12-14:/writing/automate-cross-account-access-using-sts-assume-role/</id><summary type="html">&lt;p&gt;Learn to automate AWS cross-account access securely with AWS STS AssumeRole, reducing costs and operational overhead effectively&lt;/p&gt;</summary><content type="html">&lt;p&gt;Managing multiple AWS accounts within the same organization is common today. In my experience, I have worked in an organization that manages 26 AWS accounts simultaneously.&lt;/p&gt;
&lt;p&gt;While AWS Control Tower centralizes management, managing cross-account access for automations located in the central account to other accounts can be challenging.&lt;/p&gt;
&lt;p&gt;Also, running the same automation in each account isn't an option either.&lt;/p&gt;
&lt;p&gt;After testing several methods, I found that using AWS STS (Security Token Service) to assume roles for cross-account access was the most secure and scalable solution. It also reduced costs and operational overhead.&lt;/p&gt;
&lt;p&gt;In this post, I’ll explain how I used AWS STS to run automation from the central account and access resources in other accounts.&lt;/p&gt;
&lt;h2 id="aws-security-token-service-assume-role"&gt;AWS Security Token Service Assume Role&lt;/h2&gt;
&lt;p&gt;AWS STS AssumeRole provides temporary security credentials (access key, secret key, and security token) to access AWS resources in the same account or across other accounts.&lt;/p&gt;
&lt;p&gt;In simple terms, STS allows you to assume a role and gain the permissions associated with that role for a temporary period.&lt;/p&gt;
&lt;p&gt;So how you do it?&lt;/p&gt;
&lt;h2 id="creating-role-in-target-account"&gt;Creating Role in Target Account&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a Role in the Target Account&lt;/strong&gt;: In the account you want to access, create a new IAM role and give it the permissions needed for the resources in that account.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Update Policy in the Source Account&lt;/strong&gt;: In the account that will be accessing the target account, update the IAM user's or role's policy to allow it to assume the role you just created in target account.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add Trust Relationship in the Target Account&lt;/strong&gt;: In the target account, edit the trust policy of the role and add the IAM user or role (ARN) from the source account. This allows the source account to assume the role.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Source Account Role Policy&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;json
    {
      Effect: Allow,
      Action: [
        sts:AssumeRole
      ],
      Resource: [
        arn:aws:iam::DESTINATION-ACCOUNT-ID:role/DESTINATION-ROLENAME
      ]
    }&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Destination Account Role Trust Policy&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;json
    {
    Effect: Allow,
    Principal: {
      AWS: arn:aws:iam::SOURCE-ACCOUNT-ID:user/SOURCE-USERNAME
    },
    Action: sts:AssumeRole
  }&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can reference this from the AWS &lt;a href="https://repost.aws/knowledge-center/cross-account-access-iam" rel="nofollow" target="_blank"&gt;document&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="best-way-to-manage-role-for-cross-account-access"&gt;Best Way to Manage Role for Cross-Account Access&lt;/h2&gt;
&lt;p&gt;I created a role named &lt;code&gt;rol_sts_cross_account&lt;/code&gt; in all AWS accounts within the organization using a CloudFormation StackSet. This ensures that the role name, permissions, and trust policy are consistent across all accounts.&lt;/p&gt;
&lt;p&gt;Next, I created a configuration that can be used by all automation jobs requiring cross-account access, simply by passing the account ID as a parameter.&lt;/p&gt;
&lt;p&gt;The function like one below that accepts the account ID, service type, session type, and region which returns a temporary session for accessing the specified service.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;getSession&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;accountId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sessionType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;us-east-1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
    &lt;span class="n"&gt;iamRoleArn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;arn:aws:iam::&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;accountId&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;:role/rol_sts_cross_account&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;sts_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sts_client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assume_role&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;RoleArn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;iamRoleArn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;RoleSessionName&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;aws-sts-boto3-cross-account-access&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sessionType&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;aws_access_key_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sts_response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Credentials&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;AccessKeyId&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;aws_secret_access_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sts_response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Credentials&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SecretAccessKey&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;aws_session_token&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sts_response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Credentials&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SessionToken&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;retryConfig&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt; 

    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;sessionType&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;aws_access_key_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sts_response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Credentials&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;AccessKeyId&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;aws_secret_access_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sts_response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Credentials&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SecretAccessKey&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;aws_session_token&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sts_response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Credentials&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SessionToken&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;retryConfig&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With this setup, you will receive temporary credentials and be able to access the services. However, ensure that the assumed role has the necessary permissions for those services.&lt;/p&gt;
&lt;p&gt;You can find more informations about the source code in this &lt;a href="https://github.com/alonshrestha/aws-sts-multiple-cross-account-access-boto3/tree/main" rel="nofollow" target="_blank"&gt;repository&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Automating the Secure Sharing of AWS AMIs Across Accounts</title><link href="https://cloudwithalon.com/writing/automating-the-secure-sharing-of-aws-amis-across-accounts/" rel="alternate"/><published>2024-12-10T00:00:00+00:00</published><updated>2024-12-10T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-12-10:/writing/automating-the-secure-sharing-of-aws-amis-across-accounts/</id><summary type="html">&lt;p&gt;Learn how to automate secure AWS AMI sharing across accounts using custom KMS keys and Python scripting for enhanced security and efficiency&lt;/p&gt;</summary><content type="html">&lt;p&gt;You can share AWS AMIs across multiple accounts in two ways: publicly and privately.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Public Sharing&lt;/strong&gt;: If you've created a community AMI that you want to make available to everyone, you can set its visibility to public. This allows anyone to access and use the AMI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Private Sharing&lt;/strong&gt;: For AMIs containing sensitive or confidential information (such as organization-specific), it's important to share them privately. This ensures that only authorized AWS accounts can access the AMI.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This page will explain how you can securely share your AMI privately across AWS accounts, along with an automated solution built using Python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To skip the details and go straight to the automation workflow, jump ahead to the&lt;/strong&gt; &lt;a href="#workflow-of-the-ami-sharing-automation"&gt;&lt;strong&gt;section below&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If your AMI’s snapshot is unencrypted, you can simply share the AMI, and the destination account can access and use it. However, this approach may not be secure.&lt;/p&gt;
&lt;p&gt;Additionally, many organizations have encryption enabled by default for EBS volumes and snapshots to ensure data security.&lt;/p&gt;
&lt;p&gt;If the AMI’s snapshot is encrypted using the default AWS key &lt;code&gt;(aws/ebs)&lt;/code&gt;, you cannot share it. This is because the default key cannot be shared across accounts.&lt;/p&gt;
&lt;p&gt;To share an AMI securely, it must be encrypted using a custom KMS key. Additionally, the destination account must have the necessary permissions to access the custom KMS key in order to use the shared AMI.&lt;/p&gt;
&lt;h2 id="create-a-custom-kms-key"&gt;Create a Custom KMS Key&lt;/h2&gt;
&lt;p&gt;Create a custom KMS key and allow the destination account to access it. The JSON policy would look something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;Sid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Allow&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ex&lt;/span&gt;&lt;span class="kc"&gt;ternal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;accou&lt;/span&gt;&lt;span class="kc"&gt;nt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;111122223333&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;o&lt;/span&gt;&lt;span class="kc"&gt;f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;he&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;cus&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;omer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ma&lt;/span&gt;&lt;span class="kc"&gt;na&lt;/span&gt;&lt;span class="err"&gt;ged&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;E&lt;/span&gt;&lt;span class="kc"&gt;ffe&lt;/span&gt;&lt;span class="err"&gt;c&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;Pri&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;cipal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="err"&gt;AWS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="err"&gt;ar&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;aws&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;iam&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="mi"&gt;111122223333&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;roo&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;Ac&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;io&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="err"&gt;kms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;E&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;cryp&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="err"&gt;kms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;Decryp&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="err"&gt;kms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;ReE&lt;/span&gt;&lt;span class="kc"&gt;n&lt;/span&gt;&lt;span class="err"&gt;cryp&lt;/span&gt;&lt;span class="kc"&gt;t&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="err"&gt;kms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;Ge&lt;/span&gt;&lt;span class="kc"&gt;nerate&lt;/span&gt;&lt;span class="err"&gt;Da&lt;/span&gt;&lt;span class="kc"&gt;ta&lt;/span&gt;&lt;span class="err"&gt;Key*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="err"&gt;kms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;DescribeKey&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;Resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For more details, refer to the &lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying-external-accounts.html#cross-account-key-policy" rel="nofollow" target="_blank"&gt;AWS documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="encrypt-ami-using-custom-kms-key"&gt;Encrypt AMI Using Custom KMS Key&lt;/h2&gt;
&lt;p&gt;Once the KMS key is ready, copy the AMI within the same region using the newly created KMS key. You can copy the AMI to any other region where you want it to be available.&lt;/p&gt;
&lt;p&gt;However, you cannot directly share an AMI from Region A in the source account to Region B in the destination account. The AMI will be shared only in the same region from where it was originally shared.&lt;/p&gt;
&lt;h2 id="share-ami"&gt;Share AMI&lt;/h2&gt;
&lt;p&gt;To share an AMI, select the AMI and add the destination account's ID under AMI permissions (private share). You can add multiple AWS accounts, but ensure they all have access to the custom KMS key.&lt;/p&gt;
&lt;p&gt;When the AMI is shared, the source account controls the sharing. If the source account deletes the shared AMI or removes the destination account’s permission, the AMI will no longer be available to the destination account, since the destination does not own it.&lt;/p&gt;
&lt;p&gt;To own the AMI, launch an instance from the shared AMI in the destination account, then create a new AMI from that instance. This ensures the destination account becomes the owner of the new AMI.&lt;/p&gt;
&lt;p&gt;Alternatively, a simpler option is to re-copy the shared AMI to your own account. By doing so, you become the owner of the AMI, and it will remain available even if the source account revokes access. However, the source account must grant read permissions for the snapshot storage in order for you to copy the AMI.&lt;/p&gt;
&lt;h2 id="workflow-of-the-ami-sharing-automation"&gt;Workflow of the AMI Sharing Automation&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Automation source code is available&lt;/strong&gt; &lt;a href="https://github.com/alonshrestha/labs/tree/main/playground/share-aws-ami-cross-account" rel="nofollow" target="_blank"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The script requires the proper permissions, role assumptions, and custom KMS key configurations for both the source and destination accounts.&lt;/p&gt;
&lt;h3 id="pre-requisites"&gt;Pre-requisites:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h4 id="required-access"&gt;Required Access:&lt;/h4&gt;
&lt;p&gt;Ensure that both the source and destination AWS accounts have the necessary permissions for the operations to be performed (role assumption, AMI copying, modifying permissions, etc.).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id="custom-kms-key"&gt;Custom KMS Key:&lt;/h4&gt;
&lt;p&gt;The script uses a custom KMS key for encryption. You must have a KMS key with appropriate permissions to be used in the AMI copy process.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4 id="role-assumption"&gt;Role Assumption:&lt;/h4&gt;
&lt;p&gt;Create an IAM role named &lt;code&gt;role/role_sts_cross_account&lt;/code&gt; in both the source and destination accounts, allowing the script to assume the role and perform the necessary operations (such as copying the AMI).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="step-by-step-workflow"&gt;Step-by-Step Workflow:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In the script, you'll need to define the AWS account IDs for both the source and destination accounts:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;python
accountConfig = {
    AccountA: {id: 123123123123},
    AccountB: {id: 321321312321},
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Replace AccountA and AccountB with the actual names of your accounts, and update their corresponding AWS account IDs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the value for the custom KMS key in the variable &lt;code&gt;ebsKMSKeyForShareAMI&lt;/code&gt;. This key will be used for encrypting the copied AMI.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;python
ebsKMSKeyForShareAMI = alias/your-custom-kms-key&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To run the script, pass the following parameters:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;bash
python3.12 main.py -s AccountA -d AccountB -a ami-xxxid -e email@example.com
-s is the source account name (e.g., AccountA).
-d is the destination account name (e.g., AccountB).
-a is the AMI ID to be copied (e.g., ami-xxxid).
-e is the email address for receiving the notification (e.g., email@example.com).&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The script first assumes the role in the source account (provided in the -s argument) using AWS STS. Ensure that the source account has the correct role &lt;code&gt;role/role_sts_cross_account&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The script copies the AMI within the same region (us-east-1 by default). The copied AMI is encrypted using the custom KMS key specified in &lt;code&gt;ebsKMSKeyForShareAMI&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The script waits and checks the status of the copied AMI every 10 seconds. Once the AMI's state is available, the script proceeds to share the AMI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The AMI is shared with the destination account by modifying its permissions. It grants the destination account read permissions for the AMI and its associated snapshots.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After sharing the AMI, now the script assumes the role in the destination account (provided in the -d argument).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The script then re-copies the shared AMI into the destination account. This ensures the destination account becomes the owner of the AMI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Similar to the earlier step, the script checks the status of the AMI in the destination account every 10 seconds. Once the AMI's state is available, the script proceeds to clean up.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once the AMI is copied successfully in the destination account, the script deletes the shared AMI and its associated snapshots from the source account.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, the script sends an email notification via AWS SES to the provided recipient. The email includes details about the operation, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Source Account and Source AMI ID&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Destination Account and Destination AMI ID&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;KMS Key used for encryption&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="key-considerations"&gt;Key Considerations:&lt;/h3&gt;
&lt;h4 id="region-limitation"&gt;Region Limitation:&lt;/h4&gt;
&lt;p&gt;Currently, the script only works in the us-east-1 region. If you need it to work in other regions, you can modify the script to support that.&lt;/p&gt;
&lt;h4 id="permissions"&gt;Permissions:&lt;/h4&gt;
&lt;p&gt;Ensure that both the source and destination accounts have the necessary permissions for the script to perform actions such as assuming roles, modifying AMI permissions, copying AMIs, and deleting snapshots.&lt;/p&gt;
&lt;h4 id="custom-kms-key_1"&gt;Custom KMS Key:&lt;/h4&gt;
&lt;p&gt;The destination account must have access to the custom KMS key used for encryption. Make sure the key’s policy grants the necessary permissions to the destination account.&lt;/p&gt;
&lt;p&gt;Thank you for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>How Linux Boots on AWS EC2 Instance</title><link href="https://cloudwithalon.com/writing/how-linux-boots-on-aws-ec2-instance/" rel="alternate"/><published>2024-12-08T00:00:00+00:00</published><updated>2024-12-08T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-12-08:/writing/how-linux-boots-on-aws-ec2-instance/</id><summary type="html">&lt;p&gt;Learn Linux boot process on AWS EC2 to optimize and troubleshoot: infrastructure allocation to user environment setup&lt;/p&gt;</summary><content type="html">&lt;p&gt;When you launch an EC2 instance, it goes through a boot process similar to physical computers, but with some cloud-specific twists.&lt;/p&gt;
&lt;p&gt;Understanding this boot process can help you troubleshoot and optimize your EC2 instances more effectively.&lt;/p&gt;
&lt;h2 id="infrastructure-allocation"&gt;Infrastructure Allocation&lt;/h2&gt;
&lt;p&gt;When you start or create an EC2 instance, AWS allocates the necessary infrastructure resources to make your instance available.&lt;/p&gt;
&lt;p&gt;Once the instance is allocated, AWS's hypervisor (Nitro or Xen) hands control to the instance's firmware to begin the boot sequence. At the same time, AWS starts monitoring &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-system-instance-status-check.html" rel="nofollow" target="_blank"&gt;status checks&lt;/a&gt;, including system, instance, and volume. If any of these checks fail, the EC2 instance will not start successfully.&lt;/p&gt;
&lt;p&gt;AWS's Nitro system provides hardware-level isolation, presenting virtualized hardware components (CPU, memory, storage) that appear as physical hardware to the guest operating system. The hypervisor ensures the instance has exclusive access to its allocated resources during the boot process.&lt;/p&gt;
&lt;h2 id="firmware-initialization"&gt;Firmware Initialization&lt;/h2&gt;
&lt;p&gt;After resource allocation, your EC2 instance boots up and relies on the firmware installed on the underlying hardware (motherboard chip). This firmware is the first software that runs, initializing the platform so that the operating system on the instance can start.&lt;/p&gt;
&lt;p&gt;There are two main types of firmware:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;UEFI&lt;/strong&gt;: A newer version, UEFI offers more features, like support for larger hard drives and faster boot times.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Legacy BIOS&lt;/strong&gt;: An older firmware standard, still used in some cases, particularly for older hardware that doesn’t support UEFI.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can check this in the Boot Mode parameter of the AMI. This parameter can have one of three values: &lt;code&gt;uefi&lt;/code&gt;, &lt;code&gt;legacy-bios&lt;/code&gt;, or &lt;code&gt;uefi-preferred&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If the value is empty, the instance will use the default boot mode for the selected instance type.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Graviton instance types&lt;/strong&gt;: Use UEFI by default.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Intel and AMD instance types&lt;/strong&gt;: Use Legacy BIOS by default.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The firmware performs its Power-On Self-Test (POST), it checks essential hardware components like the CPU, memory, storage devices, and other basic functionalities to ensure they're working correctly.&lt;/p&gt;
&lt;p&gt;During POST, the firmware also establishes the boot device order. In EC2, this typically prioritizes the EBS root volume or instance store volume where the AMI is located. The firmware then locates the Master Boot Record (MBR) or GUID Partition Table (GPT) on the boot device to find the bootloader.&lt;/p&gt;
&lt;h2 id="boot-loaders"&gt;Boot Loaders&lt;/h2&gt;
&lt;p&gt;After the firmware completes its POST, it detects the bootloader, a program responsible for loading the operating system into memory. The bootloader is typically located on the root device where the system image is installed.&lt;/p&gt;
&lt;p&gt;GRUB is one of the most common bootloaders used in Linux. It allows you to select from multiple kernel versions. However, not all AMIs use GRUB. Some might use simpler bootloaders that automatically load the default kernel without giving you a choice.&lt;/p&gt;
&lt;p&gt;If your AMI uses the GRUB bootloader, you can access it through the EC2 serial console.&lt;/p&gt;
&lt;p&gt;Once the bootloader is detected, it loads the Linux kernel, the core operating system, into memory.&lt;/p&gt;
&lt;h2 id="kernel-loading"&gt;Kernel Loading&lt;/h2&gt;
&lt;p&gt;At first, when the kernel is loaded, it doesn’t know how to interact with storage devices or file systems.&lt;/p&gt;
&lt;p&gt;To fix this, the kernel loads a temporary file system, either &lt;code&gt;initrd&lt;/code&gt; or &lt;code&gt;initramfs&lt;/code&gt; (a more advanced version). These contain the essential drivers needed to access hard drives, initialize hardware, and mount the root file system, which contains the core files necessary for the operating system to boot. The bootloader also passes kernel parameters (like root device location) that were configured in the AMI or instance metadata.&lt;/p&gt;
&lt;p&gt;The kernel allocates memory for itself and the initial RAM disk. At this stage, the kernel also initializes basic hardware drivers for virtualized components like the Xen or Nitro network and storage interfaces, allowing it to communicate with AWS infrastructure.&lt;/p&gt;
&lt;h2 id="service-initialization-with-init-and-systemd"&gt;Service Initialization with init and systemd&lt;/h2&gt;
&lt;p&gt;Once the root file system is mounted, the kernel starts the first user-space program, called &lt;code&gt;init&lt;/code&gt;. This program is responsible for setting up and managing all the necessary services and processes to get the system running smoothly.&lt;/p&gt;
&lt;p&gt;In older systems, &lt;code&gt;init&lt;/code&gt; starts services sequentially, one after another, based on a series of shell scripts located in directories like &lt;code&gt;/etc/init.d/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, modern systems use &lt;code&gt;systemd&lt;/code&gt;, a more advanced &lt;code&gt;init&lt;/code&gt; system that can start services in parallel. &lt;code&gt;systemd&lt;/code&gt; uses unit files, which are located in directories like &lt;code&gt;/etc/systemd/system/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;They handle essential services like networking, logging, and device management.&lt;/p&gt;
&lt;p&gt;Key boot-time services include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Network initialization&lt;/strong&gt;: Virtual network interfaces come online and acquire IP addresses via DHCP&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Time synchronization&lt;/strong&gt;: NTP or chrony services start to sync with AWS time servers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storage mounting&lt;/strong&gt;: Additional EBS volumes get attached and mounted according to the instance's block device mapping&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Instance metadata access&lt;/strong&gt;: The metadata service (169.254.169.254) becomes available for the instance to query its configuration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;During service initialization, cloud-init runs and executes your user-data scripts (if configured). These scripts are an important part of instance configuration.&lt;/p&gt;
&lt;p&gt;You can view the system and boot logs from the EC2 console using the Instance System Log or Screenshot options. These are useful tools for debugging when an EC2 instance fails to start.&lt;/p&gt;
&lt;h2 id="user-environment"&gt;User Environment&lt;/h2&gt;
&lt;p&gt;After the core services are up, the system either displays a graphical login screen (GUI) or a text-based login prompt, depending on the system configuration. Once you log in, you can access the operating system and start using it.&lt;/p&gt;
&lt;p&gt;I would love to hear your feedback in the comments below!&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Understanding AWS Data Transfer Costs</title><link href="https://cloudwithalon.com/writing/understanding-aws-data-transfer-costs/" rel="alternate"/><published>2024-11-18T00:00:00+00:00</published><updated>2024-11-18T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-11-18:/writing/understanding-aws-data-transfer-costs/</id><summary type="html">&lt;p&gt;Explore AWS data transfer costs and discover strategies for optimizing expenses across various scenarios and services&lt;/p&gt;</summary><content type="html">&lt;p&gt;Data transfer costs are often overlooked when developing AWS cloud cost strategies.&lt;/p&gt;
&lt;p&gt;Most engineers focus primarily on optimizing storage and compute capacity, assuming that's sufficient for maximum savings. However, data transfer costs can be significant, because AWS's billing for data transfer is complex and opaque.&lt;/p&gt;
&lt;p&gt;The lack of transparency makes it difficult to track and understand, causing many customers to miss opportunities for potential savings.&lt;/p&gt;
&lt;p&gt;This article explains the general billing principles and provides optimization tips for AWS data transfer.&lt;/p&gt;
&lt;p&gt;There are four main ways data can be transferred in AWS:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Transfer into AWS (Ingress)&lt;/strong&gt;: Data coming from the internet into AWS.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Transfer within AWS&lt;/strong&gt;: Data transferred within AWS, such as between different AWS services.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Transfer out of AWS (Egress)&lt;/strong&gt;: Data transferred from AWS to the internet.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Transfer between AWS and On-Premises&lt;/strong&gt;: Data transferred between AWS and your on-premises infrastructure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;AWS charges these data transfers based on factors such as region, availability zones, service, data transfer volume, and applicable taxes.&lt;/p&gt;
&lt;h2 id="data-transfer-into-aws"&gt;Data Transfer into AWS&lt;/h2&gt;
&lt;p&gt;AWS does not charge for inbound data. This applies to traffic coming into AWS, whether from the internet or your on-premises network.&lt;/p&gt;
&lt;p&gt;Instead, the requester (e.g., the user or system initiating the connection) may incur charges based on the medium they use to connect to AWS, such as data packages, ISP fees, or VPN costs.&lt;/p&gt;
&lt;p&gt;But here's the twist: Communication is always two-way.&lt;/p&gt;
&lt;p&gt;When AWS sends a response to the requestor, that outbound traffic is subject to charges (data transfer out of AWS). We’ll cover these charges in more detail in the next sections.&lt;/p&gt;
&lt;h2 id="data-transfer-within-aws"&gt;Data Transfer within AWS&lt;/h2&gt;
&lt;p&gt;AWS has over 200 services, and many of them can communicate with each other. Data transfer within AWS typically happens in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A workload making requests to AWS services. (e.g., an app running in EC2 instance accessing S3)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;One AWS service making requests to another AWS service. (e.g., Lambda accessing DynamoDB)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Charges for data transfer within AWS depend on the specific scenario and location of the resources. Let’s look at different situations:&lt;/p&gt;
&lt;h3 id="data-transfer-within-aws-in-same-region"&gt;Data Transfer within AWS in Same Region&lt;/h3&gt;
&lt;p&gt;When data is transferred within the same region, you’ll typically incur lower charges than for cross-region data transfer. Here are some key points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same Availability Zone with Private IPv4 and IPv6&lt;/strong&gt;: Data transfer between compute resources like EC2 or containers within the same Availability Zone (AZ) using private IPv4 or v6 is free.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same Availability Zone with Public IP and Elastic Ip&lt;/strong&gt;: When data is transferred using Public IP or Elastic IP, even within the same AZ and VPC, data transfer costs apply for both sending(egress) and receiving(ingress).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same Availability Zone with Different VPC:&lt;/strong&gt; Data transfer is free if traffic stays within the same AZ and uses private IPs over VPC Peering.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Different Availability Zone&lt;/strong&gt;: Data transfer between different AZs and VPCs, regardless of the network type(private or public), incurs charges for both ingress and egress. This type of cost is called Bi-direction data transfer.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;For example&lt;/strong&gt;, if an EC2 instance makes a request to an RDS instance in a different AZ, you will incur charges for: EC2 data out, RDS data in, RDS data out, and EC2 data in.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Load Balancer&lt;/strong&gt;: Data transfer between a Classic Load Balancer or an Application Load Balancer and EC2 instances across AZs within the same region is free.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi-AZ Replication&lt;/strong&gt;: Data transfer between multiple AZs for replication purposes, such as with Amazon RDS, is free within the same region.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NAT Gateway&lt;/strong&gt;: When a compute resource (e.g., EC2 instance or container) accesses AWS services like S3, SQS, SNS, or ECR through a NAT Gateway, there are charges for both the NAT Gateway and the data processed by the gateway before being sent to the destination. However, accessing these services via a Public IP or VPC Endpoint is free, with costs only applying for the Public IP or VPC Endpoint usage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;CloudFront&lt;/strong&gt;: Data fetches from origin like EC2, S3, or ELB to CloudFront is free.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Route53&lt;/strong&gt;: The Alias record type in Amazon Route 53 is free of charge, unlike other record types such as CNAME, A, and AAAA, which incur costs for DNS queries.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="data-transfer-within-aws-in-different-region"&gt;Data Transfer within AWS in Different Region&lt;/h3&gt;
&lt;p&gt;Data transfer across regions using VPC Peering or Transit Gateway is charged based on the source region. For example, data transfer from US West (N. California) costs $0.02/GB, from Ohio costs $0.01/GB, while transfers from US East (Verizon) - Nashville and Tampa are free.&lt;/p&gt;
&lt;p&gt;If you pull data from an S3 bucket located in the US West (N. California) region, the cost will be $0.02/GB.&lt;/p&gt;
&lt;h2 id="data-transfer-out-of-aws"&gt;Data transfer out of AWS&lt;/h2&gt;
&lt;p&gt;AWS provides 100 GB of free data transfer from AWS to the internet each month for all customers. This allowance applies across all services and regions, excluding China and AWS GovCloud.&lt;/p&gt;
&lt;p&gt;Any data transfer beyond this 100 GB is charged based on the service, region, and amount of data transferred.&lt;/p&gt;
&lt;h2 id="data-transfer-between-aws-and-on-premises"&gt;Data Transfer between AWS and On-Premises&lt;/h2&gt;
&lt;p&gt;You can connect to AWS from on-premises using either site-to-site VPN or direct connect.&lt;/p&gt;
&lt;h3 id="site-to-site-vpn"&gt;Site-to-Site VPN&lt;/h3&gt;
&lt;p&gt;When you set up a Site-to-Site VPN connection, AWS charges for the time the VPN connection is active, based on hourly rates.&lt;/p&gt;
&lt;p&gt;In addition, you'll incur standard AWS data transfer charges for any data sent over the VPN connection.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Data transfer into AWS is free.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data transfer out from AWS is charged based on the amount of data transferred from AWS to your on-premises infrastructure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, if you transfer 1,000 GB into AWS and 500 GB out, you'll only be charged for the 500 GB transferred out of AWS.&lt;/p&gt;
&lt;h3 id="direct-connect"&gt;Direct Connect&lt;/h3&gt;
&lt;p&gt;AWS Direct Connect charges are based on three main factors:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Transfer Capacity&lt;/strong&gt;: The maximum transfer rate of the connection.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Port Speed and Port Hours&lt;/strong&gt;: The speed of the connection and the duration for which the port is provisioned.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Connection Type&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dedicated Connection&lt;/strong&gt;: A physical connection between your on-premises network and AWS.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hosted Connection&lt;/strong&gt;: A logical connection provided by an AWS Direct Connect partner, typically more affordable than dedicated connections.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Like Site-to-site VPN, data transfer into AWS via Direct Connect is free.&lt;/p&gt;
&lt;h2 id="ways-to-save-on-data-transfer-in-aws"&gt;Ways to Save on Data Transfer in AWS&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use VPC Endpoints&lt;/strong&gt;: Avoid routing traffic over the internet when accessing AWS services. VPC Endpoints are generally more cost-effective, reduce latency, and keep traffic within AWS's private network.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Avoid Public IP or Elastic IP&lt;/strong&gt;: Even when transferring data within the same Availability Zone (AZ) and region, using Public IPs or Elastic IPs incurs charges. Stick to private IPs to avoid extra costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Direct Connect for On-Premises Transfers&lt;/strong&gt;: For transferring data to on-premises infrastructure, consider using Direct Connect. This option is more cost-effective than using the internet for large-scale data transfer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stay Within the Same AZ When Possible&lt;/strong&gt;: While multiple AZs provide high availability, keeping your resources within the same AZ can save costs on cross-AZ data transfer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Avoid Cross-Region Data Transfers&lt;/strong&gt;: Transferring data between AWS regions typically incurs additional charges. Only transfer data across regions if it's absolutely necessary for your business requirements.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Avoid NAT Gateways When Possible&lt;/strong&gt;: While NAT Gateways provide secure access to AWS services, they come with high data processing costs. Instead, use custom NAT Instance where possible to reduce costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Consider Amazon CloudFront&lt;/strong&gt;: When transferring data to internet users, Amazon CloudFront is usually cheaper than transferring data directly from AWS regions. It also reduces latency for global content delivery.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Choose Cost-Effective Regions&lt;/strong&gt;: Data transfer pricing varies by region. If you don’t have strict compliance or latency requirements, choose the most cost-effective region for your workloads.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use S3 Requester Pays&lt;/strong&gt;: If you store large objects in Amazon S3 and other AWS accounts need to access them, you can enable the Requester Pays feature. This feature shifts the cost of downloading the objects from the bucket owner to the requester. The requester must be a valid AWS account holder (not an anonymous user) in order to incur the download costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sign Up for the AWS Data Transfer Private Pricing Program&lt;/strong&gt;: If your organization has significant data transfer needs, enroll in the AWS Data Transfer Private Pricing Program to negotiate better rates based on your usage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Monitoring Tools&lt;/strong&gt;: Leverage tools like AWS Cost &amp;amp; Usage Reports or third-party monitoring tools to track your data transfer costs and identify areas where you can optimize.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope this article was helpful to you. Please share your feedback in the comments below.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Scanning Vulnerabilities on EC2 Instance Using AWS Inspector</title><link href="https://cloudwithalon.com/writing/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/" rel="alternate"/><published>2024-10-31T00:00:00+00:00</published><updated>2024-10-31T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-10-31:/writing/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/</id><summary type="html">&lt;p&gt;Learn how to scan EC2 instances for vulnerabilities using AWS Inspector, generate reports, and explore AWS's vulnerability management tools&lt;/p&gt;</summary><content type="html">&lt;p&gt;Protecting cloud resources is a top priority for every organization. To help with this, AWS comes with another security tool: AWS Inspector.&lt;/p&gt;
&lt;p&gt;This vulnerability management tool automatically discovers your workloads and continuously scans for software and network vulnerabilities.&lt;/p&gt;
&lt;p&gt;It supports EC2 instances, container images in ECR (Elastic Container Registry), and Lambda functions.&lt;/p&gt;
&lt;p&gt;In this post, I will focus on scanning EC2 instances, generating reports, and exploring additional features.&lt;/p&gt;
&lt;h2 id="my-lab-environment-setup"&gt;My Lab Environment Setup&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;EC2 Instance&lt;/strong&gt;: RockyLinux 9.4 and AmazonLinux 2023 using t3a.micro instance type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AWS Inspector&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By default, AWS Inspector will not be enabled. You can follow the &lt;a href="https://docs.aws.amazon.com/inspector/latest/user/getting_started_tutorial.html" rel="nofollow" target="_blank"&gt;AWS Documentation&lt;/a&gt; to enable it.&lt;/p&gt;
&lt;p&gt;After activating AWS Inspector, the first step I took was to choose agent-based scanning for my EC2 resources.&lt;/p&gt;
&lt;p&gt;AWS Inspector offers two scanning types: agent-based and agentless. To use both agentless and agent-based scanning, select Hybrid in the scan mode section of your account settings.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector scan mode configuration" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/fb97965f-195c-48f9-9a65-1c1b40d0f837.webp"&gt;&lt;/p&gt;
&lt;p&gt;For agent-based scanning, it uses the SSM(Systems Manager) agent to scan resources. If your EC2 instance has the SSM agent installed, no further action is required; it will automatically install the Inspector plugin.&lt;/p&gt;
&lt;p&gt;For agentless scanning, AWS first creates a snapshot of the EBS volume, scans it, generates findings, and then deletes the snapshot.&lt;/p&gt;
&lt;h2 id="scanning-ec2-instance"&gt;Scanning EC2 Instance&lt;/h2&gt;
&lt;p&gt;I created a EC2 Instance of Rocky Linux 9.4 image.&lt;/p&gt;
&lt;p&gt;As soon as I configured SSM, my instances appeared in the AWS Inspector dashboard.&lt;/p&gt;
&lt;p&gt;The scanning process took about 15 minutes, and once completed, the inventory was filled with vulnerabilities.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector vulnerability scan results" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/8e86bc76-4c1c-4035-912b-7b274a4a7882.webp"&gt;&lt;/p&gt;
&lt;p&gt;Before patching the server, I counted the total vulnerabilities. The result was:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Total: 39&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector vulnerability count before patching" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/13d8b319-2f70-479e-939e-16005453138d.webp"&gt;&lt;/p&gt;
&lt;h2 id="observing-aws-inspector-findings"&gt;Observing AWS Inspector Findings&lt;/h2&gt;
&lt;p&gt;AWS Inspector sources vulnerability data from the &lt;a href="https://nvd.nist.gov/vuln" rel="nofollow" target="_blank"&gt;National Vulnerability Database (NVD)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It analyzes NVD data and scores, assessing EC2 Instnace's criticality, such as network exposure, to provide a custom score.&lt;/p&gt;
&lt;p&gt;For example, if the NVD assigns a risk score of 9 to a vulnerability, but your EC2 Instance is isolated and not exposed to the internet, AWS Inspector may assign a lower score for that vulnerability.&lt;/p&gt;
&lt;p&gt;This is helpful because it allows organizations to focus on remediating the most critical issues first, reducing unnecessary panic.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector vulnerability details and remediation" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/91cdce9c-7310-4c86-9adf-9ee93598b75a.webp"&gt;&lt;/p&gt;
&lt;p&gt;The vulnerability details were comprehensive, similar to those provided by other reputable third-party vendors. It included remediation commands to execute, along with the current and fixed versions, CVE IDs, score, instance details and more.&lt;/p&gt;
&lt;p&gt;For some vulnerabilities, it didn’t provide specific remediation steps but offered a good summary with recommendations.&lt;/p&gt;
&lt;p&gt;After that, I applied a patch to the server.&lt;/p&gt;
&lt;p&gt;After patching and rebooting, I waited for the next scan to occur. The time interval for each scan of my EC2 Instance was 38 minutes.&lt;/p&gt;
&lt;p&gt;AWS Inspector automatically initiates a scan when a new instance is launched, when new or existing packages are installed, or when new vulnerabilities are added to its database.&lt;/p&gt;
&lt;p&gt;Although AWS Inspector scans continuously, I did not find an option to initiate on-demand scans.&lt;/p&gt;
&lt;p&gt;I was impressed to see that the active vulnerabilities decreased to 9 after the patch.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector vulnerability count after patching" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/d7a1b1ef-f764-41b5-bdca-68476741b0e2.webp"&gt;&lt;/p&gt;
&lt;h2 id="aws-inspector-deep-inspection"&gt;AWS Inspector Deep Inspection&lt;/h2&gt;
&lt;p&gt;AWS Inspector also offers deep inspection for Linux EC2 instances. During this scan, it detects package vulnerabilities for &lt;a href="https://docs.aws.amazon.com/inspector/latest/user/supported.html#supported-programming-languages-deep-inspection" rel="nofollow" target="_blank"&gt;supported application programming language&lt;/a&gt; packages.&lt;/p&gt;
&lt;p&gt;Below is the vulnerability detail for the Python 3 library found on my server, along with the remediation steps.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector Python library vulnerability details" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/ae8b583b-6efe-4345-9b05-a15ec3fc1c62.webp"&gt;&lt;/p&gt;
&lt;p&gt;Another feature is the ability to add custom paths for scanning.&lt;/p&gt;
&lt;p&gt;You can specify up to 5 custom paths, with each path required to be between 1 and 256 characters long.&lt;/p&gt;
&lt;p&gt;This means you cannot insert paths like &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;/var/www/html/projects/2024/client-portfolio/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector custom path configuration" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/2766b569-e3b6-4a9b-b28c-4b01a6ab56f6.webp"&gt;&lt;/p&gt;
&lt;h2 id="monitoring-performance"&gt;Monitoring Performance&lt;/h2&gt;
&lt;p&gt;I monitored the server while AWS Inspector was scanning to check performance and resource utilization.&lt;/p&gt;
&lt;p&gt;I used a t3a.micro instance (1 GB memory and 2 vCPUs) and did not observe heavy resource consumption from Inspector.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector resource utilization monitoring" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/8939f6a3-a0a4-45f4-953f-78947ccfdd68.webp"&gt;&lt;/p&gt;
&lt;p&gt;While memory usage appeared above average, it’s important to consider that the server was also running multiple different workloads.&lt;/p&gt;
&lt;h2 id="cost-consideration"&gt;Cost Consideration&lt;/h2&gt;
&lt;p&gt;AWS Inspector offers a 15-day free trial, after which you pay based on usage.&lt;/p&gt;
&lt;p&gt;Charges are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For agent-based scanning, the cost is $1.2528 per instance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For agentless scanning, the cost is $1.7496 per instance.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/inspector/pricing/" rel="nofollow" target="_blank"&gt;Learn more about pricing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;AWS recommends using Hybrid scanning, but for cost optimization I prefer agent-based since it is cheaper.&lt;/p&gt;
&lt;p&gt;With agentless, you incur additional costs for the snapshots AWS Inspector creates during the scan.&lt;/p&gt;
&lt;p&gt;To further reduce costs, you can exclude unnecessary EC2 instances from scanning by implementing the &lt;code&gt;InspectorEc2Exclusion&lt;/code&gt; tag.&lt;/p&gt;
&lt;p&gt;Another great feature of AWS Inspector is the cost usage dashboard.&lt;/p&gt;
&lt;p&gt;This provides monthly projected costs and the cost details for scanned resources across EC2 instances, ECR, and Lambda.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Inspector cost usage dashboard" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/935a78cf-2020-4093-8c99-3ff55121fa76.webp"&gt;&lt;/p&gt;
&lt;h2 id="additional-takeaway"&gt;Additional Takeaway&lt;/h2&gt;
&lt;p&gt;AWS Inspector also allows you to scan for CIS benchmarks for your EC2 instances.&lt;/p&gt;
&lt;p&gt;You can set up notifications or automation using AWS EventBridge for each new vulnerability detected.&lt;/p&gt;
&lt;p&gt;This can be easily implemented across your entire AWS organization accounts.&lt;/p&gt;
&lt;p&gt;Finally, I tried Amazon Inspector on a vanilla Amazon Linux 2023 and was surprised that it did not report any vulnerabilities.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Amazon Linux 2023 vulnerability scan results" src="/images/post/scanning-vulnerabilities-on-ec2-instance-using-aws-inspector/3aec5e01-5cf9-42ad-9f74-494acb09e45b.webp"&gt;&lt;/p&gt;
&lt;p&gt;Does this mean that this image is completely free of vulnerabilities?&lt;/p&gt;
&lt;p&gt;Let me know your thoughts in the comment below.&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Choosing Right AWS EC2 Dynamic Autoscaling Policies</title><link href="https://cloudwithalon.com/writing/choosing-right-aws-ec2-dynamic-autoscaling-policies/" rel="alternate"/><published>2024-10-25T00:00:00+00:00</published><updated>2024-10-25T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-10-25:/writing/choosing-right-aws-ec2-dynamic-autoscaling-policies/</id><summary type="html">&lt;p&gt;Learn about simple, step, and target-tracking scaling policies, their use cases, and setup strategies. Ideal for managing aws autoscaling group&lt;/p&gt;</summary><content type="html">&lt;p&gt;AWS offers three types of auto scaling policies for EC2 instances: dynamic, predictive, and scheduled.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Predictive&lt;/strong&gt; scaling uses AI to forecast capacity needs based on historical data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scheduled&lt;/strong&gt; scaling is similar to a cron job, adjusting capacity at predetermined time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, &lt;strong&gt;Dynamic&lt;/strong&gt; scaling includes three sub-types: simple, step, and target-tracking. While they sound straightforward, choosing the right one can be challenging.&lt;/p&gt;
&lt;p&gt;In this article, I'll explore each dynamic scaling policy, discuss their use cases, and clarify when to use each one.&lt;/p&gt;
&lt;h2 id="my-lab-environment-setup"&gt;My Lab Environment Setup&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Three Auto Scaling Groups&lt;/strong&gt;: One for each scaling policy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ec2 Instance&lt;/strong&gt;: Amazon Linux 2023, Spot Instances of type t3a.micro.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Monitoring and Alarm&lt;/strong&gt;: CloudWatch alarms based on the AutoScalingGroup's Average CPU Utilization.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Load Testing&lt;/strong&gt;: Using a third-party tool called &lt;code&gt;Stress&lt;/code&gt; to generate CPU load for demonstration, and manually changing the CloudWatch alarm state to &lt;code&gt;ALARM&lt;/code&gt; using the AWS CLI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Infrastructure as Code&lt;/strong&gt;: &lt;a href="https://github.com/alonshrestha/labs/tree/main/playground/aws-autoscale-dynamic-scaling-policies" rel="nofollow" target="_blank"&gt;Project source code&lt;/a&gt; is available in both CloudFormation and Terraform.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="simple-scaling"&gt;Simple Scaling&lt;/h2&gt;
&lt;p&gt;This is the most basic and oldest option offered by AWS.&lt;/p&gt;
&lt;p&gt;The workflow for this policy is straightforward. If a condition is met, then a specific action is taken, similar to a basic if-else statement.&lt;/p&gt;
&lt;p&gt;To use it, you first need to create CloudWatch alarms that trigger the policy for scaling in and out. You need to create these alarms yourself and link them to the scaling policy.&lt;/p&gt;
&lt;p&gt;You can choose custom metric for the alarms, such as memory usage, network traffic, or even SQS queue length. In this case, I chose the Average CPU Utilization of the same Auto Scaling Group where this policy is attached.&lt;/p&gt;
&lt;p&gt;One important point to note is that there is a strictly enforced &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scaling-cooldowns.html" rel="nofollow" target="_blank"&gt;cooldown period&lt;/a&gt;. After scaling in or out, the autoscaling group must wait for this cooldown period to expire. During this period, the autoscaling group cannot add or remove instances, and any triggers that occur will be rejected and missed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Let's build this.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Scenario: I want to scale up to 2 instances when the average CPU utilization exceeds 50% and scale down to 1 instance when it drops below 50%.&lt;/p&gt;
&lt;p&gt;For the &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html#as-scaling-adjustment"&gt;adjustment type&lt;/a&gt;, I’ve chosen &lt;code&gt;ExactCapacity&lt;/code&gt;, but &lt;code&gt;ChangeInCapacity&lt;/code&gt; and &lt;code&gt;PercentChangeInCapacity&lt;/code&gt; are also the options.&lt;/p&gt;
&lt;p&gt;I've set up 2 policies scale-in and scale-out. For this I also have created 2 alarms for each with 50% threshold.&lt;/p&gt;
&lt;p&gt;Scaling Policy:&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Auto Scaling simple scaling policy configuration" src="/images/post/choosing-right-aws-ec2-dynamic-autoscaling-policies/d743e056-f3bc-46aa-9304-6cdc0348edb9.webp"&gt;&lt;/p&gt;
&lt;p&gt;CloudWatch Alarm:&lt;/p&gt;
&lt;p&gt;&lt;img alt="CloudWatch alarm configuration for Auto Scaling" src="/images/post/choosing-right-aws-ec2-dynamic-autoscaling-policies/61780c8a-584d-4232-872b-570d4020e209.webp"&gt;&lt;/p&gt;
&lt;h2 id="step-scaling"&gt;Step Scaling&lt;/h2&gt;
&lt;p&gt;I see this as an upgraded version of simple scaling. Instead of a basic 'if-else' statement, step scaling is a concept of an 'if-elseif-else' structure.&lt;/p&gt;
&lt;p&gt;Similarly, to use it, you need to create CloudWatch alarms and link them to the scaling policy yourself.&lt;/p&gt;
&lt;p&gt;Again, I chose the Average CPU Utilization of the same Auto Scaling Group where this policy is attached.&lt;/p&gt;
&lt;p&gt;Unlike simple scaling, it scales immediately without waiting for the cooldown period to end. Instead, it uses an &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-default-instance-warmup.html" rel="nofollow" target="_blank"&gt;instance warmup period&lt;/a&gt;, which allows new instances to stabilize before they start reporting metrics in CloudWatch for monitoring.&lt;/p&gt;
&lt;p&gt;When configuring, it’s important to understand the workflow of step adjustments. You get two bounds interval: the lower interval(minimum threshold) and the upper interval(maximum threshold) of a specific metric.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Now, let’s consider a scenario where I want to set an average CPU alarm at 25%.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here’s how I can configure the step adjustments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If the alarm threshold is above 25% and below 45%, set the capacity to 2.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the alarm reaches between 45% and 65%, set the capacity to 3.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the alarm goes above 65%, set the capacity to 4.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The step adjustments would look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;StepAdjustments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;MetricIntervalLowerBound&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;0&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;MetricIntervalUpperBound&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;20&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;ScalingAdjustment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;2&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;MetricIntervalLowerBound&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;20&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;MetricIntervalUpperBound&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;40&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;ScalingAdjustment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;3&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;MetricIntervalLowerBound&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;40&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;ScalingAdjustment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;#39;4&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To understand how bounds work, simply add bound values to the alarm metrics. The alarm is set at 25%, with a lower bound of 0 and an upper bound of 20. This means that the effective range for scaling adjustments is from 25% to 45%.&lt;/p&gt;
&lt;p&gt;Note that in the last adjustment, I’ve used only a lower bound of 40 without an upper bound. This means that if the CPU usage exceeds 65%, the capacity adjustment will be 4, regardless of how high it goes (e.g., above 65%)&lt;/p&gt;
&lt;p&gt;Scaling Policy:&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Auto Scaling step scaling policy setup" src="/images/post/choosing-right-aws-ec2-dynamic-autoscaling-policies/af205703-db08-4c37-b05c-b82753ad049c.webp"&gt;&lt;/p&gt;
&lt;p&gt;CloudWatch Alarm:&lt;/p&gt;
&lt;p&gt;&lt;img alt="CloudWatch alarm for step scaling policy" src="/images/post/choosing-right-aws-ec2-dynamic-autoscaling-policies/bdad013b-f35c-4af7-8b00-c26368c6dab3.webp"&gt;&lt;/p&gt;
&lt;h2 id="target-tracking-scaling"&gt;Target Tracking Scaling&lt;/h2&gt;
&lt;p&gt;This is the easiest scaling policy to use because it operates automatically.&lt;/p&gt;
&lt;p&gt;Simply select a metric and provide a target value you want to maintain. The policy will automatically adjust instance capacity to keep you at your target value.&lt;/p&gt;
&lt;p&gt;It includes &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-target-tracking.html#target-tracking-choose-metrics" rel="nofollow" target="_blank"&gt;built-in CloudWatch metrics&lt;/a&gt; that can automatically create alarms linked to the scaling policy. Just ensure you set appropriate min and max capacity values in policy.&lt;/p&gt;
&lt;p&gt;You can also create custom CloudWatch alarms using the AWS CLI or SDK.&lt;/p&gt;
&lt;p&gt;One important thing to consider is that you need to enable the scale-in feature in your scaling policy; it isn’t enabled by default.&lt;/p&gt;
&lt;p&gt;If it’s not enabled, the policy will only add capacity and won’t remove instances when utilization falls below the threshold, which can lead to increased costs.&lt;/p&gt;
&lt;p&gt;Similarly, scaling capacity is not affected by the cooldown period; instead, it relies on instance warmup.&lt;/p&gt;
&lt;p&gt;Here’re some workflow on how automatic scaling occurs with instance warmup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If you have 4 active instances and 2 are still warming up, the policy will only add new instances if the average utilization of the 2 active instances is higher than the threshold.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Scale in, or removing instances won't happen if the group has instances in the warm up state.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-default-instance-warmup.html#scaling-performance-considerations" rel="nofollow" target="_blank"&gt;You can find more information here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Let’s take a scenario.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I've an application that gets affected if the average CPU utilization exceeds 50%, so I want to maintain it at that level.&lt;/p&gt;
&lt;p&gt;I chose the built-in ASGAverageCPUUtilization metric provided by Target Tracking and set the target to 50%. Also, configured the min capacity to 1, desired capacity to 2, and max capacity to 4.&lt;/p&gt;
&lt;p&gt;This setup will automatically adjust the capacity to maintain my CPU utilization at 50%.&lt;/p&gt;
&lt;p&gt;Scaling Policy:&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Auto Scaling target tracking policy configuration" src="/images/post/choosing-right-aws-ec2-dynamic-autoscaling-policies/a9107c4e-8adb-4d0e-915c-a6681c86802a.webp"&gt;&lt;/p&gt;
&lt;p&gt;CloudWatch Alarm:&lt;/p&gt;
&lt;p&gt;&lt;img alt="CloudWatch alarm for target tracking scaling" src="/images/post/choosing-right-aws-ec2-dynamic-autoscaling-policies/695cc5f5-0669-446b-aca9-375070f77475.webp"&gt;&lt;/p&gt;
&lt;h2 id="use-case"&gt;Use Case&lt;/h2&gt;
&lt;p&gt;Each scaling policy has its own features, and with proper knowledge, you can implement any of these in various real-world scenarios.&lt;/p&gt;
&lt;h3 id="simple-scaling_1"&gt;Simple Scaling&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complexity&lt;/strong&gt;: Straightforward and simple, but offers less flexibility.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;: Ideal for applications with consistent and predictable traffic patterns.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="step-scaling_1"&gt;Step Scaling&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complexity&lt;/strong&gt;: More complex; requires defining multiple thresholds and actions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;: Suitable for fluctuating traffic that benefits from incremental adjustments rather than large, direct changes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="target-tracking-scaling_1"&gt;Target Tracking Scaling&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complexity&lt;/strong&gt;: Easy to set up.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;: Best for applications with unpredictable traffic patterns, allowing for automatic adjustments.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="consideration"&gt;Consideration&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Always test and set the optimal min and max capacity for your auto scaling group. This helps prevent underutilization or over-provisioning, allowing for cost savings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can use multiple scaling policies within the same group for more flexibility, but they can conflict with each other. Adjustments may be needed when adding or removing policies to avoid issues.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AWS recommends using step or target tracking scaling for more flexibility instead of cooldown periods with simple scaling. However, if you prefer simplicity, simple scaling is still an option.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can create custom metrics for scaling, and some best common metric choices are cpu usage, memory usage, network traffic, and ALB request count.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Remember that CloudWatch alarms only trigger scaling policies when their thresholds are met. The scaling policy defines how much to scale and how many instances to add or remove.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To prevent manual intervention, prefer target tracking. It is AWS's managed option for automatic adjustments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AWS recommends using metrics that update every minute for quicker response to usage changes. By default, Amazon EC2 metrics update every five minutes, but you can change this frequency, which may increase costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up monitoring for your Auto Scaling Group and configure activity events for alerts and notifications.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope you enjoyed the post, and I would love to hear your feedback in the comments below!&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;- Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Building High-Resilient AWS VPC Architecture</title><link href="https://cloudwithalon.com/writing/building-high-resilient-aws-vpc-architecture/" rel="alternate"/><published>2024-10-08T18:15:00+00:00</published><updated>2024-10-08T18:15:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2024-10-08:/writing/building-high-resilient-aws-vpc-architecture/</id><summary type="html">&lt;p&gt;Learn to build a high-resilient AWS VPC architecture focused on security, scalability, and cost efficiency for deploying PaaS or IaaS services&lt;/p&gt;</summary><content type="html">&lt;p&gt;Before deploying PaaS or IaaS services, you must have a configured Virtual Private Cloud (VPC) in AWS.&lt;/p&gt;
&lt;p&gt;AWS provides a default VPC with an internet gateway for convenience. While this setup is easy to use, it may lead to higher costs and increased security risks.&lt;/p&gt;
&lt;p&gt;For enhanced architecture, security, and cost efficiency, you can create a custom VPC to your requirements.&lt;/p&gt;
&lt;p&gt;This blog post outlines my minimal and preferred VPC setup for any new projects I undertake, featuring a highly resilient emphasizing security and cost efficiency.&lt;/p&gt;
&lt;p&gt;&lt;img alt="High-resilient AWS VPC architecture diagram" src="/images/post/building-high-resilient-aws-vpc-architecture/2dba1969-3cf8-4375-84e0-2129c2ea795c.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/alonshrestha/aws-vpc-resilient-architecture" rel="nofollow" target="_blank"&gt;Project Source Code&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="high-resiliency"&gt;High Resiliency&lt;/h2&gt;
&lt;p&gt;The rule of thumb for high availability is to have at least two subnets in different AZs for resource distribution. Additionally, including one AZ for backup ensures compliance and supports AWS resources that may not be available in every AZ.&lt;/p&gt;
&lt;h3 id="subnets"&gt;Subnets&lt;/h3&gt;
&lt;p&gt;I chose to create subnets in three different AZs, with one designated for backup.&lt;/p&gt;
&lt;p&gt;The subnets are also grouped into three types of internet connectivity: Public, Private-NAT, and Private subnets.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Public Subnet&lt;/strong&gt;: Configured with an internet gateway, enabling direct internet access. Resources launched here receive public IP addresses, making it ideal for those needing a public endpoint.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Private Nat Subnet&lt;/strong&gt;: Configured with a NAT gateway, this setup allows resources to access the internet while remaining hidden from public view. It's ideal for resources that need internet access without being exposed publicly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Private Subnet&lt;/strong&gt;: Also known as an isolated subnet, it has no internet access. This setup is ideal for internal resources that do not require internet connectivity.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This architecture allows me to run small to medium-scale businesses.&lt;/p&gt;
&lt;p&gt;You can create subnets in all available AZs to increase resiliency. However, I found that this approach adds management complexity and potential costs issues.&lt;/p&gt;
&lt;h3 id="nat-gateway-and-internet-gateway"&gt;NAT Gateway and Internet Gateway&lt;/h3&gt;
&lt;p&gt;For the Internet Gateway, you don’t need to worry about resiliency. It provides high scalability, redundancy, and availability, all managed by AWS. One Internet Gateway can be shared by all public subnets within a VPC.&lt;/p&gt;
&lt;p&gt;However, in private NAT subnets, it's best to create a NAT Gateway for each subnet in each Availability Zone (AZ) to ensure high resiliency in production. If one AZ fails, the NAT Gateway in that AZ also becomes unavailable, potentially impacting availability. While this approach can be more expensive, it provides redundancy.&lt;/p&gt;
&lt;p&gt;For non-critical applications, you can create a single NAT gateway in one AZ and use it for subnets in other AZs, accepting the risk of a single point of failure. But this introduces additional costs due to cross-AZ data transfer.&lt;/p&gt;
&lt;h3 id="cidr-block"&gt;CIDR Block&lt;/h3&gt;
&lt;p&gt;It’s also important to consider CIDR range planning for future expansion without affecting existing configurations.&lt;/p&gt;
&lt;p&gt;I've created a VPC CIDR range of 10.0.0.0/16. In AWS, you can only create private networks using the ranges 10.x.x.x, 172.16.x.x, and 192.168.x.x, with sizes ranging from /16 to /28.&lt;/p&gt;
&lt;h2 id="security"&gt;Security&lt;/h2&gt;
&lt;p&gt;Security is crucial in networking; if your network is compromised, your entire infrastructure is at risk. In AWS VPC, you can simply manage security at the subnet level using Network ACLs.&lt;/p&gt;
&lt;p&gt;Network ACLs are stateless and consist of allow and deny rules. This means you must explicitly permit both inbound and outbound traffic for connections to be established.&lt;/p&gt;
&lt;p&gt;AWS lets you set rules numbered from 1 to 32766, with lower numbers taking priority. It's best to start numbering your rules from 100 so you can easily add more rules below 100 later.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Network ACL rule configuration example" src="/images/post/building-high-resilient-aws-vpc-architecture/314574f6-d159-4598-be2f-a187b0e957f1.webp"&gt;&lt;/p&gt;
&lt;p&gt;I've used rule number 3276 to allow 0.0.0.0/0, ensuring that other rules are positioned above it.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;📝 Note: 32766 is the maximum rule number, not the maximum number of rules you can add to an ACL. You can add up to 40 inbound and 40 outbound rules.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="cost-management"&gt;Cost Management&lt;/h2&gt;
&lt;p&gt;Knowing how &lt;a href="https://cloudwith.alon.com.np/optimizing-data-retrieval-from-dynamodb-using-boto3"&gt;data transfer influences your costs&lt;/a&gt; is vital when working with AWS.&lt;/p&gt;
&lt;h3 id="inbound-and-outbound-traffic"&gt;Inbound and Outbound Traffic&lt;/h3&gt;
&lt;p&gt;Inbound traffic to AWS is free, but outbound traffic from AWS to the internet incurs costs, so minimizing outbound data can reduce expenses.&lt;/p&gt;
&lt;h3 id="public-ip-and-elastic-ip"&gt;Public Ip and Elastic IP&lt;/h3&gt;
&lt;p&gt;Public subnets require public or Elastic IPs, which can be expensive, so it's best to limit their use and consider private subnets when possible.&lt;/p&gt;
&lt;h3 id="az-data-transfer"&gt;AZ Data Transfer&lt;/h3&gt;
&lt;p&gt;Data transfer between different availability zones (AZs) costs money, while transfers within the same AZ are free; therefore, keeping applications that frequently exchange data in the same AZ can save costs.&lt;/p&gt;
&lt;h3 id="utilizing-vpc-endpoints"&gt;Utilizing VPC Endpoints&lt;/h3&gt;
&lt;p&gt;Additionally, using AWS VPC endpoints allows you to transfer data between AWS services without going through the internet, which is more cost-effective, such as connecting EC2 instances to S3 or Systems Manager (SSM) or CloudWatch etc.&lt;/p&gt;
&lt;p&gt;You can access the project code &lt;a href="https://github.com/alonshrestha/aws-vpc-resilient-architecture" rel="nofollow" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I hope you enjoyed the post, and I would love to hear your feedback in the comments below!&lt;/p&gt;
&lt;p&gt;Thanks for reading,&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry><entry><title>Set Up Counter-Strike: Global Offensive Dedicated Server on AWS EC2 Instance</title><link href="https://cloudwithalon.com/writing/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/" rel="alternate"/><published>2020-11-28T00:00:00+00:00</published><updated>2020-11-28T00:00:00+00:00</updated><author><name>Alon Shrestha</name></author><id>tag:cloudwithalon.com,2020-11-28:/writing/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/</id><summary type="html">&lt;p&gt;Learn how to set up a dedicated CS:GO server on AWS EC2, customize game settings, and optimize performance for a seamless gaming experience&lt;/p&gt;</summary><content type="html">&lt;p&gt;It’s possible to host CS:GO on your own server, and the main benefit is a lower ping rate.&lt;/p&gt;
&lt;p&gt;You can have more control over the game and modify various settings like tick rate, game rules, map pool, plugins, custom skins and many more to make the game more enjoyable.&lt;/p&gt;
&lt;p&gt;Want to know how to do this all?&lt;/p&gt;
&lt;p&gt;This article covers step-by-step instructions on how to host CS:GO on AWS EC2 Instance.&lt;/p&gt;
&lt;p&gt;First step is to choose the server that meets your needs.&lt;/p&gt;
&lt;p&gt;For this tutorial, I used the &lt;strong&gt;t2.micro&lt;/strong&gt; instance with 40 GB EBS volume. This was sufficient for me to play a competitive match with my nine other friends.&lt;/p&gt;
&lt;p&gt;However, if you plan to host a server for more players, you may want to consider t3a.small, t3a.medium, or higher, depending on your needs.&lt;/p&gt;
&lt;h2 id="csgo-server-system-requirements"&gt;CS:GO Server System Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;RAM: 2 GB Minimum - 4 GB Maximum&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;CPUs: 2 Minimum&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Disk Space: 40 GB (Recommended)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bandwidth: Unlimited (Recommended)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Operating System: Linux (CentOS, Ubuntu)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Usually, CS:GO can be installed in 15 - 20 GB disk space but due to frequent game updates and space used by OS 40GB disk is recommended for optimal performance.&lt;/p&gt;
&lt;h2 id="setup-csgo-on-linuxubuntucentos"&gt;Setup CS:GO on Linux(Ubuntu/CentOS)&lt;/h2&gt;
&lt;p&gt;Launch an EC2 instance using either a CentOS or Ubuntu image. Log in to the server with a root user, then install the libraries that support SteamCMD.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: SteamCMD also known as steam console client is a command-line version of steam.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Install the necessary library package.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For Ubuntu:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;lib32gcc1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;For CentOS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;yum&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;glibc.i686&lt;span class="w"&gt; &lt;/span&gt;libstdc++.i686
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Create a separate user &lt;code&gt;steam&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;useradd&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;steam
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Switch user to &lt;code&gt;steam&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;su&lt;span class="w"&gt; &lt;/span&gt;-&lt;span class="w"&gt; &lt;/span&gt;steam
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Create an installation directory.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;~/Steam&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~/Steam
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id="download-and-install-steamcmd"&gt;Download and Install SteamCMD&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Download the latest version of SteamCMD.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;wget&lt;span class="w"&gt; &lt;/span&gt;https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;: Extract and run SteamCMD.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;tar&lt;span class="w"&gt; &lt;/span&gt;xf&lt;span class="w"&gt; &lt;/span&gt;steamcmd_linux.tar.gz
./steamcmd.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After the update is downloaded from Steam, it will then provide you with a command prompt as shown in the example below.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Steam&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt;: Login to Steam by typing the following command, replacing “userID” and “password” with your own credentials:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Steam&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;login&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;userID&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;password&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Alternatively, you can log in as an anonymous user by typing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Steam&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;login&lt;span class="w"&gt; &lt;/span&gt;anonymous
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt;: Set the installation directory for CS:GO by typing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;force_install_dir&lt;span class="w"&gt; &lt;/span&gt;./cs_go/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 9&lt;/strong&gt;: Finally, download and install CS:GO by typing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;app_update&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;740&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;validate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This may take some time. Once it’s finished, you should see &lt;em&gt;“Success! App ‘740’ fully installed”&lt;/em&gt; on your screen.&lt;/p&gt;
&lt;p&gt;&lt;img alt="CS:GO server installation success message" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/88a668cb-0939-42bc-80f0-b9a3335b633d.webp"&gt;&lt;/p&gt;
&lt;h3 id="allow-tcp-and-udp-ports-for-csgo-in-security-group"&gt;Allow TCP and UDP Ports for CS:GO in Security Group&lt;/h3&gt;
&lt;p&gt;To connect to the game server, ensure that TCP and UDP ports are open for all players. The default port for a CS:GO server is 27015.&lt;/p&gt;
&lt;p&gt;In my case, I have allowed access to everyone. For security reasons, you can specify particular IPs as needed.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AWS Security Group configuration for CS:GO server ports" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/8fea28c6-fa8c-47de-8927-ca77ec5d9de6.webp"&gt;&lt;/p&gt;
&lt;h3 id="generate-a-csgo-game-auth-token-id"&gt;Generate a CS:GO Game Auth Token ID&lt;/h3&gt;
&lt;p&gt;To host a CS:GO game, you need a Steam Auth Token ID. Your Steam account must meet certain requirements to generate the ID.&lt;/p&gt;
&lt;p&gt;You can check the &lt;a href="https://steamcommunity.com/dev/managegameservers" rel="nofollow" target="_blank"&gt;requirements&lt;/a&gt; and get your Auth Token ID by following the steps in the image below.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Steam Auth Token generation for CS:GO dedicated server" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/4f23780e-124f-4fd8-af8c-aa362151b7eb.webp"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: The registered ID for the Counter-Strike: Global Offensive dedicated server is&lt;/em&gt; &lt;a href="https://steamdb.info/app/740/" rel="nofollow" target="_blank"&gt;&lt;em&gt;appID 740&lt;/em&gt;&lt;/a&gt; &lt;em&gt;, while&lt;/em&gt; &lt;a href="https://steamdb.info/app/730/" rel="nofollow" target="_blank"&gt;&lt;em&gt;appID 730&lt;/em&gt;&lt;/a&gt; &lt;em&gt;is the official game ID.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;After following the steps, you will receive an Auth Token ID that looks similar to &lt;strong&gt;“X38F6E71A3B8G6FE08354AF5BE078”&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="run-csgo-on-dedicated-server"&gt;Run CS:GO on Dedicated Server&lt;/h2&gt;
&lt;p&gt;To run the CS:GO server, you need to execute a command based on the game mode you want to play. Before running the command, ensure that you are inside the &lt;code&gt;cs_go&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;Here’s an example of the command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./srcds_run&lt;span class="w"&gt; &lt;/span&gt;-game&lt;span class="w"&gt; &lt;/span&gt;csgo&lt;span class="w"&gt; &lt;/span&gt;-console&lt;span class="w"&gt; &lt;/span&gt;-usercon&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;game_type&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;game_mode&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;mapgroup&lt;span class="w"&gt; &lt;/span&gt;mg_active&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;map&lt;span class="w"&gt; &lt;/span&gt;de_dust2&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;sv_setsteamaccount&lt;span class="w"&gt; &lt;/span&gt;YOUR&lt;span class="w"&gt; &lt;/span&gt;AUTH&lt;span class="w"&gt; &lt;/span&gt;TOKEN&lt;span class="w"&gt; &lt;/span&gt;THISGSLTHERE&lt;span class="w"&gt; &lt;/span&gt;-net_port_try
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For different modes, you need to change the game_mode value.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Casual&lt;/strong&gt; = game_mode 0&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Competitive&lt;/strong&gt; = game_mode 1&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Deathmatch&lt;/strong&gt; = game_mode 2&lt;/p&gt;
&lt;p&gt;Remember to replace “YOUR AUTH TOKEN” with your own authentication token.&lt;/p&gt;
&lt;p&gt;Once you’ve entered the command, you’ll see the public IP of your game server.&lt;/p&gt;
&lt;p&gt;&lt;img alt="CS:GO server public IP address display" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/fab438b6-7bb5-445b-a0ea-c98d30b66f6a.webp"&gt;&lt;/p&gt;
&lt;h2 id="join-csgo-server"&gt;Join CS:GO Server&lt;/h2&gt;
&lt;p&gt;To join a CS:GO server, you can use either of the following methods:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Method 1:&lt;/strong&gt; Connect through the game console.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Launch CS:GO and enable the developer console in the game settings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;img alt="CS:GO developer console settings" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/06141a2b-4ff6-479e-889a-5e2ed5b4cfd5.webp"&gt;&lt;/p&gt;
&lt;p&gt;Return to the dashboard and open the console using the &lt;code&gt;~&lt;/code&gt; key.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Type in &lt;code&gt;connect &amp;lt;your-ip-address&amp;gt;&lt;/code&gt; to join the server.&lt;/p&gt;
&lt;p&gt;&lt;img alt="CS:GO console connect command" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/d9033c94-8650-45cf-897f-3aa2594faf1c.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Method 2:&lt;/strong&gt; Add the server IP to your favourite list&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Launch CS:GO and go to the Community Server Browser.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;img alt="CS:GO Community Server Browser" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/505937d5-73b9-4fe1-8fd1-df700cc32e32.webp"&gt;&lt;/p&gt;
&lt;p&gt;Click on the Favourite tab.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add your server IP to the list and connect to it.&lt;/p&gt;
&lt;p&gt;&lt;img alt="CS:GO server favorites list" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/5c80eec9-bd5d-4a0b-b611-f9de00c659a5.webp"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="run-csgo-in-background"&gt;Run CS:GO In Background&lt;/h2&gt;
&lt;p&gt;If you log out of the server, your game will be disconnected or stopped, and you can’t host the game while logged in forever.&lt;/p&gt;
&lt;p&gt;You can use the &lt;code&gt;screen&lt;/code&gt; utility in Linux to run processes in the background.&lt;/p&gt;
&lt;p&gt;Install on Ubuntu:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;apt-get&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;screen&lt;span class="w"&gt; &lt;/span&gt;-y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Install on CentOS:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="go"&gt;sudo yum install screen -y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Create a new screen session:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;screen&lt;span class="w"&gt; &lt;/span&gt;-R&lt;span class="w"&gt; &lt;/span&gt;csgo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Run the game:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./srcds_run&lt;span class="w"&gt; &lt;/span&gt;-game&lt;span class="w"&gt; &lt;/span&gt;csgo&lt;span class="w"&gt; &lt;/span&gt;-console&lt;span class="w"&gt; &lt;/span&gt;-usercon&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;game_type&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;game_mode&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;mapgroup&lt;span class="w"&gt; &lt;/span&gt;mg_active&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;map&lt;span class="w"&gt; &lt;/span&gt;de_dust2&lt;span class="w"&gt; &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;sv_setsteamaccount&lt;span class="w"&gt;  &lt;/span&gt;“YOUR&lt;span class="w"&gt; &lt;/span&gt;AUTH&lt;span class="w"&gt; &lt;/span&gt;TOKEN”&lt;span class="w"&gt; &lt;/span&gt;THISGSLTHERE&lt;span class="w"&gt; &lt;/span&gt;-net_port_try
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When the game is hosted successfully, you can exit the session while it runs in the background by pressing the keys simultaneously &lt;code&gt;Crtl + a + d&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now you are out of screen session. To see the running background session, type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;screen&lt;span class="w"&gt; &lt;/span&gt;-ls
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You will see output like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="go"&gt;There is a screen on:&lt;/span&gt;
&lt;span class="go"&gt;    7166.csgo    (Detached)&lt;/span&gt;
&lt;span class="go"&gt;1 Socket in /run/screen/S-stechalon.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In the above output, &lt;strong&gt;7166&lt;/strong&gt; is the ID, and &lt;strong&gt;csgo&lt;/strong&gt; is the name of the screen. To rejoin the detached screen, type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;screen&lt;span class="w"&gt; &lt;/span&gt;-r&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;7166&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id="secure-your-csgo-server-with-a-hostname-and-password"&gt;Secure your CS:GO Server with a Hostname and Password&lt;a href="http://localhost:1313/blogs/create-dedicated-csgo-linux-server/#secure-your-csgo-server-with-a-hostname-and-password"&gt;&lt;strong&gt;#&lt;/strong&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To add a layer of security to your CS:GO server, you can configure a hostname and password. This will ensure that only authorized players can join the game.&lt;/p&gt;
&lt;p&gt;First, locate the &lt;code&gt;autoexec.cfg&lt;/code&gt; file and open it. Add your desired hostname and password to the file.&lt;/p&gt;
&lt;p&gt;To set the hostname, add the following line: hostname “your_hostname_here”&lt;/p&gt;
&lt;p&gt;To set the password, add the following line: password “your_password_here”&lt;/p&gt;
&lt;p&gt;&lt;img alt="CS:GO autoexec.cfg configuration file" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/ecb8a8e0-7b41-4485-b468-84ea2447743a.webp"&gt;&lt;/p&gt;
&lt;p&gt;Save the file and exit.&lt;/p&gt;
&lt;p&gt;Next, refresh your favourite list and check the hostname. You should now see the changes you made reflected there.&lt;/p&gt;
&lt;p&gt;&lt;img alt="CS:GO server with custom hostname in browser" src="/images/post/set-up-counter-strike-global-offensive-dedicated-server-on-aws-ec2-instance/0d7626b5-e48b-4233-87ba-57fb66fbf01a.webp"&gt;&lt;/p&gt;
&lt;p&gt;If you want to customize your server further, you can modify additional settings in the &lt;code&gt;autoexec.cfg&lt;/code&gt; file, such as round time, buy time, and other game parameters to enhance your gaming experience.ize your CS:GO game further, CS:GO advanced &lt;a href="https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers" rel="nofollow" target="_blank"&gt;configuration article&lt;/a&gt; can be a helpful resource.&lt;/p&gt;
&lt;h2 id="change-csgo-tick-rate"&gt;Change CS:GO Tick Rate&lt;/h2&gt;
&lt;p&gt;Tick rate refers to the frequency at which the game server updates the game state and sends the information to players.&lt;/p&gt;
&lt;p&gt;The higher the tick rate, the more frequently the server updates the game state, resulting in a more accurate representation of player actions and movements.&lt;/p&gt;
&lt;p&gt;To change the tick rate in CS:GO, you need to add some commands to the &lt;code&gt;autoexec.cfg&lt;/code&gt; file located in &lt;code&gt;csgo/cfg/autoexec.cfg&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Add the following lines to the file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;sv_minupdaterate 128&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;sv_mincmdrate 128&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This simple step will improve your game performance and make your gameplay experience smoother.&lt;/p&gt;
&lt;h2 id="update-your-csgo-dedicated-server"&gt;Update Your CS:GO Dedicated Server&lt;/h2&gt;
&lt;p&gt;Regular updates are released for CS:GO every week or month, and to keep your server running smoothly, it’s important to update it as well.&lt;/p&gt;
&lt;p&gt;To update your CS:GO game on your dedicated server, you need to follow the &lt;strong&gt;steps 6 to 9&lt;/strong&gt; which involve from running SteamCMD to app update. These steps will guide you through the process of updating your game.&lt;/p&gt;
&lt;h2 id="achieve-low-ping-in-csgo-gameplay"&gt;Achieve Low Ping in CS:GO Gameplay&lt;/h2&gt;
&lt;p&gt;Low ping rate in CS:GO gameplay is crucial for a smooth and enjoyable gaming experience. Here are some tips to help you reduce your ping:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Host the game near your AWS Region:&lt;/strong&gt; Setup a server located near your region to minimize ping. The closer the server is to your location, the lower the ping will be. This is also the most cost-effective setup you can choose.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use AWS Global Accelerator:&lt;/strong&gt; AWS Global Accelerator can significantly reduce ping rates, but it can be expensive depending on your data transfer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use a VPN:&lt;/strong&gt; A VPN can help you reduce your ping by selecting a server location that is closer to the game server.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By implementing these tips, you can significantly reduce your ping and enjoy a lag-free CS:GO gameplay experience.&lt;/p&gt;
&lt;h2 id="wrapping-up-how-to-host-a-csgo-dedicated-server"&gt;Wrapping Up - How to Host a CS:GO Dedicated Server&lt;/h2&gt;
&lt;p&gt;Congratulations! You have successfully set up your own CS:GO server on a personal dedicated server. In this guide, we covered everything you need to know to get started with hosting a CS:GO server, from installing and configuring the server to updating it and optimizing gameplay.&lt;/p&gt;
&lt;p&gt;If you have any questions or concerns, please don’t hesitate to leave a comment below.&lt;/p&gt;
&lt;p&gt;Thanks for reading and happy gaming!&lt;/p&gt;
&lt;p&gt;-Alon&lt;/p&gt;</content><category term="misc"/></entry></feed>