<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Irosh Mathews on Medium]]></title>
        <description><![CDATA[Stories by Irosh Mathews on Medium]]></description>
        <link>https://medium.com/@iromathews4?source=rss-bc8eaf2deaec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*alLk02otfYzOr3E7kwO5Uw.jpeg</url>
            <title>Stories by Irosh Mathews on Medium</title>
            <link>https://medium.com/@iromathews4?source=rss-bc8eaf2deaec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 13:30:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iromathews4/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AWS S3 Fundamentals (Part 5): Integration, Performance, & Static Websites with Hands-On CloudShell]]></title>
            <link>https://medium.com/@iromathews4/aws-s3-fundamentals-part-5-integration-performance-static-websites-with-hands-on-cloudshell-b1f2d8807662?source=rss-bc8eaf2deaec------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1f2d8807662</guid>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <category><![CDATA[aws-cloudshell]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Irosh Mathews]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 06:32:20 GMT</pubDate>
            <atom:updated>2026-03-11T09:56:49.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szNacHucWTG2OiduS33GMw.png" /></figure><p>Over the last four modules, we have transformed our S3 buckets from empty, vulnerable folders into highly secure, WORM-compliant, and cost-optimised fortresses.</p><p>But a fortress isn’t very useful if it’s slow to access, isolated from the rest of your architecture, or hidden from the world when you actually <em>want</em> people to see it. In this final installment, we are going to look at <strong>Integration &amp; Advanced Performance</strong>, and we will cap it all off by hosting a live, public website entirely on S3!</p><p>As always, we are writing maintainable, consistent, simplified code, reducing code duplication, and following best code practices in our trusty s3-toolkit.sh.</p><p><strong>Series Index:</strong></p><ul><li><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-1-e8641269f52c"><strong>Part 1 — The Primer &amp; Core Mechanics</strong> — Buckets, Objects, Keys, Global vs. Regional, Flat Structure</a></li><li><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-2-securing-your-buckets-with-hands-on-cloudshell-f3c84a3c3d85"><strong>Part 2 — Securing Your S3 Buckets</strong> — Block Public Access, Bucket Policies vs IAM, Encryption (SSE/CSE), Pre-signed URLs</a></li><li><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-3-data-protection-compliance-with-hands-on-cloudshell-5dc09dcc0347"><strong>Part 3 — Data Protection &amp; Compliance</strong> — Object Versioning, Delete Markers, Replication (SRR/CRR), Object &amp; Vault Locks, MFA Delete</a></li><li><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d"><strong>Part 4 — Cost Optimization &amp; Storage Classes</strong> — Standard =&gt; Glacier Tiers, Intelligent Tiering, Lifecycle Configurations</a></li><li><strong>Part 5 — Integration &amp; Advanced Performance</strong> — Static Website Hosting, Multi-part Uploads, Transfer Acceleration, Event Notifications.</li></ul><p>Let’s dive into part 5!</p><h3>1. Conquering Massive Files &amp; Global Latency</h3><p>When dealing with massive files or global users, basic uploads just won’t cut it.</p><p><strong>Multipart Uploads:</strong> If you try to upload a 50GB file <strong>(able to upload up to 5TB) </strong>as a single stream and your network blips at 49GB, the entire upload fails. Multipart Upload breaks large files into smaller parts <strong>(up to 10,000 parts)</strong> that upload in parallel. If one part fails, AWS only retries that specific part. S3 automatically reassembles them at the end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfcLgpxeXh-H8mPYjROoXw.png" /></figure><blockquote><strong><em>Exam Tip:</em></strong><em> AWS </em>recommends<em> Multipart Uploads for files over 100MB and </em>requires<em> it for files over 5GB.</em></blockquote><p><strong>S3 Transfer Acceleration:</strong> If your bucket is in Virginia but your user is in Sydney, data has to travel over the unpredictable public internet. Transfer Acceleration routes user uploads to their nearest Amazon CloudFront <strong>Edge Location</strong>. From there, the data travels over AWS’s private, high-speed fibre-optic network straight to your bucket. The edge locations are part of the AWS Global Network, which is a high-speed <em>(can speed up content by 50% –500%)</em>, secure, and reliable network for AWS services</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ht9q89nF9V_kNw1T66YhWg.png" /></figure><p>To use Transfer Acceleration, you simply enable it for the target S3 bucket, and then access the bucket using a special endpoint URL that includes the keyword “accelerate”.</p><p>Transfer Acceleration may incur additional data transfer costs depending on the volume of data, geographic location and usage.</p><h3>2. Event Notifications: The Nervous System (S3 to SQS)</h3><p>S3 isn’t just a passive storage drive; it is event-driven. You can configure S3 to act as a trigger. For example, the moment a new file is uploaded (s3:ObjectCreated), S3 can send a notification.</p><p>To prevent our backend servers from crashing if 1,000 files are uploaded at the exact same second, we use <strong>Amazon SQS (Simple Queue Service)</strong>. SQS acts as a “shock absorber.” S3 drops 1,000 event tickets into the SQS queue, and your servers safely pull them out one by one at their own pace.</p><h3>3. The Grand Finale: Static Website Hosting</h3><p>Did you know S3 can act as a highly scalable web server? You can host static websites (HTML, CSS, client-side JavaScript) directly out of a bucket.</p><p>There is a catch, though: <strong>To do this, we must intentionally break the security rules we established in Part 2.</strong> We have to turn off “Block Public Access” and attach a public-read bucket policy so the internet can see our site.</p><h3>Hands-On: Expanding the S3 Automation Toolkit (Part 5)</h3><p>Let’s add these final superpowers to our toolkit.</p><h3>Step 1: Open the Toolkit in Nano</h3><p>Make sure you are in your home directory, then open your toolkit one last time.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Ensure%252520you%252520are%252520in%252520your%252520persistent%252520home%252520directory%25250Acd%252520%257E%25250A%25250A%252523%252520Open%252520the%252520existing%252520toolkit%252520in%252520Nano%25250Anano%252520s3-toolkit.sh&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Ensure%25252520you%25252520are%25252520in%25252520your%25252520persistent%25252520home%25252520directory%2525250Acd%25252520%25257E%2525250A%2525250A%25252523%25252520Open%25252520the%25252520existing%25252520toolkit%25252520in%25252520Nano%2525250Anano%25252520s3-toolkit.sh&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href">https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href</a></iframe><h3>Step 2: Append the Final Functions</h3><p>Scroll to the very bottom. Copy and paste this pure Bash code. This handles our Multipart threshold, Transfer Acceleration, SQS Integration, and the Static Website configuration!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v37K4O2JSzLNGUr4LgD0QA.png" /></figure><p>source code <a href="https://gist.github.com/Mathews-axisTech/5e523c084921ffad4a8c0683ec2c23b9">here</a></p><h3>Step 4: Execute the Final Lab!</h3><p>Let’s test our event triggers and launch a live website to the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUhs0w4tCw1tTI70nCa1tg.png" /></figure><p>source code <a href="https://gist.github.com/Mathews-axisTech/9d192d0c3d51256392936d0469bb56c3">here</a></p><h3>Series Conclusion</h3><p>Congratulations! Over these five parts, you have built an incredibly powerful, reusable s3-toolkit.sh script. You didn&#39;t just learn <em>what</em> S3 does; you learned <em>how</em> to orchestrate it like a Senior Cloud Engineer using Infrastructure as Code principles.</p><p>You can now create fortresses, automate your AWS billing tiers, hook S3 up to event-driven serverless architectures, and host websites — all without leaving the command line.</p><p><strong>Thank you for following along with this complete AWS S3 Mastery series. Let me know in the comments which AWS service we should tackle next!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1f2d8807662" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3 Fundamentals (Part 4): Cost Optimization & Storage Classes with Hands-On CloudShell]]></title>
            <link>https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d?source=rss-bc8eaf2deaec------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff7e8f19fd0d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <category><![CDATA[aws-cloudshell]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Irosh Mathews]]></dc:creator>
            <pubDate>Mon, 09 Mar 2026 03:14:53 GMT</pubDate>
            <atom:updated>2026-03-11T09:56:50.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OB0zmU5OC0xEbBKS96KFTQ.png" /></figure><p>Welcome back! In Part 3, we built a fortress. We enabled Versioning to prevent accidental overwrites, deployed Object Lock for strict WORM compliance, and set up Replication for disaster recovery.</p><p>But there is a catch: <strong>Protecting data means storing more of it.</strong> If you keep every single version of every file forever in S3’s default tier, your AWS bill will skyrocket.</p><p><strong>Series Index:</strong></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-1-e8641269f52c"><strong>Part 1 — The Primer &amp; Core Mechanics</strong> — Buckets, Objects, Keys, Global vs. Regional, Flat Structure</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-2-securing-your-buckets-with-hands-on-cloudshell-f3c84a3c3d85"><strong>Part 2 — Securing Your S3 Buckets</strong> — Block Public Access, Bucket Policies vs IAM, Encryption (SSE/CSE), Pre-signed URLs</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-3-data-protection-compliance-with-hands-on-cloudshell-5dc09dcc0347"><strong>Part 3 — Data Protection &amp; Compliance</strong> — Object Versioning, Delete Markers, Replication (SRR/CRR), Object &amp; Vault Locks, MFA Delete</a></p><p><strong>Part 4 — Cost Optimization &amp; Storage Classes</strong> — Standard =&gt; Glacier Tiers, Intelligent Tiering, Lifecycle Configurations</p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-5-integration-performance-static-websites-with-hands-on-cloudshell-b1f2d8807662"><strong>Part 5 — Integration &amp; Advanced Performance</strong> — Static Website Hosting, Multi-part Uploads, Transfer Acceleration, Event Notifications</a></p><p>Let’s dive into Part 4!</p><h3>1. S3 Storage Classes: Paying Only for What You Need</h3><p>By default, every file you upload is stored in <strong>S3 Standard</strong>. It is highly available, stores data across at least 3 Availability Zones (AZs), and boasts 99.999999999% (“11 nines”) durability. Moving data <em>into</em> S3 is free, but storing it indefinitely in the Standard tier gets expensive.</p><p>AWS offers different storage classes to match your access patterns. However, watch out for “gotchas” like minimum storage durations — even if you delete or move a file early, AWS will still charge you for the minimum duration!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVlBcqYQagK-xy-zPin7OQ.png" /></figure><ul><li><strong>S3 Standard:</strong> Best for frequently accessed data. High storage cost, zero retrieval cost.</li><li><strong>S3 Intelligent-Tiering:</strong> The automated option. It moves data to the most cost-effective tier as access patterns change. Data moves to Infrequent Access after 30 days, and Archive Instant Access after 90 days. There are no retrieval fees, but AWS charges a small monitoring fee per 1,000 objects. (Note: Objects smaller than 128 KB stay in Frequent Access ).</li><li><strong>S3 Standard-Infrequent Access (Standard-IA):</strong> For data accessed infrequently. It has a 30-day minimum duration and a 128 KB minimum object size charge.</li><li><strong>S3 One Zone-IA:</strong> Stores data in a single AZ (Availability Zone), making it cheaper but less reliable. Best used for replaceable data that is accessed infrequently.</li><li><strong>S3 Glacier Instant Retrieval:</strong> For archive data accessed once a quarter. It requires a 90-day minimum storage duration and a 128 KB minimum object charge.</li><li><strong>S3 Glacier Flexible Retrieval:</strong> For archive data accessed once per year. It has a 90-day minimum duration and a smaller minimum object size of 40 KB. Retrievals are not instant: you can choose Expedited (1–5 min), Standard (3–5 hours), or Bulk (5–12 hours).</li><li><strong>S3 Glacier Deep Archive:</strong> The absolute cheapest storage. Best for archive data that is almost never needed. It has a strict 180-day minimum duration and 40 KB minimum object size. Retrieving data takes 12 hours (Standard) or 48 hours (Bulk).</li></ul><h3>2. Lifecycle Policies: The Automated Janitor</h3><p>You don’t want to manually click around the console, moving files to Glacier. A <strong>Lifecycle Policy</strong> is a configuration you apply to a bucket to automate these transitions when you already know your data’s usage patterns.</p><p>There are three critical rules to remember about Lifecycle Policies:</p><ol><li><strong>Transition Actions:</strong> You can move objects down to cheaper storage (e.g., Standard to Glacier), but you <strong>cannot</strong> use a lifecycle rule to automatically move data “up” to a more expensive tier (e.g., Glacier to Standard).</li><li><strong>Expiration Actions:</strong> You can configure S3 to permanently delete files after a set period.</li><li><strong>Transition Costs:</strong> While storing data in Glacier is cheaper, the actual action of <em>moving</em> objects through classes incurs a per-object transition fee. If you transition millions of tiny files, the transition fee might cost more than the storage savings!</li></ol><h3>Hands-On: Expanding the S3 Automation Toolkit (Part 4)</h3><p>Let’s put these cost optimizations into code. We will write a function that dynamically generates and applies a cascading Lifecycle Policy to any bucket, automatically moving data through ONEZONE_IA, GLACIER_IR, GLACIER, and finally DEEP_ARCHIVE before expiring it.</p><h3>Step 1: Open the Toolkit in Nano</h3><p>First, ensure you are in your home directory, then open your existing toolkit script using the Nano text editor.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Ensure%252520you%252520are%252520in%252520your%252520persistent%252520home%252520directory%25250Acd%252520%257E%25250A%25250A%252523%252520Open%252520the%252520existing%252520toolkit%252520in%252520Nano%25250Anano%252520s3-toolkit.sh&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Ensure%25252520you%25252520are%25252520in%25252520your%25252520persistent%25252520home%25252520directory%2525250Acd%25252520%25257E%2525250A%2525250A%25252523%25252520Open%25252520the%25252520existing%25252520toolkit%25252520in%25252520Nano%2525250Anano%25252520s3-toolkit.sh&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href">https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href</a></iframe><h3>Step 2: Append the Advanced Cost Optimization Function</h3><p>Scroll to the very bottom of the file. Copy and paste this pure Bash code. Notice how our JSON transitions perfectly match the minimum storage durations we discussed earlier so we don’t get hit with early deletion penalties!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_6zD5DhSwZOS2dCltA1qnA.png" /></figure><p>source code <a href="https://gist.github.com/Mathews-axisTech/4bd53d8bbdef3457329b6cded787022a">here</a></p><h3>Step 3: “Source” the Updated Toolkit</h3><p>Run source s3-toolkit.sh command to load the newly updated functions into the current session.</p><h3>Step 4: Execute the Cost Optimization Lab</h3><p>Let’s test our new advanced lifecycle function. We will also perform a direct upload to the <strong>Glacier Instant Retrieval</strong> tier, proving that you don’t always have to wait for a lifecycle rule if you already know the data’s access pattern!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-7H4W9PVTKJ3hd824Daew.png" /></figure><p>source code <a href="https://gist.github.com/Mathews-axisTech/5d3777877ae8cb5a6e16cae30bdef379">here</a></p><p>Your s3-toolkit.sh script is now saving you money while you sleep. Next, let&#39;s focus on speed and automation. Continue to the final chapter, <strong>[</strong><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-5-integration-performance-static-websites-with-hands-on-cloudshell-b1f2d8807662"><strong>Part 5: Integration &amp; Advanced Performance]</strong></a>, to master Multipart Uploads and S3 Event Notifications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff7e8f19fd0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3 Fundamentals (Part 3): Data Protection & Compliance with Hands-On CloudShell]]></title>
            <link>https://medium.com/@iromathews4/aws-s3-fundamentals-part-3-data-protection-compliance-with-hands-on-cloudshell-5dc09dcc0347?source=rss-bc8eaf2deaec------2</link>
            <guid isPermaLink="false">https://medium.com/p/5dc09dcc0347</guid>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[aws-cloudshell]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Irosh Mathews]]></dc:creator>
            <pubDate>Sat, 07 Mar 2026 06:34:41 GMT</pubDate>
            <atom:updated>2026-03-11T09:48:31.658Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWAPb0Zrr69_jgY9jsNoaw.png" /></figure><p>Welcome back! In Part 2, we successfully locked down our S3 buckets against unauthorized access. But what happens if an authorized user accidentally deletes a critical file or overwrites an important document😱? Security keeps the bad guys out, but <strong>Data Protection</strong> saves us from our own mistakes.</p><p>In this module, we will explore how AWS S3 protects your data from accidental deletion, physical disasters, and even malicious compliance breaches.</p><p>As always, we are completely skipping the AWS Management Console. We will continue to build our s3-toolkit.sh in CloudShell, writing maintainable consistent simplified code reducing code duplication and following best code practices!</p><p><strong>Series Index:</strong></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-1-e8641269f52c"><strong>Part 1 — The Primer &amp; Core Mechanics</strong> — Buckets, Objects, Keys, Global vs. Regional, Flat Structure</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-2-securing-your-buckets-with-hands-on-cloudshell-f3c84a3c3d85"><strong>Part 2 — Securing Your S3 Buckets</strong> — Block Public Access, Bucket Policies vs IAM, Encryption (SSE/CSE), Pre-signed URLs</a></p><p><strong>Part 3 — Data Protection &amp; Compliance</strong> — Object Versioning, Delete Markers, Replication (SRR/CRR), Object &amp; Vault Locks, MFA Delete</p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d"><strong>Part 4 — Cost Optimization &amp; Storage Classes</strong> — Standard =&gt; Glacier Tiers, Intelligent Tiering, Lifecycle Configurations</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-5-integration-performance-static-websites-with-hands-on-cloudshell-b1f2d8807662"><strong>Part 5 — Integration &amp; Advanced Performance</strong> — Static Website Hosting, Multi-part Uploads, Transfer Acceleration, Event Notifications</a></p><p>Let’s dive into Part 3!</p><h3>1. Object Versioning: Your S3 Time Machine</h3><p>By default, if you upload a file named report.pdf and then upload a new file with the exact same name, S3 will overwrite the original file permanently.</p><p>If you enable <strong>Versioning</strong>, S3 stops overwriting. Instead, it assigns a unique “Version ID” to every upload.</p><ul><li>Upload report.pdf (V1 is created).</li><li>Upload a new report.pdf (V2 is created. V1 is hidden but still securely stored).</li></ul><p>Bucket versioning can be enabled at bucket creation or even after.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*C0lpWSphJXDPqIa2ErZbhQ.png" /></figure><blockquote>Note — Once bucket versioning is enabled, it cannot be disabled; it can only be suspended.</blockquote><h3>The Magic of Delete Markers</h3><p>What happens if you delete a file in a versioned bucket? S3 doesn’t actually delete the data. Instead, it places a <strong>Delete Marker</strong> over the file. The file disappears from your standard view, but beneath it, all previous versions still exist. To truly permanently delete the file, you must specify the exact Version ID in your delete command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RLq9DChPSt1WdzcXfzYEQ.png" /></figure><p>1 — For objects that were present before enabling bucket versioning, the Version ID is shown as null.</p><p>2 — To see versions of each of the objects, enable the “show versions” toggle.<br>You may tick any checkbox for the versions and delete them permanently from here.</p><p>3 — You can see that older versions still take space in S3. <strong>You are billed for space consumed by all versions</strong></p><p>4 — A delete marker is added because this object was deleted. But since versioning is enabled, it is just marked as delete. <br>(You can “undelete” an object by removing the delete marker)</p><h3>2. MFA Delete: The Ultimate Safety Net</h3><p>For highly sensitive environments, Versioning isn’t enough. A compromised administrator account could still permanently delete specific versions of your files. MFA Delete adds a critical layer of protection against accidental or unauthorized data loss, even if an attacker compromises your standard AWS credentials.</p><p><strong>MFA (Multi-Factor Authentication) Delete</strong> requires the user to input a 6-digit code from a physical or virtual MFA device to:</p><ol><li>Permanently delete an object version.</li><li>Suspend versioning on the bucket.</li></ol><p><strong>KEY CONCEPTS</strong></p><ul><li><strong>Requires Root User Credentials:</strong> Only the AWS account root user can enable or disable MFA Delete. IAM users, even those with full administrative permissions, cannot modify this setting.</li><li><strong>Requires Versioning:</strong> MFA Delete can only be enabled on a bucket that has S3 Versioning enabled. Versioning ensures that multiple versions of an object are preserved, and MFA is then required to permanently remove any version.</li><li><strong>CLI or API Only:</strong> MFA Delete cannot be configured through the AWS Management Console; it must be enabled using the AWS CLI or the S3 REST API.</li></ul><h3>3. Replication: SRR and CRR</h3><p>To protect against regional disasters or move data closer to your global users, S3 offers automatic, asynchronous object copying across buckets.</p><ol><li><strong>Cross-Region Replication (CRR):</strong> Copies data to a completely different AWS geographical region (e.g., from US-East to Europe). It is used strictly for disaster recovery and to reduce latency for global users.</li><li><strong>Same-Region Replication (SRR):</strong> Copies data to another bucket in the same region. Often used to live replicate between production and test accounts, archiving, data sharing between accounts, etc.</li></ol><p><strong>KEY CONCEPTS</strong></p><ul><li>Versioning must be enabled on both the source and destination buckets for this to work.</li><li>S3 replication is asynchronous. Meaning buckets are <strong>not </strong>immediately replicated to the destination.</li><li>Replication rules may be added to specify which objects to be replicated (tag/ prefix/ entire bucket), replication frequency, whether the storage class needs to be changed, etc.</li></ul><h4>Replication Time Control (RTC)</h4><p>RTC is an option that ensures 99.99% of objects are replicated within 15 minutes, at an additional cost.</p><h3>4. Object Lock &amp; Glacier Vault Lock</h3><p>If you work in finance, healthcare, or government, you might be legally required to store data in a <strong>WORM</strong> (Write Once, Read Many) model.</p><p>This Lock applies for a specified period where once locked —prevents even the root account administrator — from deleting or modifying an object for a specified retention period (e.g., “Do not allow deletion for 7 years”) or indefinitely.</p><p><strong>S3 Object Lock</strong> applies to individual objects, while <strong>Glacier Vault Lock</strong> applies to whole vaults</p><h3>Hands-On: Expanding the S3 Automation Toolkit (Part 3)</h3><p>We are going to append new functions to our s3-toolkit.sh script to handle Versioning, Object Lock, Replication, and secure cleanup. Then, we will run focused execution labs to see these protections in action.</p><h3>Step 1: Open the Toolkit in Nano</h3><p>Ensure you are in your home directory so your work saves to persistent storage, then open your existing toolkit script.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Ensure%252520you%252520are%252520in%252520your%252520persistent%252520home%252520directory%25250Acd%252520%257E%25250A%25250A%252523%252520Open%252520the%252520existing%252520toolkit%252520in%252520Nano%25250Anano%252520s3-toolkit.sh&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Ensure%25252520you%25252520are%25252520in%25252520your%25252520persistent%25252520home%25252520directory%2525250Acd%25252520%25257E%2525250A%2525250A%25252523%25252520Open%25252520the%25252520existing%25252520toolkit%25252520in%25252520Nano%2525250Anano%25252520s3-toolkit.sh&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href">https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href</a></iframe><h3>Step 2: Append the Data Protection &amp; Cleanup Functions</h3><p>Use your down arrow key to scroll to the very bottom of the file. We are adding functions that apply our core theories:</p><ul><li><strong>Versioning:</strong> Creates a safety net by keeping multiple variants of an object in the same bucket.</li><li><strong>Object Lock:</strong> Enforces WORM (Write Once, Read Many) compliance, physically preventing deletion.</li><li><strong>Replication:</strong> Automates copying data to another bucket for disaster recovery.</li><li><strong>Versioned Cleanup:</strong> A critical script that hunts down hidden versions and delete markers so we can safely delete the bucket without AWS blocking us!</li></ul><p>Copy and paste this pure Bash code below your existing functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7CLNRdMKGnFV4VblK-Q8bw.png" /></figure><p>source code <a href="https://gist.github.com/Mathews-axisTech/cb2e64abfee8c00c4a0b81fd91c81868">here</a></p><h3>Step 3: “Source” the Updated Toolkit</h3><p>Run source s3-toolkit.sh command to load the newly updated functions into the current session.</p><h3>Step 4: Execute the Protection Labs</h3><h4>Lab 3.1: The Time Machine (Versioning)</h4><p>Let’s create a file, overwrite it, and reveal the hidden history.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DVAULT_BUCKET%25253D%252522s3-vault-lab-%252524%2528date%252520%25252B%252525s%2529%252522%25250Acreate_new_bucket%252520%252522%252524VAULT_BUCKET%252522%252520%252522us-east-1%252522%25250Aenable_bucket_versioning%252520%252522%252524VAULT_BUCKET%252522%25250A%25250A%252523%252520Upload%252520Version%2525201%25252C%252520then%252520overwrite%252520with%252520Version%2525202%25250Aecho%252520%252522Version%2525201%25253A%252520Original%252520terms.%252522%252520%25253E%252520contract.txt%25250Aaws%252520s3%252520cp%252520contract.txt%252520s3%25253A%25252F%25252F%252522%252524VAULT_BUCKET%252522%25252Fcontract.txt%25250A%25250Aecho%252520%252522Version%2525202%25253A%252520Renegotiated%252520terms.%252522%252520%25253E%252520contract.txt%25250Aaws%252520s3%252520cp%252520contract.txt%252520s3%25253A%25252F%25252F%252522%252524VAULT_BUCKET%252522%25252Fcontract.txt%25250A%25250A%252523%252520Reveal%252520the%252520hidden%252520history%252520using%252520our%252520toolkit%2521%25250Alist_object_versions%252520%252522%252524VAULT_BUCKET%252522%252520%252522contract.txt%252522%25250A%25250A%252523%252520Clean%252520up%25253A%252520Our%252520Part%2525201%252520function%252520will%252520fail%252520here%25252C%252520so%252520we%252520use%252520our%252520new%252520version-aware%252520cleanup%2521%25250Adelete_versioned_bucket%252520%252522%252524VAULT_BUCKET%252522%25250Arm%252520contract.txt&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DVAULT_BUCKET%2525253D%25252522s3-vault-lab-%25252524%252528date%25252520%2525252B%25252525s%252529%25252522%2525250Acreate_new_bucket%25252520%25252522%25252524VAULT_BUCKET%25252522%25252520%25252522us-east-1%25252522%2525250Aenable_bucket_versioning%25252520%25252522%25252524VAULT_BUCKET%25252522%2525250A%2525250A%25252523%25252520Upload%25252520Version%252525201%2525252C%25252520then%25252520overwrite%25252520with%25252520Version%252525202%2525250Aecho%25252520%25252522Version%252525201%2525253A%25252520Original%25252520terms.%25252522%25252520%2525253E%25252520contract.txt%2525250Aaws%25252520s3%25252520cp%25252520contract.txt%25252520s3%2525253A%2525252F%2525252F%25252522%25252524VAULT_BUCKET%25252522%2525252Fcontract.txt%2525250A%2525250Aecho%25252520%25252522Version%252525202%2525253A%25252520Renegotiated%25252520terms.%25252522%25252520%2525253E%25252520contract.txt%2525250Aaws%25252520s3%25252520cp%25252520contract.txt%25252520s3%2525253A%2525252F%2525252F%25252522%25252524VAULT_BUCKET%25252522%2525252Fcontract.txt%2525250A%2525250A%25252523%25252520Reveal%25252520the%25252520hidden%25252520history%25252520using%25252520our%25252520toolkit%252521%2525250Alist_object_versions%25252520%25252522%25252524VAULT_BUCKET%25252522%25252520%25252522contract.txt%25252522%2525250A%2525250A%25252523%25252520Clean%25252520up%2525253A%25252520Our%25252520Part%252525201%25252520function%25252520will%25252520fail%25252520here%2525252C%25252520so%25252520we%25252520use%25252520our%25252520new%25252520version-aware%25252520cleanup%252521%2525250Adelete_versioned_bucket%25252520%25252522%25252524VAULT_BUCKET%25252522%2525250Arm%25252520contract.txt&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e79ba51d589dd57c14ac78205f10597/href">https://medium.com/media/6e79ba51d589dd57c14ac78205f10597/href</a></iframe><h4>Lab 3.2: The Indestructible File (Object Lock)</h4><p>Object Lock requires the bucket to be configured for it <em>at creation</em>. We will use our specialized create_locked_bucket function, then apply a 1-day strict compliance lock.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DWORM_BUCKET%25253D%252522s3-worm-lab-%252524%2528date%252520%25252B%252525s%2529%252522%25250A%25250A%252523%252520Create%252520a%252520specialized%252520locked%252520bucket%25250Acreate_locked_bucket%252520%252522%252524WORM_BUCKET%252522%252520%252522us-east-1%252522%25250A%25250A%252523%252520Upload%252520a%252520file%25250Aecho%252520%252522Financial%252520ledger%252520for%2525202026%252522%252520%25253E%252520ledger.txt%25250Aaws%252520s3%252520cp%252520ledger.txt%252520s3%25253A%25252F%25252F%252522%252524WORM_BUCKET%252522%25252Fledger.txt%25250A%25250A%252523%252520Lock%252520it%252520in%252520COMPLIANCE%252520mode%252520for%2525201%252520day%25250Alock_object_compliance%252520%252522%252524WORM_BUCKET%252522%252520%252522ledger.txt%252522%2525201%25250A%25250A%252523%252520If%252520you%252520try%252520to%252520run%252520%252560delete_versioned_bucket%252520%252522%252524WORM_BUCKET%252522%252560%252520right%252520now%25252C%252520AWS%252520will%252520block%252520you%2521%25250A%252523%252520You%252520must%252520wait%25252024%252520hours%252520until%252520the%252520retention%252520period%252520expires%252520to%252520run%252520the%252520cleanup%252520command.%25250A%252523%252520%2528Don%2527t%252520worry%25252C%252520a%252520single%252520text%252520file%252520stored%252520for%252520one%252520day%252520costs%252520fractions%252520of%252520a%252520cent%2521%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DWORM_BUCKET%2525253D%25252522s3-worm-lab-%25252524%252528date%25252520%2525252B%25252525s%252529%25252522%2525250A%2525250A%25252523%25252520Create%25252520a%25252520specialized%25252520locked%25252520bucket%2525250Acreate_locked_bucket%25252520%25252522%25252524WORM_BUCKET%25252522%25252520%25252522us-east-1%25252522%2525250A%2525250A%25252523%25252520Upload%25252520a%25252520file%2525250Aecho%25252520%25252522Financial%25252520ledger%25252520for%252525202026%25252522%25252520%2525253E%25252520ledger.txt%2525250Aaws%25252520s3%25252520cp%25252520ledger.txt%25252520s3%2525253A%2525252F%2525252F%25252522%25252524WORM_BUCKET%25252522%2525252Fledger.txt%2525250A%2525250A%25252523%25252520Lock%25252520it%25252520in%25252520COMPLIANCE%25252520mode%25252520for%252525201%25252520day%2525250Alock_object_compliance%25252520%25252522%25252524WORM_BUCKET%25252522%25252520%25252522ledger.txt%25252522%252525201%2525250A%2525250A%25252523%25252520If%25252520you%25252520try%25252520to%25252520run%25252520%25252560delete_versioned_bucket%25252520%25252522%25252524WORM_BUCKET%25252522%25252560%25252520right%25252520now%2525252C%25252520AWS%25252520will%25252520block%25252520you%252521%2525250A%25252523%25252520You%25252520must%25252520wait%2525252024%25252520hours%25252520until%25252520the%25252520retention%25252520period%25252520expires%25252520to%25252520run%25252520the%25252520cleanup%25252520command.%2525250A%25252523%25252520%252528Don%252527t%25252520worry%2525252C%25252520a%25252520single%25252520text%25252520file%25252520stored%25252520for%25252520one%25252520day%25252520costs%25252520fractions%25252520of%25252520a%25252520cent%252521%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/29c858feea50dcd93cf8d80edd1e7d3c/href">https://medium.com/media/29c858feea50dcd93cf8d80edd1e7d3c/href</a></iframe><h4>Lab 3.3: Cross-Region Replication (CRR)</h4><p>To replicate data, we need two buckets with versioning enabled, plus an IAM role that grants S3 permission to copy the files on your behalf.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DSOURCE%25253D%252522s3-source-%252524%2528date%252520%25252B%252525s%2529%252522%25250ADEST%25253D%252522s3-dest-%252524%2528date%252520%25252B%252525s%2529%252522%25250A%25250A%252523%2525201.%252520Create%252520buckets%252520in%252520different%252520regions%25250Acreate_new_bucket%252520%252522%252524SOURCE%252522%252520%252522us-east-1%252522%25250Acreate_new_bucket%252520%252522%252524DEST%252522%252520%252522eu-west-1%252522%25250A%25250A%252523%2525202.%252520Enable%252520versioning%252520on%252520BOTH%25250Aenable_bucket_versioning%252520%252522%252524SOURCE%252522%25250Aenable_bucket_versioning%252520%252522%252524DEST%252522%25250A%25250A%252523%2525203.%252520Apply%252520the%252520rule%252520%2528Note%25253A%252520In%252520a%252520real%252520environment%25252C%252520replace%252520%2527YOUR_ROLE_ARN%2527%252520with%252520an%252520actual%252520IAM%252520Role%252520ARN%2529%25250A%252523%252520apply_replication_rule%252520%252522%252524SOURCE%252522%252520%252522%252524DEST%252522%252520%252522arn%25253Aaws%25253Aiam%25253A%25253A123456789012%25253Arole%25252Fs3-replication-role%252522%25250Aecho%252520%252522%2525E2%25259C%252585%252520Replication%252520setup%252520staged%2521%252522%25250A%25250A%252523%252520Clean%252520up%25253A%252520Both%252520source%252520and%252520destination%252520buckets%252520have%252520versioning%252520enabled%2521%25250Adelete_versioned_bucket%252520%252522%252524SOURCE%252522%25250Adelete_versioned_bucket%252520%252522%252524DEST%252522&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DSOURCE%2525253D%25252522s3-source-%25252524%252528date%25252520%2525252B%25252525s%252529%25252522%2525250ADEST%2525253D%25252522s3-dest-%25252524%252528date%25252520%2525252B%25252525s%252529%25252522%2525250A%2525250A%25252523%252525201.%25252520Create%25252520buckets%25252520in%25252520different%25252520regions%2525250Acreate_new_bucket%25252520%25252522%25252524SOURCE%25252522%25252520%25252522us-east-1%25252522%2525250Acreate_new_bucket%25252520%25252522%25252524DEST%25252522%25252520%25252522eu-west-1%25252522%2525250A%2525250A%25252523%252525202.%25252520Enable%25252520versioning%25252520on%25252520BOTH%2525250Aenable_bucket_versioning%25252520%25252522%25252524SOURCE%25252522%2525250Aenable_bucket_versioning%25252520%25252522%25252524DEST%25252522%2525250A%2525250A%25252523%252525203.%25252520Apply%25252520the%25252520rule%25252520%252528Note%2525253A%25252520In%25252520a%25252520real%25252520environment%2525252C%25252520replace%25252520%252527YOUR_ROLE_ARN%252527%25252520with%25252520an%25252520actual%25252520IAM%25252520Role%25252520ARN%252529%2525250A%25252523%25252520apply_replication_rule%25252520%25252522%25252524SOURCE%25252522%25252520%25252522%25252524DEST%25252522%25252520%25252522arn%2525253Aaws%2525253Aiam%2525253A%2525253A123456789012%2525253Arole%2525252Fs3-replication-role%25252522%2525250Aecho%25252520%25252522%252525E2%2525259C%25252585%25252520Replication%25252520setup%25252520staged%252521%25252522%2525250A%2525250A%25252523%25252520Clean%25252520up%2525253A%25252520Both%25252520source%25252520and%25252520destination%25252520buckets%25252520have%25252520versioning%25252520enabled%252521%2525250Adelete_versioned_bucket%25252520%25252522%25252524SOURCE%25252522%2525250Adelete_versioned_bucket%25252520%25252522%25252524DEST%25252522&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e56ed50cf57348a592de8818de13e99f/href">https://medium.com/media/e56ed50cf57348a592de8818de13e99f/href</a></iframe><h4>Lab 3.4: The Root-Only Defences (MFA Delete &amp; Vault Lock)</h4><p><em>Disclaimer: You cannot fully execute these commands in a standard CloudShell lab. MFA Delete requires the </em><strong><em>Account Root User</em></strong><em>, and Vault Lock requires a dedicated Glacier Vault.</em> However, your toolkit is prepared! If you were logged in as Root, you would simply run:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Syntax%252520for%252520enabling%252520MFA%252520Delete%252520%2528Requires%252520Root%252520User%252520%252526%252520Physical%25252FVirtual%252520MFA%252520device%2529%25250A%252523%252520aws%252520s3api%252520put-bucket-versioning%252520--bucket%252520%252522my-secure-bucket%252522%252520%25255C%25250A%252523%252520%252520%252520%252520--versioning-configuration%252520Status%25253DEnabled%25252CMFADelete%25253DEnabled%252520%25255C%25250A%252523%252520%252520%252520%252520--mfa%252520%252522arn%25253Aaws%25253Aiam%25253A%25253A123456789012%25253Amfa%25252Froot-account-mfa-device%252520123456%252522%25250A%25250A%252523%252520Syntax%252520for%252520Glacier%252520Vault%252520Lock%252520%2528Requires%252520%2527aws%252520glacier%2527%252520API%2529%25250A%252523%252520aws%252520glacier%252520initiate-vault-lock%252520--account-id%252520-%252520--vault-name%252520%252522ComplianceVault%252522%252520--vault-lock-policy%252520file%25253A%25252F%25252Fpolicy.json&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Syntax%25252520for%25252520enabling%25252520MFA%25252520Delete%25252520%252528Requires%25252520Root%25252520User%25252520%25252526%25252520Physical%2525252FVirtual%25252520MFA%25252520device%252529%2525250A%25252523%25252520aws%25252520s3api%25252520put-bucket-versioning%25252520--bucket%25252520%25252522my-secure-bucket%25252522%25252520%2525255C%2525250A%25252523%25252520%25252520%25252520%25252520--versioning-configuration%25252520Status%2525253DEnabled%2525252CMFADelete%2525253DEnabled%25252520%2525255C%2525250A%25252523%25252520%25252520%25252520%25252520--mfa%25252520%25252522arn%2525253Aaws%2525253Aiam%2525253A%2525253A123456789012%2525253Amfa%2525252Froot-account-mfa-device%25252520123456%25252522%2525250A%2525250A%25252523%25252520Syntax%25252520for%25252520Glacier%25252520Vault%25252520Lock%25252520%252528Requires%25252520%252527aws%25252520glacier%252527%25252520API%252529%2525250A%25252523%25252520aws%25252520glacier%25252520initiate-vault-lock%25252520--account-id%25252520-%25252520--vault-name%25252520%25252522ComplianceVault%25252522%25252520--vault-lock-policy%25252520file%2525253A%2525252F%2525252Fpolicy.json&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0a7a04fa04bc9645000789bba2f5623/href">https://medium.com/media/a0a7a04fa04bc9645000789bba2f5623/href</a></iframe><p><strong>Next Step:</strong> Protecting data is critical, but storing every single version of a file forever or replicating it across the globe can get incredibly expensive. In <a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d"><strong>Part 4</strong></a>, we will dive into <a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d"><strong>Cost Optimization &amp; Storage Classes</strong></a> so you can automate your cost savings!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5dc09dcc0347" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3 Fundamentals (Part 2): Securing Your Buckets with Hands-On CloudShell]]></title>
            <link>https://medium.com/@iromathews4/aws-s3-fundamentals-part-2-securing-your-buckets-with-hands-on-cloudshell-f3c84a3c3d85?source=rss-bc8eaf2deaec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3c84a3c3d85</guid>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws-cloudshell]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <dc:creator><![CDATA[Irosh Mathews]]></dc:creator>
            <pubDate>Sun, 22 Feb 2026 18:59:31 GMT</pubDate>
            <atom:updated>2026-03-11T07:58:27.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdH_MxFwaOAE8XTCU-frUQ.jpeg" /></figure><p>Welcome back to the definitive guide to Amazon Simple Storage Service (S3). In Part 1, we mastered the core mechanics of buckets, objects, and the flat structure of S3. Now is the time to tackle one of the most critical topics for cloud engineers and AWS certification exams: s<strong>ecurity</strong>.</p><p>A single misconfigured S3 bucket can lead to massive data breaches. In fact, many high-profile cloud leaks happen simply because someone left a bucket wide open to the internet.</p><blockquote>Ex: -<a href="https://www.upguard.com/breaches/verizon-cloud-leak">2017 Verizon’s major data breach due to a misconfigured S3 bucket</a></blockquote><p><strong>Series Index:</strong></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-1-e8641269f52c"><strong>Part 1 — The Primer &amp; Core Mechanics</strong> — Buckets, Objects, Keys, Global vs. Regional, Flat Structure</a></p><p><strong>Part 2 — Securing Your S3 Buckets</strong> — Block Public Access, Bucket Policies vs IAM, Encryption (SSE/CSE), Pre-signed URLs</p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-3-data-protection-compliance-with-hands-on-cloudshell-5dc09dcc0347"><strong>Part 3 — Data Protection &amp; Compliance</strong> — Object Versioning, Delete Markers, Replication (SRR/CRR), Object &amp; Vault Locks, MFA Delete</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d"><strong>Part 4 — Cost Optimization &amp; Storage Classes</strong> — Standard =&gt; Glacier Tiers, Intelligent Tiering, Lifecycle Configurations</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-5-integration-performance-static-websites-with-hands-on-cloudshell-b1f2d8807662"><strong>Part 5 — Integration &amp; Advanced Performance</strong> — Static Website Hosting, Multi-part Uploads, Transfer Acceleration, Event Notifications</a></p><p>Let’s dive into Part 2!</p><h3>1. The “Block Public Access” Shield</h3><p>By default, Amazon S3 is secure. S3 buckets have an added layer of protection blocking all public access by default. This master switch acts as a safety net. Even if you accidentally write a policy that grants public access, this account-level or bucket-level setting will override it and keep your data private. It essentially ignores any Access Control Lists (ACLs) or bucket policies that attempt to grant public access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kV2flvadiooitxFhXyQSfg.png" /></figure><h3>2. Access Control: Bucket Policies vs. IAM and the legacy of ACLs</h3><p>When you want to grant specific access to your S3 bucket, you generally use policies. But there are two main types you need to understand:</p><ol><li><strong>Identity-Based Policies (IAM):</strong> These are attached to a <em>user, group, or role</em>. They dictate what that specific identity is allowed to do across AWS.</li><li><strong>Resource-Based Policies (Bucket Policies):</strong> These are attached to a resource. A resource-based policy controls who can access a specific resource (e.g., an S3 bucket — then it is also called a Bucket Policy). Resource-based policies are mandatory for resources which you want to be accessible by external identities (i.e. from outside your account).</li></ol><h4>How this works</h4><p>For same-account identities, a combination of rules from their identity-based policy and rules from the resource-based policy applies. Think of it as a security checkpoint where AWS checks both the IAM policy (what the user is allowed to do) and the Bucket Policy (who the bucket allows in). If <em>either</em> policy grants access, the request is allowed — with one unbreakable rule: <strong>the explicit deny</strong>. As usual, an explicit “deny” in either of the policies will override all “allows”. Even if an IAM user is a full administrator, if the Bucket Policy explicitly denies them access, they are entirely blocked from that bucket.</p><blockquote><strong>The Key Difference:</strong> Resource-based policies contain the “Principal” term, whereas Identity-based policies do not. The “Principal” defines <em>who</em> is allowed (or denied) access to the bucket.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dapplication%252Fjson%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25257B%25250A%252520%252520%252522Version%252522%25253A%252520%2525222012-10-17%252522%25252C%25250A%252520%252520%252522Statement%252522%25253A%252520%25255B%25250A%252520%252520%252520%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252522Sid%252522%25253A%252520%252522AllowReadAccessToSpecificUser%252522%25252C%25250A%252520%252520%252520%252520%252520%252520%252522Effect%252522%25253A%252520%252522Allow%252522%25252C%25250A%252520%252520%252520%252520%252520%252520%252522Principal%252522%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252522AWS%252522%25253A%252520%252522arn%25253Aaws%25253Aiam%25253A%25253A123456789012%25253Auser%25252FJohnDoe%252522%25250A%252520%252520%252520%252520%252520%252520%25257D%25252C%25250A%252520%252520%252520%252520%252520%252520%252522Action%252522%25253A%252520%252522s3%25253AGetObject%252522%25252C%25250A%252520%252520%252520%252520%252520%252520%252522Resource%252522%25253A%252520%252522arn%25253Aaws%25253As3%25253A%25253A%25253Aexample-bucket%25252F%252A%252522%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25255D%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dapplication%25252Fjson%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525257B%2525250A%25252520%25252520%25252522Version%25252522%2525253A%25252520%252525222012-10-17%25252522%2525252C%2525250A%25252520%25252520%25252522Statement%25252522%2525253A%25252520%2525255B%2525250A%25252520%25252520%25252520%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252522Sid%25252522%2525253A%25252520%25252522AllowReadAccessToSpecificUser%25252522%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252522Effect%25252522%2525253A%25252520%25252522Allow%25252522%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252522Principal%25252522%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252522AWS%25252522%2525253A%25252520%25252522arn%2525253Aaws%2525253Aiam%2525253A%2525253A123456789012%2525253Auser%2525252FJohnDoe%25252522%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252522Action%25252522%2525253A%25252520%25252522s3%2525253AGetObject%25252522%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252522Resource%25252522%2525253A%25252520%25252522arn%2525253Aaws%2525253As3%2525253A%2525253A%2525253Aexample-bucket%2525252F%25252A%25252522%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525255D%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1973953c9dafa303c26bb0021977797/href">https://medium.com/media/d1973953c9dafa303c26bb0021977797/href</a></iframe><h4>What are S3 ACLs? (And why you should ignore them)</h4><p>Access Control Lists (ACLs) were the very first security mechanism AWS introduced for S3 back in 2006. An ACL is a set of grants that define which AWS accounts or predefined groups have specific permissions (READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL) on a bucket or an individual object.</p><p><strong>AWS highly recommends disabling S3 ACLs completely.</strong> Managing permissions across thousands of individual object ACLs causes massive code duplication and auditing nightmares. Modern industry best practices dictate relying entirely on centralized IAM and Bucket Policies. In fact, as of April 2023, AWS enforces a “Bucket Owner Enforced” setting that disables ACLs by default for all new buckets.</p><h3>3. Data Encryption: SSE vs. CSE</h3><p>Protecting who can access your data is step one. Step two is making sure the data is unreadable if intercepted. There are two types of encryption in S3: Server-Side Encryption (SSE) and Client-Side Encryption (CSE).</p><ul><li><strong>Server-Side Encryption (SSE):</strong> This is the default encryption and is always ON. Objects are encrypted by the server <strong>after</strong> they are uploaded. AWS manages the heavy lifting for you.</li><li><strong>Client-Side Encryption (CSE):</strong> This is an additional and optional layer. Objects are encrypted by the client <strong>before</strong> they are uploaded. Because you encrypt the data locally, AWS never sees what is behind the encryption.</li></ul><h3>4. Pre-signed URLs: The Missing Piece for Temporary Access</h3><p>What if your bucket is completely private, but you need to share a single report with a client for 24 hours? Or what if you are building an app and want users to upload profile pictures directly to S3 without passing those heavy files through your backend server?</p><p>You don’t want to make the bucket public, and creating an IAM user for every single client or app user is impossible.</p><p>Enter the <strong>Pre-signed URL</strong>.</p><p>A pre-signed URL is a temporary, time-bound link that grants temporary access to a specific private object. It essentially “borrows” the security credentials of the IAM user or role that generated it. There are two primary use cases:</p><ul><li><strong>Viewing/Downloading (GET Requests):</strong> You generate a link to a private file (like a PDF report or an invoice) and email it to a client. Once the expiration time hits (e.g., 1 hour), the link instantly becomes dead, protecting your data automatically.</li><li><strong>Uploading (PUT Requests):</strong> This is an industry secret for highly scalable apps. Instead of a user uploading a massive video file to your web server (which costs you processing power and bandwidth), your server generates a pre-signed PUT URL. The user’s browser uses that link to upload the file <em>directly</em> into your private S3 bucket.</li></ul><blockquote><strong><em>Security Note:</em></strong><em> The person using the pre-signed URL can only perform the specific action (GET or PUT) that the creator authorized, and only for the exact file specified in the URL.</em></blockquote><h3>Hands-On: Expanding the S3 Automation Toolkit</h3><p>Let’s lock down our data. Instead of writing long, error-prone JSON policies directly into the command line every time, we are going to append new security functions to our existing s3-toolkit.sh script.</p><h3>Step 1: Open the Toolkit in Nano</h3><p>First, ensure you are in your home directory, then open your existing toolkit script using the Nano text editor.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Ensure%252520you%252520are%252520in%252520your%252520persistent%252520home%252520directory%25250Acd%252520%257E%25250A%25250A%252523%252520Open%252520the%252520existing%252520toolkit%252520in%252520Nano%25250Anano%252520s3-toolkit.sh&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D17%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Ensure%25252520you%25252520are%25252520in%25252520your%25252520persistent%25252520home%25252520directory%2525250Acd%25252520%25257E%2525250A%2525250A%25252523%25252520Open%25252520the%25252520existing%25252520toolkit%25252520in%25252520Nano%2525250Anano%25252520s3-toolkit.sh&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href">https://medium.com/media/ce93206e229cd8efa0590b26c7db4b66/href</a></iframe><h3>Step 2: Append the Security Functions</h3><p>Once the editor opens, <strong>use your down arrow key to scroll all the way to the bottom of the file</strong>. We are going to add three new functions. Here is how they apply the theories we just learned:</p><ul><li><strong>disable_bucket_acls:</strong> Applies the modern best practice of turning off legacy Object ACLs, forcing the bucket to rely strictly on secure, centralized IAM and Bucket Policies.</li><li><strong>enforce_https_policy:</strong> Dynamically generates a Resource-Based Policy (Bucket Policy) that uses the unbreakable <strong>explicit deny</strong> rule to block any unencrypted (HTTP) traffic.</li><li><strong>generate_download_link:</strong> Creates a Pre-signed URL to grant temporary, time-bound access to a private file without changing the bucket&#39;s strict public access settings.</li></ul><p>Copy and paste this pure Bash code below your existing functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIawYovaRyv3ujT5_aKujw.png" /></figure><p>source code is <a href="https://gist.github.com/Mathews-axisTech/6be3d3b87fa48fdc190647ea89b4c71a">here</a></p><h3>Step 3: “Source” the Updated Toolkit</h3><p>Run source s3-toolkit.sh command to load the newly updated functions into the current session.</p><h3>Step 4: Execute the Simplified Security Lab</h3><p>Now, execute the lab. Notice how we are reusing the create_new_bucket and delete_bucket_and_contents functions from Part 1, completely eliminating redundant code!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%2525201.%252520Define%252520our%252520variables%25250ASECURE_BUCKET%25253D%252522s3-security-lab-%252524%2528date%252520%25252B%252525s%2529%252522%25250ASECRET_FILE%25253D%252522q4-earnings.txt%252522%25250A%25250A%252523%2525202.%252520Create%252520the%252520bucket%252520%2528Using%252520our%252520Part%2525201%252520function%2529%25250Acreate_new_bucket%252520%252522%252524SECURE_BUCKET%252522%252520%252522us-east-1%252522%25250A%25250A%252523%2525203.%252520Lock%252520it%252520down%252520using%252520our%252520new%252520Part%2525202%252520functions%25250Adisable_bucket_acls%252520%252522%252524SECURE_BUCKET%252522%25250Aenforce_https_policy%252520%252522%252524SECURE_BUCKET%252522%25250A%25250A%252523%2525204.%252520Create%252520and%252520upload%252520a%252520private%252520file%25250Aecho%252520%252522Highly%252520confidential%252520financial%252520data%252522%252520%25253E%252520%252522%252524SECRET_FILE%252522%25250Aaws%252520s3%252520cp%252520%252522%252524SECRET_FILE%252522%252520s3%25253A%25252F%25252F%252522%252524SECURE_BUCKET%252522%25252F%252522%252524SECRET_FILE%252522%25250A%25250A%252523%2525205.%252520Generate%252520a%252520secure%252520sharing%252520link%252520%2528Valid%252520for%252520exactly%25252015%252520minutes%252520%25252F%252520900%252520seconds%2529%25250Agenerate_download_link%252520%252522%252524SECURE_BUCKET%252522%252520%252522%252524SECRET_FILE%252522%252520900%25250A%25250A%252523%252520Copy%252520the%252520generated%252520URL%252520from%252520your%252520terminal%252520and%252520paste%252520it%252520into%252520a%252520browser%252520tab%252520to%252520view%252520it%2521%25250A%25250A%252523%2525206.%252520Clean%252520up%252520%2528Using%252520our%252520Part%2525201%252520function%2529%25250Adelete_bucket_and_contents%252520%252522%252524SECURE_BUCKET%252522%25250Arm%252520%252522%252524SECRET_FILE%252522&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D11%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%252525201.%25252520Define%25252520our%25252520variables%2525250ASECURE_BUCKET%2525253D%25252522s3-security-lab-%25252524%252528date%25252520%2525252B%25252525s%252529%25252522%2525250ASECRET_FILE%2525253D%25252522q4-earnings.txt%25252522%2525250A%2525250A%25252523%252525202.%25252520Create%25252520the%25252520bucket%25252520%252528Using%25252520our%25252520Part%252525201%25252520function%252529%2525250Acreate_new_bucket%25252520%25252522%25252524SECURE_BUCKET%25252522%25252520%25252522us-east-1%25252522%2525250A%2525250A%25252523%252525203.%25252520Lock%25252520it%25252520down%25252520using%25252520our%25252520new%25252520Part%252525202%25252520functions%2525250Adisable_bucket_acls%25252520%25252522%25252524SECURE_BUCKET%25252522%2525250Aenforce_https_policy%25252520%25252522%25252524SECURE_BUCKET%25252522%2525250A%2525250A%25252523%252525204.%25252520Create%25252520and%25252520upload%25252520a%25252520private%25252520file%2525250Aecho%25252520%25252522Highly%25252520confidential%25252520financial%25252520data%25252522%25252520%2525253E%25252520%25252522%25252524SECRET_FILE%25252522%2525250Aaws%25252520s3%25252520cp%25252520%25252522%25252524SECRET_FILE%25252522%25252520s3%2525253A%2525252F%2525252F%25252522%25252524SECURE_BUCKET%25252522%2525252F%25252522%25252524SECRET_FILE%25252522%2525250A%2525250A%25252523%252525205.%25252520Generate%25252520a%25252520secure%25252520sharing%25252520link%25252520%252528Valid%25252520for%25252520exactly%2525252015%25252520minutes%25252520%2525252F%25252520900%25252520seconds%252529%2525250Agenerate_download_link%25252520%25252522%25252524SECURE_BUCKET%25252522%25252520%25252522%25252524SECRET_FILE%25252522%25252520900%2525250A%2525250A%25252523%25252520Copy%25252520the%25252520generated%25252520URL%25252520from%25252520your%25252520terminal%25252520and%25252520paste%25252520it%25252520into%25252520a%25252520browser%25252520tab%25252520to%25252520view%25252520it%252521%2525250A%2525250A%25252523%252525206.%25252520Clean%25252520up%25252520%252528Using%25252520our%25252520Part%252525201%25252520function%252529%2525250Adelete_bucket_and_contents%25252520%25252522%25252524SECURE_BUCKET%25252522%2525250Arm%25252520%25252522%25252524SECRET_FILE%25252522&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a741e8e5efd6b8e41e27d9ceba3fffef/href">https://medium.com/media/a741e8e5efd6b8e41e27d9ceba3fffef/href</a></iframe><p>Your bucket is now a fortress, but what if a “good guy” accidentally deletes a critical file? In <a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-3-data-protection-compliance-with-hands-on-cloudshell-5dc09dcc0347"><strong>[Part 3: Data Protection &amp; Compliance]</strong></a>, we’ll add a “Time Machine” to our toolkit using Versioning and learn how to make files physically indestructible with Object Lock.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3c84a3c3d85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3 Fundamentals (Part 1): The Ultimate Beginner’s Guide with Hands-On CloudShell]]></title>
            <link>https://medium.com/@iromathews4/aws-s3-fundamentals-part-1-e8641269f52c?source=rss-bc8eaf2deaec------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8641269f52c</guid>
            <category><![CDATA[aws-cloudshell]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[aws-s3-bucket]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Irosh Mathews]]></dc:creator>
            <pubDate>Fri, 20 Feb 2026 16:06:13 GMT</pubDate>
            <atom:updated>2026-03-16T16:47:48.066Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*w80xnp7HqPzg32iG34mhjg.png" /></figure><p>Welcome to the definitive guide to mastering Amazon Simple Storage Service (S3)! In this series, we will cover the AWS S3 fundamentals. <br>If you are studying to crush your AWS Certified Cloud Practitioner exam, or building a strong foundation in AWS S3, you are in the right place.</p><p>Here is the truth: real-world cloud engineers don’t spend their days clicking through the AWS Management Console. They automate, script, and use the command line. That is why this series skips the endless console navigation. Instead, we are using <strong>AWS CloudShell</strong>.</p><p>By the end of this five-part series, you won’t just understand S3 theory — you will have the exact muscle memory to use it like a pro.</p><p><strong>Series Index:</strong></p><p><strong>Part 1 — The Primer &amp; Core Mechanics</strong> — Buckets, Objects, Keys, Global vs. Regional, Flat Structure</p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-2-securing-your-buckets-with-hands-on-cloudshell-f3c84a3c3d85"><strong>Part 2 — Securing Your S3 Buckets</strong> — Block Public Access, Bucket Policies vs IAM, Encryption (SSE/CSE), Pre-signed URLs</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-3-data-protection-compliance-with-hands-on-cloudshell-5dc09dcc0347"><strong>Part 3 — Data Protection &amp; Compliance</strong> — Object Versioning, Delete Markers, Replication (SRR/CRR), Object &amp; Vault Locks, MFA Delete</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-4-cost-optimization-storage-classes-with-hands-on-cloudshell-ff7e8f19fd0d"><strong>Part 4 — Cost Optimization &amp; Storage Classes</strong> — Standard =&gt; Glacier Tiers, Intelligent Tiering, Lifecycle Configurations</a></p><p><a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-5-integration-performance-static-websites-with-hands-on-cloudshell-b1f2d8807662"><strong>Part 5 — Integration &amp; Advanced Performance</strong> — Static Website Hosting, Multi-part Uploads, Transfer Acceleration, Event Notifications</a></p><p>Let’s dive into Part 1!</p><h3>What is Amazon S3 (Simple Storage Service)?</h3><p>S3 is AWS&#39;s first core service. It provides object storage through a web interface and allows users to store and retrieve any amount of data, at any time, from anywhere on the web. Use cases include images, audio, video, big data, archives, static websites, backups, logs, and more. It is used by companies like Netflix, Pinterest, NASA, and Coca-Cola.</p><p>To master S3, you first need to understand its fundamental entities: <strong>Buckets</strong> and <strong>Objects</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*3M-mOrXLnQuq5BS7c_-gwQ.png" /></figure><h3>Buckets: Your Storage Containers</h3><p>Think of a bucket as the top-level container for your files. However, there are a few strict rules you must follow when creating them:</p><ul><li><strong>Globally Unique Names:</strong> Buckets must have globally unique names across all of AWS. If someone else in the world has a bucket named my-test-bucket, you cannot use that name.</li></ul><blockquote>(Note: As of March 2026, AWS introduced “<strong>account regional namespaces</strong>” which allows you to bypass the global uniqueness rule by scoping a bucket to your specific account. However, we will still use the standard global naming format for our buckets in this guide, as it keeps our AWS CloudShell commands simpler and more straightforward.)</blockquote><ul><li><strong>Regional Placement:</strong> While S3 is a global service, buckets are strictly region-based. You need to select a specific region for each bucket you create.</li></ul><h3>Objects: Your Data</h3><p>Objects are the fundamental entities stored in Amazon S3. An object is simply the file you are storing (like an image, CSV, or video), plus any metadata associated with it.</p><ul><li><strong>Size Limits</strong>: Each object can range from 0 KB to 5 TB. <br><em>(Note: Uploading files larger than 5 GB via CLI/SDK/API requires a special process called </em><strong><em>Multi-part Upload</em></strong><em>, which we will deep-dive into in Part 5!)</em></li></ul><h3>The “Folder” Illusion: S3 is Not a Filesystem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MlB9vy5AZPT6mipGMqw9jg.png" /></figure><p>One of the most common misconceptions about S3 is how it organizes data. S3 is not a filesystem. All objects are stored in one flat structure. It&#39;s not hierarchical.</p><p>So, how do you organize thousands of files if there are no folders? S3 does this using <strong>Keys</strong> and <strong>Prefixes</strong>.</p><ul><li>Objects are identified through keys. For example, in s3://example-bucket/file.png, the Object Key is file.png.</li><li>Object keys may contain prefixes that look like folders. If your file path is s3://example-bucket/folder1/folder2/file.jpg, the &quot;folders&quot; are actually just a long prefix in the file&#39;s name. It acts like a folder visually in the AWS Console, but underneath, it remains a flat structure.</li></ul><h3>Hands-On: Core Mechanics in AWS CloudShell</h3><p>Let’s get our hands dirty. Real-world cloud engineers don’t spend their days clicking through the AWS Management Console, nor do they type out the same isolated commands over and over. They write maintainable, consistent, simplified code to reduce code duplication and follow best practices.</p><p>Instead of writing throwaway commands, we are going to use <strong>AWS CloudShell</strong> to build a reusable bash script named s3-toolkit.sh. We will expand this toolkit in every part of the series.</p><h3>Step 1: Secure Your Persistent Storage</h3><p>AWS CloudShell provides 1 GB of persistent storage in your home directory. If you save files outside of this directory, they are deleted when your session ends. Let’s make sure we are in the right place, so we don’t lose our progress!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dapplication%252Fx-sh%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Ensure%252520you%252520are%252520in%252520your%252520persistent%252520home%252520directory%25250Acd%252520%257E&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dapplication%25252Fx-sh%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Ensure%25252520you%25252520are%25252520in%25252520your%25252520persistent%25252520home%25252520directory%2525250Acd%25252520%25257E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f5205d3d2b881823d1fbe44f4df357d/href">https://medium.com/media/7f5205d3d2b881823d1fbe44f4df357d/href</a></iframe><h3>Step 2: Create the Base Toolkit</h3><p>AWS CloudShell comes with <strong>Nano</strong>, a beginner-friendly text editor. Type nano s3-toolkit.sh in your terminal and press Enter to open it. Once the editor opens, copy the pure Bash code below and paste it directly into the terminal. This script will contain two simplified functions: one for creating a bucket using the low-level API (s3api), and one for cleaning up using the high-level wrapper (s3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LC6N1aOVyLoUFxYqLBYfDA.png" /></figure><p>source code is <a href="https://gist.github.com/Mathews-axisTech/63878f4ceee94b27ba57575f4018c68e">here</a></p><p><strong>To save and exit Nano:</strong></p><ol><li>Press Ctrl + O (the letter O, not zero) to save the file.</li><li>Press Enter to confirm the file name.</li><li>Press Ctrl + X to exit the editor and return to the normal command line.</li></ol><h3>Step 3: Make Executable and “Source” the Toolkit</h3><p>To use the custom functions we just wrote, we need to grant execution permissions to the script and then load it into our terminal.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%252520Make%252520the%252520script%252520executable%25250Achmod%252520%25252Bx%252520s3-toolkit.sh%25250A%25250A%252523%252520Load%252520the%252520functions%252520into%252520the%252520current%252520session%25250Asource%252520s3-toolkit.sh&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%25252520Make%25252520the%25252520script%25252520executable%2525250Achmod%25252520%2525252Bx%25252520s3-toolkit.sh%2525250A%2525250A%25252523%25252520Load%25252520the%25252520functions%25252520into%25252520the%25252520current%25252520session%2525250Asource%25252520s3-toolkit.sh&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/674558ec2ffa1d70e0cfe2d83c0f2a1e/href">https://medium.com/media/674558ec2ffa1d70e0cfe2d83c0f2a1e/href</a></iframe><blockquote><strong>Pro Tip: Why do we use </strong><strong>source?</strong> <em>If you run a script normally (e.g., </em><em>./s3-toolkit.sh), Linux opens a temporary background terminal (a subshell) to do the work. Once finished, it instantly forgets any functions it learned. By using </em><em>source s3-toolkit.sh, we force our current terminal session to memorize our custom functions so we can use them directly in the command line!</em></blockquote><h3>Step 4: Execute the Simplified Commands</h3><p>Now, look how clean and maintainable our actual lab execution becomes. We define our variables and call our custom functions, proving out the theories we discussed earlier.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528198%252C214%252C188%252C1%2529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dapplication%252Fx-sh%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252523%2525201.%252520Define%252520a%252520globally%252520unique%252520bucket%252520name%252520using%252520a%252520timestamp%25250AMY_BUCKET%25253D%252522s3-mastery-lab-%252524%2528date%252520%25252B%252525s%2529%252522%25250A%25250A%252523%2525202.%252520Create%252520the%252520bucket%252520%2528tied%252520to%252520a%252520specific%252520Region%2529%25250Acreate_new_bucket%252520%252522%252524MY_BUCKET%252522%252520%252522us-east-1%252522%25250A%25250A%252523%2525203.%252520Create%252520a%252520test%252520file%252520locally%25250Aecho%252520%252522Hello%252520from%252520the%252520S3%252520Toolkit%2521%252522%252520%25253E%252520lab1.txt%25250A%25250A%252523%2525204.%252520Upload%252520the%252520object%252520using%252520the%252520standard%252520AWS%252520CLI%25250A%252523%252520We%252520use%252520a%252520%2527labs%25252F%2527%252520prefix%252520in%252520the%252520key%252520to%252520create%252520the%252520illusion%252520of%252520a%252520folder%2521%25250Aaws%252520s3%252520cp%252520lab1.txt%252520s3%25253A%25252F%25252F%252522%252524MY_BUCKET%252522%25252Flabs%25252Flab1.txt%25250A%25250A%252523%2525205.%252520List%252520the%252520bucket%252520contents%252520to%252520view%252520the%252520flat%252520structure%25250A%252523%252520You%252520will%252520see%252520the%252520actual%252520object%252520key%252520is%252520%252522labs%25252Flab1.txt%252522%25250Aaws%252520s3%252520ls%252520s3%25253A%25252F%25252F%252522%252524MY_BUCKET%252522%252520--recursive%25250A%25250A%252523%2525206.%252520Clean%252520up%252520using%252520our%252520toolkit%252520function%252520to%252520prevent%252520unwanted%252520AWS%252520charges%25250Adelete_bucket_and_contents%252520%252522%252524MY_BUCKET%252522&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528198%25252C214%25252C188%25252C1%252529%26t%3Dshades-of-purple%26wt%3Dnone%26l%3Dapplication%25252Fx-sh%26width%3D680%26ds%3Dtrue%26dsyoff%3D44px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D25px%26ph%3D100px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252523%252525201.%25252520Define%25252520a%25252520globally%25252520unique%25252520bucket%25252520name%25252520using%25252520a%25252520timestamp%2525250AMY_BUCKET%2525253D%25252522s3-mastery-lab-%25252524%252528date%25252520%2525252B%25252525s%252529%25252522%2525250A%2525250A%25252523%252525202.%25252520Create%25252520the%25252520bucket%25252520%252528tied%25252520to%25252520a%25252520specific%25252520Region%252529%2525250Acreate_new_bucket%25252520%25252522%25252524MY_BUCKET%25252522%25252520%25252522us-east-1%25252522%2525250A%2525250A%25252523%252525203.%25252520Create%25252520a%25252520test%25252520file%25252520locally%2525250Aecho%25252520%25252522Hello%25252520from%25252520the%25252520S3%25252520Toolkit%252521%25252522%25252520%2525253E%25252520lab1.txt%2525250A%2525250A%25252523%252525204.%25252520Upload%25252520the%25252520object%25252520using%25252520the%25252520standard%25252520AWS%25252520CLI%2525250A%25252523%25252520We%25252520use%25252520a%25252520%252527labs%2525252F%252527%25252520prefix%25252520in%25252520the%25252520key%25252520to%25252520create%25252520the%25252520illusion%25252520of%25252520a%25252520folder%252521%2525250Aaws%25252520s3%25252520cp%25252520lab1.txt%25252520s3%2525253A%2525252F%2525252F%25252522%25252524MY_BUCKET%25252522%2525252Flabs%2525252Flab1.txt%2525250A%2525250A%25252523%252525205.%25252520List%25252520the%25252520bucket%25252520contents%25252520to%25252520view%25252520the%25252520flat%25252520structure%2525250A%25252523%25252520You%25252520will%25252520see%25252520the%25252520actual%25252520object%25252520key%25252520is%25252520%25252522labs%2525252Flab1.txt%25252522%2525250Aaws%25252520s3%25252520ls%25252520s3%2525253A%2525252F%2525252F%25252522%25252524MY_BUCKET%25252522%25252520--recursive%2525250A%2525250A%25252523%252525206.%25252520Clean%25252520up%25252520using%25252520our%25252520toolkit%25252520function%25252520to%25252520prevent%25252520unwanted%25252520AWS%25252520charges%2525250Adelete_bucket_and_contents%25252520%25252522%25252524MY_BUCKET%25252522&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a0aefd2185f4d5961d0d1d7b059ce58/href">https://medium.com/media/6a0aefd2185f4d5961d0d1d7b059ce58/href</a></iframe><p>Your baseline toolkit is ready! Head over to <a href="https://medium.com/@iromathews4/aws-s3-fundamentals-part-2-securing-your-buckets-with-hands-on-cloudshell-f3c84a3c3d85"><strong>[Part 2: Securing Your S3 Buckets]</strong></a> to write secure, maintainable code for managing bucket access and pre-signed URLs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8641269f52c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Does My Bash Script Fail on Line 4? (It’s Probably the Spaces)]]></title>
            <link>https://medium.com/@iromathews4/why-does-my-bash-script-fail-on-line-4-its-probably-the-spaces-c34cc1610afa?source=rss-bc8eaf2deaec------2</link>
            <guid isPermaLink="false">https://medium.com/p/c34cc1610afa</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[bash-script]]></category>
            <dc:creator><![CDATA[Irosh Mathews]]></dc:creator>
            <pubDate>Sat, 07 Feb 2026 08:43:01 GMT</pubDate>
            <atom:updated>2026-02-07T08:43:01.988Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A simple guide to the three invisible rules that break every beginner’s shell script: Brackets, Spaces, and Variables.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTgUjgJy0E2EJUX5babYHg.png" /></figure><p>You’ve been there. You write a simple script to back up a folder or launch a project. It looks perfect. You run it, and the terminal screams at you:</p><p>bash: syntax error near unexpected token &#39;then&#39; or [: missing &#39;]&#39;</p><p>You stare at the code. You add a space. It breaks. You remove a space. It breaks differently.</p><p>Welcome to Bash scripting.</p><p>Unlike modern languages like Python or JavaScript, Bash is old. It has strict, sometimes invisible rules about spaces, brackets, and quotes. If you’ve ever wondered why x=10 works but x = 10 fails, or why we sometimes use (( )) and sometimes [[ ]], this guide is for you.</p><p>Let’s decode the logic.</p><h3>Mystery #1: The Battle of the Brackets</h3><p>The most common confusion is knowing which brackets to use. In modern Bash, we really only care about two main types: The <strong>Logician</strong> and the <strong>Mathematician</strong>.</p><h4>1. The Logician: [[ ... ]]</h4><p>Use double square brackets when you are asking a question about <strong>Text (Strings)</strong> or <strong>Files</strong>.</p><ul><li><em>Does this file exist?</em></li><li><em>Is this password correct?</em></li></ul><p><strong>The Rule:</strong> You <strong>must</strong> put spaces inside the brackets.</p><pre># Correct<br>if [[ -f &quot;file.txt&quot; ]]; then ...<br><br># Wrong (Bash will panic)<br>if [[-f &quot;file.txt&quot;]]; then ...</pre><h4>2. The Mathematician: (( ... ))</h4><p>Use double parentheses when you are doing <strong>Math</strong> (Integers).</p><ul><li><em>Is the counter less than 10?</em></li><li><em>Add 1 to the score.</em></li></ul><p><strong>The Rule:</strong> Spaces don’t matter here! You can squish it all together</p><pre># All of these work in Math Mode<br>((a=5))<br>(( a = 5 ))<br>((a++))</pre><h3>Mystery #2: The “Space” Dilemma</h3><p>Why does Bash hate spaces sometimes and demand them other times? It comes down to one question: <strong>Are you assigning a value, or comparing it?</strong></p><h4>Assignment (No Spaces Allowed)</h4><p>When you want to set a variable, you are gluing a name to a value. No gaps allowed.</p><pre>name=&quot;Bob&quot;      # Good.<br>name = &quot;Bob&quot;    # Bad. Bash thinks &#39;name&#39; is a command you are trying to run.</pre><h4>Comparison (Spaces Required)</h4><p>When you are inside [[ ... ]], the symbols == or = or != are operators. They need breathing room.</p><pre>if [[ &quot;$name&quot; == &quot;Bob&quot; ]]; then ...   # Good.<br>if [[ &quot;$name&quot;==&quot;Bob&quot; ]]; then ...     # Bad. Bash sees one long string.</pre><h3>Mystery #3: To $ or Not to $?</h3><p>Sometimes you see var, sometimes $var, and sometimes &quot;$var&quot;. It feels random, but there is a logic to it.</p><h4>No Dollar Sign (var)</h4><p>Use this only when you are <strong>writing</strong> to the box.</p><pre>score=0</pre><h4>With Dollar Sign ($var)</h4><p>Use this when you are <strong>reading</strong> the value from the box.</p><pre>echo $score</pre><h4>With Quotes (&quot;$var&quot;)</h4><p>This is the safety belt. In Bash, a space usually means “start a new command.” If your filename is My Cool Script.sh and you forget the quotes, Bash sees two separate files: My and Cool.</p><blockquote><strong>The Exception:</strong> Inside the Mathematician (( ... )), Bash is smart enough to know you are dealing with numbers, so the $ is optional.(( score = score + 1 )) works perfectly!</blockquote><pre>file=&quot;My Cool Script.sh&quot;</pre><pre># DANGEROUS:<br>if [[ -f $file ]]; ... # Bash reads: if [[ -f My Cool Script.sh ]] -&gt; ERROR</pre><pre># SAFE:<br>if [[ -f &quot;$file&quot; ]]; ... # Bash reads: if [[ -f &quot;My Cool Script.sh&quot; ]] -&gt; SUCCESS</pre><h3>Summary: The “It Works” Checklist</h3><p>Next time your script fails, check these three things first:</p><p><strong>Are you doing Math or Logic?</strong></p><ul><li>Math (( ... )) uses symbols like &lt; &gt;.</li><li>Logic [[ ... ]] uses flags like -lt -gt.</li></ul><p><strong>Are you Setting or Asking?</strong></p><ul><li>Setting var=val (No spaces).</li><li>Asking [[ $var == val ]] (Spaces required).</li></ul><p><strong>Are you Quoting?</strong></p><p>When in doubt, quote your variables: &quot;$var&quot;.</p><p>Happy scripting! May your exit codes always be 0.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c34cc1610afa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>