{"id":4872,"date":"2026-09-01T23:51:06","date_gmt":"2026-09-01T18:21:06","guid":{"rendered":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/"},"modified":"2026-09-01T23:51:06","modified_gmt":"2026-09-01T18:21:06","slug":"10-essential-aws-best-practices-for-cloud-optimization-4","status":"publish","type":"post","link":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/","title":{"rendered":"10 Essential AWS Best Practices for Cloud Optimization"},"content":{"rendered":"<p>text<br \/>\n[root@ops-bastion-01 ~]# aws ce get-cost-and-usage \\<br \/>\n    &#8211;time-period Start=2024-05-18,End=2024-05-21 \\<br \/>\n    &#8211;granularity DAILY \\<br \/>\n    &#8211;metrics &#8220;UnblendedCost&#8221; \\<br \/>\n    &#8211;group-by Type=DIMENSION,Key=SERVICE<\/p>\n<p>{<br \/>\n    &#8220;ResultsByTime&#8221;: [<br \/>\n        {<br \/>\n            &#8220;TimePeriod&#8221;: {&#8220;Start&#8221;: &#8220;2024-05-18&#8221;, &#8220;End&#8221;: &#8220;2024-05-19&#8221;},<br \/>\n            &#8220;Groups&#8221;: [<br \/>\n                {&#8220;Keys&#8221;: [&#8220;Amazon Elastic Compute Cloud &#8211; Compute&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;412.45&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}},<br \/>\n                {&#8220;Keys&#8221;: [&#8220;Amazon Simple Storage Service&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;89.12&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}},<br \/>\n                {&#8220;Keys&#8221;: [&#8220;Amazon VPC&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;12.50&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}<br \/>\n            ]<br \/>\n        },<br \/>\n        {<br \/>\n            &#8220;TimePeriod&#8221;: {&#8220;Start&#8221;: &#8220;2024-05-19&#8221;, &#8220;End&#8221;: &#8220;2024-05-20&#8221;},<br \/>\n            &#8220;Groups&#8221;: [<br \/>\n                {&#8220;Keys&#8221;: [&#8220;Amazon Elastic Compute Cloud &#8211; Compute&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;84200.15&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}},<br \/>\n                {&#8220;Keys&#8221;: [&#8220;Amazon Simple Storage Service&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;112450.30&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}},<br \/>\n                {&#8220;Keys&#8221;: [&#8220;Amazon VPC&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;53120.44&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}<br \/>\n            ]<br \/>\n        }<br \/>\n    ]<br \/>\n}<br \/>\n[root@ops-bastion-01 ~]# tail -n 50 \/var\/log\/k8s-autoscaler.log<br \/>\nE0519 03:14:22.123456 static_autoscaler.go:214] Failed to scale up: InsufficientInstanceCapacity for c5.9xlarge in us-east-1a<br \/>\nW0519 03:14:25.987654 cluster_state.go:120] Node group &#8216;worker-pool-heavy&#8217; is at max size 500, but pending pods exist.<br \/>\n[root@ops-bastion-01 ~]# date<br \/>\nMon May 21 04:12:09 UTC 2024<\/p>\n<pre class=\"codehilite\"><code>I haven't slept since Saturday. My keyboard is sticky with spilled espresso and the bitter residue of a &quot;cloud-native&quot; architecture designed by a consultant who charged $400 an hour to build a system that nearly bankrupted us in a single weekend. The Slack alerts started at 3:00 AM on Sunday\u2014the kind of alerts that don't just ping, they scream. PagerDuty was essentially a funeral dirge for our burn rate.\n\nThe &quot;Incident&quot; wasn't a hack. It wasn't a DDoS. It was a perfectly functioning, &quot;infinitely scalable&quot; pipeline doing exactly what it was told to do. It was a monument to the hubris of ignoring the underlying physics of networking and the predatory pricing models of managed services.\n\n## Ticket #9902: The $10,000-an-Hour NAT Gateway\n\nThe first thing I saw in the Cost Explorer was a vertical line for VPC costs. In a sane world, VPC costs are a rounding error. In this world\u2014the one the &quot;Architects&quot; built\u2014we were routing 400TB of raw telemetry data from a fleet of EKS worker nodes in a private subnet through a single pair of NAT Gateways to reach an S3 bucket in the same region.\n\nThe consultant didn't believe in VPC Endpoints. &quot;Too much complexity,&quot; they said. &quot;Just use the default route,&quot; they said.\n\nHere is the math they ignored: NAT Gateway processing charges are $0.045 per GB. That sounds small until you realize that 400TB through a NAT Gateway is $18,000 just in processing fees, not counting the standard data transfer rates. Because the worker nodes were in `us-east-1a` and the NAT Gateway was in `us-east-1b` (don't ask), we were also getting hit with cross-AZ transfer taxes of $0.01 per GB in both directions.\n\nI had to rip out the routing table and replace it with a Gateway Endpoint while the system was under load. This is the Terraform I had to hot-patch into production at 4:00 AM while my hands were shaking:\n\n```hcl\n# Terraform 1.7.x - Fixing the &quot;Consultant Special&quot;\nresource &quot;aws_vpc_endpoint&quot; &quot;s3_gateway&quot; {\n  vpc_id       = var.vpc_id\n  service_name = &quot;com.amazonaws.us-east-1.s3&quot;\n  vpc_endpoint_type = &quot;Gateway&quot;\n\n  # Attach to all private route tables to bypass the NAT Gateway\n  route_table_ids = data.aws_route_tables.private.ids\n\n  tags = {\n    Name        = &quot;s3-gateway-endpoint&quot;\n    Environment = &quot;production&quot;\n    Reason      = &quot;Stopping the NAT Gateway bleeding&quot;\n  }\n}\n\n# We also had to kill the NAT Gateways once the routes propagated\n# But first, we had to ensure the Interface Endpoints for STS and Kinesis were there\nresource &quot;aws_vpc_endpoint&quot; &quot;kinesis_interface&quot; {\n  vpc_id              = var.vpc_id\n  service_name        = &quot;com.amazonaws.us-east-1.kinesis-streams&quot;\n  vpc_endpoint_type   = &quot;Interface&quot;\n  private_dns_enabled = true\n\n  subnet_ids          = var.private_subnet_ids\n  security_group_ids  = [aws_security_group.vpc_endpoint_sg.id]\n}\n<\/code><\/pre>\n<p>The &#8220;aws best&#8221; practices\u2014the ones they actually put in the whitepapers but nobody reads because they&#8217;re too busy looking at &#8220;Serverless&#8221; infographics\u2014explicitly state that you should use Gateway Endpoints for S3 and DynamoDB. It\u2019s free. It\u2019s a routing table entry. But no, we paid $53,000 for a NAT Gateway to act as a glorified, expensive straw for our data.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a9736f5a2579\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a9736f5a2579\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#Ticket_9905_S3_Egress_and_the_%E2%80%9CInfinite%E2%80%9D_Data_Lake_Mirage\" >Ticket #9905: S3 Egress and the &#8220;Infinite&#8221; Data Lake Mirage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#Ticket_9908_IAM_Spaghetti_and_the_AdministratorAccess_Crutch\" >Ticket #9908: IAM Spaghetti and the AdministratorAccess Crutch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#Ticket_9912_The_x86_Legacy_Tax_and_the_Graviton_Migration_That_Wasnt\" >Ticket #9912: The x86 Legacy Tax and the Graviton Migration That Wasn&#8217;t<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#Ticket_9915_Auto-Scaling_or_Auto-Bankruptcy\" >Ticket #9915: Auto-Scaling or Auto-Bankruptcy?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#Ticket_9920_Remediation_and_the_Terraform_State_of_Despair\" >Ticket #9920: Remediation and the Terraform State of Despair<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#Related_Articles\" >Related Articles<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Ticket_9905_S3_Egress_and_the_%E2%80%9CInfinite%E2%80%9D_Data_Lake_Mirage\"><\/span>Ticket #9905: S3 Egress and the &#8220;Infinite&#8221; Data Lake Mirage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The second spike was S3. Specifically, S3 Egress. The &#8220;Data Science&#8221; team\u2014bless their hearts\u2014decided to run a &#8220;global aggregation&#8221; job. They had a fleet of <code>c5.9xlarge<\/code> instances in <code>us-west-2<\/code> (Oregon) pulling the entire 400TB dataset from <code>us-east-1<\/code> (N. Virginia).<\/p>\n<p>They thought &#8220;The Cloud&#8221; was just one big happy computer. They didn&#8217;t realize that crossing the continental United States with a bitstream costs $0.02 per GB. <\/p>\n<p>400,000 GB * $0.02 = $8,000. <\/p>\n<p>But it wasn&#8217;t just one pass. Their Spark job was misconfigured, leading to massive &#8220;shuffling&#8221; and re-reads. They were calling <code>GetObject<\/code> on the same 100MB Parquet files thousands of times because they hadn&#8217;t implemented any local caching or used S3 Select to filter the data at the source.<\/p>\n<p>I looked at the S3 access logs. It was a horror show of <code>GET<\/code> requests.<\/p>\n<pre class=\"codehilite\"><code class=\"language-json\">{\n    &quot;eventTime&quot;: &quot;2024-05-19T04:00:01Z&quot;,\n    &quot;eventSource&quot;: &quot;s3.amazonaws.com&quot;,\n    &quot;eventName&quot;: &quot;GetObject&quot;,\n    &quot;requestParameters&quot;: {\n        &quot;bucketName&quot;: &quot;prod-telemetry-lake&quot;,\n        &quot;key&quot;: &quot;year=2024\/month=05\/day=19\/data.parquet&quot;\n    },\n    &quot;sourceIPAddress&quot;: &quot;54.x.x.x&quot;, \n    &quot;userAgent&quot;: &quot;aws-sdk-java\/1.12.x (Spark-Runtime)&quot;\n}\n<\/code><\/pre>\n<p>The &#8220;S3 Egress Trap&#8221; is real. You put data in for free, but you pay a ransom to get it out, especially if you&#8217;re crossing regions. I had to kill their IAM roles mid-job to stop the bleeding. They complained about &#8220;broken experiments.&#8221; I showed them the $112,000 S3 bill. They went quiet.<\/p>\n<p>We had to implement S3 Lifecycle policies immediately. We had &#8220;zombie data&#8221;\u2014petabytes of logs from 2021 that were still sitting in S3 Standard. <\/p>\n<pre class=\"codehilite\"><code class=\"language-hcl\">resource &quot;aws_s3_bucket_lifecycle_configuration&quot; &quot;telemetry_lifecycle&quot; {\n  bucket = aws_s3_bucket.telemetry.id\n\n  rule {\n    id     = &quot;archive-old-telemetry&quot;\n    status = &quot;Enabled&quot;\n\n    transition {\n      days          = 30\n      storage_class = &quot;INTELLIGENT_TIERING&quot;\n    }\n\n    transition {\n      days          = 90\n      storage_class = &quot;GLACIER_IR&quot;\n    }\n\n    expiration {\n      days = 365\n    }\n  }\n}\n<\/code><\/pre>\n<p>If you aren&#8217;t using Intelligent-Tiering, you are essentially donating money to Jeff Bezos&#8217;s next rocket launch. The &#8220;consultant-grade&#8221; architecture just left everything in Standard because &#8220;it&#8217;s simpler for the developers.&#8221; Simplicity is a luxury we can no longer afford.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ticket_9908_IAM_Spaghetti_and_the_AdministratorAccess_Crutch\"><\/span>Ticket #9908: IAM Spaghetti and the AdministratorAccess Crutch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>While I was digging through the wreckage, I found the IAM roles. It was a nightmare of &#8220;IAM Spaghetti.&#8221; Every single Lambda function, every EC2 instance, and every developer had <code>AdministratorAccess<\/code> or some variation of a <code>Resource: \"*\"<\/code> policy. <\/p>\n<p>The &#8220;Architect&#8221; had argued that &#8220;fine-grained IAM policies slow down velocity.&#8221; You know what else slows down velocity? A $250,000 bill and a security audit that takes six months.<\/p>\n<p>I found a &#8220;Cleanup Script&#8221; running on a t3.medium that had this policy:<\/p>\n<pre class=\"codehilite\"><code class=\"language-json\">{\n    &quot;Version&quot;: &quot;2012-10-17&quot;,\n    &quot;Statement&quot;: [\n        {\n            &quot;Effect&quot;: &quot;Allow&quot;,\n            &quot;Action&quot;: [\n                &quot;s3:*&quot;,\n                &quot;ec2:*&quot;,\n                &quot;rds:*&quot;,\n                &quot;lambda:*&quot;\n            ],\n            &quot;Resource&quot;: &quot;*&quot;\n        }\n    ]\n}\n<\/code><\/pre>\n<p>This is &#8220;dangerously permissive&#8221; doesn&#8217;t even begin to cover it. This is an invitation for a total account takeover. If that instance was compromised, the attacker wouldn&#8217;t even need to escalate privileges; they were already the king of the castle.<\/p>\n<p>I spent six hours writing &#8220;least privilege&#8221; policies using the Access Analyzer, which, by the way, is the only thing that kept me from quitting on the spot. I had to move us to something that actually resembles a security posture:<\/p>\n<pre class=\"codehilite\"><code class=\"language-json\">{\n    &quot;Version&quot;: &quot;2012-10-17&quot;,\n    &quot;Statement&quot;: [\n        {\n            &quot;Sid&quot;: &quot;AllowS3ReadWriteSpecificBucket&quot;,\n            &quot;Effect&quot;: &quot;Allow&quot;,\n            &quot;Action&quot;: [\n                &quot;s3:GetObject&quot;,\n                &quot;s3:PutObject&quot;,\n                &quot;s3:ListBucket&quot;\n            ],\n            &quot;Resource&quot;: [\n                &quot;arn:aws:s3:::prod-telemetry-lake&quot;,\n                &quot;arn:aws:s3:::prod-telemetry-lake\/*&quot;\n            ]\n        },\n        {\n            &quot;Sid&quot;: &quot;EnforceEncryptionAndVPC&quot;,\n            &quot;Effect&quot;: &quot;Deny&quot;,\n            &quot;Action&quot;: &quot;s3:*&quot;,\n            &quot;Resource&quot;: &quot;arn:aws:s3:::prod-telemetry-lake\/*&quot;,\n            &quot;Condition&quot;: {\n                &quot;Bool&quot;: {\n                    &quot;aws:SecureTransport&quot;: &quot;false&quot;\n                },\n                &quot;StringNotEquals&quot;: {\n                    &quot;aws:SourceVpc&quot;: &quot;vpc-0a1b2c3d4e5f6g7h8&quot;\n                }\n            }\n        }\n    ]\n}\n<\/code><\/pre>\n<p>The &#8220;aws best&#8221; way to handle this is to use Permission Boundaries and Service Control Policies (SCPs) at the Organization level, but we were too &#8220;agile&#8221; for that. We were so agile we ran straight off a cliff.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ticket_9912_The_x86_Legacy_Tax_and_the_Graviton_Migration_That_Wasnt\"><\/span>Ticket #9912: The x86 Legacy Tax and the Graviton Migration That Wasn&#8217;t<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>As I was looking at the EC2 fleet, I realized we were still running almost entirely on <code>c5.4xlarge<\/code> and <code>m5.large<\/code> instances. These are Intel-based machines. They are the &#8220;legacy tax&#8221; of the cloud. <\/p>\n<p>AWS has been screaming about Graviton (ARM-based) for years. 20% cheaper, 40% better performance. But the developers didn&#8217;t want to &#8220;deal with cross-compiling.&#8221; They just wanted to push their bloated Docker images and go to happy hour.<\/p>\n<p>During the spike, the <code>c5.9xlarge<\/code> instances were struggling with the I\/O wait times. I did a quick test\u2014I spun up a <code>c6g.8xlarge<\/code> (Graviton3) and ran the same ingestion script. Not only did it handle the throughput better, but the hourly rate was significantly lower.<\/p>\n<p>We are literally burning money to support x86 instructions that our Python and Go code doesn&#8217;t even care about. <\/p>\n<pre class=\"codehilite\"><code class=\"language-hcl\"># The old, expensive way\nresource &quot;aws_instance&quot; &quot;legacy_worker&quot; {\n  instance_type = &quot;c5.4xlarge&quot; # $0.68 per hour\n  ami           = data.aws_ami.intel_ami.id\n}\n\n# The &quot;I want to keep my job&quot; way\nresource &quot;aws_instance&quot; &quot;modern_worker&quot; {\n  instance_type = &quot;c7g.4xlarge&quot; # $0.58 per hour (and faster)\n  ami           = data.aws_ami.graviton_ami.id\n}\n<\/code><\/pre>\n<p>The transition to Graviton isn&#8217;t just a &#8220;nice to have&#8221; anymore. It&#8217;s a survival tactic. If you&#8217;re still on x86 for general-purpose workloads, you&#8217;re paying a 20% premium for the privilege of being lazy.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ticket_9915_Auto-Scaling_or_Auto-Bankruptcy\"><\/span>Ticket #9915: Auto-Scaling or Auto-Bankruptcy?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The &#8220;Infinite Scalability&#8221; myth is the most dangerous lie in tech. The consultant set up the Cluster Autoscaler on EKS with a maximum node count of 500. They thought they were being &#8220;resilient.&#8221; <\/p>\n<p>When the Spark job went haywire and started spawning thousands of pods due to a recursive retry logic error, the Autoscaler did exactly what it was told. It started spinning up <code>c5.9xlarge<\/code> instances like it was trying to win a prize. <\/p>\n<p>The problem is that there is no &#8220;circuit breaker&#8221; in the standard AWS scaling logic. If your code starts looping and requesting more resources, AWS will happily provide them until your credit line is exhausted. <\/p>\n<p>We saw &#8220;InsufficientInstanceCapacity&#8221; errors in <code>us-east-1a<\/code>, which means we actually exhausted the physical supply of those instances in that AZ. We were so &#8220;scalable&#8221; we broke the region&#8217;s inventory.<\/p>\n<p>I had to implement hard limits and &#8220;Scale-In&#8221; protections that should have been there from day one. I also had to deal with &#8220;zombie instances&#8221;\u2014nodes that the Autoscaler thought were healthy but were actually stuck in a <code>NotReady<\/code> state due to the NAT Gateway saturation, yet they were still racking up charges.<\/p>\n<pre class=\"codehilite\"><code class=\"language-bash\"># Finding the zombies\nfor node in $(kubectl get nodes | grep NotReady | awk '{print $1}'); do\n  INSTANCE_ID=$(kubectl get node $node -o jsonpath='{.spec.providerID}' | cut -d'\/' -f5)\n  echo &quot;Terminating zombie instance: $INSTANCE_ID&quot;\n  aws ec2 terminate-instances --instance-ids $INSTANCE_ID\ndone\n<\/code><\/pre>\n<p>And then there are the &#8220;cold starts.&#8221; The consultant decided that every single micro-task should be a Lambda function. We had 50,000 Lambdas firing per minute. The &#8220;Provisioned Concurrency&#8221; costs alone were $12,000 because they wanted to avoid the 200ms cold start. <\/p>\n<p>If you have that much consistent traffic, you don&#8217;t use Lambda. You use a long-running process on Fargate or EKS. Lambda is for intermittent, event-driven tasks. Using it for a high-throughput data pipeline is like using a fleet of Ferraris to move gravel. It\u2019s flashy, it\u2019s expensive, and it\u2019s the wrong tool for the job.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ticket_9920_Remediation_and_the_Terraform_State_of_Despair\"><\/span>Ticket #9920: Remediation and the Terraform State of Despair<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The sun is coming up now. The bill has stabilized. The NAT Gateways are gone, replaced by Gateway Endpoints. The cross-region egress has been throttled. The IAM roles are being systematically gutted and replaced with least-privilege policies.<\/p>\n<p>But the damage is done. $250,000. That\u2019s a couple of senior engineer salaries gone in a weekend because of &#8220;architectural best practices&#8221; that were anything but.<\/p>\n<p>I\u2019m looking at the Terraform state file now. It\u2019s 15MB of JSON misery. I\u2019m using the new <code>removed<\/code> block in Terraform 1.7 to clean up the mess without destroying the world:<\/p>\n<pre class=\"codehilite\"><code class=\"language-hcl\">removed {\n  from = aws_nat_gateway.expensive_mistake\n\n  lifecycle {\n    destroy = true\n  }\n}\n\n# Moving to a more sane architecture\nmodule &quot;vpc_endpoints&quot; {\n  source  = &quot;terraform-aws-modules\/vpc\/aws\/\/modules\/vpc-endpoints&quot;\n  version = &quot;5.8.1&quot;\n\n  vpc_id             = var.vpc_id\n  security_group_ids = [aws_security_group.endpoints.id]\n\n  endpoints = {\n    s3 = {\n      service      = &quot;s3&quot;\n      service_type = &quot;Gateway&quot;\n      route_table_ids = data.aws_route_tables.private.ids\n    },\n    dynamodb = {\n      service      = &quot;dynamodb&quot;\n      service_type = &quot;Gateway&quot;\n      route_table_ids = data.aws_route_tables.private.ids\n    },\n    ecr_api = {\n      service             = &quot;ecr.api&quot;\n      private_dns_enabled = true\n      subnet_ids          = var.private_subnet_ids\n    },\n    ecr_dkr = {\n      service             = &quot;ecr.dkr&quot;\n      private_dns_enabled = true\n      subnet_ids          = var.private_subnet_ids\n    }\n  }\n}\n<\/code><\/pre>\n<p>The &#8220;aws best&#8221; practices aren&#8217;t just suggestions. They are the difference between a successful product and a &#8220;Post-Mortem of My Sanity.&#8221; <\/p>\n<p>If I see one more &#8220;Serverless-First&#8221; diagram that doesn&#8217;t include a VPC Endpoint or a cost estimation for data transfer, I\u2019m going to throw my MacBook into the nearest river. <\/p>\n<p>The &#8220;Infinite Scalability&#8221; of the cloud is a lie. It\u2019s only as infinite as your company\u2019s bank account. And right now, our account is looking very, very finite.<\/p>\n<p>I\u2019m going home. I\u2019m turning off my phone. If the cluster scales up again, let it. Let the whole thing burn. At least the fire will be warm, which is more than I can say for this office.<\/p>\n<p>[EOF] &#8211; SRE Out.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Related_Articles\"><\/span>Related Articles<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Explore more insights and best practices:<\/p>\n<ul>\n<li><a href=\"https:\/\/itsupportwale.com\/blog\/javascript-best-practices-master-clean-and-efficient-code\/\">Javascript Best Practices Master Clean And Efficient Code<\/a><\/li>\n<li><a href=\"https:\/\/itsupportwale.com\/blog\/install-ubuntu-20-04-lts-server\/\">Install Ubuntu 20 04 Lts Server<\/a><\/li>\n<li><a href=\"https:\/\/itsupportwale.com\/blog\/10-essential-devops-best-practices-for-faster-delivery-2\/\">10 Essential Devops Best Practices For Faster Delivery 2<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>text [root@ops-bastion-01 ~]# aws ce get-cost-and-usage \\ &#8211;time-period Start=2024-05-18,End=2024-05-21 \\ &#8211;granularity DAILY \\ &#8211;metrics &#8220;UnblendedCost&#8221; \\ &#8211;group-by Type=DIMENSION,Key=SERVICE { &#8220;ResultsByTime&#8221;: [ { &#8220;TimePeriod&#8221;: {&#8220;Start&#8221;: &#8220;2024-05-18&#8221;, &#8220;End&#8221;: &#8220;2024-05-19&#8221;}, &#8220;Groups&#8221;: [ {&#8220;Keys&#8221;: [&#8220;Amazon Elastic Compute Cloud &#8211; Compute&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;412.45&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}, {&#8220;Keys&#8221;: [&#8220;Amazon Simple Storage Service&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;89.12&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}, {&#8220;Keys&#8221;: [&#8220;Amazon &#8230; <a title=\"10 Essential AWS Best Practices for Cloud Optimization\" class=\"read-more\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\" aria-label=\"Read more  on 10 Essential AWS Best Practices for Cloud Optimization\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4872","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>10 Essential AWS Best Practices for Cloud Optimization - ITSupportWale<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"10 Essential AWS Best Practices for Cloud Optimization - ITSupportWale\" \/>\n<meta property=\"og:description\" content=\"text [root@ops-bastion-01 ~]# aws ce get-cost-and-usage  &#8211;time-period Start=2024-05-18,End=2024-05-21  &#8211;granularity DAILY  &#8211;metrics &#8220;UnblendedCost&#8221;  &#8211;group-by Type=DIMENSION,Key=SERVICE { &#8220;ResultsByTime&#8221;: [ { &#8220;TimePeriod&#8221;: {&#8220;Start&#8221;: &#8220;2024-05-18&#8221;, &#8220;End&#8221;: &#8220;2024-05-19&#8221;}, &#8220;Groups&#8221;: [ {&#8220;Keys&#8221;: [&#8220;Amazon Elastic Compute Cloud &#8211; Compute&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;412.45&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}, {&#8220;Keys&#8221;: [&#8220;Amazon Simple Storage Service&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;89.12&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}, {&#8220;Keys&#8221;: [&#8220;Amazon ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\" \/>\n<meta property=\"og:site_name\" content=\"ITSupportWale\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Itsupportwale-298547177495978\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-01T18:21:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itsupportwale.com\/blog\/wp-content\/uploads\/2021\/05\/android-chrome-512x512-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Techie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Techie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\"},\"author\":{\"name\":\"Techie\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/#\/schema\/person\/8c5a2b3d36396e0a8fd91ec8242fd46d\"},\"headline\":\"10 Essential AWS Best Practices for Cloud Optimization\",\"datePublished\":\"2026-09-01T18:21:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\"},\"wordCount\":1404,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\",\"url\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\",\"name\":\"10 Essential AWS Best Practices for Cloud Optimization - ITSupportWale\",\"isPartOf\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/#website\"},\"datePublished\":\"2026-09-01T18:21:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/itsupportwale.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"10 Essential AWS Best Practices for Cloud Optimization\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/#website\",\"url\":\"https:\/\/itsupportwale.com\/blog\/\",\"name\":\"ITSupportWale\",\"description\":\"Tips, Tricks, Fixed-Errors, Tutorials &amp; Guides\",\"publisher\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/itsupportwale.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/#organization\",\"name\":\"itsupportwale\",\"url\":\"https:\/\/itsupportwale.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/itsupportwale.com\/blog\/wp-content\/uploads\/2023\/09\/cropped-Logo-trans-without-slogan.png\",\"contentUrl\":\"https:\/\/itsupportwale.com\/blog\/wp-content\/uploads\/2023\/09\/cropped-Logo-trans-without-slogan.png\",\"width\":1119,\"height\":144,\"caption\":\"itsupportwale\"},\"image\":{\"@id\":\"https:\/\/itsupportwale.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Itsupportwale-298547177495978\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/itsupportwale.com\/blog\/#\/schema\/person\/8c5a2b3d36396e0a8fd91ec8242fd46d\",\"name\":\"Techie\",\"sameAs\":[\"https:\/\/itsupportwale.com\",\"iswblogadmin\"],\"url\":\"https:\/\/itsupportwale.com\/blog\/author\/iswblogadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"10 Essential AWS Best Practices for Cloud Optimization - ITSupportWale","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/","og_locale":"en_US","og_type":"article","og_title":"10 Essential AWS Best Practices for Cloud Optimization - ITSupportWale","og_description":"text [root@ops-bastion-01 ~]# aws ce get-cost-and-usage  &#8211;time-period Start=2024-05-18,End=2024-05-21  &#8211;granularity DAILY  &#8211;metrics &#8220;UnblendedCost&#8221;  &#8211;group-by Type=DIMENSION,Key=SERVICE { &#8220;ResultsByTime&#8221;: [ { &#8220;TimePeriod&#8221;: {&#8220;Start&#8221;: &#8220;2024-05-18&#8221;, &#8220;End&#8221;: &#8220;2024-05-19&#8221;}, &#8220;Groups&#8221;: [ {&#8220;Keys&#8221;: [&#8220;Amazon Elastic Compute Cloud &#8211; Compute&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;412.45&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}, {&#8220;Keys&#8221;: [&#8220;Amazon Simple Storage Service&#8221;], &#8220;Metrics&#8221;: {&#8220;UnblendedCost&#8221;: {&#8220;Amount&#8221;: &#8220;89.12&#8221;, &#8220;Unit&#8221;: &#8220;USD&#8221;}}}, {&#8220;Keys&#8221;: [&#8220;Amazon ... Read more","og_url":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/","og_site_name":"ITSupportWale","article_publisher":"https:\/\/www.facebook.com\/Itsupportwale-298547177495978","article_published_time":"2026-09-01T18:21:06+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/itsupportwale.com\/blog\/wp-content\/uploads\/2021\/05\/android-chrome-512x512-1.png","type":"image\/png"}],"author":"Techie","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Techie","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#article","isPartOf":{"@id":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/"},"author":{"name":"Techie","@id":"https:\/\/itsupportwale.com\/blog\/#\/schema\/person\/8c5a2b3d36396e0a8fd91ec8242fd46d"},"headline":"10 Essential AWS Best Practices for Cloud Optimization","datePublished":"2026-09-01T18:21:06+00:00","mainEntityOfPage":{"@id":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/"},"wordCount":1404,"commentCount":0,"publisher":{"@id":"https:\/\/itsupportwale.com\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/","url":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/","name":"10 Essential AWS Best Practices for Cloud Optimization - ITSupportWale","isPartOf":{"@id":"https:\/\/itsupportwale.com\/blog\/#website"},"datePublished":"2026-09-01T18:21:06+00:00","breadcrumb":{"@id":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/itsupportwale.com\/blog\/10-essential-aws-best-practices-for-cloud-optimization-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/itsupportwale.com\/blog\/"},{"@type":"ListItem","position":2,"name":"10 Essential AWS Best Practices for Cloud Optimization"}]},{"@type":"WebSite","@id":"https:\/\/itsupportwale.com\/blog\/#website","url":"https:\/\/itsupportwale.com\/blog\/","name":"ITSupportWale","description":"Tips, Tricks, Fixed-Errors, Tutorials &amp; Guides","publisher":{"@id":"https:\/\/itsupportwale.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itsupportwale.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/itsupportwale.com\/blog\/#organization","name":"itsupportwale","url":"https:\/\/itsupportwale.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsupportwale.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itsupportwale.com\/blog\/wp-content\/uploads\/2023\/09\/cropped-Logo-trans-without-slogan.png","contentUrl":"https:\/\/itsupportwale.com\/blog\/wp-content\/uploads\/2023\/09\/cropped-Logo-trans-without-slogan.png","width":1119,"height":144,"caption":"itsupportwale"},"image":{"@id":"https:\/\/itsupportwale.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Itsupportwale-298547177495978"]},{"@type":"Person","@id":"https:\/\/itsupportwale.com\/blog\/#\/schema\/person\/8c5a2b3d36396e0a8fd91ec8242fd46d","name":"Techie","sameAs":["https:\/\/itsupportwale.com","iswblogadmin"],"url":"https:\/\/itsupportwale.com\/blog\/author\/iswblogadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/posts\/4872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/comments?post=4872"}],"version-history":[{"count":0,"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/posts\/4872\/revisions"}],"wp:attachment":[{"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/media?parent=4872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/categories?post=4872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsupportwale.com\/blog\/wp-json\/wp\/v2\/tags?post=4872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}