<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aniket Abhishek Soni</title>
    <description>The latest articles on DEV Community by Aniket Abhishek Soni (@aniketsoni).</description>
    <link>https://dev.to/aniketsoni</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3954381%2Fc17f147f-e19b-4160-be20-e2d4dd2af1dd.png</url>
      <title>DEV Community: Aniket Abhishek Soni</title>
      <link>https://dev.to/aniketsoni</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aniketsoni"/>
    <language>en</language>
    <item>
      <title>Why is my Athena query failing or costing more after moving to a Medallion architecture?</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Fri, 20 Nov 2026 16:13:15 +0000</pubDate>
      <link>https://dev.to/aniketsoni/why-is-my-athena-query-failing-or-costing-more-after-moving-to-a-medallion-architecture-5598</link>
      <guid>https://dev.to/aniketsoni/why-is-my-athena-query-failing-or-costing-more-after-moving-to-a-medallion-architecture-5598</guid>
      <description>&lt;p&gt;Many data engineers assume that simply organizing S3 prefixes into "Bronze," "Silver," and "Gold" folders is enough to ensure a performant and cost-effective Medallion architecture. In practice, this structural approach often leads to excessive S3 request costs, slow Athena query times, and massive metadata overhead, particularly when the underlying file formats and partitioning strategies are not aligned with how the AWS Glue Data Catalog tracks them.&lt;/p&gt;

&lt;p&gt;This article provides a troubleshooting guide for engineers facing performance degradation or spiraling costs within an AWS-native Medallion pipeline. We cover identifying misaligned partitioning, excessive small files, and incorrect Iceberg table configurations. This scope assumes an architecture using Amazon S3 for storage, AWS Glue for the catalog and ETL, and Amazon Athena for ad-hoc analysis.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    S3Raw["S3 (Bronze)"] --&amp;gt; GlueETL["AWS Glue ETL"]
    GlueETL --&amp;gt; S3Silver["S3 (Silver/Iceberg)"]
    S3Silver --&amp;gt; GlueCatalog["AWS Glue Data Catalog"]
    GlueCatalog --&amp;gt; Athena["Amazon Athena"]
    Athena --&amp;gt; S3Silver&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Consider a hypothetical pipeline where a team has migrated their "Silver" layer to Apache Iceberg tables on S3. They find that queries against the &lt;code&gt;events&lt;/code&gt; table are scanning significantly more data than expected, and simple &lt;code&gt;SELECT&lt;/code&gt; statements are taking seconds longer than they did when using standard Parquet files in a Hive-style layout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Symptoms
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Query Latency:&lt;/strong&gt; Queries against the Silver layer are slower than expected for the amount of data processed.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Cost Spikes:&lt;/strong&gt; Athena "Data Scanned" metrics in AWS Cost Explorer are higher than the total size of the partitions being queried.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Metadata Overload:&lt;/strong&gt; Athena query history shows high execution times spent in "Planning" or "Metadata initialization."&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;False Leads:&lt;/strong&gt; The team might suspect network latency, complex joins, or the need for more expensive compute resources, when the issue is actually the way files are stored and indexed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Excessive Small Files in the Silver Layer
&lt;/h2&gt;

&lt;p&gt;A common mistake is treating the Silver layer as a landing zone where every incoming batch creates a new file. In Apache Iceberg, every file is an object in S3; having thousands of tiny files forces Athena to perform excessive S3 &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;LIST&lt;/code&gt; requests, which inflates cost and latency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Check the number of files per partition using the AWS CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3 ls s3://your-data-bucket/silver/events/ --recursive &lt;span class="o"&gt;|&lt;/span&gt; wc -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see thousands of files for a single day's partition, your compaction strategy is failing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
Use the &lt;code&gt;rewrite_data_files&lt;/code&gt; procedure in Athena to compact small files into larger ones (aim for 128MB to 512MB).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="no"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rewrite_data_files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'your_database'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'events'&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;p&gt;&lt;strong&gt;Verify the fix:&lt;/strong&gt;&lt;br&gt;
Re-run the &lt;code&gt;aws s3 ls&lt;/code&gt; command or query the &lt;code&gt;files&lt;/code&gt; metadata table to confirm a reduction in file count:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) FROM "your_database"."events$files";
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Incorrect Partition Pruning
&lt;/h2&gt;

&lt;p&gt;If your Glue Data Catalog partition keys do not align with your query &lt;code&gt;WHERE&lt;/code&gt; clauses, Athena will perform a full table scan. Even with Iceberg, partition evolution requires that your queries filter on the columns defined in the table schema.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Check the query execution details in the Athena console. Look for "Data Scanned" vs. "Data Scanned per Partition." If the ratio is 1:1, you are scanning the entire dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
Explicitly filter by the partition key. If your table is partitioned by &lt;code&gt;event_date&lt;/code&gt;, ensure your query includes it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;silver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;event_date&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="s1"&gt;'2023-10-01'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;event_date&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'2023-10-02'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are using hidden partitioning (e.g., partitioning by &lt;code&gt;day(timestamp_column)&lt;/code&gt;), ensure your query uses the source timestamp column, not a derived string column.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify the fix:&lt;/strong&gt;&lt;br&gt;
Review the Athena query execution plan to see if "Partition Pruning" is listed as a filter step.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Missing or Stale Table Statistics
&lt;/h2&gt;

&lt;p&gt;Athena’s query optimizer relies on statistics in the Glue Data Catalog (or Iceberg metadata) to decide how to join tables and how much data to scan. If these stats are missing, the optimizer may default to a sub-optimal execution plan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;DESCRIBE FORMATTED&lt;/code&gt; on your table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="no"&gt;DESCRIBE&lt;/span&gt; &lt;span class="no"&gt;FORMATTED&lt;/span&gt; &lt;span class="n"&gt;your_database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for &lt;code&gt;numFiles&lt;/code&gt;, &lt;code&gt;totalSize&lt;/code&gt;, and &lt;code&gt;numRows&lt;/code&gt; in the output. If these are null or outdated, the optimizer is flying blind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
For Iceberg tables, statistics are managed by the engine. You can update them using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ANALYZE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;your_database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="no"&gt;COMPUTE&lt;/span&gt; &lt;span class="no"&gt;STATISTICS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For non-Iceberg tables, you must run an AWS Glue Crawler or manually update statistics via the Glue API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify the fix:&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;DESCRIBE FORMATTED&lt;/code&gt; again and verify that &lt;code&gt;numRows&lt;/code&gt; and &lt;code&gt;totalSize&lt;/code&gt; now reflect the current state of your data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Preventing it
&lt;/h2&gt;

&lt;p&gt;To keep a Medallion architecture performant, implement these systemic safeguards:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Automate Maintenance:&lt;/strong&gt; Do not rely on manual compaction. Use AWS Glue ETL jobs or AWS Step Functions to trigger &lt;code&gt;rewrite_data_files&lt;/code&gt; on a schedule based on table growth.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Use Iceberg for Silver/Gold:&lt;/strong&gt; Avoid legacy Hive-style partitioning for Silver and Gold layers. Apache Iceberg handles partition evolution and metadata indexing far better than standard Parquet, which mitigates many "small file" problems at the ingestion layer.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Strict Schema Evolution:&lt;/strong&gt; Use the AWS Glue Schema Registry to ensure that incoming Bronze data matches the expected format. Drifting schemas often break partition logic, leading to empty results or massive scans of incorrectly formatted data.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Monitor with Athena Query Metrics:&lt;/strong&gt; Use the &lt;code&gt;AthenaQueryExecution&lt;/code&gt; API to track &lt;code&gt;DataScannedInBytes&lt;/code&gt; for your most frequent queries. Set up Amazon CloudWatch Alarms to alert when the 95th percentile of data scanned per query exceeds a specific threshold.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;If you created test tables or Glue databases to investigate these issues, ensure you clean them up to avoid storage costs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Drop the tables: &lt;code&gt;DROP TABLE your_database.events;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; Delete the S3 data: &lt;code&gt;aws s3 rm s3://your-data-bucket/silver/events/ --recursive&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; Delete the Glue Database: &lt;code&gt;aws glue delete-database --name your_database&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By shifting the focus from "folder structure" to "file maintenance and metadata accuracy," you can stop treating the Medallion architecture as a static organization method and start treating it as a dynamic, tunable data system.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://iceberg.apache.org/docs/latest/spark-procedures/" rel="noopener noreferrer"&gt;Apache Iceberg: Maintenance Procedures&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/athena/latest/ug/tuning.html" rel="noopener noreferrer"&gt;Amazon Athena: Tuning Query Performance&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/glue/latest/dg/statistics-overview.html" rel="noopener noreferrer"&gt;AWS Glue: Managing Data Catalog Statistics&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;About the examples: automated checks confirmed that 1 AWS CLI command matches the AWS service API models (operation and parameter names). The examples have not been run end to end, so test them in a non-production environment before relying on them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@elimendeinagella?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Elimende Inagella&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>dataengineering</category>
      <category>athena</category>
      <category>glue</category>
    </item>
    <item>
      <title>Control S3 Costs by Tracking Requests and Data Transfer</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Thu, 19 Nov 2026 14:45:26 +0000</pubDate>
      <link>https://dev.to/aniketsoni/control-s3-costs-by-tracking-requests-and-data-transfer-4ik2</link>
      <guid>https://dev.to/aniketsoni/control-s3-costs-by-tracking-requests-and-data-transfer-4ik2</guid>
      <description>&lt;p&gt;Imagine a nightly job that processes several terabytes of data stored in Amazon S3. The monthly bill shows a steady increase in S3 costs, but the total volume of stored data hasn't grown proportionally. You suspect that the cost is driven by high-frequency metadata operations or inter-region data transfer rather than the bytes at rest, but the top-level AWS Cost Explorer dashboard only shows an aggregate "S3" line item. Without granular visibility into which specific buckets or access patterns are inflating the bill, you are left to guess which optimization to prioritize.&lt;/p&gt;

&lt;p&gt;This article explains how to decompose your S3 bill into storage, request, and data transfer components using cost allocation tags and AWS Data Exports. We will focus on implementing a tagging strategy and configuring automated reporting to identify the actual drivers of your spend, providing a clear path to cost-efficient architecture.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; Unmonitored S3 costs often mask architectural inefficiencies, such as excessive list requests in recursive directory scans or cross-region data transfers. By attributing costs to specific workloads, you move from reactive budgeting to proactive infrastructure design, ensuring that your data platform's growth remains economically sustainable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The cost anatomy of S3
&lt;/h2&gt;

&lt;p&gt;S3 costs are not just about storage; they are a function of three distinct categories:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; The volume of data (GB-months) and the storage class used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Requests:&lt;/strong&gt; The number of GET, PUT, COPY, or LIST operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Transfer:&lt;/strong&gt; Moving data out of an AWS Region or across the public internet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The primary engineering challenge is that these costs are aggregated by service at the account level. To isolate these, you must categorize your buckets using cost allocation tags, which allow AWS to break down costs in the Billing and Cost Management console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing cost visibility with tagging
&lt;/h2&gt;

&lt;p&gt;Tagging is the foundation of cost governance. You should implement a tagging policy where every bucket has at least an &lt;code&gt;Environment&lt;/code&gt;, &lt;code&gt;Project&lt;/code&gt;, and &lt;code&gt;DataClassification&lt;/code&gt; tag. Using AWS CDK, you can enforce this on all buckets created in your infrastructure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CfnTag&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'aws-cdk-lib'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Construct&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'constructs'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;BucketEncryption&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'aws-cdk-lib/aws-s3'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Tags&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'aws-cdk-lib'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DataLakeStack&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="nc"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dataBucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'RawDataBucket'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;encryption&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BucketEncryption&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;S3_MANAGED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Enforce cost allocation tags&lt;/span&gt;
    &lt;span class="nc"&gt;Tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataBucket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Project'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'AnalyticsPipeline'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataBucket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'CostCenter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'12345'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&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;p&gt;Once you apply these tags, you must activate them in the AWS Billing console under &lt;strong&gt;Cost Allocation Tags&lt;/strong&gt;. AWS only reports on tags you have explicitly activated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Analyzing request and transfer patterns
&lt;/h2&gt;

&lt;p&gt;To identify if your costs are driven by requests rather than storage, you need to correlate your access logs with your cost data. The following diagram illustrates the data flow for cost analysis:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    S3["Amazon S3 Buckets"] --&amp;gt; CloudTrail["AWS CloudTrail (Data Events)"]
    S3 --&amp;gt; S3AccessLogs["S3 Server Access Logs"]
    CloudTrail --&amp;gt; Athena["Amazon Athena"]
    S3AccessLogs --&amp;gt; Athena
    Billing["AWS Billing/Cost Exports"] --&amp;gt; S3Bucket["S3 Cost &amp;amp; Usage Reports Bucket"]
    S3Bucket --&amp;gt; Athena
    Athena --&amp;gt; Quicksight["Reporting/Observability"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The request path for a typical data job involves multiple API calls. If you are using a tool like Apache Spark or Athena, a single query might trigger thousands of &lt;code&gt;LIST&lt;/code&gt; or &lt;code&gt;HEAD&lt;/code&gt; operations if the data isn't partitioned correctly. You can use S3 Server Access Logs to count these operations. Once configured, logs are delivered to a destination bucket, where you can query them using Athena to identify high-frequency callers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automating cost reporting with AWS Data Exports
&lt;/h2&gt;

&lt;p&gt;For a scalable solution, use AWS Data Exports to deliver Cost and Usage Reports (CUR) to an S3 bucket. Unlike the standard Cost Explorer, CUR provides line-item granularity, including the &lt;code&gt;UsageType&lt;/code&gt; column, which distinguishes between &lt;code&gt;StandardStorage&lt;/code&gt;, &lt;code&gt;PutRequests&lt;/code&gt;, and &lt;code&gt;DataTransfer-Out-Bytes&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create an Export:&lt;/strong&gt; Configure an export in the AWS Billing console targeting an S3 bucket.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partition the Data:&lt;/strong&gt; Use a Glue crawler to create an Athena table over the exported CSV or Parquet files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query the Data:&lt;/strong&gt; Use SQL to isolate the cost drivers by tag and usage type.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;line_item_usage_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line_item_unblended_cost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;total_cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;resource_tags_user_project&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; 
    &lt;span class="n"&gt;cur_table&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; 
    &lt;span class="n"&gt;line_item_product_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'AmazonS3'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; 
    &lt;span class="n"&gt;line_item_usage_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;resource_tags_user_project&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; 
    &lt;span class="n"&gt;total_cost&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify the controls
&lt;/h2&gt;

&lt;p&gt;To verify your cost visibility setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ensure your tags are active in the AWS Billing console.&lt;/li&gt;
&lt;li&gt;Run the SQL query above in Athena.&lt;/li&gt;
&lt;li&gt;Look for &lt;code&gt;UsageType&lt;/code&gt; values like &lt;code&gt;Requests-Tier1&lt;/code&gt; (PUT, COPY, POST) or &lt;code&gt;Requests-Tier2&lt;/code&gt; (GET, LIST). If &lt;code&gt;Requests-Tier2&lt;/code&gt; dominates your costs, your application is likely over-scanning the bucket.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What this doesn't cover
&lt;/h2&gt;

&lt;p&gt;This approach identifies cost drivers but does not automatically optimize them. It does not replace the need for lifecycle policies to transition data to cheaper storage classes (like S3 Glacier Instant Retrieval) or the use of S3 Inventory reports to understand object age distributions. Additionally, this methodology focuses on the "what" and "where" of costs; it does not provide performance tuning advice for specific compute frameworks like Spark or Flink.&lt;/p&gt;

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

&lt;p&gt;By implementing cost allocation tags and leveraging AWS Data Exports, you transform the S3 bill from an opaque "storage cost" into a granular map of your data platform's behavior. The key decision is to treat cost metadata as a first-class citizen of your infrastructure, just like performance metrics or security logs. Your next step should be to enable S3 Server Access Logs on your most expensive bucket and run a sample query to identify if &lt;code&gt;LIST&lt;/code&gt; requests are the silent culprit behind your rising costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html" rel="noopener noreferrer"&gt;AWS Billing and Cost Management: Cost Allocation Tags&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/aws-usage-report-understand.html" rel="noopener noreferrer"&gt;Amazon S3: Monitoring costs with Cost Explorer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/cur/latest/userguide/cur-create.html" rel="noopener noreferrer"&gt;AWS Data Exports: Creating a Cost and Usage Report&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html" rel="noopener noreferrer"&gt;Amazon S3: Logging requests with server access logging&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@ismailenesayhan?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;İsmail Enes Ayhan&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>s3</category>
      <category>finops</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>Should you use S3 Event Notifications or EventBridge for file arrivals?</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Wed, 18 Nov 2026 11:31:14 +0000</pubDate>
      <link>https://dev.to/aniketsoni/should-you-use-s3-event-notifications-or-eventbridge-for-file-arrivals-4ndn</link>
      <guid>https://dev.to/aniketsoni/should-you-use-s3-event-notifications-or-eventbridge-for-file-arrivals-4ndn</guid>
      <description>&lt;p&gt;S3 Event Notifications can lose events if you misconfigure the underlying destination, yet many engineers treat them as a reliable message queue. When your S3 bucket receives thousands of files per minute, a misconfigured downstream consumer—such as a Lambda function with insufficient concurrency limits—leads to silent event loss or massive retry storms that overwhelm your downstream databases.&lt;/p&gt;

&lt;p&gt;This article explains the architectural differences between direct S3 Event Notifications and the EventBridge-based approach. You will learn how to shift from a direct, "fire-and-forget" notification model to a robust, event-driven pattern using Amazon EventBridge. This scope covers the configuration of both mechanisms and the implications for delivery reliability and observability; it does not cover S3 Batch Operations or S3 Inventory reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you'll build
&lt;/h2&gt;

&lt;p&gt;You will implement an event-driven architecture that captures S3 object creation events and routes them through EventBridge to a consumer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  A source S3 bucket configured to publish events to the default EventBridge bus.&lt;/li&gt;
&lt;li&gt;  An EventBridge rule to filter specific object-creation events.&lt;/li&gt;
&lt;li&gt;  A target Amazon SQS queue to decouple the arrival event from the processor, providing buffering and retry capabilities.&lt;/li&gt;
&lt;li&gt;  A Lambda function as an idempotent consumer.
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    S3["Amazon S3 (bucket)"] --&amp;gt; EB["Amazon EventBridge (default bus)"]
    EB --&amp;gt; SQS["Amazon SQS (queue)"]
    SQS --&amp;gt; Lambda["AWS Lambda (processor)"]&lt;/code&gt;&lt;/pre&gt;



&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  An AWS account with access to the AWS CLI v2 and IAM permissions to create buckets, rules, and queues.&lt;/li&gt;
&lt;li&gt;  AWS CLI configured with a profile that has &lt;code&gt;AdministratorAccess&lt;/code&gt; for the purpose of this tutorial.&lt;/li&gt;
&lt;li&gt;  The tutorial assumes you are working in a single Region, such as &lt;code&gt;us-east-1&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Configure S3 to publish to EventBridge
&lt;/h2&gt;

&lt;p&gt;By default, S3 buckets do not send events to EventBridge. You must explicitly enable this via the bucket's notification configuration. Enabling this allows you to leverage EventBridge's routing capabilities instead of tight coupling to a single destination.&lt;/p&gt;

&lt;p&gt;Run the following command to enable event notifications for your bucket:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3api put-bucket-notification-configuration \
    --bucket &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-unique-bucket-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --notification-configuration &lt;span class="s1"&gt;'{
        "EventBridgeConfiguration": {}
    }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify this configuration by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3api get-bucket-notification-configuration \
    --bucket &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-unique-bucket-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;"EventBridgeConfiguration": {}&lt;/code&gt; in the JSON output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create a buffer queue
&lt;/h2&gt;

&lt;p&gt;Directly invoking Lambda from S3 events is common, but using an SQS queue as an intermediary provides a safety net. If your processing logic fails or hits a concurrency limit, the events remain in the queue rather than being lost or forcing an immediate, potentially destructive retry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws sqs create-queue --queue-name s3-event-buffer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Capture the Queue URL from the output for use in the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Create an EventBridge rule
&lt;/h2&gt;

&lt;p&gt;The rule acts as a filter. Instead of receiving every S3 event, we only want to trigger our pipeline when a file is uploaded to a specific prefix (e.g., &lt;code&gt;uploads/&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Create a file named &lt;code&gt;rule.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"aws.s3"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"detail-type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Object Created"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"detail"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"bucket"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;your-unique-bucket-name&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"prefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"uploads/"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&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;p&gt;Now, create the rule and link it to your SQS queue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws events put-rule \
    --name s3-to-sqs-rule \
    --event-pattern file://rule.json

aws events put-targets \
    --rule s3-to-sqs-rule \
    --targets &lt;span class="s2"&gt;"Id"&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"target1"&lt;/span&gt;,&lt;span class="s2"&gt;"Arn"&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:sqs:&amp;lt;region&amp;gt;:&amp;lt;account-id&amp;gt;:s3-event-buffer"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify, upload a test file to the bucket:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;touch test.txt
aws s3 cp test.txt s3://&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-unique-bucket-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/uploads/test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the SQS queue depth after a few seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws sqs get-queue-attributes \
    --queue-url &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-queue-url&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --attribute-names ApproximateNumberOfMessages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Configure Lambda with an SQS trigger
&lt;/h2&gt;

&lt;p&gt;Your Lambda function should read from the SQS queue. Because SQS allows for partial batch failures, ensure your code logic handles individual messages and only deletes them from the queue upon successful processing.&lt;/p&gt;

&lt;p&gt;When writing your consumer, assume messages might arrive more than once. Use the S3 Object ETag or the event timestamp combined with the object key to ensure your data sink remains idempotent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design decisions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;EventBridge, not direct S3 notifications.&lt;/strong&gt; S3 event notifications allow you to send events directly to SQS, SNS, or Lambda. However, EventBridge provides a centralized bus where you can add multiple consumers—such as a logging service, an alerting service, and your data pipeline—without modifying the S3 bucket configuration.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;SQS buffer, not direct Lambda invocation.&lt;/strong&gt; Direct invocation is simpler but lacks a native retry buffer. If your Lambda function fails due to an upstream database timeout, direct invocations are harder to manage. SQS provides a Dead Letter Queue (DLQ) mechanism, which is critical for handling poison messages.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Filtering at the bus, not at the processor.&lt;/strong&gt; By using EventBridge rules to filter events, you save compute costs. You only pay for the events that trigger your downstream targets, rather than invoking a Lambda function just to have it check a string and exit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Symptom: Events are not appearing in the SQS queue.&lt;/strong&gt; Check if the SQS queue policy allows the &lt;code&gt;events.amazonaws.com&lt;/code&gt; service principal to perform &lt;code&gt;sqs:SendMessage&lt;/code&gt;. Without this, EventBridge cannot deliver the message.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Symptom: Lambda is not receiving events.&lt;/strong&gt; Ensure the Lambda function is mapped to the SQS trigger and that the execution role has &lt;code&gt;sqs:ReceiveMessage&lt;/code&gt;, &lt;code&gt;sqs:DeleteMessage&lt;/code&gt;, and &lt;code&gt;sqs:GetQueueAttributes&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Symptom: High latency in processing.&lt;/strong&gt; Verify the batch size and batch window settings on your SQS-to-Lambda trigger. If the batch window is set to a high value, Lambda waits until that duration passes or the batch size is reached before executing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;To avoid ongoing charges for these resources, delete the created components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Delete the rule and targets&lt;/span&gt;
aws events remove-targets --rule s3-to-sqs-rule --ids target1
aws events delete-rule --name s3-to-sqs-rule

&lt;span class="c"&gt;# Delete the queue&lt;/span&gt;
aws sqs delete-queue --queue-url &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-queue-url&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;# Remove bucket notification&lt;/span&gt;
aws s3api put-bucket-notification-configuration \
    --bucket &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-unique-bucket-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --notification-configuration &lt;span class="s1"&gt;'{}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;By using EventBridge as the intermediary for S3 file events, you gain the ability to decouple your data producers from your consumers and add multiple downstream listeners without operational complexity. Using an SQS queue between EventBridge and your processing logic provides the necessary buffer to handle surges and failures gracefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it:&lt;/strong&gt; Modify the EventBridge rule pattern to trigger only on specific file extensions (like &lt;code&gt;.parquet&lt;/code&gt; or &lt;code&gt;.csv&lt;/code&gt;) to further refine which files enter your data pipeline.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventNotifications.html" rel="noopener noreferrer"&gt;Amazon S3 Event Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html" rel="noopener noreferrer"&gt;Amazon EventBridge Event Patterns&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html" rel="noopener noreferrer"&gt;Using AWS Lambda with Amazon SQS&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tags: #aws #s3 #eventdriven #dataengineering&lt;/p&gt;

&lt;p&gt;&lt;em&gt;About the examples: automated checks confirmed that the JSON block parses and that 9 AWS CLI commands match the AWS service API models (operation and parameter names). The examples have not been run end to end, so test them in a non-production environment before relying on them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@dries_v?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Dries Vanlerberghe&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>s3</category>
      <category>eventdriven</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>Why does my Lambda function hit "Too many connections" on Amazon RDS?</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Tue, 17 Nov 2026 05:04:21 +0000</pubDate>
      <link>https://dev.to/aniketsoni/why-does-my-lambda-function-hit-too-many-connections-on-amazon-rds-3eg9</link>
      <guid>https://dev.to/aniketsoni/why-does-my-lambda-function-hit-too-many-connections-on-amazon-rds-3eg9</guid>
      <description>&lt;p&gt;Consider a hypothetical pipeline where a set of AWS Lambda functions processes incoming event streams from an Amazon Data Firehose delivery stream. Each time a record arrives, the Lambda function spins up, opens a new TCP connection to an Amazon RDS for PostgreSQL instance, executes a small &lt;code&gt;INSERT&lt;/code&gt; query, and closes the connection. During steady state, this works fine. However, during a traffic spike, the number of concurrent Lambda executions exceeds the database's &lt;code&gt;max_connections&lt;/code&gt; parameter, causing the database to reject new connections. The system starts failing with connection timeout errors, leading to data loss in the ingestion layer.&lt;/p&gt;

&lt;p&gt;This article explains how to mitigate connection exhaustion by introducing Amazon RDS Proxy between your serverless compute and your relational database. We will cover the mechanics of proxying, how to configure it to manage connection pooling, and the operational trade-offs involved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Symptoms
&lt;/h2&gt;

&lt;p&gt;Engineers often observe these symptoms when connection saturation occurs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Application Errors:&lt;/strong&gt; The logs show &lt;code&gt;psycopg2.OperationalError: FATAL: remaining connection slots are reserved for non-replication superuser connections&lt;/code&gt; or generic "connection refused" messages.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;High Database Load:&lt;/strong&gt; Even if CPU usage is low, the &lt;code&gt;DatabaseConnections&lt;/code&gt; metric in Amazon CloudWatch shows a flat line at the &lt;code&gt;max_connections&lt;/code&gt; limit.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Latency Spikes:&lt;/strong&gt; Queries wait in a queue or time out while trying to establish a connection, not because the query itself is slow.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A common false lead is to simply increase the &lt;code&gt;max_connections&lt;/code&gt; parameter on the RDS instance. While this provides temporary relief, it increases the memory pressure on the database server, as each connection consumes RAM for buffers and thread management. This approach fails to address the underlying architectural issue: the mismatch between the short-lived, bursty nature of serverless compute and the overhead of establishing stateful TCP connections to a relational database.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    lambda["AWS Lambda (Compute)"]
    proxy["Amazon RDS Proxy"]
    db["Amazon RDS / Aurora"]

    lambda -- "Pooled Connection" --&amp;gt; proxy
    proxy -- "Persistent Connection" --&amp;gt; db&lt;/code&gt;&lt;/pre&gt;



&lt;h2&gt;
  
  
  1. Connection Saturation
&lt;/h2&gt;

&lt;p&gt;The most common cause is the "one-request, one-connection" pattern. Every time a Lambda function initializes, it performs a TCP handshake and a TLS negotiation, followed by a database authentication handshake. This process is computationally expensive for the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt; Check the &lt;code&gt;DatabaseConnections&lt;/code&gt; metric in CloudWatch. If it consistently hits the limit defined in your RDS Parameter Group, you have reached your capacity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt; Introduce Amazon RDS Proxy. It maintains a pool of established connections to the database. When a Lambda function requests a connection, the proxy assigns an existing, idle connection from the pool rather than forcing the database to spawn a new backend process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify:&lt;/strong&gt; Monitor the &lt;code&gt;DatabaseConnections&lt;/code&gt; metric after enabling the proxy. You should see a lower number of connections to the RDS instance, as the proxy multiplexes many client connections over a smaller number of established server connections.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Incorrect Proxy Target Configuration
&lt;/h2&gt;

&lt;p&gt;A common error occurs when Lambda functions attempt to connect to the RDS endpoint directly instead of the RDS Proxy endpoint. The proxy cannot pool connections if the traffic bypasses it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt; Inspect your Lambda environment variables. Ensure the &lt;code&gt;DB_HOST&lt;/code&gt; variable points to the proxy endpoint (e.g., &lt;code&gt;proxy-name.proxy-xyz.region.rds.amazonaws.com&lt;/code&gt;), not the RDS instance endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt; Update your infrastructure-as-code to route application traffic to the proxy endpoint. If using AWS CDK, reference the proxy endpoint programmatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example: AWS CDK snippet&lt;/span&gt;
&lt;span class="n"&gt;proxy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DatabaseProxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Proxy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;proxy_target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;rds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProxyTarget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_db_instance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_db_instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;my_secret&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;vpc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;my_vpc&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Use proxy.endpoint in your application config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Verify:&lt;/strong&gt; Use &lt;code&gt;netstat&lt;/code&gt; or check the application logs to confirm the connection is being routed to the proxy’s DNS name.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Excessive Connection Idle Timeout
&lt;/h2&gt;

&lt;p&gt;If the &lt;code&gt;IdleClientTimeout&lt;/code&gt; in your proxy configuration is too high, the proxy might keep too many connections open, preventing the database from reclaiming resources. Conversely, if it is too low, the proxy constantly creates and destroys connections, negating the performance benefits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt; Check the &lt;code&gt;ClientConnections&lt;/code&gt; and &lt;code&gt;DatabaseConnections&lt;/code&gt; metrics in the RDS Proxy CloudWatch namespace. If &lt;code&gt;ClientConnections&lt;/code&gt; is high but &lt;code&gt;DatabaseConnections&lt;/code&gt; is also near the limit, your pooling efficiency is low.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt; Tune the &lt;code&gt;IdleClientTimeout&lt;/code&gt; parameter based on your workload's inter-arrival time. For bursty workloads, a value that matches your average event interval is ideal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify:&lt;/strong&gt; Observe the &lt;code&gt;DatabaseConnections&lt;/code&gt; metric. You want to see it remain stable even as &lt;code&gt;ClientConnections&lt;/code&gt; (the incoming Lambda requests) fluctuates.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Authentication Mismatch
&lt;/h2&gt;

&lt;p&gt;RDS Proxy requires the Lambda function to have access to the database credentials stored in AWS Secrets Manager. If the IAM role attached to the Lambda lacks &lt;code&gt;secretsmanager:GetSecretValue&lt;/code&gt; permissions, the proxy cannot authenticate the connection on behalf of the function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt; Check CloudWatch Logs for &lt;code&gt;Access Denied&lt;/code&gt; errors or authentication failures during the connection phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt; Ensure the IAM policy for the Lambda function follows the principle of least privilege:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"secretsmanager:GetSecretValue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;your-secret-arn&amp;gt;"&lt;/span&gt;
        &lt;span class="p"&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;p&gt;&lt;strong&gt;Verify:&lt;/strong&gt; Run a test invocation of the Lambda function. If the connection succeeds, the proxy successfully retrieved the secret.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preventing it
&lt;/h2&gt;

&lt;p&gt;To prevent these issues systemically:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Use Connection Pooling:&lt;/strong&gt; Never allow serverless functions to open connections without a proxy in a high-concurrency environment.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Monitor Early:&lt;/strong&gt; Set up CloudWatch Alarms on the &lt;code&gt;DatabaseConnections&lt;/code&gt; metric before you reach your limit.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Decouple with Queues:&lt;/strong&gt; If possible, introduce an Amazon SQS queue between your event source and the Lambda function to throttle the rate at which connections are requested, effectively smoothing out the bursts.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Implement Exponential Backoff:&lt;/strong&gt; Ensure your application code uses a connection retry strategy with exponential backoff to avoid overwhelming the proxy during a recovery phase.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;If you have created an RDS Proxy for testing purposes, ensure you delete it to avoid ongoing costs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Navigate to the &lt;strong&gt;RDS Console&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Select &lt;strong&gt;Proxies&lt;/strong&gt; from the navigation pane.&lt;/li&gt;
&lt;li&gt; Select the proxy and choose &lt;strong&gt;Delete&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Remove the associated Secrets Manager secret and the RDS instance if they are no longer required.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Amazon RDS Proxy solves the problem of connection exhaustion by decoupling the number of incoming client requests from the number of established database connections. By correctly routing your traffic to the proxy endpoint and ensuring your IAM roles have the necessary permissions to access database secrets, you can maintain system stability even under high, bursty traffic. As a next step, audit your existing Lambda functions to ensure they are using persistent connection objects defined outside the function handler, which allows the Lambda execution environment to reuse connections between invocations.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/rds/latest/userguide/rds-proxy.html" rel="noopener noreferrer"&gt;Amazon RDS Proxy documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/rds/latest/userguide/rds-proxy-managing.html" rel="noopener noreferrer"&gt;Managing connections with RDS Proxy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html" rel="noopener noreferrer"&gt;AWS Secrets Manager documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;About the examples: automated checks confirmed that the Python and JSON blocks parse. The examples have not been run end to end, so test them in a non-production environment before relying on them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@tylergm?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Tyler&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>database</category>
      <category>lambda</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Use dedicated IAM roles for every data pipeline job</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Mon, 16 Nov 2026 19:15:46 +0000</pubDate>
      <link>https://dev.to/aniketsoni/use-dedicated-iam-roles-for-every-data-pipeline-job-2jh9</link>
      <guid>https://dev.to/aniketsoni/use-dedicated-iam-roles-for-every-data-pipeline-job-2jh9</guid>
      <description>&lt;p&gt;Most data engineers assume that a single "ETL-Role" shared across an entire orchestration platform is sufficient because the services are internal. This assumption is a common precursor to lateral movement if a single job is compromised, as that job inherits the broad permissions of every other pipeline in your environment. When a job that only needs to read from a specific S3 prefix suddenly has the ability to delete tables in your data warehouse or read sensitive secrets from Parameter Store, your blast radius is effectively the entire platform.&lt;/p&gt;

&lt;p&gt;This article shows how to break the "shared service role" pattern by implementing job-specific IAM roles. We will focus on defining discrete execution roles for individual tasks, ensuring that a failure in one pipeline component cannot be used to escalate privileges or access data outside of that component’s narrow scope. This scope covers AWS IAM policy design and resource-based policy attachments for common data orchestration patterns.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; Shared roles violate the principle of least privilege by granting aggregate permissions to every job, which complicates auditing and increases the risk of data exfiltration. By assigning a dedicated role to each job, you ensure that even a compromised process remains sandboxed within its intended data domain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What you'll build
&lt;/h2&gt;

&lt;p&gt;You will create a granular IAM infrastructure that isolates a data ingestion job from a transformation job. Instead of a single powerful role, each job uses a unique identity with only the permissions required for its specific task.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    JobA["Data Ingestion Job (IAM Role A)"] --&amp;gt; S3Raw["Amazon S3 (Raw Bucket)"]
    JobB["Transformation Job (IAM Role B)"] --&amp;gt; S3Raw
    JobB --&amp;gt; S3Clean["Amazon S3 (Clean Bucket)"]
    JobA -.-&amp;gt; S3Clean
    style JobA fill:#f9f,stroke:#333
    style JobB fill:#ccf,stroke:#333
    style S3Raw fill:#eee,stroke:#333
    style S3Clean fill:#eee,stroke:#333&lt;/code&gt;&lt;/pre&gt;



&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An active AWS account.&lt;/li&gt;
&lt;li&gt;AWS CLI v2 installed and configured.&lt;/li&gt;
&lt;li&gt;Basic familiarity with AWS IAM JSON policy syntax.&lt;/li&gt;
&lt;li&gt;You should have two S3 buckets: &lt;code&gt;data-raw-bucket&lt;/code&gt; and &lt;code&gt;data-clean-bucket&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Create the ingestion execution role
&lt;/h2&gt;

&lt;p&gt;The ingestion job only needs &lt;code&gt;s3:PutObject&lt;/code&gt; access to the raw bucket. We create a dedicated role for this purpose to prevent it from ever reading or writing to the clean bucket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:PutObject"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::data-raw-bucket/*"&lt;/span&gt;
    &lt;span class="p"&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;p&gt;Use the AWS CLI to create this role and attach the policy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws iam create-role --role-name IngestionJobRole --assume-role-policy-document &lt;span class="s1"&gt;'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}'&lt;/span&gt;
aws iam put-role-policy --role-name IngestionJobRole --policy-name S3WriteOnly --policy-document file://ingest-policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the role exists: &lt;code&gt;aws iam get-role --role-name IngestionJobRole&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create the transformation execution role
&lt;/h2&gt;

&lt;p&gt;The transformation job requires &lt;code&gt;s3:GetObject&lt;/code&gt; on the raw bucket and &lt;code&gt;s3:PutObject&lt;/code&gt; on the clean bucket. It must not have any permissions to modify existing raw data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::data-raw-bucket/*"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:PutObject"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::data-clean-bucket/*"&lt;/span&gt;
    &lt;span class="p"&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;p&gt;Apply this policy to a distinct role:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws iam create-role --role-name TransformationJobRole --assume-role-policy-document &lt;span class="s1"&gt;'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}'&lt;/span&gt;
aws iam put-role-policy --role-name TransformationJobRole --policy-name S3TransformPolicy --policy-document file://transform-policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the role: &lt;code&gt;aws iam get-role --role-name TransformationJobRole&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Enforce the boundary with bucket policies
&lt;/h2&gt;

&lt;p&gt;Even with distinct roles, it is a best practice to verify bucket policies to deny access from unauthorized entities. This provides a secondary layer of protection should an IAM policy be accidentally modified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Deny"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"s3:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:s3:::data-clean-bucket/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Condition"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"StringNotLike"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nl"&gt;"aws:PrincipalArn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:iam::&amp;lt;account-id&amp;gt;:role/TransformationJobRole"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&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;p&gt;Apply this policy via &lt;code&gt;aws s3api put-bucket-policy&lt;/code&gt;. This ensures that even if an administrator mistakenly adds a new permission to a different role, the bucket itself will reject the request if the principal is not &lt;code&gt;TransformationJobRole&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design decisions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Role-per-job, not Role-per-service.&lt;/strong&gt; By isolating at the job level, you gain granular CloudTrail logs that identify exactly which business process performed an action. You give up the simplicity of managing a single global role but gain a significant reduction in blast radius.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inline policies, not Managed policies.&lt;/strong&gt; For highly specific jobs, inline policies ensure the policy cannot be accidentally shared or modified by updates to a managed policy. Use managed policies only for common, broad permissions that are truly ubiquitous across your platform.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deny-by-default in Resource Policies.&lt;/strong&gt; Use bucket policies to explicitly deny access to everyone except your designated role. This provides a safety net against "permission creep" where IAM roles are modified over time without corresponding updates to the data layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Access Denied on S3:&lt;/strong&gt; If your job fails with an Access Denied error, verify the &lt;code&gt;PrincipalArn&lt;/code&gt; in your bucket policy matches the ARN of the role being assumed by your job. Use &lt;code&gt;aws sts get-caller-identity&lt;/code&gt; inside your job environment to confirm the active role.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conflicting Policies:&lt;/strong&gt; If a role has both an inline policy and a managed policy, the effective permission is the union of both. Check all attached policies if a job seems to have "extra" access it shouldn't possess.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implicit Deny:&lt;/strong&gt; Remember that IAM evaluates all policies; if any policy contains a &lt;code&gt;Deny&lt;/code&gt;, the request is rejected regardless of any &lt;code&gt;Allow&lt;/code&gt; statements. If you see unexpected access errors, scan for explicit Deny statements in your Service Control Policies (SCPs) or bucket policies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;To remove the resources created in this tutorial, execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws iam delete-role-policy --role-name IngestionJobRole --policy-name S3WriteOnly
aws iam delete-role --role-name IngestionJobRole
aws iam delete-role-policy --role-name TransformationJobRole --policy-name S3TransformPolicy
aws iam delete-role --role-name TransformationJobRole
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;By mapping every data job to a unique IAM role, you transition from a "trusted platform" model to a "zero-trust" execution model where every pipeline component is individually permissioned. This reduces the risk of lateral movement and makes your infrastructure significantly easier to audit and secure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it:&lt;/strong&gt; Audit your current infrastructure by listing all roles used by your data pipelines and checking for overlap; consolidate any "general purpose" roles by splitting them into job-specific identities today.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html" rel="noopener noreferrer"&gt;AWS IAM Policies and Permissions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html" rel="noopener noreferrer"&gt;Using Bucket Policies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html" rel="noopener noreferrer"&gt;AWS Identity and Access Management Best Practices&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;About the examples: automated checks confirmed that the JSON blocks parse and that 12 AWS CLI commands match the AWS service API models (operation and parameter names). The examples have not been run end to end, so test them in a non-production environment before relying on them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@harveypower?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Harvey Power&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>security</category>
      <category>dataengineering</category>
      <category>s3</category>
    </item>
    <item>
      <title>Use EMR Serverless for Spark Jobs When You Want to Avoid Cluster Management</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Mon, 16 Nov 2026 19:15:38 +0000</pubDate>
      <link>https://dev.to/aniketsoni/use-emr-serverless-for-spark-jobs-when-you-want-to-avoid-cluster-management-1a6b</link>
      <guid>https://dev.to/aniketsoni/use-emr-serverless-for-spark-jobs-when-you-want-to-avoid-cluster-management-1a6b</guid>
      <description>&lt;p&gt;Imagine a nightly job that processes several terabytes of log data, requiring a massive compute footprint for two hours, after which the resource needs disappear entirely. If you manage a traditional Amazon EMR cluster, you are either paying for idle nodes while waiting for the next job or scrambling to handle cold-start provisioning delays. You either over-provision and hemorrhage budget, or under-provision and hit latency SLAs. Amazon EMR Serverless solves this by abstracting the infrastructure entirely; you define the Spark application, and the service handles the capacity allocation and de-allocation.&lt;/p&gt;

&lt;p&gt;This article walks through the deployment of a PySpark job on EMR Serverless, explains the underlying mechanics of how EMR Serverless manages capacity, and compares this model against running persistent EMR clusters.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mechanics of EMR Serverless
&lt;/h2&gt;

&lt;p&gt;When you submit a job to EMR Serverless, you are not interacting with an EC2 instance directly. Instead, you define an &lt;code&gt;Application&lt;/code&gt;—a logical construct that acts as a container for your jobs. When a job runs, the service spins up workers dynamically based on the configuration you provide in the &lt;code&gt;start-job-run&lt;/code&gt; request.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    job["Spark Submit Request"] --&amp;gt; app["EMR Serverless Application"]
    app --&amp;gt; worker1["Worker Node (Spark Executor)"]
    app --&amp;gt; worker2["Worker Node (Spark Executor)"]
    worker1 --&amp;gt; s3["Amazon S3 (Data Lake)"]
    worker2 --&amp;gt; s3
    app --&amp;gt; logs["Amazon CloudWatch Logs"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The service uses an internal capacity management layer that handles the lifecycle of these workers. Because the infrastructure is managed, you focus on Spark configuration—specifically &lt;code&gt;spark.executor.instances&lt;/code&gt; and &lt;code&gt;spark.driver.memory&lt;/code&gt;—rather than instance types or Auto Scaling Group policies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The contenders
&lt;/h2&gt;

&lt;p&gt;You are likely deciding between two primary paths for running Spark on AWS:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Amazon EMR Serverless&lt;/strong&gt;: An option where you define the application type (Spark) and the service handles the underlying cluster lifecycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon EMR on EC2&lt;/strong&gt;: The traditional approach where you manage a cluster of EC2 instances, handle patching, and configure Auto Scaling policies.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Performance and operational trade-offs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Operational overhead
&lt;/h3&gt;

&lt;p&gt;EMR on EC2 requires you to maintain the cluster state. You are responsible for OS-level patching, choosing the right instance families for your workload, and configuring EMR Managed Scaling to prevent the cluster from sitting idle. EMR Serverless removes the need to touch the OS or the cluster lifecycle. You submit the job, and the service manages the worker lifecycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost model
&lt;/h3&gt;

&lt;p&gt;In EMR on EC2, you pay for the EC2 instances regardless of whether the Spark executors are actively processing data, unless you have aggressive scaling policies that terminate nodes. EMR Serverless charges based on the vCPU, memory, and storage resources consumed by your application during the duration of the job run. The primary cost driver is the duration of the execution multiplied by the resource request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Failure modes
&lt;/h3&gt;

&lt;p&gt;On EMR on EC2, a node failure can potentially take down part of your application if not configured with high availability. Because EMR Serverless is a managed service, it handles individual worker failures internally. However, the trade-off is visibility; you have less control over the underlying network configuration and local storage mount options compared to a custom EMR on EC2 cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Amazon EMR on EC2&lt;/th&gt;
&lt;th&gt;Amazon EMR Serverless&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cluster Management&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Manual (OS, patching)&lt;/td&gt;
&lt;td&gt;Managed by AWS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Startup Latency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High (Cluster provisioning)&lt;/td&gt;
&lt;td&gt;Low (Pre-initialized workers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost Model&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Instance-hour&lt;/td&gt;
&lt;td&gt;VCPU/Memory-hour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Customization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High (Bootstraps, custom images)&lt;/td&gt;
&lt;td&gt;Limited (Spark config, custom images)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to measure it yourself
&lt;/h2&gt;

&lt;p&gt;To understand how your job behaves on EMR Serverless, start by creating a minimal application and monitoring the execution metrics in Amazon CloudWatch.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create the application:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws emr-serverless create-application \
    --name &lt;span class="s2"&gt;"my-spark-app"&lt;/span&gt; \
    --type &lt;span class="s2"&gt;"SPARK"&lt;/span&gt; \
    --release-label &lt;span class="s2"&gt;"emr-7.2.0"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Submit a test job:&lt;/strong&gt;
Use a simple script that reads a sample file from S3 and writes it back to a different prefix to measure execution time.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws emr-serverless start-job-run \
    --application-id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;application-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --execution-role-arn &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;role-arn&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --job-driver &lt;span class="s1"&gt;'{
        "sparkSubmit": {
            "entryPoint": "s3://&amp;lt;bucket&amp;gt;/scripts/test_script.py",
            "sparkSubmitParameters": "--conf spark.executor.cores=2 --conf spark.executor.memory=4g"
        }
    }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check metrics:&lt;/strong&gt;
Navigate to the EMR Serverless console and select your application. Look for the "Worker utilization" and "Job run duration" metrics. Compare these against your historical job run times on persistent clusters to determine if the overhead of cold starts (if any) impacts your specific workload.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What I'd pick, and why
&lt;/h2&gt;

&lt;p&gt;If your workload is bursty—meaning you have gaps between jobs or highly variable data volumes—I recommend EMR Serverless. The administrative savings of not managing cluster configurations and patches usually outweigh the slight premium in resource pricing. &lt;/p&gt;

&lt;p&gt;However, if you have a 24/7 streaming job or a massive, constant ETL pipeline that runs continuously, a persistent EMR on EC2 cluster or EMR on EKS might be more cost-effective due to the ability to leverage Spot instances more effectively and optimize instance types for specific memory-to-CPU ratios. &lt;/p&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;To avoid ongoing charges for your serverless application:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Delete the application:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws emr-serverless delete-application --application-id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;application-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Remove temporary files:&lt;/strong&gt;
Delete the S3 buckets or prefixes used for job scripts and output data.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; #aws #dataengineering #pyspark #serverless&lt;/p&gt;

&lt;p&gt;&lt;em&gt;About the examples: automated checks confirmed that 2 AWS CLI commands match the AWS service API models (operation and parameter names). The examples have not been run end to end, so test them in a non-production environment before relying on them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@steve_j?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Steve A Johnson&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>dataengineering</category>
      <category>pyspark</category>
      <category>spark</category>
    </item>
    <item>
      <title>Handling Poison Messages in AWS Event-Driven Pipelines</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Mon, 16 Nov 2026 05:08:07 +0000</pubDate>
      <link>https://dev.to/aniketsoni/handling-poison-messages-in-aws-event-driven-pipelines-jnd</link>
      <guid>https://dev.to/aniketsoni/handling-poison-messages-in-aws-event-driven-pipelines-jnd</guid>
      <description>&lt;p&gt;Imagine a hypothetical production pipeline where a Lambda function consumes events from an Amazon SQS queue to perform schema validation and write records to an Amazon DynamoDB table. One afternoon, an upstream system pushes a malformed JSON payload that misses a required primary key. The Lambda function crashes, SQS puts the message back in the queue after the visibility timeout expires, and the function immediately consumes the same bad message again. This "poison message" loop creates a self-inflicted denial-of-service attack, inflating your execution costs and delaying the processing of valid downstream events.&lt;/p&gt;

&lt;p&gt;In event-driven architectures, poison messages are inevitable. They are not always malicious; they are often caused by schema evolution mismatches, serialization errors, or unexpected data types. Handling them correctly is a requirement for building resilient systems, not an optional optimization. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To implement the patterns below, you should have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An active AWS account.&lt;/li&gt;
&lt;li&gt;AWS CLI v2 installed and configured.&lt;/li&gt;
&lt;li&gt;Basic familiarity with AWS Lambda, Amazon SQS, and Amazon EventBridge.&lt;/li&gt;
&lt;li&gt;The AWS CDK v2 installed for provisioning infrastructure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide assumes your infrastructure uses standard IAM execution roles with the principle of least privilege. We will focus on the SQS-Lambda pattern as it is the most common integration point for event processing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1568636808164-53becccdb024%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwxNnx8d2FybmluZyUyMHNpZ24lMjBpY29ufGVufDB8MHx8fDE3OTQ3ODAxMzV8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1568636808164-53becccdb024%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwxNnx8d2FybmluZyUyMHNpZ24lMjBpY29ufGVufDB8MHx8fDE3OTQ3ODAxMzV8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="yellow Danger signage at daytime" width="1080" height="723"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@helloimnik?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Nik&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Configuring SQS Dead-Letter Queues
&lt;/h2&gt;

&lt;p&gt;The first line of defense against poison messages is a Dead-Letter Queue (DLQ). Instead of letting a message block the primary consumer indefinitely, you configure the source queue to move messages to a secondary queue after a specified number of failed attempts.&lt;/p&gt;

&lt;p&gt;In your CDK stack, define both the primary queue and the DLQ. The &lt;code&gt;maxReceiveCount&lt;/code&gt; is the critical attribute; set this based on your retry logic. If your code is idempotent, a low number (e.g., 3) is usually sufficient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;aws_cdk&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;aws_sqs&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sqs&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;aws_cdk&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;

&lt;span class="c1"&gt;# The Dead Letter Queue&lt;/span&gt;
&lt;span class="n"&gt;dlq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Queue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PipelineDLQ"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# The Primary Queue&lt;/span&gt;
&lt;span class="n"&gt;source_queue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Queue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PipelineSourceQueue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;dead_letter_queue&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sqs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DeadLetterQueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;max_receive_count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dlq&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;visibility_timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&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;p&gt;By offloading the message to the &lt;code&gt;dlq&lt;/code&gt; after three attempts, you ensure the primary consumer remains healthy and available for subsequent, valid messages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Implementing Idempotent Consumers
&lt;/h2&gt;

&lt;p&gt;Moving a message to a DLQ is only half the battle. If your consumer fails partially through a batch process, you risk processing the same message twice. You must design your consumers to be idempotent.&lt;/p&gt;

&lt;p&gt;When using Lambda with SQS, partial batch failures can occur. If your Lambda processes a batch of 10 messages and the 8th message fails, you don't want to re-process the first 7. You can use the &lt;code&gt;ReportBatchItemFailures&lt;/code&gt; feature to tell SQS exactly which messages failed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;batch_item_failures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Records'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Process record logic&lt;/span&gt;
            &lt;span class="nf"&gt;process_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Add failed message ID to the list&lt;/span&gt;
            &lt;span class="n"&gt;batch_item_failures&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"itemIdentifier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'messageId'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"batchItemFailures"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;batch_item_failures&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By returning the &lt;code&gt;itemIdentifier&lt;/code&gt; of the failed messages, SQS will only keep those specific messages in the queue, while the successful ones are deleted. This prevents duplicate processing and ensures only the "poison" entries eventually hit the DLQ.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Handling Poison Messages in Streaming Services
&lt;/h2&gt;

&lt;p&gt;When moving from queue-based to stream-based processing with Amazon Kinesis Data Streams or Amazon MSK, the "poison message" concept changes. You cannot simply "delete" a message from a stream. Instead, you must use a "discard and continue" or a "side-output" pattern.&lt;/p&gt;

&lt;p&gt;For Amazon Managed Service for Apache Flink, you can use a &lt;code&gt;SideOutput&lt;/code&gt; to route malformed records to a separate destination (like an S3 bucket or a different Kinesis stream) without stopping the main application pipeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Conceptual Java snippet for Flink&lt;/span&gt;
&lt;span class="nc"&gt;OutputTag&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;deadLetterTag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OutputTag&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"dead-letters"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;SingleOutputStreamOperator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyData&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;processedStream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inputStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProcessFunction&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MyData&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;processElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Collector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyData&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;output&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadLetterTag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;processedStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getSideOutput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadLetterTag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;S3Sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&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;p&gt;This ensures that the main stream processor does not block on bad data while providing an audit trail for the poisoned records.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1666148670142-2f01b117e6e0%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyfHxkYXRhJTIwZmxvdyUyMGRpYWdyYW18ZW58MHwwfHx8MTc5NDc4MDEzNnww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1666148670142-2f01b117e6e0%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyfHxkYXRhJTIwZmxvdyUyMGRpYWdyYW18ZW58MHwwfHx8MTc5NDc4MDEzNnww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="diagram" width="1080" height="658"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@kenny161616?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;kenny cheng&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Pitfalls
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Infinite Loops:&lt;/strong&gt; If your DLQ consumer also fails to process the poison message and triggers a retry, you can end up with a recursive loop where messages move between queues. Ensure your DLQ consumer has robust exception handling that specifically catches schema errors and moves them to a "parking lot" storage (like S3) instead of attempting to re-process.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visibility Timeout Mismatch:&lt;/strong&gt; If your Lambda execution time exceeds the SQS &lt;code&gt;visibility_timeout&lt;/code&gt;, SQS will assume the function failed and put the message back in the queue even if the function is still working. Ensure &lt;code&gt;visibility_timeout&lt;/code&gt; is at least 6 times your Lambda &lt;code&gt;timeout&lt;/code&gt; setting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring Batch Metadata:&lt;/strong&gt; When processing batches, ensure you are using the correct metadata from the event object. Relying on global state or shared variables within a Lambda execution context during batch processing is a common source of non-deterministic behavior.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Poison messages are a diagnostic signal that your system needs better validation or error handling. By using SQS DLQs, implementing partial batch failure reporting, and utilizing side-outputs in streaming applications, you transform these failures from production outages into manageable data quality tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it:&lt;/strong&gt; Create an SQS queue with a DLQ attached. Send a dummy message that triggers an exception in your code. Verify that the message moves to the DLQ after the &lt;code&gt;maxReceiveCount&lt;/code&gt; is reached, and then inspect the message body using the AWS CLI:&lt;br&gt;
&lt;code&gt;aws sqs receive-message --queue-url &amp;lt;dlq-url&amp;gt; --max-number-of-messages 1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clean up:&lt;/strong&gt; Delete the SQS queues and any associated Lambda functions to avoid recurring costs.&lt;br&gt;
&lt;code&gt;aws sqs delete-queue --queue-url &amp;lt;primary-queue-url&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;aws sqs delete-queue --queue-url &amp;lt;dlq-url&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@trhammerhead?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Bryson Hammer&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>streaming</category>
      <category>dataengineering</category>
      <category>lambda</category>
    </item>
    <item>
      <title>Why Is Your Encrypted RDS Instance Refusing Connection Requests?</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Sun, 15 Nov 2026 05:59:52 +0000</pubDate>
      <link>https://dev.to/aniketsoni/why-is-your-encrypted-rds-instance-refusing-connection-requests-g1d</link>
      <guid>https://dev.to/aniketsoni/why-is-your-encrypted-rds-instance-refusing-connection-requests-g1d</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; When you enable encryption at rest for Amazon RDS or Aurora using AWS KMS, the database instance relies on the KMS service to decrypt its storage volumes on the fly. If the IAM identity or the RDS service-linked role loses its cryptographic permissions, the database may enter an inaccessible state or fail to perform essential operations like snapshots or cross-region replication, leading to silent production failures.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Consider a hypothetical pipeline that utilizes an Amazon Aurora PostgreSQL cluster. You have enforced encryption at rest using a Customer Managed Key (CMK). The infrastructure is deployed via Terraform, and you have strictly scoped IAM roles for the application services connecting to the database. Everything passes CI, but once deployed, the application encounters persistent "Access Denied" errors, and the database instance frequently reports performance degradation during automated snapshot intervals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Symptoms
&lt;/h2&gt;

&lt;p&gt;You observe the following in your monitoring tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Application logs report &lt;code&gt;connection timed out&lt;/code&gt; or &lt;code&gt;authentication failed&lt;/code&gt; errors, even though credentials are correct.&lt;/li&gt;
&lt;li&gt;  The RDS console displays a status of "Available," but attempts to create a manual snapshot fail with an &lt;code&gt;AccessDeniedException&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  CloudWatch Metrics show a spike in &lt;code&gt;KMSKeyError&lt;/code&gt; or similar diagnostic events.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The false lead here is to assume a network or VPC security group issue. You might spend hours checking Security Groups or NACLs, only to find that the network path is perfectly clear. The culprit is almost always a mismatch between the KMS Key Policy and the IAM role permissions required to perform the &lt;code&gt;kms:Decrypt&lt;/code&gt; and &lt;code&gt;kms:GenerateDataKey&lt;/code&gt; operations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1576269076940-31c888bebb3e%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyN3x8c2VydmVyJTIwcmFjayUyMHdpcmluZ3xlbnwwfDB8fHwxNzk0NjkyMzk1fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1576269076940-31c888bebb3e%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyN3x8c2VydmVyJTIwcmFjayUyMHdpcmluZ3xlbnwwfDB8fHwxNzk0NjkyMzk1fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="black cables" width="1080" height="720"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@thevictorbarrios?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Victor Barrios&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. The KMS Key Policy is Too Restrictive
&lt;/h2&gt;

&lt;p&gt;The most common failure pattern occurs when the KMS Key Policy does not explicitly grant the RDS service-linked role (or the specific IAM role interacting with the database) the necessary permissions to perform cryptographic operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Check the Key Policy in the AWS KMS console or via the CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws kms get-key-policy \
    --key-id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-kms-key-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --policy-name default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
Ensure your Key Policy allows the RDS service to use the key. A standard policy block should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"AllowRDSUse"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"Service"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"rds.amazonaws.com"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"kms:Encrypt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"kms:Decrypt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"kms:ReEncrypt*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"kms:GenerateDataKey*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"kms:DescribeKey"&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"*"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Missing Permissions for the IAM User/Role
&lt;/h2&gt;

&lt;p&gt;Even if the Key Policy is open, your application or the user attempting to access the database must have an IAM policy that allows them to use the key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Check the IAM policy attached to the principal executing the connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws iam simulate-principal-policy \
    --policy-source-arn &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-iam-role-arn&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
    --action-names kms:Decrypt kms:GenerateDataKey \
    --resource-arns &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-kms-key-arn&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
Attach an inline or managed policy to the IAM role that allows the &lt;code&gt;kms:Decrypt&lt;/code&gt; action for your specific key ARN. Avoid using &lt;code&gt;Resource: "*"&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s2"&gt;"kms:Decrypt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"kms:GenerateDataKey"&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;your-kms-key-arn&amp;gt;"&lt;/span&gt;
    &lt;span class="p"&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&gt;
  
  
  3. KMS Key Scheduled for Deletion
&lt;/h2&gt;

&lt;p&gt;If you recently performed a cleanup of "unused" keys, you might have inadvertently scheduled the key used by your RDS instance for deletion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Check the key status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws kms describe-key --key-id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-kms-key-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for the &lt;code&gt;KeyState&lt;/code&gt; field. If it is &lt;code&gt;PendingDeletion&lt;/code&gt;, the database will lose access to the key material required to decrypt its storage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
Cancel the deletion immediately if the waiting period has not expired:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws kms cancel-key-deletion --key-id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-kms-key-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Cross-Account KMS Access Failures
&lt;/h2&gt;

&lt;p&gt;In complex architectures, the RDS instance might reside in one account while the KMS key resides in a centralized security account. This requires a two-way trust: the KMS key policy must trust the RDS account, and the RDS account's IAM role must have permission to use the key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to confirm:&lt;/strong&gt;&lt;br&gt;
Check if the Key Policy allows access from the external account ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"AllowExternalAccountAccess"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"AWS"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arn:aws:iam::&amp;lt;external-account-id&amp;gt;:root"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"kms:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"*"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How to fix:&lt;/strong&gt;&lt;br&gt;
Update the Key Policy to include the ARN of the IAM role in the remote account, or the root user of that account, then ensure the remote IAM role has the corresponding policy described in point #2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1659782229445-19a69f10f6d8%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwxOHx8Y2xvdWQlMjBpbmZyYXN0cnVjdHVyZSUyMGRpYWdyYW18ZW58MHwwfHx8MTc5NDY5MjM5Nnww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1659782229445-19a69f10f6d8%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwxOHx8Y2xvdWQlMjBpbmZyYXN0cnVjdHVyZSUyMGRpYWdyYW18ZW58MHwwfHx8MTc5NDY5MjM5Nnww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="a colorful toy on a table" width="1080" height="608"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@theshubhamdhage?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Shubham Dhage&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Preventing it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Infrastructure as Code (IaC) Validation:&lt;/strong&gt; Use &lt;code&gt;tflint&lt;/code&gt; or &lt;code&gt;checkov&lt;/code&gt; to scan your Terraform templates for overly permissive or missing KMS key policies before deployment.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Service-Linked Roles:&lt;/strong&gt; Never attempt to manually modify or delete the &lt;code&gt;AWSServiceRoleForRDS&lt;/code&gt; service-linked role. It is managed by AWS and required for RDS to interact with KMS.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;CloudTrail Auditing:&lt;/strong&gt; Set up an EventBridge rule to alert you whenever a &lt;code&gt;kms:DisableKey&lt;/code&gt; or &lt;code&gt;kms:ScheduleKeyDeletion&lt;/code&gt; event occurs. &lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;IAM Access Analyzer:&lt;/strong&gt; Enable IAM Access Analyzer to identify if your KMS key policies allow access from outside your account, which helps in identifying accidental misconfigurations in multi-account environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;If you created resources for testing, ensure you clean them up to avoid ongoing costs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Delete the RDS/Aurora instance:&lt;/strong&gt; &lt;code&gt;aws rds delete-db-instance --db-instance-identifier &amp;lt;your-instance-id&amp;gt; --skip-final-snapshot&lt;/code&gt; (Use &lt;code&gt;--final-db-snapshot-identifier&lt;/code&gt; if you wish to retain data).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Disable/Delete the KMS Key:&lt;/strong&gt; If the key is no longer needed, schedule its deletion: &lt;code&gt;aws kms schedule-key-deletion --key-id &amp;lt;your-kms-key-id&amp;gt; --pending-window-in-days 7&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Remove IAM Policies:&lt;/strong&gt; Delete any temporary IAM roles or policies created for testing the access scenarios.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@isaax_the_artist?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Kedibone Isaac Makhumisane&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>database</category>
      <category>security</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>Is Your S3 Partitioning Strategy Silently Killing Your Athena Performance?</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:42:17 +0000</pubDate>
      <link>https://dev.to/aniketsoni/is-your-s3-partitioning-strategy-silently-killing-your-athena-performance-i39</link>
      <guid>https://dev.to/aniketsoni/is-your-s3-partitioning-strategy-silently-killing-your-athena-performance-i39</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- The "Anti-Pattern": Thousands of tiny files in a deep partition structure&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) FROM raw_logs WHERE event_date = '2023-10-01';

-- The "Optimized" Approach: Compaction and partition pruning
SELECT count(*)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;optimized_logs&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;event_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'2023-10-01'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; Amazon Athena charges based on the volume of data scanned. When your S3 layout creates a "small-files problem," Athena is forced to open, read metadata, and scan thousands of tiny objects, leading to increased latency and unnecessary costs that scale linearly with your technical debt.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every data engineer working with AWS eventually reaches the same threshold: the moment their S3 bucket transitions from a simple landing zone to a queryable data lake. You start with a few JSON files, but within months, you have millions of objects spread across a deep, nested directory tree. You assume that because you are using a "modern" stack, performance will remain constant. &lt;/p&gt;

&lt;p&gt;It does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it actually works
&lt;/h2&gt;

&lt;p&gt;When you execute a query in Amazon Athena, the engine must perform a "split" operation. It scans the metadata of the files located in the target prefix. If your data is scattered across thousands of 10KB files, the engine spends more time performing S3 &lt;code&gt;ListObjectsV2&lt;/code&gt; and &lt;code&gt;HeadObject&lt;/code&gt; API calls than it does actually processing your data.&lt;/p&gt;

&lt;p&gt;Consider an illustrative scenario: a logging pipeline writing events directly to S3 partitioned by date and hour.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;s3://my-data-lake/logs/year=2023/month=10/day=01/hour=01/file1.json
s3://my-data-lake/logs/year=2023/month=10/day=01/hour=01/file2.json
...
s3://my-data-lake/logs/year=2023/month=10/day=01/hour=01/file1000.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this layout, if you query for a single hour, Athena must reconcile 1,000 file headers. If you scale this to a year, you are looking at millions of metadata requests. The overhead of opening these files creates a "bottleneck of small files."&lt;/p&gt;

&lt;p&gt;To solve this, we move toward table formats like Apache Iceberg. Iceberg abstracts the physical file layout from the logical table. Instead of relying on Hive-style directory partitioning (which is brittle and metadata-heavy), Iceberg maintains a manifest file that acts as a map to your data files.&lt;/p&gt;

&lt;p&gt;When you use the AWS Glue Data Catalog with Iceberg, you can define your partitioning strategy explicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Using Iceberg with Glue/Athena&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;logs_iceberg&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;event_time&lt;/span&gt; &lt;span class="kt"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;event_id&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;PARTITIONED&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;days&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;LOCATION&lt;/span&gt; &lt;span class="s1"&gt;'s3://my-data-lake/iceberg/logs/'&lt;/span&gt;
&lt;span class="no"&gt;TBLPROPERTIES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'table_type'&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ICEBERG'&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;p&gt;By leveraging &lt;code&gt;days(event_time)&lt;/code&gt;, Iceberg performs hidden partitioning. You no longer need to manage physical directory paths like &lt;code&gt;year=/month=/day=&lt;/code&gt;. The engine manages the file mapping, and more importantly, allows for automated compaction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1546146975-e9583ed1396e%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyNXx8c2VydmVyJTIwcmFjayUyMGFic3RyYWN0aW9ufGVufDB8MHx8fDE3OTQ2MzQ5MDR8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1546146975-e9583ed1396e%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyNXx8c2VydmVyJTIwcmFjayUyMGFic3RyYWN0aW9ufGVufDB8MHx8fDE3OTQ2MzQ5MDR8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="yellow and blue crates" width="1080" height="809"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@jason_wu?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Jason Wu&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Design choices and tradeoffs
&lt;/h2&gt;

&lt;p&gt;The primary tradeoff in S3 layout design is between &lt;strong&gt;ingestion latency&lt;/strong&gt; and &lt;strong&gt;query performance&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you optimize for real-time ingestion (writing every single event as it arrives), you create small files. This is great for producers but terrible for consumers like Athena or Amazon Redshift Spectrum. If you optimize for query performance, you must buffer data and write in larger chunks (typically 128MB to 512MB for Parquet/ORC files).&lt;/p&gt;

&lt;p&gt;Compaction is the answer, but it is not free. &lt;/p&gt;

&lt;p&gt;When running a &lt;code&gt;rewrite_data_files&lt;/code&gt; procedure in Iceberg, you are effectively running a background job that reads small files and writes them back out into larger, optimized ones.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Compacting small files into 128MB chunks&lt;/span&gt;
&lt;span class="no"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rewrite_data_files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'my_catalog.my_db.logs_iceberg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'target-file-size-bytes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'134217728'&lt;/span&gt;&lt;span class="p"&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;p&gt;&lt;strong&gt;The trade-offs:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Compute Cost:&lt;/strong&gt; Compaction is an EMR or Glue job. You pay for the compute to "clean up" your lake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write Amplification:&lt;/strong&gt; You are writing the same data twice (once on ingest, once during compaction).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Ensure you have a strategy for dealing with deleted data. Iceberg handles this via snapshots and vacuuming, but you must monitor these to avoid ballooning storage costs.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When to reach for it (and when not to)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Reach for Iceberg/Compaction when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your query patterns involve scanning large time ranges (e.g., "give me the last 30 days of sales").&lt;/li&gt;
&lt;li&gt;You are hitting S3 throttling limits on metadata operations.&lt;/li&gt;
&lt;li&gt;Your Athena queries are consistently slow despite having few rows returned, indicating an overhead-bound query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Avoid over-engineering when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have a small dataset (under 100GB total). The overhead of managing manifests and compaction jobs will outweigh the performance gains.&lt;/li&gt;
&lt;li&gt;You are using S3 Select for simple, ad-hoc file retrieval where partitioning is irrelevant.&lt;/li&gt;
&lt;li&gt;You have a strict requirement for "milliseconds-from-event-to-query." In this case, accept the small-file penalty and use a tool like Amazon Managed Service for Apache Flink to aggregate before landing on S3.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1663577726664-dcd20f647915%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyMHx8ZGlnaXRhbCUyMGZvcmVzdCUyMG1hcHxlbnwwfDB8fHwxNzk0NjM0OTA1fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1663577726664-dcd20f647915%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyMHx8ZGlnaXRhbCUyMGZvcmVzdCUyMG1hcHxlbnwwfDB8fHwxNzk0NjM0OTA1fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="a forest of trees" width="1080" height="810"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@evil_bumblebee?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Ivan Stepanov&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;

&lt;p&gt;If you have been testing these patterns with AWS Glue and Athena, remember to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Delete the data from your S3 bucket to stop incurring storage costs.&lt;/li&gt;
&lt;li&gt;Drop the tables from your AWS Glue Data Catalog.&lt;/li&gt;
&lt;li&gt;Delete the IAM roles or service-linked roles created for your testing environment.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;The "small-files problem" is rarely a failure of the platform; it is a failure of the layout. By shifting from physical directory partitioning to managed table formats like Apache Iceberg, you decouple your storage layout from your query logic. Focus on file size consistency—aiming for the 128MB–512MB sweet spot—and automate your compaction. Your query costs will thank you.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@aashish_27?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Aashish Yadav&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>dataengineering</category>
      <category>athena</category>
      <category>s3</category>
    </item>
    <item>
      <title>Why Your Docker Builds Aren't Reproducible (And How to Fix Them)</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Sat, 14 Nov 2026 04:10:43 +0000</pubDate>
      <link>https://dev.to/aniketsoni/why-your-docker-builds-arent-reproducible-and-how-to-fix-them-3bg2</link>
      <guid>https://dev.to/aniketsoni/why-your-docker-builds-arent-reproducible-and-how-to-fix-them-3bg2</guid>
      <description>&lt;p&gt;The myth that &lt;code&gt;pip install -r requirements.txt&lt;/code&gt; creates a reproducible environment is the single most common cause of "it works on my machine" bugs in data engineering pipelines.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; In regulated data environments, non-deterministic builds are a compliance risk. If you cannot guarantee exactly which sub-dependency versions were installed in your production container, you cannot guarantee the integrity of your data processing logic.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem with loose requirements
&lt;/h2&gt;

&lt;p&gt;When you define dependencies in a &lt;code&gt;requirements.txt&lt;/code&gt; file using loose versioning (e.g., &lt;code&gt;pandas&amp;gt;=2.0.0&lt;/code&gt;), &lt;code&gt;pip&lt;/code&gt; resolves the environment at &lt;em&gt;build time&lt;/em&gt;. If you rebuild that same image two weeks later, &lt;code&gt;pip&lt;/code&gt; may fetch newer versions of sub-dependencies, resulting in a different runtime environment than the one you tested. To achieve true reproducibility, you need a "lock file"—a static snapshot of the entire dependency graph, including hashes for security.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1634634465913-5bb5600942f2%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyM3x8c291cmNlJTIwY29kZSUyMHRlcm1pbmFsfGVufDB8MHx8fDE3OTQ2MTAxNzJ8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1634634465913-5bb5600942f2%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyM3x8c291cmNlJTIwY29kZSUyMHRlcm1pbmFsfGVufDB8MHx8fDE3OTQ2MTAxNzJ8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="a computer screen with a bunch of text on it" width="1080" height="810"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@fongsoul?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;FONG&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;We will compare a standard, non-deterministic &lt;code&gt;requirements.txt&lt;/code&gt; approach with a locked environment using &lt;code&gt;uv&lt;/code&gt; (a modern, high-performance Python package manager).&lt;/p&gt;

&lt;p&gt;Ensure you have Docker installed. We will use &lt;code&gt;python:3.11-slim&lt;/code&gt; as our base image.&lt;/p&gt;

&lt;p&gt;Create a directory with the following files:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;requirements.in&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dockerfile.loose&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; python:3.11-slim
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; requirements.txt .
&lt;span class="k"&gt;RUN&lt;/span&gt; pip install --no-cache-dir -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The experiment
&lt;/h2&gt;

&lt;p&gt;In this experiment, we will generate a lock file and compare the build behavior.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initialize the locked environment:&lt;/strong&gt;
Using &lt;code&gt;uv&lt;/code&gt;, we generate a &lt;code&gt;requirements.txt&lt;/code&gt; that is fully pinned.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Install uv first&lt;/span&gt;
   pip install uv
   &lt;span class="c"&gt;# Generate the lock file&lt;/span&gt;
   uv pip compile requirements.in -o requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Examine the output:&lt;/strong&gt;&lt;br&gt;
Open the generated &lt;code&gt;requirements.txt&lt;/code&gt;. You will notice it includes every sub-dependency of &lt;code&gt;pandas&lt;/code&gt; and &lt;code&gt;requests&lt;/code&gt;, each pinned to an exact version with a corresponding hash.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build the hardened image:&lt;/strong&gt;&lt;br&gt;
We use a multi-stage Dockerfile to ensure our final image is minimal and secure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Stage 1: Build dependencies&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; python:3.11-slim AS builder
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;RUN&lt;/span&gt; apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get install -y --no-install-recommends gcc python3-dev &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; rm -rf /var/lib/apt/lists/*
&lt;span class="k"&gt;COPY&lt;/span&gt; requirements.txt .
&lt;span class="k"&gt;RUN&lt;/span&gt; pip install --user --no-cache-dir -r requirements.txt

&lt;span class="c"&gt;# Stage 2: Final runtime&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; python:3.11-slim
&lt;span class="c"&gt;# Create a non-root user for security&lt;/span&gt;
&lt;span class="k"&gt;RUN&lt;/span&gt; groupadd -r appuser &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; useradd -r -g appuser appuser
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="c"&gt;# Copy only the installed packages from builder&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder /root/.local /home/appuser/.local
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/appuser/.local/bin:&lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt; appuser
&lt;span class="c"&gt;# Add a healthcheck&lt;/span&gt;
&lt;span class="k"&gt;HEALTHCHECK&lt;/span&gt; --interval=30s --timeout=3s &lt;span class="k"&gt;CMD&lt;/span&gt; python -c &lt;span class="s2"&gt;"import pandas; print('ok')"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What to measure
&lt;/h2&gt;

&lt;p&gt;You are looking for two specific outcomes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Determinism:&lt;/strong&gt; If you run &lt;code&gt;docker build&lt;/code&gt; today and again in six months, the layer containing your dependencies should remain identical because the &lt;code&gt;requirements.txt&lt;/code&gt; file has not changed its hash-verified contents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Because you are using fixed versions and hashes, you have eliminated the risk of a malicious actor publishing a compromised "new" version of a sub-dependency that your loose requirement would have automatically pulled in.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Reproduce it
&lt;/h2&gt;

&lt;p&gt;Run the following commands to confirm the build process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Prepare requirements&lt;/span&gt;
pip install uv
uv pip compile requirements.in -o requirements.txt

&lt;span class="c"&gt;# 2. Build the image&lt;/span&gt;
docker build -t my-hardened-app:latest .

&lt;span class="c"&gt;# 3. Verify the image layers&lt;/span&gt;
docker &lt;span class="nb"&gt;history&lt;/span&gt; my-hardened-app:latest

&lt;span class="c"&gt;# 4. Run the container as non-root&lt;/span&gt;
docker run --rm --read-only --tmpfs /tmp --tmpfs /home/appuser/.local/lib/python3.11/site-packages/my_app my-hardened-app:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why this is the standard
&lt;/h2&gt;

&lt;p&gt;By using &lt;code&gt;uv pip compile&lt;/code&gt; (or &lt;code&gt;pip-compile&lt;/code&gt; from &lt;code&gt;pip-tools&lt;/code&gt;), you move the "resolution" step outside of your Docker build. The Dockerfile now only performs "installation." &lt;/p&gt;

&lt;p&gt;If you do not lock your files, you are effectively letting the &lt;code&gt;pip&lt;/code&gt; resolver perform a network call to PyPI to determine the latest available versions every time you build. This introduces a non-deterministic variable into your pipeline. In regulated industries, where "reproducibility" is often a requirement for audit trails, this is unacceptable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Security hardening notes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-stage builds:&lt;/strong&gt; By separating the build environment (which needs compilers like &lt;code&gt;gcc&lt;/code&gt;) from the runtime environment, you drastically reduce the attack surface of your final image.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-root users:&lt;/strong&gt; The &lt;code&gt;useradd&lt;/code&gt; command creates a dedicated user. Running as root inside a container is a vulnerability that should be avoided by default, especially in shared Kubernetes clusters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-only filesystems:&lt;/strong&gt; The &lt;code&gt;--read-only&lt;/code&gt; flag in &lt;code&gt;docker run&lt;/code&gt; ensures that your application cannot modify its own source code or install new packages at runtime, which is a critical defense-in-depth practice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By treating your dependencies as a static, locked artifact, you align your Python environment management with the same rigor you apply to your infrastructure-as-code or database migrations. If the environment is not pinned, it is not production-ready.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@growtika?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Growtika&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>Controlling Databricks Costs with Cluster Policies and Tagging</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Sat, 14 Nov 2026 04:10:28 +0000</pubDate>
      <link>https://dev.to/aniketsoni/controlling-databricks-costs-with-cluster-policies-and-tagging-25b6</link>
      <guid>https://dev.to/aniketsoni/controlling-databricks-costs-with-cluster-policies-and-tagging-25b6</guid>
      <description>&lt;p&gt;Giving data scientists and engineers direct access to create clusters is the fastest way to turn a cloud budget into a smoking crater. Most platforms attempt to solve this with "process"—asking users to check a box or follow a naming convention—but manual governance in distributed systems is a fantasy that fails the moment a deadline approaches.&lt;/p&gt;

&lt;p&gt;If you aren't using Databricks Cluster Policies to constrain the compute environment, you aren't managing costs; you are merely witnessing them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The contenders
&lt;/h2&gt;

&lt;p&gt;The choice here is between &lt;strong&gt;unrestricted cluster creation&lt;/strong&gt; (the default state) and &lt;strong&gt;policy-based enforcement&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Unrestricted creation allows maximum flexibility, letting users pick any instance type, runtime version, or library configuration. In environments where "move fast" is the only directive, this leads to massive instances being spun up for trivial tasks and forgotten when the notebook session closes.&lt;/p&gt;

&lt;p&gt;Cluster Policies, conversely, act as a schema for cluster creation. When a user creates a cluster via the UI or API, the policy acts as a gatekeeper. It can force specific configurations, hide dangerous options, or mandate tags. You are moving from a "please play nice" culture to a "the system prevents you from doing otherwise" architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1662210509843-5d1da1037b2b%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyM3x8cGFkbG9jayUyMG9uJTIwc2NyZWVufGVufDB8MHx8fDE3OTQ1MjM4NTF8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1662210509843-5d1da1037b2b%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyM3x8cGFkbG9jayUyMG9uJTIwc2NyZWVufGVufDB8MHx8fDE3OTQ1MjM4NTF8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="a close-up of a green leaf" width="1080" height="715"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@nika_benedictova?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Nika Benedictova&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Cost and resource constraints
&lt;/h2&gt;

&lt;p&gt;At the level of the Spark driver and executor, cluster policy is your primary tool for enforcing resource limits. You can use the &lt;code&gt;spark_conf&lt;/code&gt; attribute in a policy to force specific configurations or set absolute maximums for instance types.&lt;/p&gt;

&lt;p&gt;Consider an illustrative scenario where you want to prevent users from accidentally selecting memory-optimized instances for a simple ETL job. You can define a policy that restricts the &lt;code&gt;node_type_id&lt;/code&gt; to a specific list of general-purpose instances.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"node_type_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"fixed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Standard_DS3_v2"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"autotermination_minutes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"fixed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&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;p&gt;By forcing the &lt;code&gt;autotermination_minutes&lt;/code&gt; to 30, you ensure that even if a user forgets to shut down their cluster after a job runs, the platform terminates the compute automatically. This is a mechanism that operates at the cloud provider level (e.g., terminating the VM instances) rather than just pausing the Spark application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enforcing organizational accountability with tags
&lt;/h2&gt;

&lt;p&gt;In regulated industries, knowing exactly which cost center or project owns a specific cluster isn't just about accounting; it's a security and audit requirement. Databricks policies allow you to force the inclusion of custom tags.&lt;/p&gt;

&lt;p&gt;If you don't enforce tags via policy, they will be missing. It is that simple. By using the &lt;code&gt;custom_tags&lt;/code&gt; attribute in a cluster policy, you can mandate that users provide a &lt;code&gt;ProjectID&lt;/code&gt; or &lt;code&gt;CostCenter&lt;/code&gt; before they are even allowed to click "Create Cluster."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"custom_tags.ProjectID"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"unlimited"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"custom_tags.Environment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"fixed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"production"&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;p&gt;When a user attempts to create a cluster using this policy, the API will reject the request if the &lt;code&gt;ProjectID&lt;/code&gt; tag is missing. This pushes the data quality of your billing logs to the point of origin, ensuring that cloud provider invoices are sliced by tag without needing a separate, error-prone manual reconciliation process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Operational burden and failure modes
&lt;/h2&gt;

&lt;p&gt;The primary failure mode of implementing cluster policies is "policy drift" or being overly restrictive. If you lock down the &lt;code&gt;spark_version&lt;/code&gt; to a specific runtime that hits end-of-life, every cluster creation request will fail simultaneously.&lt;/p&gt;

&lt;p&gt;Policies require maintenance. You must treat them as code. If you define your policies through the Databricks UI, you lose the ability to version control your governance strategy. I recommend managing these policies via Terraform using the &lt;code&gt;databricks_cluster_policy&lt;/code&gt; resource. This allows you to peer-review changes to your infrastructure governance just like you would review a change to a PySpark transformation.&lt;/p&gt;

&lt;p&gt;Another failure mode is the "permission trap." If you remove the &lt;code&gt;canUse&lt;/code&gt; permission from a user or service principal, their existing automated jobs—if they rely on that policy—will fail to start during their next run. Always test policy updates in a staging workspace before applying them to a production environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Unrestricted&lt;/th&gt;
&lt;th&gt;Policy-Enforced&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost Control&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Hard limits via instance type/autoterm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Billing Accuracy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relies on user input&lt;/td&gt;
&lt;td&gt;Mandatory tagging enforcement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ops Burden&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low initially&lt;/td&gt;
&lt;td&gt;Requires lifecycle management&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;User Experience&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High freedom&lt;/td&gt;
&lt;td&gt;Context-specific guardrails&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1625296276703-3fbc924f07b5%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyMHx8c3ByZWFkc2hlZXQlMjBncmFwaHN8ZW58MHwwfHx8MTc5NDUyMzg1MXww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1625296276703-3fbc924f07b5%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyMHx8c3ByZWFkc2hlZXQlMjBncmFwaHN8ZW58MHwwfHx8MTc5NDUyMzg1MXww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="a computer screen with a bunch of data on it" width="1080" height="720"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@justin_morgan?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Justin Morgan&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to measure it yourself
&lt;/h2&gt;

&lt;p&gt;To see the impact of your policy, you don't need a massive cluster. You can observe the policy mechanism locally by simulating a request to the Databricks Clusters API.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a policy in your workspace.&lt;/li&gt;
&lt;li&gt;Use the Databricks CLI or a Python script with the &lt;code&gt;databricks-sdk&lt;/code&gt; to attempt to create a cluster that violates your policy.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;databricks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sdk&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;WorkspaceClient&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;databricks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;compute&lt;/span&gt;

&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;WorkspaceClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Attempt to create a cluster with a policy ID that forces a 30-min timeout&lt;/span&gt;
&lt;span class="c1"&gt;# and a specific node type.&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clusters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;cluster_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"test-policy-violation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;spark_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"13.3.x-scala2.12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;node_type_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Standard_F4s_v2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# Assuming policy forbids this&lt;/span&gt;
        &lt;span class="n"&gt;policy_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;your-policy-id&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;autotermination_minutes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt; &lt;span class="c1"&gt;# Assuming policy forbids this&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Policy successfully blocked the request: {e}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the API returns a &lt;code&gt;400 Bad Request&lt;/code&gt; related to policy validation, your guardrails are working. If the cluster spins up, your policy is either not applied to your user or is too permissive.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd pick, and why
&lt;/h2&gt;

&lt;p&gt;I always default to &lt;strong&gt;mandatory policies&lt;/strong&gt;. The argument that policies "slow down" developers is usually a symptom of poorly designed policies rather than the concept of policies itself. &lt;/p&gt;

&lt;p&gt;If you design your policies to be "self-service" (e.g., a "Data Science" policy that allows slightly more memory but forces cost tags, and an "ETL" policy that is rigid and cheap), developers won't feel shackled. They will feel supported because they don't have to guess what configuration is "correct."&lt;/p&gt;

&lt;p&gt;Avoid the temptation to create a "catch-all" policy. That leads to bloat and makes it impossible to update configurations without risking a workspace-wide outage. Instead, create a hierarchy of policies mapped to specific user personas or workloads. &lt;/p&gt;

&lt;p&gt;The goal isn't to stop people from doing data work; it’s to ensure that when they do that work, the platform is configured to be reliable, auditable, and cost-efficient by default.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; #databricks #dataengineering #cloud #security&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@amonwatdumkrut?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;AMONWAT DUMKRUT&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>databricks</category>
      <category>dataengineering</category>
      <category>cloud</category>
      <category>security</category>
    </item>
    <item>
      <title>Semantic models are not documentation-free zones</title>
      <dc:creator>Aniket Abhishek Soni</dc:creator>
      <pubDate>Thu, 12 Nov 2026 15:27:34 +0000</pubDate>
      <link>https://dev.to/aniketsoni/semantic-models-are-not-documentation-free-zones-4b1b</link>
      <guid>https://dev.to/aniketsoni/semantic-models-are-not-documentation-free-zones-4b1b</guid>
      <description>&lt;p&gt;The manual, click-based configuration of semantic models is a structural liability that no amount of documentation can fix. When you build large-scale models in Microsoft Fabric or Power BI, the GUI provides a false sense of control while hiding the technical debt accumulating in your metadata. &lt;/p&gt;

&lt;p&gt;Consider a hypothetical pipeline that manages a large-scale semantic model for a retail organization. The model contains hundreds of measures, dozens of calculated columns, and complex relationships. As the model grows, developers routinely rename columns directly in the Power BI Desktop file, create measures with inconsistent naming conventions, and forget to define format strings or descriptions. Eventually, the model becomes impossible to maintain, and the "technical debt" manifests as slow query performance and unintuitive reports for end-users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Symptoms
&lt;/h2&gt;

&lt;p&gt;An engineer managing this hypothetical model would likely notice these symptoms:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inconsistent user experience:&lt;/strong&gt; Reports suffer from "measure sprawl," where five different versions of a &lt;code&gt;Total Sales&lt;/code&gt; calculation exist with slightly different logic, leading to inconsistent numbers across the business.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance degradation:&lt;/strong&gt; Queries against the model take longer than expected, particularly in Direct Lake mode where suboptimal DAX can trigger fallback to DirectQuery.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metadata chaos:&lt;/strong&gt; Essential properties like &lt;code&gt;DisplayFolder&lt;/code&gt;, &lt;code&gt;Description&lt;/code&gt;, and &lt;code&gt;FormatString&lt;/code&gt; are missing, making the model opaque to self-service analysts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;False leads:&lt;/strong&gt; Engineers often spend hours debugging individual DAX queries, assuming the engine is at fault, when the actual issue is a lack of standardization in the underlying Tabular Object Model (TOM).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1684369175833-4b445ad6bfb5%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwzfHxhdXRvbWF0ZWQlMjB0ZXN0aW5nfGVufDB8MHx8fDE3OTQ0NDAzOTh8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1684369175833-4b445ad6bfb5%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwzfHxhdXRvbWF0ZWQlMjB0ZXN0aW5nfGVufDB8MHx8fDE3OTQ0NDAzOTh8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="a white robot with blue eyes and a laptop" width="1080" height="788"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@coopery?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Mohamed Nohassi&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. The "Default Sorting" Trap
&lt;/h2&gt;

&lt;p&gt;A common issue occurs when columns used for axes in visuals are not properly associated with a sort-by column (e.g., a &lt;code&gt;MonthName&lt;/code&gt; column should be sorted by a &lt;code&gt;MonthNumber&lt;/code&gt; column). Without this, your visuals look unprofessional and confusing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirmation:&lt;/strong&gt; Use Tabular Editor to connect to your semantic model. Navigate to the &lt;code&gt;Tables&lt;/code&gt; folder and inspect a date or category column. If &lt;code&gt;SortByColumn&lt;/code&gt; is empty, the model is likely defaulting to alphabetical order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Create a Best Practice Analyzer (BPA) rule. In Tabular Editor, go to &lt;code&gt;Tools &amp;gt; Manage BPA Rules&lt;/code&gt;. Add a new rule with this expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Checks if columns that look like months have a SortByColumn set&lt;/span&gt;
&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Month"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SortByColumn&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, define the fix action to prompt the developer to select the appropriate numeric sorting column.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Inconsistent Measure Categorization
&lt;/h2&gt;

&lt;p&gt;In large models, measures scattered at the root of a table are a sign of neglect. They should be grouped in &lt;code&gt;DisplayFolders&lt;/code&gt; to assist the end-user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirmation:&lt;/strong&gt; Inspect the metadata of your measures. If &lt;code&gt;DisplayFolder&lt;/code&gt; is empty for most measures, the model lacks logical structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Automate the detection of "orphan" measures. Add this BPA rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Flag any measure that does not belong to a display folder&lt;/span&gt;
&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DisplayFolder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This forces developers to organize their work as they develop, preventing the "wall of measures" problem before it reaches the production workspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Missing Documentation and Descriptions
&lt;/h2&gt;

&lt;p&gt;In regulated industries, data lineage and dictionary definitions are non-negotiable. If a measure is created without a &lt;code&gt;Description&lt;/code&gt; property, it is effectively a "black box" calculation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirmation:&lt;/strong&gt; Run the BPA scan. If you see dozens of warnings for "Missing Description," your model is poorly documented.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Use a BPA rule that enforces documentation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Flag measures that lack a description&lt;/span&gt;
&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can enforce this by setting the rule to "Error" rather than "Warning," preventing the deployment of models that fail to meet these documentation standards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1772976994862-d408ea419241%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyN3x8ZGF0YSUyMHdhcmVob3VzZSUyMGFyY2hpdGVjdHVyZXxlbnwwfDB8fHwxNzk0NDQwMzk4fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1772976994862-d408ea419241%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3w5NzU0MjJ8MHwxfHNlYXJjaHwyN3x8ZGF0YSUyMHdhcmVob3VzZSUyMGFyY2hpdGVjdHVyZXxlbnwwfDB8fHwxNzk0NDQwMzk4fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="A large white dome structure on a hill" width="1080" height="720"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@josh_katt?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Joshua katt&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Suboptimal DAX Patterns
&lt;/h2&gt;

&lt;p&gt;Some DAX functions are notoriously expensive. For example, using &lt;code&gt;FILTER(Table, ...)&lt;/code&gt; over an entire table instead of &lt;code&gt;KEEPFILTERS&lt;/code&gt; or specific columns can lead to massive performance overhead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirmation:&lt;/strong&gt; Review your model for high-cardinality columns used in filters. If you see large tables being filtered in their entirety, your Direct Lake performance will suffer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Use the following BPA rule to flag the use of &lt;code&gt;FILTER&lt;/code&gt; on large tables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Flag the use of FILTER on tables with more than 10,000 rows&lt;/span&gt;
&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Expression&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"FILTER"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Partitions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Rows&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Ensure your model is connected to the Fabric workspace to allow the BPA to access partition row counts.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Preventing it
&lt;/h2&gt;

&lt;p&gt;The transition from "manual development" to "automated governance" requires treating your Tabular Model Definition (TMDL or BIM file) as code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;BPA in the CI/CD Pipeline:&lt;/strong&gt; Do not rely on manual checks. Integrate Tabular Editor’s command-line interface (CLI) into your Azure DevOps or GitHub Actions pipeline. If the BPA scan returns an error-level violation, fail the build before it hits the Fabric workspace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standardized Templates:&lt;/strong&gt; Distribute a &lt;code&gt;.pbit&lt;/code&gt; (Power BI Template) file that includes a pre-configured &lt;code&gt;BPA.rules&lt;/code&gt; file. This ensures every developer starts with the same governance guardrails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Direct Lake Awareness:&lt;/strong&gt; Since Direct Lake mode in Fabric relies on efficient DAX to avoid fallback, use the BPA to specifically enforce "Direct Lake friendly" patterns. For example, warn against using &lt;code&gt;USERELATIONSHIP&lt;/code&gt; on columns that aren't materialized, as this forces the engine to change its execution path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular Audits:&lt;/strong&gt; Even for projects currently in development, schedule a weekly BPA report. It provides a "scorecard" for the model’s health, identifying which areas are drifting from architectural standards.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By moving the review process from "human memory" to "automated metadata analysis," you eliminate the subjectivity that plagues model development. Treat your semantic model like any other piece of software, and the infrastructure will remain stable even as the data volume grows.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; #microsoftfabric #powerbi #dataquality #architecture&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/@growtika?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Growtika&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=articles_pipeline&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>microsoftfabric</category>
      <category>powerbi</category>
      <category>dataquality</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
