<?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: CloudSkill Consulting LLC</title>
    <description>The latest articles on DEV Community by CloudSkill Consulting LLC (@cloudskillconsultingllc).</description>
    <link>https://dev.to/cloudskillconsultingllc</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%2F4187968%2F44d15f25-59b1-46bd-83ab-244f0c9dadab.png</url>
      <title>DEV Community: CloudSkill Consulting LLC</title>
      <link>https://dev.to/cloudskillconsultingllc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cloudskillconsultingllc"/>
    <language>en</language>
    <item>
      <title>RDS Extended Support Charges on the AWS Bill? A MySQL 8.0 or PostgreSQL 13 Database Passed Its End of Standard Support</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Wed, 18 Nov 2026 05:45:54 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/rds-extended-support-charges-on-the-aws-bill-a-mysql-80-or-postgresql-13-database-passed-its-end-4274</link>
      <guid>https://dev.to/cloudskillconsultingllc/rds-extended-support-charges-on-the-aws-bill-a-mysql-80-or-postgresql-13-database-passed-its-end-4274</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 18, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Your Amazon RDS line on the AWS bill went up this month. Nobody changed an instance size, added storage or bought anything new. The database runs the same version as last month. The new cost is &lt;strong&gt;RDS Extended Support&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This can catch many teams this year. RDS for MySQL 8.0 reached its RDS end of standard support on July 31, 2026. RDS for PostgreSQL 13 reached it on February 28, 2026. In this post we show what the charge is and why it started without anyone clicking anything. We also show how to find the databases behind it and stop it safely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause: an old major version keeps running, for a fee
&lt;/h2&gt;

&lt;p&gt;Here is how AWS describes it. Extended Support "allows you to continue running a database on a major engine version" past its RDS end of standard support date. AWS charges extra for this. (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support.html" rel="noopener noreferrer"&gt;RDS Extended Support&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Charges start "the day after the RDS end of standard support date." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-charges.html" rel="noopener noreferrer"&gt;RDS Extended Support charges&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;For the two versions most teams ask about, AWS's own calendars show:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;RDS end of standard support&lt;/th&gt;
&lt;th&gt;Extended Support year 1 pricing starts&lt;/th&gt;
&lt;th&gt;Year 3 pricing starts&lt;/th&gt;
&lt;th&gt;RDS end of Extended Support&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RDS for MySQL 8.0&lt;/td&gt;
&lt;td&gt;31 July 2026&lt;/td&gt;
&lt;td&gt;1 August 2026&lt;/td&gt;
&lt;td&gt;1 August 2028&lt;/td&gt;
&lt;td&gt;31 July 2029&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RDS for PostgreSQL 13&lt;/td&gt;
&lt;td&gt;28 February 2026&lt;/td&gt;
&lt;td&gt;1 March 2026&lt;/td&gt;
&lt;td&gt;1 March 2028&lt;/td&gt;
&lt;td&gt;28 February 2029&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(Sources: &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Concepts.VersionMgmt.html" rel="noopener noreferrer"&gt;MySQL on Amazon RDS versions&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/PostgreSQLReleaseNotes/postgresql-release-calendar.html" rel="noopener noreferrer"&gt;Release calendar for Amazon RDS for PostgreSQL&lt;/a&gt;. MySQL 5.7, PostgreSQL 11 and PostgreSQL 12 are already past their end of standard support too; see the same pages.)&lt;/p&gt;

&lt;p&gt;The MySQL page also notes that "MySQL 5.7 and 8.0 are now only available under RDS Extended Support."&lt;/p&gt;

&lt;h3&gt;
  
  
  Why nobody "turned it on"
&lt;/h3&gt;

&lt;p&gt;Enrollment is the default in many setups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With the AWS CLI or RDS API, if you "don't specify the RDS Extended Support setting, Amazon RDS defaults to enabling RDS Extended Support." AWS adds that the same default applies when you automate with CloudFormation or other services. It keeps the database available past the end of standard support. In the console, the setting "isn't selected by default." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-creating-db-instance.html" rel="noopener noreferrer"&gt;Creating a DB instance with RDS Extended Support&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;When an enrolled database reaches the date, RDS enrolls it automatically. AWS says this "doesn't change the database engine and doesn't impact the uptime or performance of your DB instance." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support.html" rel="noopener noreferrer"&gt;RDS Extended Support&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the database keeps working exactly as before. The only thing that changes is the bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the charge is priced
&lt;/h2&gt;

&lt;p&gt;For provisioned RDS for MySQL instances, AWS says "RDS Extended Support is priced per vCPU per hour." The price also depends "on the AWS Region and calendar date." (&lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for MySQL pricing&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The pricing pages give these examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RDS for MySQL 5.7 in US East (Ohio): "$0.100 per vCPU-hr between March 1, 2024 to February 28, 2026. Starting March 1, 2026, you will be charged $0.200 per vCPU-hr." (&lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for MySQL pricing&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;RDS for MySQL 5.7 on a db.r5.large in US East (N. Virginia) in the first year: "$0.200 per hour, or 2 vCPUs x $0.100 per vCPU-hr." (&lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;same page&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;RDS for PostgreSQL 12 in US East (Ohio): "$0.100 per vCPU-hr between March 1, 2025 to February 28, 2027. Starting March 1, 2027, you will be charged $0.200 per vCPU-hr." (&lt;a href="https://aws.amazon.com/rds/postgresql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for PostgreSQL pricing&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are AWS's worked examples, not the rate for every version and Region. Read the pricing page for your engine, version and Region before you estimate a bill. The formula AWS gives is simple: number of vCPUs x the hourly rate for your Region and pricing year, for every hour the instance runs.&lt;/p&gt;

&lt;p&gt;Five details make the bill bigger than people expect. All five come from the FAQ on the &lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;MySQL&lt;/a&gt; and &lt;a href="https://aws.amazon.com/rds/postgresql/pricing/" rel="noopener noreferrer"&gt;PostgreSQL&lt;/a&gt; pricing pages and the &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-charges.html" rel="noopener noreferrer"&gt;charges page&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Multi-AZ standbys pay too.&lt;/strong&gt; With one standby, you are charged "on both your primary and standby instances." With two readable standbys, on the primary and both standbys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read replicas pay too&lt;/strong&gt;, if they run a major version past its end of standard support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reserved Instances do not help.&lt;/strong&gt; "RDS Extended Support charges are independent of instance charges. Therefore, Reserved Instance discounts are not applicable to RDS Extended Support charges."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A restore can start a new charge.&lt;/strong&gt; Snapshots themselves are not charged. But restoring a DB snapshot "to a new DB instance after end of standard support" is charged "RDS Extended Support pricing for that instance." The same applies if you create a new instance on that version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The price goes up in year 3.&lt;/strong&gt; The first two years use the year 1 and 2 rate. Year 3 pricing starts "on the first day of the third year."&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: find the databases behind the charge
&lt;/h2&gt;

&lt;p&gt;List every DB instance with its engine, version and enrollment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws rds describe-db-instances \
  --query &lt;span class="s1"&gt;'DBInstances[].[DBInstanceIdentifier,Engine,EngineVersion,DBInstanceClass,MultiAZ,EngineLifecycleSupport]'&lt;/span&gt; \
  --output table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AWS says that if Extended Support is available for a database, the response includes &lt;code&gt;EngineLifecycleSupport&lt;/code&gt;. The value &lt;code&gt;open-source-rds-extended-support&lt;/code&gt; means the database is enrolled. The value &lt;code&gt;open-source-rds-extended-support-disabled&lt;/code&gt; means enrollment was turned off. (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-viewing.html" rel="noopener noreferrer"&gt;Viewing enrollment in RDS Extended Support&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Enrollment alone is not a charge. AWS notes that "Charges for RDS Extended Support only start when your DB engine version has reached the RDS end of standard support." So the list you care about is: enrolled &lt;strong&gt;and&lt;/strong&gt; on a major version whose end of standard support has passed. For Aurora clusters and Multi-AZ DB clusters, run &lt;code&gt;describe-db-clusters&lt;/code&gt; as well, because the setting lives at the cluster level.&lt;/p&gt;

&lt;p&gt;In the console, the &lt;strong&gt;Databases&lt;/strong&gt; page has an &lt;strong&gt;RDS Extended Support&lt;/strong&gt; column. If you do not see it, AWS says to turn it on under the Preferences icon. (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-viewing.html" rel="noopener noreferrer"&gt;same page&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The command lists one Region at a time, so run it in every Region you use (add &lt;code&gt;--region&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: check the dates for each version
&lt;/h2&gt;

&lt;p&gt;You can read the support dates from the CLI instead of a web page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws rds describe-db-major-engine-versions \
  --engine mysql \
  --major-engine-version 8.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AWS says the response includes &lt;code&gt;SupportedEngineLifecycles&lt;/code&gt;, with a start and end date for standard support (&lt;code&gt;open-source-rds-standard-support&lt;/code&gt;) and for Extended Support (&lt;code&gt;open-source-rds-extended-support&lt;/code&gt;). This works for the open source engines (MariaDB, MySQL and PostgreSQL), not the commercial ones. (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-viewing-support-dates.html" rel="noopener noreferrer"&gt;Viewing support dates&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-major-engine-versions.html" rel="noopener noreferrer"&gt;describe-db-major-engine-versions&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;--engine postgres&lt;/code&gt; for PostgreSQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: stop the charge the right way
&lt;/h2&gt;

&lt;p&gt;AWS lists two things that stop the charge. One is upgrading "to an engine version that's covered under standard support." The other is deleting "the database that's running a major version past the RDS end of standard support date." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-charges.html" rel="noopener noreferrer"&gt;RDS Extended Support charges&lt;/a&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  Option A: plan and test a major version upgrade (the usual fix)
&lt;/h3&gt;

&lt;p&gt;Upgrade to a major version with a long standard support window, not just the next one. AWS warns that "The charges will restart if your target engine version enters RDS Extended Support in the future." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-charges.html" rel="noopener noreferrer"&gt;same page&lt;/a&gt;) Two examples from the calendars:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MySQL: 8.4 has RDS end of standard support on 31 July 2029.&lt;/li&gt;
&lt;li&gt;PostgreSQL: 14 reaches its RDS end of standard support on 28 February 2027, only a few months away. PostgreSQL 16 runs to 28 February 2029, and 17 to 28 February 2030.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For RDS for MySQL, MariaDB and Aurora MySQL, AWS says you can use &lt;strong&gt;Blue/Green Deployments&lt;/strong&gt; to move off an Extended Support version. This works as long as Blue/Green supports your engine, Region and version. (&lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for MySQL pricing FAQ&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;If you upgrade in place, know what the command does. The CLI reference covers &lt;code&gt;--engine-version&lt;/code&gt;. It says: "Changing this parameter results in an outage and the change is applied during the next maintenance window unless the &lt;code&gt;ApplyImmediately&lt;/code&gt; parameter is enabled." A major upgrade with a non-default parameter group needs a parameter group from the new version's family. You must also set &lt;code&gt;--allow-major-version-upgrade&lt;/code&gt;. (&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-instance.html" rel="noopener noreferrer"&gt;modify-db-instance&lt;/a&gt;) Test on a restored copy first. That copy is charged Extended Support while it runs on the old version.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option B: delete what nobody uses
&lt;/h3&gt;

&lt;p&gt;Old read replicas, a forgotten test database, a copy restored "just to check something." Each one is charged on its own. If it is not needed, take a final snapshot and delete it. Snapshots are not charged Extended Support. (&lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for MySQL pricing FAQ&lt;/a&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  Be careful with "just turn it off"
&lt;/h3&gt;

&lt;p&gt;You can change enrollment at any time with the &lt;code&gt;EngineLifecycleSupport&lt;/code&gt; setting. In the CLI, that's &lt;code&gt;--engine-lifecycle-support open-source-rds-extended-support-disabled&lt;/code&gt;. But AWS warns about disabling it on a database "that is already past its standard support end date." In that case, "the instance or cluster automatically upgrades to the next supported major version." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support.html" rel="noopener noreferrer"&gt;RDS Extended Support&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;That is a major version upgrade you did not test, and if the database is in production, it happens to production. Use this only after the application has been tested on the new version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: stop new charges from appearing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set the option on purpose in code.&lt;/strong&gt; Because the CLI and API default to enrollment, add &lt;code&gt;--engine-lifecycle-support&lt;/code&gt; (or &lt;code&gt;EngineLifecycleSupport&lt;/code&gt;) to your create and restore scripts so the choice is visible. AWS notes that if you set &lt;code&gt;open-source-rds-extended-support-disabled&lt;/code&gt; and the end of standard support has passed, creating the instance "will always fail." That is a useful guard against new databases on old versions. (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-creating-db-instance.html" rel="noopener noreferrer"&gt;Creating a DB instance with RDS Extended Support&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put the next dates on the calendar.&lt;/strong&gt; PostgreSQL 14 (28 February 2027) is the next big one for many teams. Run the Step 1 command a few months ahead of each date.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When it still goes wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The charge came back after an upgrade.&lt;/strong&gt; You upgraded to a version that later reached its own end of standard support. AWS's example: a PostgreSQL 11 database upgraded to 12 on April 30, 2024 was charged again from March 1, 2025. (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-charges.html" rel="noopener noreferrer"&gt;RDS Extended Support charges&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The bill is bigger than one instance should cost.&lt;/strong&gt; Count the standbys and read replicas. Each is charged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You bought Reserved Instances and the line is still there.&lt;/strong&gt; RI discounts do not apply to this charge.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extended Support has an end too.&lt;/strong&gt; AWS says it is available "for up to 3 years past the RDS end of standard support date." After that, RDS "will automatically upgrade your major engine version." (&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support.html" rel="noopener noreferrer"&gt;RDS Extended Support&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to check first
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Which DB instances and clusters are on MySQL 5.7, MySQL 8.0, PostgreSQL 11, 12 or 13, and are they enrolled?&lt;/li&gt;
&lt;li&gt;How many vCPUs does each have, counting standbys and read replicas?&lt;/li&gt;
&lt;li&gt;Which ones can be deleted, and which need an upgrade plan?&lt;/li&gt;
&lt;li&gt;Is the target version far enough from its own end of standard support?&lt;/li&gt;
&lt;li&gt;Do your create and restore scripts set &lt;code&gt;--engine-lifecycle-support&lt;/code&gt; on purpose?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Docs checked (November 18, 2026)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Amazon RDS User Guide, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support.html" rel="noopener noreferrer"&gt;Amazon RDS Extended Support with Amazon RDS&lt;/a&gt; (what it is, automatic enrollment, changing enrollment, forced upgrade when disabled past the date, up to 3 years)&lt;/li&gt;
&lt;li&gt;Amazon RDS User Guide, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-charges.html" rel="noopener noreferrer"&gt;Amazon RDS Extended Support charges&lt;/a&gt; (start date, standbys, what stops the charge, charges restarting, the PostgreSQL 11 example)&lt;/li&gt;
&lt;li&gt;Amazon RDS User Guide, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-creating-db-instance.html" rel="noopener noreferrer"&gt;Creating a DB instance or a Multi-AZ DB cluster with RDS Extended Support&lt;/a&gt; (CLI and API default to enrollment, console does not, disabled option makes creation fail past the date)&lt;/li&gt;
&lt;li&gt;Amazon RDS User Guide, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-viewing.html" rel="noopener noreferrer"&gt;Viewing enrollment in RDS Extended Support&lt;/a&gt; (&lt;code&gt;EngineLifecycleSupport&lt;/code&gt; values, console column, enrollment vs charges)&lt;/li&gt;
&lt;li&gt;Amazon RDS User Guide, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/extended-support-viewing-support-dates.html" rel="noopener noreferrer"&gt;Viewing support dates for engine versions&lt;/a&gt; and AWS CLI &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-major-engine-versions.html" rel="noopener noreferrer"&gt;describe-db-major-engine-versions&lt;/a&gt; (&lt;code&gt;SupportedEngineLifecycles&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Amazon RDS User Guide, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Concepts.VersionMgmt.html" rel="noopener noreferrer"&gt;MySQL on Amazon RDS versions&lt;/a&gt; (MySQL 5.7, 8.0 and 8.4 dates)&lt;/li&gt;
&lt;li&gt;Amazon RDS for PostgreSQL Release Notes, &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/PostgreSQLReleaseNotes/postgresql-release-calendar.html" rel="noopener noreferrer"&gt;Release calendar for Amazon RDS for PostgreSQL&lt;/a&gt; (PostgreSQL 13, 14, 16 and 17 dates)&lt;/li&gt;
&lt;li&gt;AWS CLI, &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-instance.html" rel="noopener noreferrer"&gt;modify-db-instance&lt;/a&gt; (&lt;code&gt;--engine-lifecycle-support&lt;/code&gt; values, &lt;code&gt;--engine-version&lt;/code&gt; outage note, &lt;code&gt;--allow-major-version-upgrade&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/rds/mysql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for MySQL pricing&lt;/a&gt; and &lt;a href="https://aws.amazon.com/rds/postgresql/pricing/" rel="noopener noreferrer"&gt;Amazon RDS for PostgreSQL pricing&lt;/a&gt; (per vCPU-hour pricing, the Ohio and N. Virginia examples, Multi-AZ, read replicas, Reserved Instances, snapshots and restores, Blue/Green)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;If AWS changes a date or price after we publish this, tell us at &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt; and we'll update the post.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>rds</category>
      <category>finops</category>
      <category>database</category>
    </item>
    <item>
      <title>My H-1B Approval Runs Three Years, but the I-94 from My Last Trip Ends Sooner. Which Date Counts?</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Mon, 16 Nov 2026 13:47:12 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/my-h-1b-approval-runs-three-years-but-the-i-94-from-my-last-trip-ends-sooner-which-date-counts-4o41</link>
      <guid>https://dev.to/cloudskillconsultingllc/my-h-1b-approval-runs-three-years-but-the-i-94-from-my-last-trip-ends-sooner-which-date-counts-4o41</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 16, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;Your H-1B approval notice (Form I-797) lists a validity of three years. After a trip, the I-94 you received at re-entry ends much sooner — sometimes on the same day your passport ends. Which date should you and your employer plan around? And can the short I-94 be corrected?&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC read the admission rule, the H-1B admission rule, and CBP's pages on the I-94 and deferred inspection. This is about an I-94 that already came back short. It is a different problem from a passport that later expires while an I-94 is still valid.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Plan around the I-94 date&lt;/strong&gt; until something on that record changes. CBP treats the Form I-94 admission record as the document people use "to verify immigration status or employment authorization." You can print the most recent one from CBP's I-94 website with "Get Most Recent I-94." (&lt;a href="https://www.cbp.gov/travel/international-visitors/i-94" rel="noopener noreferrer"&gt;CBP: Arrival/Departure Forms: I-94&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The approval notice is not a substitute for that record. If the two dates disagree, put the earlier I-94 date on your calendar and tell HR the same day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the I-94 can be shorter than the approval
&lt;/h2&gt;

&lt;p&gt;Two official rules sit next to each other.&lt;/p&gt;

&lt;p&gt;First, the H-1B admission rule. &lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;8 CFR 214.1(l)(1)&lt;/a&gt; says an H-1B worker "may be admitted to the United States ... for the validity period of the petition ... plus an additional period of up to 10 days before the validity period begins and 10 days after the validity period ends." It adds: "Unless authorized under 8 CFR 274a.12, the alien may not work except during the validity period."&lt;/p&gt;

&lt;p&gt;Second, the general admission rule for a passport. On admission, the person "must present a valid passport and valid visa unless either or both documents have been waived." The passport "must be valid for a minimum of six months from the expiration date of the contemplated period of stay, unless otherwise provided in this chapter." (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;8 CFR 214.1(a)(3)&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;So a short passport can be a reason the officer did not admit you for the full petition period. That short I-94 may be a correct decision, not a typing error. Compare three dates: the I-797 validity, the I-94 admit-until date, and the passport end date. If the I-94 lines up with the passport, start with the passport rule, not with a request to "fix a typo."&lt;/p&gt;

&lt;h2&gt;
  
  
  If it was an error at entry, CBP can review it
&lt;/h2&gt;

&lt;p&gt;CBP runs Deferred Inspection Sites for people who "believe that the documentation and corresponding endorsements issued at the port of entry require review and possible correction." Staff there may "remedy errors recorded on arrival documents issued at the time of entry," including "improper non-immigrant classification, inaccurate biographical information or &lt;strong&gt;incorrect period of admission&lt;/strong&gt;, if appropriate." You can go to any designated deferred inspection location or a CBP office in an international airport, "regardless of where the actual document was issued." (&lt;a href="https://www.cbp.gov/about/contact/ports/deferred-inspection-sites" rel="noopener noreferrer"&gt;CBP: Deferred Inspection Sites&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;CBP is clear about the limit: "The Deferred Inspection Sites will only correct &lt;strong&gt;errors made at the time of entry&lt;/strong&gt;." If you want to &lt;strong&gt;extend your stay&lt;/strong&gt;, "You must contact U.S. Citizenship and Immigration Services (USCIS)." (&lt;a href="https://www.cbp.gov/about/contact/ports/deferred-inspection-sites" rel="noopener noreferrer"&gt;same page&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Ask the attorney first whether your short date looks like a recording error, or a correct, shorter admission. A recording error would be, for example, a date that matches nothing on your passport or your approval. Only the first of those is what this CBP path is for.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you need more time, that request goes to USCIS
&lt;/h2&gt;

&lt;p&gt;When the short I-94 is not an entry error, more time is an extension of stay. For H-1B, a petitioner who wants the worker's services "beyond the period previously granted" must file for an extension of stay on Form I-129. The filing must include the fee in 8 CFR 106.2 and the evidence in 8 CFR 214.2. It must also be in line with the form instructions. (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;8 CFR 214.1(c)(1)&lt;/a&gt;, current eCFR)&lt;/p&gt;

&lt;p&gt;Renewing a passport after entry does not, on its own, change an I-94 that was already issued. CBP's deferred-inspection page does not offer a "passport renewed, please lengthen the I-94" service. It only corrects entry errors, and it sends requests for more time to USCIS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do not let the short date pass
&lt;/h2&gt;

&lt;p&gt;At admission, a nonimmigrant agrees "to depart the United States at the expiration of his or her authorized period of admission or extension of stay." Failure to follow those departure requirements "may constitute a failure of the alien to maintain the terms of his or her nonimmigrant status." (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;8 CFR 214.1(a)(3)(ii)&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The authorized period is the one on the I-94, not the longer date on the approval notice. If that date is close, talk to the attorney before it arrives.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to ask your employer or attorney
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Please compare my latest I-94, my I-797, and my passport end date with me.&lt;/li&gt;
&lt;li&gt;Does this short I-94 look like an entry error, or a correct admission limited by the passport rule?&lt;/li&gt;
&lt;li&gt;If it is an error, will you help me contact a Deferred Inspection Site? CBP lists email addresses for I-94 corrections at many sites, and some say they do not take walk-ins.&lt;/li&gt;
&lt;li&gt;If I need more time, will the employer file an extension with USCIS before the I-94 date?&lt;/li&gt;
&lt;li&gt;Should I renew the passport before any new trip or any new filing, given the six-month admission rule?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CloudSkill Consulting LLC sponsors H-1B petitions for qualified candidates in some roles. Questions about our roles go to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Plan with this, decide with your papers: this summary from CloudSkill Consulting LLC isn't legal advice. The attorney who files your H-1B can tell you how the rules fit your case. Keep the official pages below open when you talk.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 16, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;8 CFR 214.1(l)(1) (admission for the petition's validity period, plus an additional period of up to 10 days before and after; work only during the validity period, unless authorized under 8 CFR 274a.12) (current eCFR): &lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/section-214.1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;8 CFR 214.1(a)(3), Requirements for admission, extension, and maintenance of status (valid passport and visa at admission; six-month passport rule unless otherwise provided; agreement to depart at the end of the authorized period) (current eCFR): &lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/section-214.1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;8 CFR 214.1(c)(1), Extension or amendment of stay for certain employment-based nonimmigrant workers (extension of H-1B stay is filed on Form I-129, with the fee and the evidence specified in 8 CFR 214.2) (current eCFR): &lt;a href="https://www.ecfr.gov/current/title-8/section-214.1" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/section-214.1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;U.S. Customs and Border Protection, Arrival/Departure Forms: I-94 (I-94 as the admission record for status and employment authorization; "Get Most Recent I-94"): &lt;a href="https://www.cbp.gov/travel/international-visitors/i-94" rel="noopener noreferrer"&gt;https://www.cbp.gov/travel/international-visitors/i-94&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;U.S. Customs and Border Protection, Deferred Inspection Sites (correction of entry errors, including incorrect period of admission; extensions of stay go to USCIS): &lt;a href="https://www.cbp.gov/about/contact/ports/deferred-inspection-sites" rel="noopener noreferrer"&gt;https://www.cbp.gov/about/contact/ports/deferred-inspection-sites&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>immigration</category>
      <category>h1b</category>
      <category>career</category>
      <category>visa</category>
    </item>
    <item>
      <title>SQS Gave the Same Message to a Second Worker. The Visibility Timeout Probably Ran Out First</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Mon, 16 Nov 2026 05:38:03 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/sqs-gave-the-same-message-to-a-second-worker-the-visibility-timeout-probably-ran-out-first-3kd0</link>
      <guid>https://dev.to/cloudskillconsultingllc/sqs-gave-the-same-message-to-a-second-worker-the-visibility-timeout-probably-ran-out-first-3kd0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 16, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;A job runs twice. A customer is charged twice. Two workers write the same row. The first worker is still working when it happens. The queue is Amazon SQS, and the usual cause is not a "bug in SQS" so much as a visibility timeout that ran out before the first worker finished and deleted the message.&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC sees this in reviews of worker services. In this post we show what the timeout does, how to set it, how to extend it while a long job is still running, and the hard 12-hour limit AWS documents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause: the message stays in the queue, it just goes hidden
&lt;/h2&gt;

&lt;p&gt;When a consumer receives a message, AWS says the message "remains in the queue but becomes temporarily invisible to other consumers." That hidden period is the &lt;strong&gt;visibility timeout&lt;/strong&gt;. You are expected to process the message and delete it during that period. If you do not delete it before the timeout ends, "the message becomes visible again in the queue and can be retrieved by another consumer." (&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;Amazon SQS visibility timeout&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The default visibility timeout for a queue is &lt;strong&gt;30 seconds&lt;/strong&gt;. You can set a queue-level value from &lt;strong&gt;0 to 43,200 seconds&lt;/strong&gt; (12 hours). (&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/set-queue-attributes.html" rel="noopener noreferrer"&gt;set-queue-attributes&lt;/a&gt; in the AWS CLI Command Reference)&lt;/p&gt;

&lt;p&gt;A 30-second default is short for many jobs: a report, a thumbnail, a call to another API that is slow. The first worker is still busy, the timeout ends, and a second worker receives the same message.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: set the queue timeout to match the work
&lt;/h2&gt;

&lt;p&gt;AWS's own guidance is to start by setting the visibility timeout "to match the maximum time your application typically needs to process and delete a message." If you are not sure, they suggest starting shorter (they use two minutes as an example) and extending as needed. (&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;Amazon SQS visibility timeout&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;This sets the queue default to five minutes (300 seconds). Use your own queue URL and a value that fits your job:&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 set-queue-attributes \
  --queue-url &lt;span class="s2"&gt;"$QUEUE_URL"&lt;/span&gt; \
  --attributes &lt;span class="nv"&gt;VisibilityTimeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;300
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The attribute name and the 0-to-43,200 range come from the &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/set-queue-attributes.html" rel="noopener noreferrer"&gt;set-queue-attributes&lt;/a&gt; reference. This changes the queue default. It does not change a message that is already in flight.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: extend the timeout while a long message is still being processed
&lt;/h2&gt;

&lt;p&gt;If one message needs more time than the queue default, AWS documents the &lt;code&gt;ChangeMessageVisibility&lt;/code&gt; action: you can extend or shorten the timeout for that message. The AWS CLI form is:&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 change-message-visibility \
  --queue-url &lt;span class="s2"&gt;"$QUEUE_URL"&lt;/span&gt; \
  --receipt-handle &lt;span class="s2"&gt;"$RECEIPT_HANDLE"&lt;/span&gt; \
  --visibility-timeout 60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/change-message-visibility.html" rel="noopener noreferrer"&gt;change-message-visibility&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;AWS also describes a heartbeat: extend the timeout from time to time so the message stays hidden until work is done. (&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;Amazon SQS visibility timeout&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Two limits matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The visibility timeout has a &lt;strong&gt;maximum of 12 hours from when the message is first received&lt;/strong&gt;. Extending it does &lt;strong&gt;not&lt;/strong&gt; reset that 12-hour clock. If the work needs longer, AWS suggests Step Functions or breaking the task into smaller steps. (&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;same page&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;If you try to set a value greater than the time left under that limit, "Amazon SQS returns an error" and does not raise the timeout for you. (&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/change-message-visibility.html" rel="noopener noreferrer"&gt;change-message-visibility&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more surprise: a &lt;code&gt;ChangeMessageVisibility&lt;/code&gt; value is not stored as the message's new default. If you do not delete the message and it is received again, AWS says the timeout "reverts to the original timeout value (not to the value you set using the &lt;code&gt;ChangeMessageVisibility&lt;/code&gt; action)." (&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/change-message-visibility.html" rel="noopener noreferrer"&gt;same CLI page&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The receipt handle is for that receive. Use the handle from the current receive, not an old one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: send repeated failures to a dead-letter queue
&lt;/h2&gt;

&lt;p&gt;If a message keeps failing, AWS recommends a dead-letter queue (DLQ) so those messages are "captured separately for further analysis or handling, preventing them from repeatedly circulating in the main queue." (&lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;Amazon SQS visibility timeout&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;That stops a poison message from being processed over and over, which is a different problem from a timeout that is simply too short — but the two often show up in the same incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it still goes wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The timeout is still shorter than the job.&lt;/strong&gt; Raise the queue default, add a heartbeat, or both.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The job can run longer than 12 hours from first receive.&lt;/strong&gt; The 12-hour cap cannot be extended past that point. Split the work or move it to a service meant for long runs, as AWS notes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two valid workers both complete the job.&lt;/strong&gt; Even after you fix the timeout, design the worker so a second delivery does not do the side effect twice. The visibility-timeout page's whole point is that a second consumer &lt;em&gt;can&lt;/em&gt; receive the message if the first one does not delete it in time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You hit the in-flight limit.&lt;/strong&gt; For most standard queues, AWS describes a limit of about 120,000 in-flight messages (received but not yet deleted). If you reach it, &lt;code&gt;OverLimit&lt;/code&gt; can be returned and no more messages are received until some in-flight messages are deleted. (&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/change-message-visibility.html" rel="noopener noreferrer"&gt;change-message-visibility&lt;/a&gt;, which restates this queue limit)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to check first
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What is the queue's &lt;code&gt;VisibilityTimeout&lt;/code&gt;, and how long does a typical (and a slow) job actually take?&lt;/li&gt;
&lt;li&gt;Does the worker delete the message only after the work succeeds?&lt;/li&gt;
&lt;li&gt;For long jobs, is there a heartbeat that calls &lt;code&gt;ChangeMessageVisibility&lt;/code&gt;, and does it respect the 12-hour cap?&lt;/li&gt;
&lt;li&gt;Is a dead-letter queue in place for messages that fail repeatedly?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 16, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amazon SQS Developer Guide, Amazon SQS visibility timeout (hidden period; default 30 seconds; message becomes visible again if not deleted; setting the timeout to match processing time; heartbeat; 12-hour limit from first receive; dead-letter queues): &lt;a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS CLI Command Reference, &lt;code&gt;set-queue-attributes&lt;/code&gt; (&lt;code&gt;VisibilityTimeout&lt;/code&gt; valid values 0 to 43,200 seconds, default 30): &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/set-queue-attributes.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cli/latest/reference/sqs/set-queue-attributes.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS CLI Command Reference, &lt;code&gt;change-message-visibility&lt;/code&gt; (minimum 0 seconds, maximum 12 hours; error if the value is greater than the time left; timeout reverts on the next receive; in-flight limit): &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/sqs/change-message-visibility.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cli/latest/reference/sqs/change-message-visibility.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>sqs</category>
      <category>devops</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Offered a Second H-1B Job and Keeping the First? When You May Start, and What Each Employer Files</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Sun, 15 Nov 2026 13:44:30 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/offered-a-second-h-1b-job-and-keeping-the-first-when-you-may-start-and-what-each-employer-files-2obb</link>
      <guid>https://dev.to/cloudskillconsultingllc/offered-a-second-h-1b-job-and-keeping-the-first-when-you-may-start-and-what-each-employer-files-2obb</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 15, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;You already work in H-1B status. Another company offers a second role — maybe evenings, maybe a paid project — and you do not want to leave the first job. Can you say yes? And is day one the day the new petition is filed, or the day it is approved?&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC read the current H-1B regulation and the USCIS H-1B page. This is about &lt;strong&gt;keeping&lt;/strong&gt; the first job and adding a second one. It is not the same as switching employers, which we wrote about in a separate post.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Each employer files its own petition.&lt;/strong&gt; The rule is direct: if you will perform services for more than one employer, "each employer must file a separate petition" with USCIS. (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(C)&lt;/a&gt;) The second employer cannot simply "add you" to the first company's papers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you are an eligible H-1B worker, you may start the second job when that new petition is properly filed.&lt;/strong&gt; You may also start on the start date requested on that petition. You start on whichever of those two dates is later. The regulation says an eligible H-1B nonimmigrant "is authorized to start concurrent or new employment" at that point. (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(H)&lt;/a&gt;) If you meet the eligibility tests below, day one is that filing date or requested start date, not the approval date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you are not eligible under that portability rule, the default is different.&lt;/strong&gt; For a change to a new petitioner, the default is in the regulation. It says you are "not authorized to begin the employment with the new petitioner until the petition is approved." That default does not apply when section 214(n) of the Immigration and Nationality Act provides otherwise (the portability rule just described). (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(D)&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Who is "eligible" to start on the filing date
&lt;/h2&gt;

&lt;p&gt;The same portability paragraph defines an eligible H-1B nonimmigrant as a person who:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;has been lawfully admitted to the United States in H-1B status, or has otherwise been given H-1B status;&lt;/li&gt;
&lt;li&gt;has a &lt;strong&gt;nonfrivolous&lt;/strong&gt; H-1B petition for new employment filed on their behalf, with a request to amend or extend stay, &lt;strong&gt;before&lt;/strong&gt; the period of stay authorized by DHS expires; and&lt;/li&gt;
&lt;li&gt;has &lt;strong&gt;not&lt;/strong&gt; been employed without authorization in the United States from the time of last admission through the filing of that new petition.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(&lt;a href="https://www.ecfr.gov/current/title-8/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(H)(1)&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;"New employment" in that paragraph includes a petition with the same employer, but it also covers a second employer, because the opening sentence of (H) names "concurrent or new employment."&lt;/p&gt;

&lt;p&gt;If the second petition is denied, authorization to work in that second job ends when USCIS decides the case. USCIS says you may continue working for the earlier employer if that earlier period of authorized employment is still valid. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;, last updated Sept. 21, 2026)&lt;/p&gt;

&lt;h2&gt;
  
  
  What the second employer has to file
&lt;/h2&gt;

&lt;p&gt;The second employer files Form I-129. The form instructions describe a "New concurrent employment" option: a request for a beneficiary "to begin new employment with an additional employer in the same nonimmigrant classification the beneficiary currently holds while the beneficiary will continue working for his or her current employer in the same classification." (&lt;a href="https://www.uscis.gov/sites/default/files/document/forms/i-129instr.pdf" rel="noopener noreferrer"&gt;Form I-129 Instructions&lt;/a&gt;, edition 09/09/26)&lt;/p&gt;

&lt;p&gt;For a specialty-occupation H-1B, that petition must include a Labor Condition Application (Form ETA-9035/9035E) certified by the Department of Labor. The USCIS H-1B page states this as a filing requirement for the petition. The second employer needs its own certified LCA for its own role, wage and work location. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Do not start the second job before that petition is properly filed, and not before the requested start date on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A special case: cap-exempt and cap-subject at the same time
&lt;/h2&gt;

&lt;p&gt;If your current job is cap-exempt and the second job is cap-subject, USCIS addresses that pairing directly. Cap-exempt work includes, for example, a job at a qualifying university or nonprofit research organization. You may take the cap-subject job &lt;strong&gt;concurrently&lt;/strong&gt; "as long as you will continue to be employed in the cap-exempt position." You may begin that concurrent work as soon as the cap-subject employer properly files a non-frivolous Form I-129. You may also begin on the requested start date. You begin on whichever of those two dates is later.&lt;/p&gt;

&lt;p&gt;USCIS also says you will not become subject to the cap again during the same H-1B validity period. That is true as long as you continue the cap-exempt employment, were previously counted toward the cap, or otherwise remain cap-exempt. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The regulation adds three things the second petitioner must show for this kind of concurrent cap-subject filing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you are in valid cap-exempt H-1B status&lt;/li&gt;
&lt;li&gt;that cap-exempt employment is expected to continue after the new petition is approved&lt;/li&gt;
&lt;li&gt;you can reasonably perform both jobs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A concurrent cap-subject approval cannot run past the validity of the cap-exempt employment. (&lt;a href="https://www.ecfr.gov/current/title-8/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(8)(iii)(F)(6)&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;If you would &lt;strong&gt;leave&lt;/strong&gt; the cap-exempt job and move only to a cap-subject employer, that is not concurrent employment. USCIS says that new petition is subject to the cap, and the new employer may first need to register in the cap season. That is a different path. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;same USCIS page&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  When it goes wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You start the second job before any petition is filed.&lt;/strong&gt; The portability rule is tied to a properly filed, nonfrivolous petition, or to the requested start date, whichever is later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your authorized stay has already ended&lt;/strong&gt; when the second petition is filed. You are not in a period of stay that the portability rule recognizes. The eligibility test requires filing before that period expires. Ask the attorney to look at your I-94 and any pending filings before anyone sets a start date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The second petition is denied.&lt;/strong&gt; Work authorization for that second job ends when USCIS decides. The first job continues only if that earlier authorization is still valid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The first, cap-exempt job ends&lt;/strong&gt; while you also hold a concurrent cap-subject approval that depended on it. The rules above tie that concurrent approval to the cap-exempt employment. Talk to the attorney before you give notice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The second company wants to "share" the first LCA or the first approval notice.&lt;/strong&gt; Each employer files its own petition, and a specialty-occupation petition needs its own certified LCA.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to ask your employer or attorney
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Am I still in H-1B status, and is my authorized stay unexpired (or otherwise a period of stay the portability rule accepts)?&lt;/li&gt;
&lt;li&gt;Will the second employer file Form I-129 as new concurrent employment, with its own certified LCA?&lt;/li&gt;
&lt;li&gt;Does the requested start date on that petition line up with when I would actually begin?&lt;/li&gt;
&lt;li&gt;If the second petition is denied, what happens to each job?&lt;/li&gt;
&lt;li&gt;If my first job is cap-exempt and the second is cap-subject, can I reasonably perform both, and will the first job continue?&lt;/li&gt;
&lt;li&gt;Who tells the first employer, and when?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CloudSkill Consulting LLC sponsors H-1B petitions for qualified candidates in some roles. Questions about our roles go to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Plan with this, decide with your papers: this summary from CloudSkill Consulting LLC isn't legal advice. The attorney who files your H-1B can tell you how the rules fit your case. Keep the official pages below open when you talk.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 15, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;8 CFR 214.2(h)(2)(i)(C) (each employer must file a separate petition), (h)(2)(i)(D) (work for a new petitioner waits for approval, except as provided by INA 214(n)), (h)(2)(i)(H) (eligible H-1B workers may start concurrent or new employment upon filing, or on the requested start date, whichever is later; eligibility and when that authorization ends), and (h)(8)(iii)(F)(6) (concurrent cap-subject employment for a cap-exempt worker) (2025 annual edition on GovInfo, consistent with the current USCIS H-1B page): &lt;a href="https://www.ecfr.gov/current/title-8/section-214.2" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/section-214.2&lt;/a&gt; and &lt;a href="https://www.govinfo.gov/content/pkg/CFR-2025-title8-vol1/xml/CFR-2025-title8-vol1-sec214-2.xml" rel="noopener noreferrer"&gt;https://www.govinfo.gov/content/pkg/CFR-2025-title8-vol1/xml/CFR-2025-title8-vol1-sec214-2.xml&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, H-1B Specialty Occupations (portability start date; work if the new petition is denied; concurrent cap-exempt and cap-subject employment; LCA with Form I-129) (last updated Sept. 21, 2026): &lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, Instructions for Form I-129, Petition for a Nonimmigrant Worker, edition 09/09/26 ("New concurrent employment" requested-action description; LCA evidence): &lt;a href="https://www.uscis.gov/sites/default/files/document/forms/i-129instr.pdf" rel="noopener noreferrer"&gt;https://www.uscis.gov/sites/default/files/document/forms/i-129instr.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>immigration</category>
      <category>h1b</category>
      <category>career</category>
      <category>visa</category>
    </item>
    <item>
      <title>CloudWatch Is the Biggest Line on the AWS Bill and It's Mostly Logs. Here's How to Find the Cause and Fix It</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Sun, 15 Nov 2026 05:51:50 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/cloudwatch-is-the-biggest-line-on-the-aws-bill-and-its-mostly-logs-heres-how-to-find-the-cause-2mmj</link>
      <guid>https://dev.to/cloudskillconsultingllc/cloudwatch-is-the-biggest-line-on-the-aws-bill-and-its-mostly-logs-heres-how-to-find-the-cause-2mmj</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 15, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;A common story from AWS users: someone opens the monthly bill and finds that CloudWatch costs more than the servers it watches. They drill in, and almost all of it is one usage type ending in &lt;code&gt;DataProcessing-Bytes&lt;/code&gt;. They ask what that is, and why it grew when traffic didn't.&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC sees the same pattern in cost reviews. In most cases nothing is broken. A service is simply sending far more log data than anyone planned, and the data is kept forever. In this post we show how to find the cause, fix it safely with the AWS CLI and Terraform, and check that the fix worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause: you pay to send logs, then to keep them
&lt;/h2&gt;

&lt;p&gt;CloudWatch Logs charges separately for each step. AWS's billing guide lists the usage types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;DataProcessing-Bytes&lt;/code&gt;: ingestion (sending data in) for the &lt;strong&gt;Standard&lt;/strong&gt; log class&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DataProcessingIA-Bytes&lt;/code&gt;: ingestion for the &lt;strong&gt;Infrequent Access&lt;/strong&gt; class (now called Essentials)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TimedStorage-ByteHrs&lt;/code&gt;: storage&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DataScanned-Bytes&lt;/code&gt;: data scanned by Logs Insights queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Cost Explorer these names have a Region code in front of them, so don't be surprised by the prefix.&lt;/p&gt;

&lt;p&gt;So a jump in &lt;code&gt;DataProcessing-Bytes&lt;/code&gt; means &lt;strong&gt;more bytes are coming in&lt;/strong&gt;. Three things usually cause it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verbose logging.&lt;/strong&gt; Debug output, full request bodies, or one log line per loop step. AWS's billing guide says it directly: a verbose log syntax drives volume and thus cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A new noisy source.&lt;/strong&gt; A new service, a retry storm, or a dependency that logs each failed call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No retention.&lt;/strong&gt; This doesn't change ingestion, but it makes storage grow every month. AWS's log group docs say log data is stored &lt;strong&gt;indefinitely&lt;/strong&gt; by default. A log group that Lambda creates for you (&lt;code&gt;/aws/lambda/&amp;lt;function name&amp;gt;&lt;/code&gt;) starts with that default.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Prices vary by Region, so we won't quote a number here. Check the &lt;a href="https://aws.amazon.com/cloudwatch/pricing/" rel="noopener noreferrer"&gt;CloudWatch pricing page&lt;/a&gt; for your Region. Its free tier includes 5 GB of logs data per month, and that covers ingestion, archive storage and Logs Insights scanning together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: find the log groups behind it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In Cost Explorer.&lt;/strong&gt; Filter Service = CloudWatch and group by Usage Type to confirm it's ingestion. Then use the &lt;strong&gt;Resource&lt;/strong&gt; dimension to see costs by log group. The billing guide notes that Resource only shows the past 14 days. For a longer view, the same page has an Athena query for the Cost and Usage Report, grouped by resource ID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With the CLI.&lt;/strong&gt; Every log group publishes an &lt;code&gt;IncomingBytes&lt;/code&gt; metric in the &lt;code&gt;AWS/Logs&lt;/code&gt; namespace, with the dimension &lt;code&gt;LogGroupName&lt;/code&gt;. AWS documents it as the volume of log events in uncompressed bytes. This lists your top 20 log groups by bytes taken in over the last 7 days:&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;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# top-log-groups.sh - read-only. Lists the 20 log groups that took in the most data&lt;/span&gt;
&lt;span class="c"&gt;# in the last 7 days. Run per Region: AWS_REGION=eu-west-1 ./top-log-groups.sh&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail
&lt;span class="nv"&gt;END&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;date -u +%Y-%m-%dT%H:%M:%SZ&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;START&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;date -u -d &lt;span class="s1"&gt;'7 days ago'&lt;/span&gt; +%Y-%m-%dT%H:%M:%SZ&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="c"&gt;# GNU date; on macOS use: date -u -v-7d ...&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; g &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;aws logs describe-log-groups --query &lt;span class="s1"&gt;'logGroups[].logGroupName'&lt;/span&gt; --output text&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;bytes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;aws cloudwatch get-metric-statistics \
    --namespace AWS/Logs --metric-name IncomingBytes \
    --dimensions &lt;span class="nv"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LogGroupName,Value=&lt;span class="s2"&gt;"$g"&lt;/span&gt; \
    --start-time &lt;span class="s2"&gt;"$START"&lt;/span&gt; --end-time &lt;span class="s2"&gt;"$END"&lt;/span&gt; \
    --period 86400 --statistics Sum \
    --query &lt;span class="s1"&gt;'sum(Datapoints[].Sum)'&lt;/span&gt; --output text&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%.0f\t%s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$bytes"&lt;/span&gt; &lt;span class="s2"&gt;"$g"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort -rn &lt;span class="o"&gt;|&lt;/span&gt; head -20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each log group costs one &lt;code&gt;GetMetricStatistics&lt;/code&gt; call. The pricing page says the first 1 million API requests a month are included, but if you have thousands of log groups, keep that in mind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which groups keep data forever?&lt;/strong&gt; A group with no retention setting has no &lt;code&gt;retentionInDays&lt;/code&gt; field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws logs describe-log-groups \
  --query &lt;span class="s1"&gt;'logGroups[?!retentionInDays].logGroupName'&lt;/span&gt; --output text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: send less
&lt;/h2&gt;

&lt;p&gt;This is where the real savings are, because ingestion is billed on every byte. AWS's billing guide says to log only the events that bring business value and to choose an efficient log syntax.&lt;/p&gt;

&lt;p&gt;For Lambda, you can do this without a code change. Lambda's &lt;strong&gt;log-level filtering&lt;/strong&gt; sends only logs at the level you choose or more serious. It needs the JSON log format. The Lambda docs show this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws lambda update-function-configuration \
  --function-name myFunction \
  --logging-config &lt;span class="nv"&gt;LogFormat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;JSON,ApplicationLogLevel=ERROR,SystemLogLevel=WARN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be careful with two details from the same page:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The default log format for Lambda managed runtimes is plain text. Switching to JSON changes what your log lines look like, so check any parser or metric filter that reads them.&lt;/li&gt;
&lt;li&gt;A log level set &lt;strong&gt;in your code&lt;/strong&gt; wins. If your code calls Python's &lt;code&gt;logging&lt;/code&gt; &lt;code&gt;setLevel()&lt;/code&gt; with INFO, that beats a WARN setting in the console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For EC2 or on-premises servers, the billing guide points to filter expressions in the CloudWatch agent to drop lines before they're sent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: set retention
&lt;/h2&gt;

&lt;p&gt;Retention doesn't lower ingestion, but it stops storage from growing forever. Allowed values are 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288 and 3653 days.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws logs put-retention-policy --log-group-name /aws/lambda/myFunction --retention-in-days 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pick the number from your audit and compliance rules, not from this post. The log group docs say expired data usually gets deleted within 72 hours, and data marked for deletion no longer adds storage cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: pick the right log class for new groups
&lt;/h2&gt;

&lt;p&gt;CloudWatch Logs has two main classes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Standard&lt;/strong&gt;: all features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Essentials&lt;/strong&gt; (formerly Infrequent Access): a lower ingestion price per GB, but fewer features.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS's log class page says the two differ in ingestion cost only. Storage and Logs Insights charges are the same.&lt;/p&gt;

&lt;p&gt;Essentials doesn't support subscription filters, metric filters, Live Tail, &lt;code&gt;GetLogEvents&lt;/code&gt;/&lt;code&gt;FilterLogEvents&lt;/code&gt;, the embedded metric format, Container Insights or Lambda Insights log ingestion, anomaly detection or field indexing. You read its data with Logs Insights. That makes it a good fit for audit or forensic logs you rarely open, and a poor fit for logs that drive alarms.&lt;/p&gt;

&lt;p&gt;One hard rule: &lt;strong&gt;a log group's class can't be changed after it's created.&lt;/strong&gt; To move logs to Essentials, send them to a new log group.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Terraform
&lt;/h2&gt;

&lt;p&gt;This creates the Lambda log group with retention before the function first runs, an Essentials group for audit logs, and an alarm on ingestion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;required_providers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;aws&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/aws"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 6.0"&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;variable&lt;/span&gt; &lt;span class="s2"&gt;"function_name"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="o"&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;variable&lt;/span&gt; &lt;span class="s2"&gt;"alarm_topic_arn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;type&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SNS topic that gets the alarm emails"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Create the Lambda log group yourself, so it never starts with "never expire".&lt;/span&gt;
&lt;span class="c1"&gt;# If Lambda already created it, import it first instead of creating a new one.&lt;/span&gt;
&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudwatch_log_group"&lt;/span&gt; &lt;span class="s2"&gt;"app"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/aws/lambda/${var.function_name}"&lt;/span&gt;
  &lt;span class="n"&gt;retention_in_days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="c1"&gt;# pick from the allowed list; 0 means keep forever&lt;/span&gt;
  &lt;span class="n"&gt;log_group_class&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"STANDARD"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Audit-only logs you rarely read: lower ingestion price per GB, fewer features.&lt;/span&gt;
&lt;span class="c1"&gt;# The class can't be changed later, so decide before the first apply.&lt;/span&gt;
&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudwatch_log_group"&lt;/span&gt; &lt;span class="s2"&gt;"audit"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/cloudskill-demo/audit"&lt;/span&gt;
  &lt;span class="n"&gt;retention_in_days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;365&lt;/span&gt;
  &lt;span class="n"&gt;log_group_class&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"INFREQUENT_ACCESS"&lt;/span&gt; &lt;span class="c1"&gt;# shown as ESSENTIALS in newer AWS responses&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Alarm when one log group takes in far more than usual.&lt;/span&gt;
&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudwatch_metric_alarm"&lt;/span&gt; &lt;span class="s2"&gt;"ingest_spike"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;alarm_name&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${var.function_name}-log-ingest-spike"&lt;/span&gt;
  &lt;span class="n"&gt;namespace&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"AWS/Logs"&lt;/span&gt;
  &lt;span class="n"&gt;metric_name&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"IncomingBytes"&lt;/span&gt;
  &lt;span class="n"&gt;dimensions&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;LogGroupName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aws_cloudwatch_log_group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;statistic&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Sum"&lt;/span&gt;
  &lt;span class="n"&gt;period&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;
  &lt;span class="n"&gt;evaluation_periods&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="n"&gt;threshold&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1073741824&lt;/span&gt; &lt;span class="c1"&gt;# 1 GiB per hour; set from your normal volume&lt;/span&gt;
  &lt;span class="n"&gt;comparison_operator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"GreaterThanThreshold"&lt;/span&gt;
  &lt;span class="n"&gt;treat_missing_data&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"notBreaching"&lt;/span&gt;
  &lt;span class="n"&gt;alarm_actions&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alarm_topic_arn&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;A few notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Terraform provider docs list &lt;code&gt;STANDARD&lt;/code&gt;, &lt;code&gt;INFREQUENT_ACCESS&lt;/code&gt; and &lt;code&gt;DELIVERY&lt;/code&gt; for &lt;code&gt;log_group_class&lt;/code&gt;. AWS's log class page says both &lt;code&gt;INFREQUENT_ACCESS&lt;/code&gt; and &lt;code&gt;ESSENTIALS&lt;/code&gt; are accepted as input, and from December 2026 read APIs return &lt;code&gt;ESSENTIALS&lt;/code&gt;. We used the value the provider docs list.&lt;/li&gt;
&lt;li&gt;In the provider docs, &lt;code&gt;retention_in_days = 0&lt;/code&gt; means keep forever. Leave it out only if that's what you want.&lt;/li&gt;
&lt;li&gt;The 1 GiB per hour threshold is a placeholder. Set it from the numbers your Step 1 script printed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Trade-offs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fewer logs means less to debug with.&lt;/strong&gt; Raising the level to ERROR saves money until the day you need the INFO lines. Many teams keep WARN or INFO in production and switch to DEBUG only for a short test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Short retention can break audit rules.&lt;/strong&gt; Check what your security and compliance teams need before you pick 30 days.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Essentials is a one-way choice per log group.&lt;/strong&gt; You can't turn on a metric filter later. If a log might feed an alarm, keep it in Standard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The CLI script makes one API call per log group.&lt;/strong&gt; That's fine for hundreds of groups. For thousands, use Cost Explorer or the Athena query instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to verify the fix
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Check the Terraform.&lt;/strong&gt; &lt;code&gt;terraform fmt -check&lt;/code&gt; and &lt;code&gt;terraform validate&lt;/code&gt; should pass. Ours passed on Terraform v1.9.8 with AWS provider v6.71.0. Run &lt;code&gt;terraform plan&lt;/code&gt; in your account. It should show 3 resources to add, or an import if the Lambda log group already exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Read the settings back.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws logs describe-log-groups --log-group-name-prefix /aws/lambda/myFunction \
  --query &lt;span class="s1"&gt;'logGroups[].[logGroupName,retentionInDays,logGroupClass]'&lt;/span&gt;
&lt;span class="c"&gt;# expect the retention you set, and STANDARD&lt;/span&gt;

aws lambda get-function-configuration --function-name myFunction --query LoggingConfig
&lt;span class="c"&gt;# expect LogFormat JSON and the levels you set&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Watch the metric.&lt;/strong&gt; Run the Step 1 script again after a few days. The group you fixed should take in fewer bytes per day than before.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Check the bill.&lt;/strong&gt; In Cost Explorer, &lt;code&gt;DataProcessing-Bytes&lt;/code&gt; for CloudWatch should flatten out in the days after the change. Storage cost falls more slowly, because old data is deleted only once it's older than the new retention period.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you ship
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] You know which log groups drive &lt;code&gt;DataProcessing-Bytes&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Noisy services log less (log level, agent filters, shorter lines)&lt;/li&gt;
&lt;li&gt;[ ] Every log group has a retention period your compliance team agrees with&lt;/li&gt;
&lt;li&gt;[ ] Rarely read logs go to new Essentials groups, and nothing in them needs metric filters&lt;/li&gt;
&lt;li&gt;[ ] An &lt;code&gt;IncomingBytes&lt;/code&gt; alarm and a budget alert are in place&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you searched for CloudSkill Consulting LLC FinOps reviews, that's us. We wrote this for teams whose CloudWatch line grew faster than their traffic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs checked (November 15, 2026)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_billing.html" rel="noopener noreferrer"&gt;Analyzing, optimizing, and reducing CloudWatch costs&lt;/a&gt; (usage types, Cost Explorer by Resource for 14 days, the Athena query, the tips on verbose logs, retention, Infrequent Access and agent filters)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch_Logs_Log_Classes.html" rel="noopener noreferrer"&gt;Log classes&lt;/a&gt; (Standard vs Essentials, ingestion-only price difference, features, class can't change)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html" rel="noopener noreferrer"&gt;Working with log groups and log streams&lt;/a&gt; (stored indefinitely by default, deletion within 72 hours)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Monitoring-CloudWatch-Metrics.html" rel="noopener noreferrer"&gt;CloudWatch Logs metrics&lt;/a&gt; (&lt;code&gt;IncomingBytes&lt;/code&gt;, &lt;code&gt;LogGroupName&lt;/code&gt; dimension)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/logs/put-retention-policy.html" rel="noopener noreferrer"&gt;AWS CLI: put-retention-policy&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/logs/describe-log-groups.html" rel="noopener noreferrer"&gt;describe-log-groups&lt;/a&gt; , &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html" rel="noopener noreferrer"&gt;get-metric-statistics&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/lambda/get-function-configuration.html" rel="noopener noreferrer"&gt;lambda get-function-configuration&lt;/a&gt; (allowed retention values, output fields, period rules, &lt;code&gt;LoggingConfig&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs-log-level.html" rel="noopener noreferrer"&gt;Lambda log-level filtering&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs-loggroups.html" rel="noopener noreferrer"&gt;Lambda log groups&lt;/a&gt; (JSON format needed, the CLI example, code settings win, the &lt;code&gt;/aws/lambda/&amp;lt;function name&amp;gt;&lt;/code&gt; default)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/cloudwatch/pricing/" rel="noopener noreferrer"&gt;Amazon CloudWatch pricing&lt;/a&gt; (pricing varies by Region, the 5 GB logs free tier, 1 million API requests included)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group" rel="noopener noreferrer"&gt;Terraform AWS provider: aws_cloudwatch_log_group&lt;/a&gt; and &lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm" rel="noopener noreferrer"&gt;aws_cloudwatch_metric_alarm&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Spotted an AWS default or limit that changed since we wrote this? Drop a line to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt; so the post stays accurate.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudwatch</category>
      <category>finops</category>
      <category>devops</category>
    </item>
    <item>
      <title>Elastic IP Addresses Are Billed Even When They're Attached. Here's How AWS Now Charges Public IPv4</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Sat, 14 Nov 2026 13:46:41 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/elastic-ip-addresses-are-billed-even-when-theyre-attached-heres-how-aws-now-charges-public-ipv4-1c0h</link>
      <guid>https://dev.to/cloudskillconsultingllc/elastic-ip-addresses-are-billed-even-when-theyre-attached-heres-how-aws-now-charges-public-ipv4-1c0h</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 14, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Teams still sometimes expect an Elastic IP to be free once it is attached to a running instance. AWS's current pages say otherwise.&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC sees this surprise in cost reviews: a quiet line for public IPv4, including addresses that are attached and in use. This post sticks to what AWS's own Elastic IP guide and the Amazon VPC pricing page say, including the hourly rate published there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause: every dedicated public IPv4 address is a billed item
&lt;/h2&gt;

&lt;p&gt;The Elastic IP guide is direct: "There is a charge for all Elastic IP addresses whether they are in use (allocated to a resource, like an EC2 instance) or idle (created in your account but unallocated)." It adds that "AWS charges for all public IPv4 addresses, including public IPv4 addresses associated with running instances and Elastic IP addresses." (&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html" rel="noopener noreferrer"&gt;Elastic IP addresses&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The Amazon VPC pricing page spells out two categories, at the same published rate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In-use public IPv4 address:&lt;/strong&gt; "Any public IPv4 address associated with a resource launched in an Amazon VPC, and public IPv4 addresses assigned to AWS Global Accelerator and AWS Site-to-Site VPN tunnel endpoints."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idle public IPv4 address:&lt;/strong&gt; "Any public IPv4 address associated to your AWS account that is not used on a resource."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"The price is the same whether the public IPv4 address is in-use ... or an idle public IPv4 address." The page lists that hourly charge as &lt;strong&gt;$0.005&lt;/strong&gt; for an in-use address and &lt;strong&gt;$0.005&lt;/strong&gt; for an idle address. The bill "is calculated in one-second increments, with a minimum of 60 seconds." (&lt;a href="https://aws.amazon.com/vpc/pricing/" rel="noopener noreferrer"&gt;Amazon VPC Pricing&lt;/a&gt;, figures read on Nov. 13, 2026, and rechecked on Nov. 14, 2026; check that page for any later change)&lt;/p&gt;

&lt;p&gt;The same page notes some public IPv4 addresses that are &lt;strong&gt;not&lt;/strong&gt; dedicated to your resource are not charged, and gives Amazon S3 addresses that are "not dedicated per S3 bucket" as an example. For the list of services that are charged, it points to AWS's public IPv4 documentation from that pricing page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disassociating is not the same as stopping the charge
&lt;/h2&gt;

&lt;p&gt;You can take an Elastic IP off an instance. That does not remove it from your account. AWS says: "A disassociated Elastic IP address remains allocated to your account until you explicitly &lt;strong&gt;release&lt;/strong&gt; it. You are charged for all Elastic IP addresses in your account, regardless of whether they are associated or disassociated with an instance." (&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html" rel="noopener noreferrer"&gt;Elastic IP addresses&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;So a cleanup that only clicks "disassociate" leaves an idle address, still billed at the same official hourly rate until someone releases it.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;1. Find the addresses.&lt;/strong&gt; In the EC2 console, open Elastic IP addresses and list every address allocated to the account, attached or not. The VPC pricing page also points to &lt;strong&gt;Public IP Insights&lt;/strong&gt;, which it describes as visibility into your public IPv4 usage, available in the Free Tier of VPC IP Address Manager (IPAM). You "do not pay for your usage of IPAM" in that Free Tier, "However, you still pay for any other AWS service that you are using." (&lt;a href="https://aws.amazon.com/vpc/pricing/" rel="noopener noreferrer"&gt;Amazon VPC Pricing&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Keep only what you still need.&lt;/strong&gt; An Elastic IP is useful when you must hold a stable public address. If the instance, NAT gateway or load balancer no longer needs that dedicated address, release it after you confirm nothing still depends on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Release, do not only disassociate.&lt;/strong&gt; After you disassociate an Elastic IP you do not plan to reuse, release it so it leaves the account. Until you do, the idle-address charge continues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Look beyond Elastic IP.&lt;/strong&gt; The pricing page says nearly all resources launched in a VPC get an IP address, and that services such as EKS, EMR, ECS, RDS and WorkSpaces can create resources in your VPC with public IPv4 addresses. In-use charges apply there too, not only to Elastic IPs you allocated by hand. (&lt;a href="https://aws.amazon.com/vpc/pricing/" rel="noopener noreferrer"&gt;Amazon VPC Pricing&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;We are not repeating AWS's worked dollar examples here, because those depend on how many addresses you have and for how long. The hourly rate above is the figure the pricing page published when we read it. Use that page for the current number before you estimate a bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it goes wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You release an address that a DNS record, partner allow-list or NAT gateway still uses.&lt;/strong&gt; Confirm the dependency first. An Elastic IP is yours until you release it. (&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html" rel="noopener noreferrer"&gt;Elastic IP addresses&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You disassociate and think the bill has stopped.&lt;/strong&gt; It has not, until the address is released.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You only look at Elastic IPs and miss public IPv4 on managed services.&lt;/strong&gt; Check Public IP Insights or the cost line for public IPv4, not only the Elastic IP list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 13, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amazon EC2 User Guide, Elastic IP addresses (charge for all Elastic IPs in use or idle; charge for public IPv4 including addresses on running instances; a disassociated address stays allocated and billed until you release it): &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon VPC Pricing, Public IPv4 Address (in-use vs idle; same $0.005 hourly charge for each, billed per second with a 60-second minimum; Public IP Insights in the IPAM Free Tier; examples of services that use public IPv4): &lt;a href="https://aws.amazon.com/vpc/pricing/" rel="noopener noreferrer"&gt;https://aws.amazon.com/vpc/pricing/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>finops</category>
      <category>vpc</category>
      <category>devops</category>
    </item>
    <item>
      <title>A Typo on Your H-1B Approval Notice? How to Get the I-797A and Its I-94 Fixed</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:49:51 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/a-typo-on-your-h-1b-approval-notice-how-to-get-the-i-797a-and-its-i-94-fixed-25aa</link>
      <guid>https://dev.to/cloudskillconsultingllc/a-typo-on-your-h-1b-approval-notice-how-to-get-the-i-797a-and-its-i-94-fixed-25aa</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 14, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;Your H-1B extension or change of status was approved. You open the notice and your last name is missing a letter. Or your birth date is off by a day. This is a paper you'll show again and again, so you want it right. What do you do?&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC read the USCIS pages on fixing errors. Here is the path they describe, in plain words.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, know which paper you have
&lt;/h2&gt;

&lt;p&gt;Look at the form number in the corner. If it says &lt;strong&gt;Form I-797A&lt;/strong&gt;, USCIS describes the I-797A as a notice "issued to an applicant as a replacement Form I-94." (&lt;a href="https://www.uscis.gov/forms/filing-guidance/form-i-797-types-and-functions" rel="noopener noreferrer"&gt;USCIS: Form I-797 Types and Functions&lt;/a&gt;) In other words, the bottom part of that notice is your I-94 record from USCIS.&lt;/p&gt;

&lt;p&gt;That matters, because USCIS treats the I-94 part as an "Arrival-Departure Record," one of its secure identity documents, with its own fix-it process. (&lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;USCIS: Immigration Documents and How to Correct, Update, or Replace Them&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;If USCIS made the typo&lt;/strong&gt;, you can ask for a correction through a USCIS online service request for a typographic error. (&lt;a href="https://www.uscis.gov/policy-manual/volume-1-part-a-chapter-4" rel="noopener noreferrer"&gt;USCIS Policy Manual, Vol. 1, Part A, Ch. 4&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If the error is on the I-94 that USCIS issued&lt;/strong&gt; (the I-797A's bottom part), the USCIS page lists Form I-102 as the way to replace it. When the error is USCIS's fault, USCIS says you generally file a new form but don't pay a new fee. (&lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;USCIS: Immigration Documents&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If CBP issued the I-94 with the error&lt;/strong&gt; (for example, at the airport), Form I-102 is the wrong tool. You go to a CBP port of entry or deferred inspection office instead. (&lt;a href="https://www.uscis.gov/i-102" rel="noopener noreferrer"&gt;USCIS: Form I-102&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Who made the error?
&lt;/h2&gt;

&lt;p&gt;This one question decides the route and the cost.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;USCIS error.&lt;/strong&gt; The petition had your name right, but the notice printed it wrong. USCIS calls this an error "that is not your fault." You generally must file a new form, but not pay a new fee. (&lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;USCIS: Immigration Documents&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not a USCIS error.&lt;/strong&gt; The wrong spelling came from the petition itself, or your details changed later (for example, a legal name change). If your information changed after USCIS issued your document, USCIS says you'll usually need to file a fresh form and pay its fee. (&lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;same page&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So before you file anything, compare the notice with a copy of what your employer actually filed. Ask HR or the attorney for that copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing it, in order
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Check every field.&lt;/strong&gt; Compare the notice and its I-94 part against your passport: name, birth date, country, class of admission and dates. Make full copies before you send any original away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Open a typo service request, if it's a clear USCIS typo.&lt;/strong&gt; USCIS's Policy Manual lists "request for correction of a typographic error" among the service requests a person can create with an online tool. USCIS says its general goal is to resolve service requests within 15 business days from the date they're created. (&lt;a href="https://www.uscis.gov/policy-manual/volume-1-part-a-chapter-4" rel="noopener noreferrer"&gt;USCIS Policy Manual, Vol. 1, Part A, Ch. 4&lt;/a&gt;) Save the confirmation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. For the I-94 part, prepare Form I-102.&lt;/strong&gt; For a USCIS-issued I-94 with a USCIS error, the USCIS page lists (&lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;USCIS: Immigration Documents&lt;/a&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Form I-102,&lt;/li&gt;
&lt;li&gt;the Arrival-Departure Record that has the error,&lt;/li&gt;
&lt;li&gt;a copy of a government-issued ID showing your legal name and date of birth,&lt;/li&gt;
&lt;li&gt;a statement explaining the change you're asking for,&lt;/li&gt;
&lt;li&gt;papers showing what the correct information should be, if needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The I-102 page adds that for a replacement due to USCIS error, you attach your original form with a letter explaining the specific error and evidence of the correct information. (&lt;a href="https://www.uscis.gov/i-102" rel="noopener noreferrer"&gt;USCIS: Form I-102&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Use the current form and address.&lt;/strong&gt; The I-102 page lists the 04/01/24 edition. It also says USCIS changed the I-102 filing location on Oct. 7, 2026. The grace period for the old address ended on Nov. 9, 2026, so forms now have to go to the new location. (&lt;a href="https://www.uscis.gov/i-102" rel="noopener noreferrer"&gt;USCIS: Form I-102&lt;/a&gt;) Check the Direct Filing Addresses page linked there before you mail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Keep copies of everything you send.&lt;/strong&gt; You'll want them while you wait, and if anyone asks what you filed.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it goes wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The I-94 came from CBP, not USCIS.&lt;/strong&gt; Then don't file Form I-102. The I-102 page says to go to the nearest CBP port of entry or deferred inspection office to fix things like a misspelled name, a wrong birth date, the visa class or the admission date. (&lt;a href="https://www.uscis.gov/i-102" rel="noopener noreferrer"&gt;USCIS: Form I-102&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The error started in the petition.&lt;/strong&gt; Then it isn't a USCIS error, and the no-fee route may not apply. Talk to your employer's attorney about the right fix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You sent the original and kept no copy.&lt;/strong&gt; USCIS says you must return the document with the incorrect information. (&lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;USCIS: Immigration Documents&lt;/a&gt;) Copy it first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You wait and travel.&lt;/strong&gt; The pages we read don't say how a typo affects travel or re-entry. Ask the attorney before any trip if your approval still shows the error.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to ask your employer or attorney
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Did the petition list my name and birth date exactly as my passport does?&lt;/li&gt;
&lt;li&gt;Is this a USCIS error, or did it come from the filing?&lt;/li&gt;
&lt;li&gt;Is the error only on the notice, or also on the I-94 part?&lt;/li&gt;
&lt;li&gt;Will you file the typo request and Form I-102, or should I?&lt;/li&gt;
&lt;li&gt;What should HR keep with my I-9 while the fix is pending?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CloudSkill Consulting LLC sponsors H-1B petitions for qualified candidates in some roles. Questions about our roles go to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Plan with this, decide with your papers: this summary from CloudSkill Consulting LLC isn't legal advice. The attorney who files your H-1B can tell you how the rules fit your case. Keep the USCIS pages below open when you talk.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 4, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;USCIS, Form I-797: Types and Functions (I-797A as a replacement Form I-94) (last updated Jan. 24, 2025): &lt;a href="https://www.uscis.gov/forms/filing-guidance/form-i-797-types-and-functions" rel="noopener noreferrer"&gt;https://www.uscis.gov/forms/filing-guidance/form-i-797-types-and-functions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, Immigration Documents and How to Correct, Update, or Replace Them (USCIS error vs. changed information, Form I-102 for a USCIS-issued I-94, what to send) (last updated Feb. 18, 2025): &lt;a href="https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents" rel="noopener noreferrer"&gt;https://www.uscis.gov/tools/uscis-tools-and-resources/information-about-your-immigration-document/updating-or-correcting-your-documents&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, Form I-102 page (edition, new filing location and Nov. 9, 2026 grace date, CBP-issued I-94s, evidence for a USCIS error) (last updated Oct. 7, 2026): &lt;a href="https://www.uscis.gov/i-102" rel="noopener noreferrer"&gt;https://www.uscis.gov/i-102&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS Policy Manual, Volume 1, Part A, Chapter 4, Service Request Management Tool (typo service requests, 15-business-day goal): &lt;a href="https://www.uscis.gov/policy-manual/volume-1-part-a-chapter-4" rel="noopener noreferrer"&gt;https://www.uscis.gov/policy-manual/volume-1-part-a-chapter-4&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>immigration</category>
      <category>h1b</category>
      <category>career</category>
      <category>visa</category>
    </item>
    <item>
      <title>My I-94 Date Passed and the H-1B Extension Isn't Approved Yet. Am I Still Allowed to Work?</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Tue, 10 Nov 2026 06:52:55 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/my-i-94-date-passed-and-the-h-1b-extension-isnt-approved-yet-am-i-still-allowed-to-work-7ic</link>
      <guid>https://dev.to/cloudskillconsultingllc/my-i-94-date-passed-and-the-h-1b-extension-isnt-approved-yet-am-i-still-allowed-to-work-7ic</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 10, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;Your employer filed your H-1B extension weeks ago. You have the receipt. But the approval (the I-797 approval notice) hasn't come, and today is past the date on your I-94. Your manager asks, "Can you still log in on Monday?"&lt;/p&gt;

&lt;p&gt;This post covers only that case: &lt;strong&gt;the same employer&lt;/strong&gt;, an extension filed on time, and a decision that hasn't arrived. Our team at CloudSkill Consulting LLC read the rule and the USCIS employer pages, and here is what they say.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;Yes, in most cases. If your employer filed the extension &lt;strong&gt;before&lt;/strong&gt; your stay ran out, you may keep working for that same employer for up to 240 days, counted from the day your authorized stay expired. That permission ends sooner if USCIS decides first. (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-274a/subpart-B/section-274a.12" rel="noopener noreferrer"&gt;8 CFR 274a.12(b)(20)&lt;/a&gt;; &lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  What the rule actually says
&lt;/h2&gt;

&lt;p&gt;The regulation is short. In plain words, it covers a worker in one of the listed classes (H-1B is one of them) whose status has expired, when an extension of stay was &lt;strong&gt;timely filed&lt;/strong&gt;. Such a worker:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;may keep working &lt;strong&gt;with the same employer&lt;/strong&gt;,&lt;/li&gt;
&lt;li&gt;for no more than &lt;strong&gt;240 days&lt;/strong&gt;, starting on the date the authorized stay expired,&lt;/li&gt;
&lt;li&gt;under the same conditions and limits as the original approval.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If USCIS denies the extension before the 240 days are up, the permission ends automatically upon notification of the denial. (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-274a/subpart-B/section-274a.12" rel="noopener noreferrer"&gt;8 CFR 274a.12(b)(20)&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;USCIS's handbook for employers matches this. When the employer files the Form I-129 extension on time, the worker can keep working while USCIS reviews it, for 240 days at most, or until USCIS decides, if that happens sooner. (&lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  "Timely filed" is the whole game
&lt;/h2&gt;

&lt;p&gt;Everything above depends on one fact: the petition reached USCIS before your stay ended. Per the handbook, the employer has to ask for the extension of stay while your approved H-1B status is still running, that is, before its end date. (&lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;What if it was filed late? That's a different and harder rule. USCIS may excuse a late filing only in its discretion, and only when, at the time of filing, the employer shows things like extraordinary circumstances beyond its control and that you didn't otherwise violate your status. (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.1" rel="noopener noreferrer"&gt;8 CFR 214.1(c)(4)&lt;/a&gt;) If your filing date is after your I-94 date, stop and call the attorney before you work another day.&lt;/p&gt;

&lt;h2&gt;
  
  
  What HR does on Form I-9
&lt;/h2&gt;

&lt;p&gt;Your employer has a small task once your old work permission date passes. Per the handbook, HR notes "240-Day Ext." in the Additional Information box of Section 2, next to the date the I-129 was sent to USCIS. (&lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;USCIS also suggests the employer keep these with your existing I-9 (&lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;USCIS I-9 Central: Temporary (Nonimmigrant) Workers&lt;/a&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a copy of the new Form I-129,&lt;/li&gt;
&lt;li&gt;proof of payment for filing it,&lt;/li&gt;
&lt;li&gt;evidence that it was mailed to USCIS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then HR must reverify your work permission in Supplement B (Reverification and Rehire) once USCIS decides, or at the end of the 240 days, whichever is earlier. (&lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;If your HR team seems unsure, send them the M-274 section 7.5 link. It's written for employers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What ends the 240 days
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Approval.&lt;/strong&gt; You keep working on the new approval, and HR reverifies your I-9.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Denial.&lt;/strong&gt; The 240-day permission ends automatically upon notification of the denial. (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-274a/subpart-B/section-274a.12" rel="noopener noreferrer"&gt;8 CFR 274a.12(b)(20)&lt;/a&gt;) Call the attorney the same day.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Day 240 with no decision.&lt;/strong&gt; The rule gives no more than 240 days. HR has to reverify by then. (&lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;) If you're getting close, ask your employer's attorney what they plan to do well before that date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A new employer.&lt;/strong&gt; The 240 days cover the same employer only. Moving to a new company runs under H-1B portability, which is a separate rule; see our Nov. 6 post on starting a new H-1B job before approval.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A proposed rule to know about (not final)
&lt;/h2&gt;

&lt;p&gt;On Oct. 14, 2026, DHS published a &lt;strong&gt;proposed&lt;/strong&gt; rule, "Removing Deference to Prior USCIS Determinations of Eligibility." It proposes to remove 8 CFR 214.1(c)(5), the part that generally has USCIS give deference to a prior approval involving the same facts when it decides an extension. (&lt;a href="https://www.federalregister.gov/documents/2026/10/14/2026-20941/removing-deference-to-prior-uscis-determinations-of-eligibility" rel="noopener noreferrer"&gt;Federal Register, 91 FR 65119&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Two things to keep straight:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;It's only a proposal.&lt;/strong&gt; When we checked the Federal Register on Nov. 4, 2026, it was listed as a proposed rule with comments due by Nov. 13, 2026. It isn't final, and today's rule text on eCFR still includes 214.1(c)(5). (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.1" rel="noopener noreferrer"&gt;eCFR, 8 CFR 214.1&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It doesn't propose to remove the 240-day rule.&lt;/strong&gt; The notice's own cost discussion says that when an extension is timely filed and still pending after status expires, the worker may remain in an authorized period of stay and may be eligible to keep working, citing 8 CFR 274a.12(b)(20). DHS also says removing deference could mean longer decision times for extensions. (&lt;a href="https://www.federalregister.gov/documents/2026/10/14/2026-20941/removing-deference-to-prior-uscis-determinations-of-eligibility" rel="noopener noreferrer"&gt;Federal Register, 91 FR 65119&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the practical point: if this proposal becomes final, waits for extensions could get longer, and the 240-day limit could matter to more people. Watch the Federal Register page for a final rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to ask your employer or attorney
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;On what date did USCIS receive the I-129? Is that date before my I-94 date?&lt;/li&gt;
&lt;li&gt;Is my I-9 marked "240-Day Ext." with the I-129 filing date?&lt;/li&gt;
&lt;li&gt;On what date does my 240-day period end?&lt;/li&gt;
&lt;li&gt;What's the plan if there's no decision by then?&lt;/li&gt;
&lt;li&gt;If the extension is denied, what are my options that same day?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep your own copy of the receipt notice, your current I-94 and your last approval notice together, so you can answer these fast.&lt;/p&gt;

&lt;p&gt;CloudSkill Consulting LLC sponsors H-1B petitions for qualified candidates in some roles. Questions about our roles go to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Plan with this, decide with your papers: this summary from CloudSkill Consulting LLC isn't legal advice. The attorney who files your H-1B can tell you how the rules fit your case. Keep the USCIS, eCFR and Federal Register pages below open when you talk.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 4, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;eCFR, 8 CFR 274a.12(b)(20), the 240-day rule (and (b)(9), H-1B among the listed classes): &lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-274a/subpart-B/section-274a.12" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-274a/subpart-B/section-274a.12&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;eCFR, 8 CFR 214.1(c)(4) and (c)(5), timely filing and deference to prior approvals: &lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.1" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, Handbook for Employers M-274, 7.5 H-1B Specialty Occupations ("240-Day Ext." I-9 note, reverification) (last updated July 26, 2023): &lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, I-9 Central: Temporary (Nonimmigrant) Workers (records to keep with the I-9) (last updated July 28, 2023): &lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Federal Register, DHS proposed rule "Removing Deference to Prior USCIS Determinations of Eligibility," 91 FR 65119 (Oct. 14, 2026; comments due Nov. 13, 2026): &lt;a href="https://www.federalregister.gov/documents/2026/10/14/2026-20941/removing-deference-to-prior-uscis-determinations-of-eligibility" rel="noopener noreferrer"&gt;https://www.federalregister.gov/documents/2026/10/14/2026-20941/removing-deference-to-prior-uscis-determinations-of-eligibility&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>immigration</category>
      <category>h1b</category>
      <category>career</category>
      <category>visa</category>
    </item>
    <item>
      <title>Terraform Says for_each Keys Can't Be Known Until Apply. Here's What It Actually Wants</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Sun, 08 Nov 2026 09:12:01 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/terraform-says-foreach-keys-cant-be-known-until-apply-heres-what-it-actually-wants-1n12</link>
      <guid>https://dev.to/cloudskillconsultingllc/terraform-says-foreach-keys-cant-be-known-until-apply-heres-what-it-actually-wants-1n12</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 8, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Terraform gives every &lt;code&gt;for_each&lt;/code&gt; instance an address like &lt;code&gt;aws_route_table_association.public["us-east-1a"]&lt;/code&gt;, and it must know those keys during &lt;strong&gt;plan&lt;/strong&gt;. If a key comes from something that only exists after &lt;strong&gt;apply&lt;/strong&gt;, plan stops with &lt;code&gt;Invalid for_each argument&lt;/code&gt;. The two usual causes are keys built from generated attributes, and a &lt;code&gt;depends_on&lt;/code&gt; on a data source that pushes its read to apply time. The fix is to take keys from your config and let only the &lt;strong&gt;values&lt;/strong&gt; be unknown. &lt;code&gt;-target&lt;/code&gt; gets you past one run but doesn't fix the config.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;A Reddit user was building route table associations for the public subnets behind a load balancer. Their flow went like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the load balancer with a data source. This data block had &lt;code&gt;depends_on&lt;/code&gt; pointing at a Helm release, so the read would wait for the release.&lt;/li&gt;
&lt;li&gt;Find the subnets in that VPC.&lt;/li&gt;
&lt;li&gt;Loop over the subnets with &lt;code&gt;for_each&lt;/code&gt;, and keep the ones whose &lt;code&gt;Name&lt;/code&gt; tag contained "public".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Plan failed with the familiar message: the &lt;code&gt;for_each&lt;/code&gt; set "includes values derived from resource attributes that cannot be determined until apply." They had already tried pushing the IDs through a &lt;code&gt;terraform_data&lt;/code&gt; resource, which didn't help.&lt;/p&gt;

&lt;p&gt;The error text suggests &lt;code&gt;-target&lt;/code&gt;, so many people stop there. That gets you through one run. It doesn't explain the cause, and the error returns the next time the dependency changes. This post covers the cause, two small repros you can run with no cloud account, the fix, and a real AWS version of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Terraform needs the keys at plan time
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;for_each&lt;/code&gt; keys aren't just loop variables. They become part of each instance's &lt;strong&gt;address&lt;/strong&gt; in state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform_data.route_assoc["public-a"]
terraform_data.route_assoc["public-b"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A plan is a list of actions against those addresses: create this one, update that one, destroy the other. If Terraform doesn't know the keys, it can't say which instances exist, so it can't write a plan. HashiCorp's &lt;code&gt;for_each&lt;/code&gt; page states the rule: the keys of the map, or the values in a set of strings, must be known values. You can't build keys from impure functions such as &lt;code&gt;uuid()&lt;/code&gt; or &lt;code&gt;timestamp()&lt;/code&gt;, and you can't use sensitive values.&lt;/p&gt;

&lt;p&gt;Note the asymmetry. &lt;strong&gt;Keys must be known. Values may be unknown.&lt;/strong&gt; Almost every fix uses that gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Repro A: keys built from a generated value
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Repro A: map keys come from a value that only exists after apply.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"random_id"&lt;/span&gt; &lt;span class="s2"&gt;"suffix"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;toset&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"logs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"assets"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;byte_length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"terraform_data"&lt;/span&gt; &lt;span class="s2"&gt;"bucket"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;# Key = the random hex. Unknown at plan time, so Terraform cannot name the instances.&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="nx"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;random_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;suffix&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hex&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hex&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"bucket-${each.value}"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;terraform plan&lt;/code&gt; (trimmed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Invalid for_each argument

  on main.tf line 9, in resource "terraform_data" "bucket":
   9:   for_each = { for r in random_id.suffix : r.hex =&amp;gt; r.hex }

The "for_each" map includes keys derived from resource attributes that cannot
be determined until apply, and so Terraform cannot determine the full set of
keys that will identify the instances of this resource.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same thing happens with AWS IDs, ARNs or any attribute the provider fills in on create.&lt;/p&gt;

&lt;h2&gt;
  
  
  Repro B: &lt;code&gt;depends_on&lt;/code&gt; on a data source
&lt;/h2&gt;

&lt;p&gt;This one matches the Reddit case and is harder to spot, because the data source looks harmless:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Repro B: a data source that depends_on a managed resource is read during apply,&lt;/span&gt;
&lt;span class="c1"&gt;# so everything derived from it is unknown at plan time.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"terraform_data"&lt;/span&gt; &lt;span class="s2"&gt;"release"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ingress-v2"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="s2"&gt;"local_file"&lt;/span&gt; &lt;span class="s2"&gt;"subnets"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;filename&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${path.module}/subnets.json"&lt;/span&gt;
  &lt;span class="nx"&gt;depends_on&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;terraform_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;release&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;locals&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;subnets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jsondecode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;local_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"terraform_data"&lt;/span&gt; &lt;span class="s2"&gt;"route_assoc"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnets&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;subnets.json&lt;/code&gt; is just &lt;code&gt;{"public-a": "subnet-0aa1", "public-b": "subnet-0bb2"}&lt;/code&gt;. The file is right there on disk, yet plan still fails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # data.local_file.subnets will be read during apply
  # (depends on a resource or a module with changes pending)
 &amp;lt;= data "local_file" "subnets" {
      + content              = (known after apply)
      ...
Error: Invalid for_each argument
  17:   for_each = local.subnets
    │ local.subnets will be known only after apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Terraform's own plan output names the cause: the read waits because of a pending change. HashiCorp's data source docs explain it. Terraform tries to read data sources during plan, but it can't predict the result when the data block "directly depends on a Terraform-managed resource that is configured to change in the current plan." &lt;code&gt;depends_on&lt;/code&gt; creates exactly that dependency. While &lt;code&gt;terraform_data.release&lt;/code&gt; has a pending change, the file read waits for apply, so its content is unknown and so are the keys.&lt;/p&gt;

&lt;p&gt;That is also why this bug feels random. On the box, the run went like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;Pending change to &lt;code&gt;release&lt;/code&gt;?&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;apply -target=terraform_data.release&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;release created&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;next &lt;code&gt;plan&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;plan works&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;change &lt;code&gt;release&lt;/code&gt; input to &lt;code&gt;ingress-v3&lt;/code&gt;, then &lt;code&gt;apply&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Invalid for_each argument&lt;/code&gt; again&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;-target&lt;/code&gt; fixed one run. The first real change to the dependency broke it again. In the Reddit setup, every Helm chart bump would do the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;The full error text already hints at it: define keys statically and keep apply-time results in the values. In practice that means two rules, one for each repro:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Keys come from config.&lt;/strong&gt; Use names you control (a list in a variable, a &lt;code&gt;toset([...])&lt;/code&gt; literal, availability zone names) as keys. Put generated IDs in the values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;depends_on&lt;/code&gt; on data blocks that feed &lt;code&gt;for_each&lt;/code&gt;.&lt;/strong&gt; If the data read really must happen after a change, that's a sign the data belongs in a separate configuration (see the trade-offs below).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fix A: keys come from config; apply-time values sit only in the map values.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"random_id"&lt;/span&gt; &lt;span class="s2"&gt;"suffix"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;toset&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"logs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"assets"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;byte_length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"terraform_data"&lt;/span&gt; &lt;span class="s2"&gt;"bucket"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;random_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;suffix&lt;/span&gt; &lt;span class="c1"&gt;# keys "logs" and "assets" are known at plan time&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"bucket-${each.key}-${each.value.hex}"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Fix B: no depends_on on the data source, so it is read during plan.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"terraform_data"&lt;/span&gt; &lt;span class="s2"&gt;"release"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ingress-v2"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="s2"&gt;"local_file"&lt;/span&gt; &lt;span class="s2"&gt;"subnets"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${path.module}/subnets.json"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;locals&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;subnets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jsondecode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;local_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"terraform_data"&lt;/span&gt; &lt;span class="s2"&gt;"route_assoc"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subnets&lt;/span&gt;
  &lt;span class="nx"&gt;input&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plan now shows seven resources to add. After &lt;code&gt;apply&lt;/code&gt;, the next &lt;code&gt;plan&lt;/code&gt; says "No changes," and the state uses stable addresses: &lt;code&gt;terraform_data.bucket["logs"]&lt;/code&gt;, &lt;code&gt;terraform_data.bucket["assets"]&lt;/code&gt;, &lt;code&gt;terraform_data.route_assoc["public-a"]&lt;/code&gt; and &lt;code&gt;terraform_data.route_assoc["public-b"]&lt;/code&gt;. Note that &lt;code&gt;for_each = random_id.suffix&lt;/code&gt; works because a resource with &lt;code&gt;for_each&lt;/code&gt; is a map keyed by its own (known) keys, even though the attributes inside are unknown.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same fix on real AWS resources
&lt;/h2&gt;

&lt;p&gt;In the Reddit case, the real goal was "associate a route table with the public subnet in each AZ." AZ names are known before anything is created, so make them the keys and look up each subnet by AZ:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;required_providers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;aws&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/aws"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 6.0"&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="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"vpc_id"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"public_route_table_id"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"public_azs"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"us-east-1a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"us-east-1b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"us-east-1c"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# One lookup per AZ. The keys come from the variable, so they are known at plan time.&lt;/span&gt;
&lt;span class="c1"&gt;# If a lookup has to wait until apply, only the value is unknown, and that is allowed.&lt;/span&gt;
&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="s2"&gt;"aws_subnet"&lt;/span&gt; &lt;span class="s2"&gt;"public"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public_azs&lt;/span&gt;
  &lt;span class="nx"&gt;vpc_id&lt;/span&gt;            &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;vpc_id&lt;/span&gt;
  &lt;span class="nx"&gt;availability_zone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;

  &lt;span class="nx"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;name&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tag:Tier"&lt;/span&gt;
    &lt;span class="nx"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"public"&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="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_route_table_association"&lt;/span&gt; &lt;span class="s2"&gt;"public"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;for_each&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;aws_subnet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public&lt;/span&gt; &lt;span class="c1"&gt;# same keys: the AZ names&lt;/span&gt;
  &lt;span class="nx"&gt;subnet_id&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
  &lt;span class="nx"&gt;route_table_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;public_route_table_id&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The filtering moved too. Instead of looping over every subnet and testing the &lt;code&gt;Name&lt;/code&gt; tag in an expression, the &lt;code&gt;tag:Tier&lt;/code&gt; filter asks AWS for the right subnet directly. That shortens the config and removes the data-dependent &lt;code&gt;if&lt;/code&gt; from the key logic.&lt;/p&gt;

&lt;p&gt;To prove the "values may be unknown" part, the box run swapped &lt;code&gt;var.vpc_id&lt;/code&gt; for the output of a &lt;code&gt;terraform_data&lt;/code&gt; resource, standing in for a VPC created in the same apply. With no real AWS account involved, plan still succeeded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # data.aws_subnet.public["us-east-1a"] will be read during apply
  # (config refers to values not yet known)
  ...
  # aws_route_table_association.public["us-east-1a"] will be created
  # aws_route_table_association.public["us-east-1b"] will be created
  # aws_route_table_association.public["us-east-1c"] will be created
Plan: 4 to add, 0 to change, 0 to destroy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The subnet lookups wait for apply, but the association addresses are fixed, so Terraform can plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You must know the keys up front.&lt;/strong&gt; Static keys mean listing AZs, environment names or service names in config. If the set truly changes outside Terraform (say, subnets someone else creates), a data source read at plan time is fine, but only if it doesn't depend on a pending change in the same run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changing a key is a replace.&lt;/strong&gt; Renaming &lt;code&gt;"logs"&lt;/code&gt; to &lt;code&gt;"log-archive"&lt;/code&gt; destroys one instance and creates another. Use a &lt;code&gt;moved&lt;/code&gt; block when you rename keys on purpose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-target&lt;/code&gt; is for emergencies.&lt;/strong&gt; HashiCorp's &lt;code&gt;plan&lt;/code&gt; docs keep targeting for exceptional cases, like recovering from mistakes, and warn that routine use can hide configuration drift. A bootstrap that always needs &lt;code&gt;-target&lt;/code&gt; will catch someone out later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Splitting configurations is sometimes right.&lt;/strong&gt; If something must exist first (for example, a load balancer created by a Helm release), put it in its own root module and pass its outputs to the second one. That adds a pipeline stage and remote state reads, but each plan is honest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't launder unknowns.&lt;/strong&gt; Passing a value through &lt;code&gt;terraform_data&lt;/code&gt;, &lt;code&gt;locals&lt;/code&gt; or a module output doesn't make it known. If the source is unknown, everything built from it is too.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to verify the fix
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Run plan with no special flags.&lt;/strong&gt; &lt;code&gt;terraform plan&lt;/code&gt; (no &lt;code&gt;-target&lt;/code&gt;) should finish without &lt;code&gt;Invalid for_each argument&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Look for deferred reads.&lt;/strong&gt; Search the plan for &lt;code&gt;will be read during apply&lt;/code&gt;. If a data block that feeds &lt;code&gt;for_each&lt;/code&gt; keys shows up there, the bug is still waiting for the next change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change the dependency and plan again.&lt;/strong&gt; In the repro, that meant editing &lt;code&gt;terraform_data.release&lt;/code&gt;. In a real stack, bump the Helm chart version or a tag on the resource you used to depend on. A correct config still plans.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the addresses.&lt;/strong&gt; After apply, &lt;code&gt;terraform state list&lt;/code&gt; should show readable keys you chose (&lt;code&gt;["us-east-1a"]&lt;/code&gt;, &lt;code&gt;["logs"]&lt;/code&gt;), not IDs or random hex.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan once more after apply.&lt;/strong&gt; You want "No changes." If the keys shift between runs, something non-deterministic is still in the key path.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All five checks passed on the box with Terraform v1.9.8. The three plans (both repros and the fix) gave the same results on v1.17.0.&lt;/p&gt;

&lt;p&gt;A Terraform codebase full of &lt;code&gt;-target&lt;/code&gt; notes may have this exact pattern underneath. In CloudSkill Consulting LLC software engineering reviews, we'd fix the keys once rather than keep repeating the workaround.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs checked (October 26, 2026)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.hashicorp.com/terraform/language/meta-arguments/for_each" rel="noopener noreferrer"&gt;The for_each meta-argument&lt;/a&gt; (limitations on values, impure functions, sensitive values)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.hashicorp.com/terraform/language/data-sources" rel="noopener noreferrer"&gt;Data sources&lt;/a&gt; (when reads are deferred to apply)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on" rel="noopener noreferrer"&gt;The depends_on meta-argument&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.hashicorp.com/terraform/cli/commands/plan" rel="noopener noreferrer"&gt;terraform plan command&lt;/a&gt; (resource targeting guidance)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.hashicorp.com/terraform/language/resources/terraform-data" rel="noopener noreferrer"&gt;The terraform_data resource type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.hashicorp.com/terraform/language/modules/develop/refactoring" rel="noopener noreferrer"&gt;Refactoring with moved blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet" rel="noopener noreferrer"&gt;AWS provider: aws_subnet data source&lt;/a&gt; and &lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association" rel="noopener noreferrer"&gt;aws_route_table_association&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;When HashiCorp changes how deferred reads or for_each keys behave, email &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt; and we'll bring this article up to date.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>aws</category>
      <category>devops</category>
      <category>iac</category>
    </item>
    <item>
      <title>Switching H-1B Employers: Is Day One the Filing Date or the Approval Date?</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Fri, 06 Nov 2026 10:58:46 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/switching-h-1b-employers-is-day-one-the-filing-date-or-the-approval-date-46h0</link>
      <guid>https://dev.to/cloudskillconsultingllc/switching-h-1b-employers-is-day-one-the-filing-date-or-the-approval-date-46h0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of November 6, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;You're on an H-1B. A new company has made you an offer, and its HR team says: "We'll file your petition this week. Can you start on the 1st?" Your friend says you have to wait for the approval. Your recruiter says you don't. Who is right?&lt;/p&gt;

&lt;p&gt;Our team at CloudSkill Consulting LLC read the rule and the USCIS pages on this. Below is what they say, in plain words.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;In most cases you don't have to wait for approval. Under H-1B portability, you may start at the new company once it properly files a non-frivolous Form I-129 for you, or on the start date written in that petition, whichever is later. (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(H)&lt;/a&gt;; &lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;"Non-frivolous" just means a real, good-faith petition. Form I-129 is the petition an employer sends to USCIS for a temporary worker.&lt;/p&gt;

&lt;p&gt;So the date that matters is the &lt;strong&gt;filing date&lt;/strong&gt;, not the approval date, and only if a few things are true.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three things that must be true
&lt;/h2&gt;

&lt;p&gt;The rule calls you an "eligible H-1B nonimmigrant" if all three of these hold (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(H)(1)&lt;/a&gt;):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You were lawfully admitted in, or otherwise given, H-1B status.&lt;/li&gt;
&lt;li&gt;The new employer filed the petition &lt;strong&gt;before&lt;/strong&gt; your authorized stay ran out.&lt;/li&gt;
&lt;li&gt;You have not worked without authorization in the U.S. from your last admission up to the filing of the new petition.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If any one of these fails, portability doesn't cover you. USCIS's I-9 page puts it simply: if you aren't in H-1B status right now, you can't change employers or start working until USCIS approves the petition. (&lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;USCIS I-9 Central: Temporary (Nonimmigrant) Workers&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do, in order
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Don't resign on a promise.&lt;/strong&gt; Wait until the new employer tells you the I-129 has actually been filed. USCIS sends the employer a receipt once it takes in the petition. No receipt is sent if a petition is rejected. (&lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;USCIS I-9 Central&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Check the start date on the petition.&lt;/strong&gt; If it says a later date than the filing date, the later date is your first allowed workday.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Expect a new Form I-9 on day one.&lt;/strong&gt; The new employer must complete a new I-9 for you. Your unexpired Form I-94 from the previous employer, together with your foreign passport, counts as a List A document. HR writes "AC-21" and the date it submitted the I-129 in the Additional Information field of Section 2. (&lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS M-274, 7.5&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;USCIS also suggests the employer keep a copy of the new I-129, proof of payment, and evidence that it mailed the petition with your I-9. (&lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;USCIS I-9 Central&lt;/a&gt;) If HR asks you for nothing beyond your passport and I-94, that's normal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Keep your own copies.&lt;/strong&gt; Get the receipt from HR and write down the filing date. You'll want both if anyone asks later why you started before approval.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long portability lasts
&lt;/h2&gt;

&lt;p&gt;Your work permission under portability lasts until USCIS decides the new petition. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;; &lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(H)(2)&lt;/a&gt;) Then:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Approved:&lt;/strong&gt; you stay with the new employer for the dates the approval shows. HR reverifies your I-9 in Supplement B once USCIS decides. (&lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;USCIS I-9 Central&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Denied:&lt;/strong&gt; work based on portability stops. You may go back to the previous employer only if your earlier period of authorized employment is still valid. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So it helps to leave the old job on good terms, at least until the new petition is approved.&lt;/p&gt;

&lt;h2&gt;
  
  
  What if you move again before the first one is decided?
&lt;/h2&gt;

&lt;p&gt;The rule covers this too. If you're working under portability and your I-94 date has passed, you're still treated as being in a period of authorized stay for this purpose. A third employer can file, and you may start there on filing or on its start date, whichever is later, even though the earlier petition is still pending. (&lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.2" rel="noopener noreferrer"&gt;8 CFR 214.2(h)(2)(i)(H)(3)&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;There's a catch. If the extension or amendment in an earlier petition in the chain is denied, a later one in the chain can't be approved for its extension either, unless your earlier approved H-1B status is still valid. Each extra move adds risk, so talk to an attorney before a second jump.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it goes wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The petition was filed after your stay ended.&lt;/strong&gt; Then condition 2 fails. Check the date on your I-94, not only the date on your old I-797.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There was unauthorized work after your last entry.&lt;/strong&gt; Condition 3 fails, even if it was only a few days.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your current H-1B is cap-exempt (for example, at a university) and the new job isn't.&lt;/strong&gt; USCIS says that petition is subject to the H-1B cap, and the new employer must register first, usually in March. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You lost the old job before the new filing.&lt;/strong&gt; USCIS describes a grace period of up to 60 consecutive days, or until your authorized validity ends if that's sooner, to find new work, change status or leave. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You travel or the request is found ineligible.&lt;/strong&gt; USCIS's H-1B page says a September 2025 Proclamation payment doesn't apply to a petition for someone inside the U.S. asking for an amendment, change of status or extension of stay when that request is granted. It can apply if USCIS finds the person ineligible, for example if they leave the U.S. before the decision. (&lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;USCIS: H-1B Specialty Occupations&lt;/a&gt;) Ask the attorney before any trip abroad while the petition is pending.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to ask before your last day
&lt;/h2&gt;

&lt;p&gt;Ask the new employer or its attorney:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Has the I-129 been filed, and on what date?&lt;/li&gt;
&lt;li&gt;What start date does the petition request?&lt;/li&gt;
&lt;li&gt;Does my I-94 show that my stay was still valid on the filing date?&lt;/li&gt;
&lt;li&gt;Was my last H-1B cap-subject, or cap-exempt?&lt;/li&gt;
&lt;li&gt;If the petition is denied, what's the plan?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And ask yourself one thing: is my old job's approval still valid in case I need to go back?&lt;/p&gt;

&lt;p&gt;This post is about &lt;strong&gt;changing employers&lt;/strong&gt;. If you're staying with the same employer and your extension is pending past your end date, that's a different rule, the 240-day rule, and we cover it in a separate post.&lt;/p&gt;

&lt;p&gt;CloudSkill Consulting LLC sponsors H-1B petitions for qualified candidates in some roles. Questions about our roles go to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Plan with this, decide with your papers: this summary from CloudSkill Consulting LLC isn't legal advice. The attorney who files your H-1B can tell you how the rules fit your case. Keep the USCIS and eCFR pages below open when you talk.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Every page below was read on Nov. 4, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;eCFR, 8 CFR 214.2(h)(2)(i)(H), H-1B portability (eligibility, how long it lasts, successive petitions): &lt;a href="https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.2" rel="noopener noreferrer"&gt;https://www.ecfr.gov/current/title-8/chapter-I/subchapter-B/part-214/section-214.2&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, H-1B Specialty Occupations (portability, denial, cap-exempt to cap-subject, 60-day period, Proclamation note) (last updated Sept. 21, 2026): &lt;a href="https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations" rel="noopener noreferrer"&gt;https://www.uscis.gov/working-in-the-united-states/h-1b-specialty-occupations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, Handbook for Employers M-274, 7.5 H-1B Specialty Occupations ("AC-21" I-9 note, List A documents) (last updated July 26, 2023): &lt;a href="https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations" rel="noopener noreferrer"&gt;https://www.uscis.gov/i-9-central/form-i-9-resources/handbook-for-employers-m-274/70-evidence-of-employment-authorization-for-certain-categories/75-h-1b-specialty-occupations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;USCIS, I-9 Central: Temporary (Nonimmigrant) Workers (receipts, records to keep, reverification) (last updated July 28, 2023): &lt;a href="https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers" rel="noopener noreferrer"&gt;https://www.uscis.gov/i-9-central/completing-form-i-9/temporary-nonimmigrant-workers&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>immigration</category>
      <category>h1b</category>
      <category>career</category>
      <category>visa</category>
    </item>
    <item>
      <title>A Lambda That Writes Back to the Bucket That Triggers It Can Bill You in a Loop. Here's a Safe Setup</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Thu, 29 Oct 2026 02:25:53 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/a-lambda-that-writes-back-to-the-bucket-that-triggers-it-can-bill-you-in-a-loop-heres-a-safe-setup-3i14</link>
      <guid>https://dev.to/cloudskillconsultingllc/a-lambda-that-writes-back-to-the-bucket-that-triggers-it-can-bill-you-in-a-loop-heres-a-safe-setup-3i14</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of October 29, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;A 2019 post on Reddit's r/aws describes a bill nobody wants. A team had a Lambda function that listened for new files in an S3 bucket. It read each file, changed it, and saved the result to S3. But the source bucket and the output bucket were set to the &lt;strong&gt;same&lt;/strong&gt; bucket. So every saved result was a new file, and every new file started the function again.&lt;/p&gt;

&lt;p&gt;It ran like that for about three and a half days, over a weekend, in a new account with no cost alerts yet. The bill was over $6,800, mostly for S3 PUT requests. The team only found out when someone at AWS asked them about the traffic.&lt;/p&gt;

&lt;p&gt;This is a common trap. AWS even warns about it in the Lambda docs. In this post we explain the root cause, show a setup that can't loop, add guard rails in case someone breaks it later, and show how to test all of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause: the output matches the trigger
&lt;/h2&gt;

&lt;p&gt;An S3 trigger is a rule on the bucket. It says, "When an object is created, call this function." AWS's Lambda docs put it plainly: if the function uploads an object to the same bucket, it "indirectly triggers itself."&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;A user uploads &lt;code&gt;orders.csv&lt;/code&gt;. S3 calls the function.&lt;/li&gt;
&lt;li&gt;The function saves &lt;code&gt;orders.json&lt;/code&gt; to the same bucket.&lt;/li&gt;
&lt;li&gt;That is a new object, so S3 calls the function again.&lt;/li&gt;
&lt;li&gt;The function saves another file. Go to step 3.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three things make it costly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Each turn is billed.&lt;/strong&gt; You pay for the Lambda run and for the S3 PUT. The Reddit bill was mostly PUT requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lambda scales out.&lt;/strong&gt; Each new file is its own event, so many copies can run at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It can be quiet.&lt;/strong&gt; If the function overwrites the same key each time, the file count doesn't grow. Nothing looks wrong in the bucket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A second, smaller bug often hides here too. The object key in an S3 event is &lt;strong&gt;URL encoded&lt;/strong&gt;. AWS's example: &lt;code&gt;red flower.jpg&lt;/code&gt; arrives as &lt;code&gt;red+flower.jpg&lt;/code&gt;. If your code uses the raw key, it can't read the file, the run fails, and S3's async retry calls the function again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doesn't AWS stop loops now?
&lt;/h2&gt;

&lt;p&gt;Partly. Lambda has &lt;strong&gt;recursive loop detection&lt;/strong&gt;, and it is on by default. This came after that post. Today the docs list Amazon S3 as a supported service, with SQS, SNS and EventBridge custom buses. If one triggering event calls your function about 16 times in a chain, Lambda stops the next call and notifies you.&lt;/p&gt;

&lt;p&gt;That helps a lot, but don't treat it as the fix:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It only works if the function uses a &lt;strong&gt;supported AWS SDK version&lt;/strong&gt; (for Python, boto3 1.24.46 or later). Check what your runtime or package ships.&lt;/li&gt;
&lt;li&gt;It allows about &lt;strong&gt;16 runs per chain&lt;/strong&gt; before it stops. Many uploads at once means many chains.&lt;/li&gt;
&lt;li&gt;Loops through services it doesn't track (the docs name DynamoDB) &lt;strong&gt;are not stopped&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Anyone can switch a function to &lt;code&gt;Allow&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The email and Health Dashboard alerts can take up to 3.5 hours.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we design the loop out, then keep detection on as a safety net.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: inputs and outputs never overlap
&lt;/h2&gt;

&lt;p&gt;AWS's docs give two safe options: &lt;strong&gt;use two buckets&lt;/strong&gt;, or &lt;strong&gt;trigger only on a prefix used for incoming objects&lt;/strong&gt;. Two buckets is the simplest and the safest. When you must use one bucket, set it up so the function's output can never match the trigger. We use four layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Trigger filter.&lt;/strong&gt; Fire only for &lt;code&gt;incoming/*.csv&lt;/code&gt;. Write output to &lt;code&gt;processed/*.jsonl&lt;/code&gt;. The filter never matches the output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IAM.&lt;/strong&gt; The function may read only &lt;code&gt;incoming/*&lt;/code&gt; and write only &lt;code&gt;processed/*&lt;/code&gt;. Even buggy code can't write back under the trigger prefix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code guards.&lt;/strong&gt; Refuse to start if the two prefixes overlap. Skip any event outside &lt;code&gt;incoming/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limits and alarms.&lt;/strong&gt; Cap concurrency, keep loop detection on, and alarm on spikes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The handler
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# handler.py - Lambda (Python 3.12). Triggered by S3 ObjectCreated on incoming/*.csv.
# Reads the CSV, writes JSON Lines under processed/. Never writes under incoming/.
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib.parse&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;unquote_plus&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;

&lt;span class="n"&gt;IN_PREFIX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;IN_PREFIX&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;incoming/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;OUT_PREFIX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OUT_PREFIX&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;processed/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;output_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;in_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;incoming/2026/orders.csv -&amp;gt; processed/2026/orders.jsonl&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;in_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IN_PREFIX&lt;/span&gt;&lt;span class="p"&gt;):]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;OUT_PREFIX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.jsonl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Guard 1: the two prefixes must not overlap, or our own writes match the trigger.
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;OUT_PREFIX&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IN_PREFIX&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;IN_PREFIX&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;OUT_PREFIX&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OUT_PREFIX &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;OUT_PREFIX&lt;/span&gt;&lt;span class="si"&gt;!r}&lt;/span&gt;&lt;span class="s"&gt; overlaps IN_PREFIX &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;IN_PREFIX&lt;/span&gt;&lt;span class="si"&gt;!r}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;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="nf"&gt;check_config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;written&lt;/span&gt; &lt;span class="o"&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="ow"&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="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Records&lt;/span&gt;&lt;span class="sh"&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;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bucket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="c1"&gt;# Keys in S3 events are URL-encoded: a space arrives as "+".
&lt;/span&gt;        &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;unquote_plus&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;object&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

        &lt;span class="c1"&gt;# Guard 2: ignore anything outside the input prefix, even if a
&lt;/span&gt;        &lt;span class="c1"&gt;# trigger is set up wrong later.
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IN_PREFIX&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;skip&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reason&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;outside IN_PREFIX&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}))&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Body&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DictReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StringIO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;output_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                      &lt;span class="n"&gt;ContentType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;application/x-ndjson&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;written&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="n"&gt;out&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;written&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;written&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why &lt;code&gt;processed/&lt;/code&gt; and not &lt;code&gt;incoming/processed/&lt;/code&gt;? Because &lt;code&gt;incoming/processed/x.jsonl&lt;/code&gt; still starts with &lt;code&gt;incoming/&lt;/code&gt;. The trigger would match it, and the loop is back. Guard 1 catches that mistake before any write.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Terraform
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;required_providers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;aws&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/aws"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 6.0"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;archive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/archive"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 2.0"&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="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"bucket_name"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"alarm_topic_arn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SNS topic that gets the alarm emails"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;locals&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;in_prefix&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"incoming/"&lt;/span&gt;
  &lt;span class="nx"&gt;out_prefix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"processed/"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_s3_bucket"&lt;/span&gt; &lt;span class="s2"&gt;"data"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bucket_name&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="s2"&gt;"archive_file"&lt;/span&gt; &lt;span class="s2"&gt;"fn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"zip"&lt;/span&gt;
  &lt;span class="nx"&gt;source_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${path.module}/handler.py"&lt;/span&gt;
  &lt;span class="nx"&gt;output_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${path.module}/build/handler.zip"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_iam_role"&lt;/span&gt; &lt;span class="s2"&gt;"fn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"csv-to-jsonl"&lt;/span&gt;
  &lt;span class="nx"&gt;assume_role_policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jsonencode&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;Version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;
    &lt;span class="nx"&gt;Statement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
      &lt;span class="nx"&gt;Effect&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;
      &lt;span class="nx"&gt;Principal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"lambda.amazonaws.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;Action&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"sts:AssumeRole"&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;# Read only from incoming/, write only to processed/.&lt;/span&gt;
&lt;span class="c1"&gt;# Even a code bug can't put an object back under the trigger prefix.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_iam_role_policy"&lt;/span&gt; &lt;span class="s2"&gt;"fn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_iam_role&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
  &lt;span class="nx"&gt;policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jsonencode&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;Version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;
    &lt;span class="nx"&gt;Statement&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="nx"&gt;Effect&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;
        &lt;span class="nx"&gt;Action&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;
        &lt;span class="nx"&gt;Resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${aws_s3_bucket.data.arn}/${local.in_prefix}*"&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;Effect&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;
        &lt;span class="nx"&gt;Action&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"s3:PutObject"&lt;/span&gt;
        &lt;span class="nx"&gt;Resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${aws_s3_bucket.data.arn}/${local.out_prefix}*"&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;Effect&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Allow"&lt;/span&gt;
        &lt;span class="nx"&gt;Action&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"logs:CreateLogGroup"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"logs:CreateLogStream"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"logs:PutLogEvents"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="nx"&gt;Resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&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="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_lambda_function"&lt;/span&gt; &lt;span class="s2"&gt;"fn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;function_name&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"csv-to-jsonl"&lt;/span&gt;
  &lt;span class="nx"&gt;role&lt;/span&gt;             &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_iam_role&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
  &lt;span class="nx"&gt;runtime&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"python3.12"&lt;/span&gt;
  &lt;span class="nx"&gt;handler&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"handler.handler"&lt;/span&gt;
  &lt;span class="nx"&gt;filename&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;archive_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;output_path&lt;/span&gt;
  &lt;span class="nx"&gt;source_code_hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;archive_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;output_base64sha256&lt;/span&gt;
  &lt;span class="nx"&gt;timeout&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;

  &lt;span class="c1"&gt;# A ceiling, not a fix: a loop can't fan out past 5 copies at once.&lt;/span&gt;
  &lt;span class="nx"&gt;reserved_concurrent_executions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;

  &lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;variables&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;IN_PREFIX&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;in_prefix&lt;/span&gt;
      &lt;span class="nx"&gt;OUT_PREFIX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;out_prefix&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;# Keep Lambda's loop detection on. "Terminate" is the default; writing it down&lt;/span&gt;
&lt;span class="c1"&gt;# stops someone from quietly switching it to "Allow".&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_lambda_function_recursion_config"&lt;/span&gt; &lt;span class="s2"&gt;"fn"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;function_name&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;function_name&lt;/span&gt;
  &lt;span class="nx"&gt;recursive_loop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Terminate"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_lambda_permission"&lt;/span&gt; &lt;span class="s2"&gt;"s3"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;statement_id&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"AllowS3Invoke"&lt;/span&gt;
  &lt;span class="nx"&gt;action&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"lambda:InvokeFunction"&lt;/span&gt;
  &lt;span class="nx"&gt;function_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;function_name&lt;/span&gt;
  &lt;span class="nx"&gt;principal&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"s3.amazonaws.com"&lt;/span&gt;
  &lt;span class="nx"&gt;source_arn&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_s3_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# The real fix: the trigger only fires for incoming/*.csv.&lt;/span&gt;
&lt;span class="c1"&gt;# Output goes to processed/*.jsonl, which this filter never matches.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_s3_bucket_notification"&lt;/span&gt; &lt;span class="s2"&gt;"data"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_s3_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;

  &lt;span class="nx"&gt;lambda_function&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;lambda_function_arn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
    &lt;span class="nx"&gt;events&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"s3:ObjectCreated:*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;filter_prefix&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;local&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;in_prefix&lt;/span&gt;
    &lt;span class="nx"&gt;filter_suffix&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;".csv"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;depends_on&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;aws_lambda_permission&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Alarm 1: Lambda stopped a loop.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudwatch_metric_alarm"&lt;/span&gt; &lt;span class="s2"&gt;"loop_dropped"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;alarm_name&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"csv-to-jsonl-recursive-loop"&lt;/span&gt;
  &lt;span class="nx"&gt;namespace&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"AWS/Lambda"&lt;/span&gt;
  &lt;span class="nx"&gt;metric_name&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"RecursiveInvocationsDropped"&lt;/span&gt;
  &lt;span class="nx"&gt;dimensions&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FunctionName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;function_name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;statistic&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Sum"&lt;/span&gt;
  &lt;span class="nx"&gt;period&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;
  &lt;span class="nx"&gt;evaluation_periods&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="nx"&gt;threshold&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="nx"&gt;comparison_operator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"GreaterThanThreshold"&lt;/span&gt;
  &lt;span class="nx"&gt;treat_missing_data&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"notBreaching"&lt;/span&gt;
  &lt;span class="nx"&gt;alarm_actions&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;alarm_topic_arn&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Alarm 2: far more runs than normal, for loops detection can't see.&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudwatch_metric_alarm"&lt;/span&gt; &lt;span class="s2"&gt;"invocation_spike"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;alarm_name&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"csv-to-jsonl-invocation-spike"&lt;/span&gt;
  &lt;span class="nx"&gt;namespace&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"AWS/Lambda"&lt;/span&gt;
  &lt;span class="nx"&gt;metric_name&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Invocations"&lt;/span&gt;
  &lt;span class="nx"&gt;dimensions&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FunctionName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_lambda_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;function_name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;statistic&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Sum"&lt;/span&gt;
  &lt;span class="nx"&gt;period&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;
  &lt;span class="nx"&gt;evaluation_periods&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
  &lt;span class="nx"&gt;threshold&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="c1"&gt;# set from your normal upload rate&lt;/span&gt;
  &lt;span class="nx"&gt;comparison_operator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"GreaterThanThreshold"&lt;/span&gt;
  &lt;span class="nx"&gt;treat_missing_data&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"notBreaching"&lt;/span&gt;
  &lt;span class="nx"&gt;alarm_actions&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;alarm_topic_arn&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;S3 filters don't take wildcards. &lt;code&gt;filter_prefix = "incoming/"&lt;/code&gt; already means "everything under &lt;code&gt;incoming/&lt;/code&gt;".&lt;/li&gt;
&lt;li&gt;S3 also refuses two rules on the same event type with overlapping prefixes or suffixes. That stops a second rule from quietly covering &lt;code&gt;processed/&lt;/code&gt;, but it won't stop a single rule with no filter at all. That's why the IAM and code guards are there.&lt;/li&gt;
&lt;li&gt;The alarm threshold of 500 runs in 5 minutes is a placeholder. Set it from your real upload rate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Trade-offs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two buckets is still simpler.&lt;/strong&gt; One bucket plus prefixes means three things must agree: the filter, the IAM policy and the code. Two buckets removes the loop by design. Pick one bucket only when you have a reason, such as one lifecycle or one set of access rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can't keep the same key.&lt;/strong&gt; With prefixes, the output has a new key. If downstream tools need the processed file at the &lt;strong&gt;same&lt;/strong&gt; key, AWS's blog post on this topic covers patterns that use object metadata or a DynamoDB table. Each costs a second Lambda run per object.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reserved concurrency slows real bursts too.&lt;/strong&gt; A cap of 5 limits the damage from a loop. It also means a big honest upload waits in line. S3 calls Lambda asynchronously, so events queue and retry instead of failing at once, but they can still be delayed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Detection needs a modern SDK.&lt;/strong&gt; If you bundle an old boto3, loop detection won't see your calls. Check the version in your deployment package.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The spike alarm needs tuning.&lt;/strong&gt; Too low and it pages on busy days. Too high and a loop runs for a while first. Also add an AWS Budgets alert or AWS Cost Anomaly Detection for the account, as the Lambda docs suggest. The Reddit account had none.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to verify the fix
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Test the logic offline.&lt;/strong&gt; This test fakes boto3, so it needs no AWS account:&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;# test_handler.py - run with: python3 test_handler.py  (no AWS account needed)
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;

&lt;span class="c1"&gt;# Fake boto3 so the test runs offline. It records every put_object call.
&lt;/span&gt;&lt;span class="n"&gt;puts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FakeS3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Key&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Body&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SimpleNamespace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id,total&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;1,9.50&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;2,3.00&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;put_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kw&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;puts&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="n"&gt;kw&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;boto3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SimpleNamespace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FakeS3&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Records&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bucket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;demo&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;object&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;}}}]}&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;handler&lt;/span&gt;

&lt;span class="c1"&gt;# 1. A normal file is written under processed/, never under incoming/.
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;incoming/2026/orders.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;written&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;processed/2026/orders.jsonl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
&lt;span class="c1"&gt;# 2. URL-encoded key ("+" means space) is decoded before use.
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;incoming/q3+report.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;written&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;processed/q3 report.jsonl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
&lt;span class="c1"&gt;# 3. Our own output arriving as an event (bad trigger) is skipped: no new write.
&lt;/span&gt;&lt;span class="n"&gt;before&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;puts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;processed/2026/orders.jsonl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;written&lt;/span&gt;&lt;span class="sh"&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;assert&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;puts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;before&lt;/span&gt;
&lt;span class="c1"&gt;# 4. No write ever lands under the trigger prefix.
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;incoming/&lt;/span&gt;&lt;span class="sh"&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;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;puts&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;puts&lt;/span&gt;
&lt;span class="c1"&gt;# 5. Overlapping prefixes are refused before any write.
&lt;/span&gt;&lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OUT_PREFIX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;incoming/out/&lt;/span&gt;&lt;span class="sh"&gt;"&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;handler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;incoming/a.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;AssertionError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;overlap not caught&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;RuntimeError&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ok  overlap refused:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ok  writes:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;puts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5 checks passed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On our box all 5 checks pass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Check the Terraform.&lt;/strong&gt; &lt;code&gt;terraform fmt -check&lt;/code&gt;, &lt;code&gt;terraform validate&lt;/code&gt; and &lt;code&gt;terraform plan&lt;/code&gt; should pass. The plan should show 9 resources, with &lt;code&gt;filter_prefix = "incoming/"&lt;/code&gt;, &lt;code&gt;filter_suffix = ".csv"&lt;/code&gt;, &lt;code&gt;reserved_concurrent_executions = 5&lt;/code&gt; and &lt;code&gt;recursive_loop = "Terminate"&lt;/code&gt;. Ours passed on Terraform v1.9.8 with AWS provider v6.70.0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Read the live settings back.&lt;/strong&gt; After &lt;code&gt;apply&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3api get-bucket-notification-configuration &lt;span class="nt"&gt;--bucket&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BUCKET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="c"&gt;# expect one LambdaFunctionConfiguration with Prefix incoming/ and Suffix .csv&lt;/span&gt;

aws lambda get-function-recursion-config &lt;span class="nt"&gt;--function-name&lt;/span&gt; csv-to-jsonl
&lt;span class="c"&gt;# expect "RecursiveLoop": "Terminate"&lt;/span&gt;

aws lambda get-function-concurrency &lt;span class="nt"&gt;--function-name&lt;/span&gt; csv-to-jsonl
&lt;span class="c"&gt;# expect "ReservedConcurrentExecutions": 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Upload one file and count the runs.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'id,total\n1,9.50\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"q3 report.csv"&lt;/span&gt;
aws s3 &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="s2"&gt;"q3 report.csv"&lt;/span&gt; &lt;span class="s2"&gt;"s3://&lt;/span&gt;&lt;span class="nv"&gt;$BUCKET&lt;/span&gt;&lt;span class="s2"&gt;/incoming/q3 report.csv"&lt;/span&gt;
&lt;span class="nb"&gt;sleep &lt;/span&gt;60
aws s3 &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="s2"&gt;"s3://&lt;/span&gt;&lt;span class="nv"&gt;$BUCKET&lt;/span&gt;&lt;span class="s2"&gt;/processed/"&lt;/span&gt;
&lt;span class="c"&gt;# expect: exactly one new file, "q3 report.jsonl"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then check the &lt;code&gt;Invocations&lt;/code&gt; metric for the function in CloudWatch for those minutes. You want &lt;strong&gt;1&lt;/strong&gt;, not 2, and not a climbing line. Also check that &lt;code&gt;RecursiveInvocationsDropped&lt;/code&gt; stays at 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Prove the IAM layer.&lt;/strong&gt; Using the function's role, try to write under the trigger prefix. Lambda's console test, or a one-off script run under that role, both work. The call &lt;code&gt;put_object(Key="incoming/test.csv")&lt;/code&gt; should fail with &lt;code&gt;AccessDenied&lt;/code&gt;. If it succeeds, the policy is too wide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you ship
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Output goes to a second bucket, or to a prefix the trigger can't match&lt;/li&gt;
&lt;li&gt;[ ] The output prefix doesn't start with the input prefix&lt;/li&gt;
&lt;li&gt;[ ] The role can write only to the output prefix&lt;/li&gt;
&lt;li&gt;[ ] The code decodes keys with &lt;code&gt;unquote_plus&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Reserved concurrency is set while you test&lt;/li&gt;
&lt;li&gt;[ ] Recursive loop detection is &lt;code&gt;Terminate&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Alarms on &lt;code&gt;RecursiveInvocationsDropped&lt;/code&gt; and &lt;code&gt;Invocations&lt;/code&gt;, plus a budget alert&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you searched for CloudSkill Consulting LLC software engineering, that's us. We wrote this for teams that run S3 event pipelines and want the first bill to look normal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs checked (October 29, 2026)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html" rel="noopener noreferrer"&gt;Process Amazon S3 event notifications with Lambda&lt;/a&gt; (the same-bucket warning)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-recursion.html" rel="noopener noreferrer"&gt;Use Lambda recursive loop detection to prevent infinite loops&lt;/a&gt; (supported services and SDKs, the ~16-call limit, alerts, &lt;code&gt;RecursiveInvocationsDropped&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/lambda/latest/api/API_PutFunctionRecursionConfig.html" rel="noopener noreferrer"&gt;PutFunctionRecursionConfig&lt;/a&gt; (&lt;code&gt;Allow&lt;/code&gt; vs &lt;code&gt;Terminate&lt;/code&gt;, default &lt;code&gt;Terminate&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-how-to-filtering.html" rel="noopener noreferrer"&gt;Configuring event notifications using object key name filtering&lt;/a&gt; (no wildcards, no overlapping rules)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html" rel="noopener noreferrer"&gt;Event message structure&lt;/a&gt; (object keys are URL encoded)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/blogs/compute/avoiding-recursive-invocation-with-amazon-s3-and-aws-lambda/" rel="noopener noreferrer"&gt;AWS Compute Blog: Avoiding recursive invocation with Amazon S3 and AWS Lambda&lt;/a&gt; (two-bucket, prefix, metadata and DynamoDB patterns; reserved concurrency)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function_recursion_config" rel="noopener noreferrer"&gt;Terraform AWS provider: aws_lambda_function_recursion_config&lt;/a&gt; and &lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_notification" rel="noopener noreferrer"&gt;aws_s3_bucket_notification&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Spotted an AWS default or limit that changed since we wrote this? Drop a line to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt; so the post stays accurate.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;CloudSkill Consulting LLC helps teams with fixed-fee cloud projects, FinOps reviews and IT staffing. Learn more at &lt;a href="https://www.cloudskillconsulting.com" rel="noopener noreferrer"&gt;cloudskillconsulting.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
      <category>finops</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Refresh a React Route on S3 + CloudFront and Get AccessDenied? Fix It Without Hiding Your API 404s</title>
      <dc:creator>CloudSkill Consulting LLC</dc:creator>
      <pubDate>Mon, 26 Oct 2026 16:52:51 +0000</pubDate>
      <link>https://dev.to/cloudskillconsultingllc/refresh-a-react-route-on-s3-cloudfront-and-get-accessdenied-fix-it-without-hiding-your-api-404s-355m</link>
      <guid>https://dev.to/cloudskillconsultingllc/refresh-a-react-route-on-s3-cloudfront-and-get-accessdenied-fix-it-without-hiding-your-api-404s-355m</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;As of October 27, 2026, this post sums up the official pages linked here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Someone on Reddit had a React app built with create-react-app and react-router. They put the build in an S3 bucket and served it through CloudFront. Moving around inside the app was fine. But if they pasted a deeper link like &lt;code&gt;/some-path&lt;/code&gt; into a new tab, or pressed refresh on that page, they got an XML page that said &lt;code&gt;AccessDenied&lt;/code&gt;. They asked how to send every path to &lt;code&gt;index.html&lt;/code&gt; while still letting the app see the real path.&lt;/p&gt;

&lt;p&gt;Plenty of teams hit this with single-page apps (SPAs) on AWS. The quick answer most people get is "add a custom error page." That answer works, but it has a side effect that often shows up weeks later. This post explains the root cause, why the quick answer can hurt, and a narrower fix with tested code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause: two kinds of navigation
&lt;/h2&gt;

&lt;p&gt;A React app with &lt;code&gt;BrowserRouter&lt;/code&gt; handles routes &lt;strong&gt;in the browser&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You open &lt;code&gt;https://example.com/&lt;/code&gt;. CloudFront returns &lt;code&gt;index.html&lt;/code&gt;, and the JavaScript loads.&lt;/li&gt;
&lt;li&gt;You click a link to &lt;code&gt;/dashboard&lt;/code&gt;. The router changes the address bar with the History API and draws the new screen. &lt;strong&gt;No request goes to CloudFront for &lt;code&gt;/dashboard&lt;/code&gt;.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;You press refresh. Now the browser really does send &lt;code&gt;GET /dashboard&lt;/code&gt; to CloudFront.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CloudFront passes that request to the S3 origin, and S3 looks for an object with the key &lt;code&gt;dashboard&lt;/code&gt;. There isn't one. Your build only has &lt;code&gt;index.html&lt;/code&gt;, a few files under &lt;code&gt;assets/&lt;/code&gt; or &lt;code&gt;static/&lt;/code&gt;, and some icons.&lt;/p&gt;

&lt;p&gt;Why &lt;code&gt;403&lt;/code&gt; and not &lt;code&gt;404&lt;/code&gt;? With origin access control (OAC), CloudFront signs requests to a private bucket. AWS notes that if the bucket policy for OAC doesn't include &lt;code&gt;s3:ListBucket&lt;/code&gt;, S3 answers a missing key with &lt;code&gt;403&lt;/code&gt; instead of &lt;code&gt;404&lt;/code&gt;. That is the &lt;code&gt;AccessDenied&lt;/code&gt; page from the thread. It isn't a permissions bug; it's a missing file.&lt;/p&gt;

&lt;p&gt;So the fix must do one thing: when the browser asks for an app route, CloudFront should serve &lt;code&gt;index.html&lt;/code&gt;, and the app should see the original URL. (The address bar keeps the original URL, so react-router still sees &lt;code&gt;/dashboard&lt;/code&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The common fix, and its catch
&lt;/h2&gt;

&lt;p&gt;The usual advice, which also appears in AWS re:Post, is to add two custom error responses on the distribution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;403 → &lt;code&gt;/index.html&lt;/code&gt;, response code 200&lt;/li&gt;
&lt;li&gt;404 → &lt;code&gt;/index.html&lt;/code&gt;, response code 200&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It works for routes. Here is the catch: custom error responses are set on the &lt;strong&gt;distribution&lt;/strong&gt;, not on a cache behavior. In the CloudFront API, &lt;code&gt;CustomErrorResponses&lt;/code&gt; sits in &lt;code&gt;DistributionConfig&lt;/code&gt;, and there's no such field in &lt;code&gt;CacheBehavior&lt;/code&gt;. So the rule applies to every path the distribution serves.&lt;/p&gt;

&lt;p&gt;That leads to three problems people hit later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API errors turn into HTML.&lt;/strong&gt; If &lt;code&gt;/api/*&lt;/code&gt; goes to an API origin through the same distribution, an API &lt;code&gt;404&lt;/code&gt; or &lt;code&gt;403&lt;/code&gt; comes back as &lt;code&gt;200&lt;/code&gt; with your &lt;code&gt;index.html&lt;/code&gt;. The frontend's &lt;code&gt;fetch&lt;/code&gt; succeeds, &lt;code&gt;response.json()&lt;/code&gt; fails, and you see &lt;code&gt;Unexpected token '&amp;lt;'&lt;/code&gt; in the console instead of a clear 404.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing assets look like success.&lt;/strong&gt; After a deploy, an old tab may ask for &lt;code&gt;/assets/main.0a1b2c.js&lt;/code&gt;, which no longer exists. Instead of a 404, it gets &lt;code&gt;index.html&lt;/code&gt; with status &lt;code&gt;200&lt;/code&gt;. The browser then refuses to run HTML as a script, and the error points you in the wrong direction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real access problems disappear.&lt;/strong&gt; If a bucket policy breaks, every request still returns &lt;code&gt;200&lt;/code&gt;. Your error-rate graph stays flat while users see a blank page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this means the error-page fix is wrong. For a site with only static files and no API behind the same distribution, it's simple and fine. Once the distribution serves more than the SPA, a narrower fix is safer.&lt;/p&gt;

&lt;h2&gt;
  
  
  A narrower fix: rewrite only app routes
&lt;/h2&gt;

&lt;p&gt;Instead of reacting to errors, decide &lt;strong&gt;before&lt;/strong&gt; the request reaches S3. A CloudFront Function on the &lt;strong&gt;viewer request&lt;/strong&gt; event can change &lt;code&gt;request.uri&lt;/code&gt;. You attach it only to the cache behavior that serves the static site, so the API behavior never runs it.&lt;/p&gt;

&lt;p&gt;The rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paths under &lt;code&gt;/api/&lt;/code&gt; (and &lt;code&gt;/.well-known/&lt;/code&gt;) pass through untouched.&lt;/li&gt;
&lt;li&gt;If the final path segment has a dot (&lt;code&gt;main.0a1b2c.js&lt;/code&gt;, &lt;code&gt;logo.svg&lt;/code&gt;, &lt;code&gt;favicon.ico&lt;/code&gt;), treat it as a file and pass it through. A missing file still gets a real error.&lt;/li&gt;
&lt;li&gt;Everything else is an app route. Rewrite it to &lt;code&gt;/index.html&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// CloudFront Function, runtime cloudfront-js-2.0, event: viewer-request.&lt;/span&gt;
&lt;span class="c1"&gt;// Sends SPA routes to /index.html. Leaves real files and API calls alone.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PASS_THROUGH_PREFIXES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.well-known/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// 1. API and other non-SPA paths go to their origin untouched.&lt;/span&gt;
  &lt;span class="c1"&gt;//    (Plain index loop: for...of is not on the runtime's supported list.)&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;PASS_THROUGH_PREFIXES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PASS_THROUGH_PREFIXES&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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="nx"&gt;request&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;// 2. Anything whose last segment has a dot is a file (main.4f1c.js, logo.svg).&lt;/span&gt;
  &lt;span class="c1"&gt;//    Keep it, so a missing file still returns a real error.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lastSegment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lastIndexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lastSegment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// 3. Everything else (/, /dashboard, /orders/42/) is a client-side route.&lt;/span&gt;
  &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;request&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;A few notes on the code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It uses only features the CloudFront Functions JavaScript runtime 2.0 lists as supported: &lt;code&gt;const&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;String.prototype.startsWith()&lt;/code&gt; and &lt;code&gt;String.prototype.includes()&lt;/code&gt;. The statement list in that runtime doesn't include &lt;code&gt;for...of&lt;/code&gt;, so the loop uses an index.&lt;/li&gt;
&lt;li&gt;It changes only &lt;code&gt;request.uri&lt;/code&gt;. The browser's address bar still shows &lt;code&gt;/dashboard&lt;/code&gt;, so the router renders the right screen.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;/api/&lt;/code&gt; check is a safety net. The real protection is that the API has its own cache behavior with no function attached.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wire it up with Terraform
&lt;/h2&gt;

&lt;p&gt;This config creates the function, attaches it to the default (site) behavior and gives &lt;code&gt;/api/*&lt;/code&gt; its own behavior. Note what's missing: there are no &lt;code&gt;custom_error_response&lt;/code&gt; blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;required_providers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;aws&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hashicorp/aws"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~&amp;gt; 6.0"&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="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"site_bucket_regional_domain"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Regional domain of the private S3 bucket, e.g. my-site.s3.us-east-1.amazonaws.com"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"api_domain"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Domain of the API origin, e.g. api.example.com"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudfront_function"&lt;/span&gt; &lt;span class="s2"&gt;"spa_rewrite"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"spa-rewrite"&lt;/span&gt;
  &lt;span class="nx"&gt;runtime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"cloudfront-js-2.0"&lt;/span&gt;
  &lt;span class="nx"&gt;comment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Send client-side routes to /index.html"&lt;/span&gt;
  &lt;span class="nx"&gt;publish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="nx"&gt;code&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"${path.module}/spa-rewrite.js"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudfront_origin_access_control"&lt;/span&gt; &lt;span class="s2"&gt;"site"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;                              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"site-oac"&lt;/span&gt;
  &lt;span class="nx"&gt;origin_access_control_origin_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"s3"&lt;/span&gt;
  &lt;span class="nx"&gt;signing_behavior&lt;/span&gt;                  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"always"&lt;/span&gt;
  &lt;span class="nx"&gt;signing_protocol&lt;/span&gt;                  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"sigv4"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_cloudfront_distribution"&lt;/span&gt; &lt;span class="s2"&gt;"site"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;enabled&lt;/span&gt;             &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="nx"&gt;default_root_object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"index.html"&lt;/span&gt;

  &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;origin_id&lt;/span&gt;                &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"site"&lt;/span&gt;
    &lt;span class="nx"&gt;domain_name&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;site_bucket_regional_domain&lt;/span&gt;
    &lt;span class="nx"&gt;origin_access_control_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_cloudfront_origin_access_control&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;site&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;origin_id&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"api"&lt;/span&gt;
    &lt;span class="nx"&gt;domain_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api_domain&lt;/span&gt;
    &lt;span class="nx"&gt;custom_origin_config&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;http_port&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
      &lt;span class="nx"&gt;https_port&lt;/span&gt;             &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
      &lt;span class="nx"&gt;origin_protocol_policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https-only"&lt;/span&gt;
      &lt;span class="nx"&gt;origin_ssl_protocols&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"TLSv1.2"&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;# Static site: the rewrite runs here only.&lt;/span&gt;
  &lt;span class="nx"&gt;default_cache_behavior&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;target_origin_id&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"site"&lt;/span&gt;
    &lt;span class="nx"&gt;viewer_protocol_policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"redirect-to-https"&lt;/span&gt;
    &lt;span class="nx"&gt;allowed_methods&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"HEAD"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;cached_methods&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"HEAD"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;cache_policy_id&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"658327ea-f89d-4fab-a63d-7e88639e58f6"&lt;/span&gt; &lt;span class="c1"&gt;# Managed-CachingOptimized&lt;/span&gt;

    &lt;span class="nx"&gt;function_association&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;event_type&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"viewer-request"&lt;/span&gt;
      &lt;span class="nx"&gt;function_arn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_cloudfront_function&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;spa_rewrite&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;# API: no rewrite, so a real 404 from the API stays a 404.&lt;/span&gt;
  &lt;span class="nx"&gt;ordered_cache_behavior&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;path_pattern&lt;/span&gt;             &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/api/*"&lt;/span&gt;
    &lt;span class="nx"&gt;target_origin_id&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"api"&lt;/span&gt;
    &lt;span class="nx"&gt;viewer_protocol_policy&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https-only"&lt;/span&gt;
    &lt;span class="nx"&gt;allowed_methods&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"HEAD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"OPTIONS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PATCH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"DELETE"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;cached_methods&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"HEAD"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;cache_policy_id&lt;/span&gt;          &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"4135ea2d-6df8-44a3-9df3-4b5a84be39ad"&lt;/span&gt; &lt;span class="c1"&gt;# Managed-CachingDisabled&lt;/span&gt;
    &lt;span class="nx"&gt;origin_request_policy_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"b689b0a8-53d0-40ab-baf2-68738e2966ac"&lt;/span&gt; &lt;span class="c1"&gt;# Managed-AllViewerExceptHostHeader&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;# Note: no custom_error_response blocks. Those apply to the whole distribution.&lt;/span&gt;

  &lt;span class="nx"&gt;restrictions&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;geo_restriction&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;restriction_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"none"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;viewer_certificate&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;cloudfront_default_certificate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&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;The three policy IDs are the AWS managed policies named in the comments. Each ID was matched against the AWS pages for managed cache policies and managed origin request policies. The S3 bucket policy that lets this OAC read the bucket is left out to keep the example short; the OAC page in the docs list below shows it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs
&lt;/h2&gt;

&lt;p&gt;No fix is free. Here is what this one costs and where it can bite:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dots in route names.&lt;/strong&gt; A route like &lt;code&gt;/users/jane.doe&lt;/code&gt; looks like a file to this rule, so it won't be rewritten. Either keep dots out of route segments, or switch rule 2 to a short list of real file extensions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unknown routes return 200.&lt;/strong&gt; &lt;code&gt;/no-such-page&lt;/code&gt; now gets &lt;code&gt;index.html&lt;/code&gt; with status &lt;code&gt;200&lt;/code&gt;. Your app must show its own "not found" screen. Search engines may treat that as a soft 404, so if SEO matters, render a not-found page and consider prerendering key routes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A function runs on every site request.&lt;/strong&gt; On pay-as-you-go pricing, CloudFront Functions are billed per invocation. Flat-rate plans count usage differently. Check the &lt;a href="https://aws.amazon.com/cloudfront/pricing/" rel="noopener noreferrer"&gt;CloudFront pricing page&lt;/a&gt; against your traffic before you assume it's free.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two places to change.&lt;/strong&gt; New top-level paths that should skip the rewrite (say &lt;code&gt;/auth/&lt;/code&gt;) need a new cache behavior, the prefix list in the function, or both.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why not the S3 website endpoint and its error document?&lt;/strong&gt; The OAC docs say a bucket set up as a website endpoint must be a custom origin, so you can't use OAC with it. You'd give up a private bucket to get the routing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your distribution only serves the SPA, the two custom error responses are still a fair choice. Just know they act on every path.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to verify the fix
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Test the logic locally.&lt;/strong&gt; CloudFront Functions don't use &lt;code&gt;module.exports&lt;/code&gt;, so load the file the way a plain script runs and call &lt;code&gt;handler&lt;/code&gt; directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// test-spa-rewrite.mjs  (run: node test-spa-rewrite.mjs)&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;readFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;vm&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:vm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;assert&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:assert/strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="nx"&gt;vm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;runInNewContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&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;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./spa-rewrite.js&lt;/span&gt;&lt;span class="dl"&gt;'&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="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cases&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/orders/42/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/settings/profile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/assets/main.4f1c9a.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/assets/main.4f1c9a.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/assets/old.0000.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/assets/old.0000.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/favicon.ico&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/favicon.ico&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/orders/42&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/orders/42&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.well-known/security.txt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.well-known/security.txt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/v1.2/release-notes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/index.html&lt;/span&gt;&lt;span class="dl"&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="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;cases&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="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;eventType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;viewer-request&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
                  &lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;querystring&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="na"&gt;cookies&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expected&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="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; -&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, expected &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;expected&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`ok  &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;padEnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt; -&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uri&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="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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="nx"&gt;cases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; cases passed`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Node 20 all 11 cases pass. The last case matters: &lt;code&gt;/v1.2/release-notes&lt;/code&gt; has a dot in a folder name, but the rule only looks at the last segment, so it's still treated as a route. Node is more relaxed than the CloudFront runtime, so a local pass checks the logic, not runtime support. That's what the next step is for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Check the Terraform.&lt;/strong&gt; &lt;code&gt;terraform fmt -check&lt;/code&gt;, &lt;code&gt;terraform validate&lt;/code&gt; and &lt;code&gt;terraform plan&lt;/code&gt; should show three resources and one &lt;code&gt;function_association&lt;/code&gt; with &lt;code&gt;event_type = "viewer-request"&lt;/code&gt;. This config passed all three with Terraform v1.9.8 and the AWS provider v6.70.0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Test in CloudFront before it goes live.&lt;/strong&gt; Save one request as &lt;code&gt;event.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="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"eventType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"viewer-request"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"viewer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"ip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"198.51.100.10"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"uri"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/dashboard"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"querystring"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"cookies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run it against the function's development stage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;ETAG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;aws cloudfront describe-function &lt;span class="nt"&gt;--name&lt;/span&gt; spa-rewrite &lt;span class="nt"&gt;--query&lt;/span&gt; ETag &lt;span class="nt"&gt;--output&lt;/span&gt; text&lt;span class="si"&gt;)&lt;/span&gt;
aws cloudfront test-function &lt;span class="nt"&gt;--name&lt;/span&gt; spa-rewrite &lt;span class="nt"&gt;--if-match&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$ETAG&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--stage&lt;/span&gt; DEVELOPMENT &lt;span class="nt"&gt;--event-object&lt;/span&gt; fileb://event.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s1"&gt;'TestResult.FunctionOutput'&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should show &lt;code&gt;"uri":"/index.html"&lt;/code&gt;. Change the URI to &lt;code&gt;/assets/main.0a1b2c.js&lt;/code&gt; and &lt;code&gt;/api/x&lt;/code&gt; and check that they come back unchanged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Check the live distribution.&lt;/strong&gt; After deployment finishes, with your real domain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;--silent&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; /dev/null &lt;span class="nt"&gt;--write-out&lt;/span&gt; &lt;span class="s1"&gt;'%{http_code} %{content_type}\n'&lt;/span&gt; https://example.com/dashboard
&lt;span class="c"&gt;# expect: 200 text/html&lt;/span&gt;

curl &lt;span class="nt"&gt;--silent&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; /dev/null &lt;span class="nt"&gt;--write-out&lt;/span&gt; &lt;span class="s1"&gt;'%{http_code}\n'&lt;/span&gt; https://example.com/assets/does-not-exist.js
&lt;span class="c"&gt;# expect: 403 or 404, not 200&lt;/span&gt;

curl &lt;span class="nt"&gt;--silent&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; /dev/null &lt;span class="nt"&gt;--write-out&lt;/span&gt; &lt;span class="s1"&gt;'%{http_code} %{content_type}\n'&lt;/span&gt; https://example.com/api/does-not-exist
&lt;span class="c"&gt;# expect: whatever your API returns, e.g. 404 application/json, not 200 text/html&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the third line comes back &lt;code&gt;200 text/html&lt;/code&gt;, a custom error response is still set on the distribution. Remove it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you ship
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] No &lt;code&gt;CustomErrorResponses&lt;/code&gt; for 403/404 on a distribution that also serves an API&lt;/li&gt;
&lt;li&gt;[ ] The function is on the site behavior only, on &lt;code&gt;viewer-request&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;/api/*&lt;/code&gt; has its own behavior with no function&lt;/li&gt;
&lt;li&gt;[ ] Route segments don't contain dots, or rule 2 uses an extension list&lt;/li&gt;
&lt;li&gt;[ ] The app shows its own not-found screen&lt;/li&gt;
&lt;li&gt;[ ] Missing assets return 403 or 404, never 200&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you got here by searching for CloudSkill Consulting LLC software engineering, that's us. We wrote this fix for teams that serve a frontend and an API from one CloudFront distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs checked (October 26, 2026)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://repost.aws/knowledge-center/cloudfront-single-page-application" rel="noopener noreferrer"&gt;AWS re:Post: Optimize CloudFront to serve single-page applications&lt;/a&gt; (403 vs 404 without &lt;code&gt;s3:ListBucket&lt;/code&gt;, the error-page approach, caching advice)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_DistributionConfig.html" rel="noopener noreferrer"&gt;CloudFront API: DistributionConfig&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CustomErrorResponse.html" rel="noopener noreferrer"&gt;CustomErrorResponse&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GeneratingCustomErrorResponses.html" rel="noopener noreferrer"&gt;Generate custom error responses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html" rel="noopener noreferrer"&gt;Customize at the edge with CloudFront Functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-javascript-runtime-20.html" rel="noopener noreferrer"&gt;JavaScript runtime 2.0 features for CloudFront Functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html" rel="noopener noreferrer"&gt;Restrict access to an Amazon S3 origin (OAC)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html" rel="noopener noreferrer"&gt;Use managed cache policies&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-origin-request-policies.html" rel="noopener noreferrer"&gt;managed origin request policies&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/cloudfront/test-function.html" rel="noopener noreferrer"&gt;AWS CLI: cloudfront test-function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_function" rel="noopener noreferrer"&gt;Terraform AWS provider: aws_cloudfront_function&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Spotted an AWS default or limit that changed since we wrote this? Drop a line to &lt;a href="mailto:info@cloudskillconsulting.com"&gt;info@cloudskillconsulting.com&lt;/a&gt; so the post stays accurate.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudfront</category>
      <category>react</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
