<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Haris</title>
    <description>The latest articles on DEV Community by Muhammad Haris (@muhammad_haris_4b47c67e8d).</description>
    <link>https://dev.to/muhammad_haris_4b47c67e8d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4144931%2F0f11ecf7-2474-40ea-9925-e6dd7c2850e6.jpg</url>
      <title>DEV Community: Muhammad Haris</title>
      <link>https://dev.to/muhammad_haris_4b47c67e8d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhammad_haris_4b47c67e8d"/>
    <language>en</language>
    <item>
      <title>Building Production-Grade AWS Infrastructure: From EC2 Guardrails and EBS Recovery to S3 Lifecycle and Route 53</title>
      <dc:creator>Muhammad Haris</dc:creator>
      <pubDate>Sat, 26 Sep 2026 23:51:25 +0000</pubDate>
      <link>https://dev.to/muhammad_haris_4b47c67e8d/building-production-grade-aws-infrastructure-from-ec2-guardrails-and-ebs-recovery-to-s3-lifecycle-335m</link>
      <guid>https://dev.to/muhammad_haris_4b47c67e8d/building-production-grade-aws-infrastructure-from-ec2-guardrails-and-ebs-recovery-to-s3-lifecycle-335m</guid>
      <description>&lt;p&gt;Hey Developers! 👋&lt;br&gt;
Most cloud tutorials stop at launching a single virtual machine or uploading an index.html file into an open storage bucket. But in a real-world enterprise environment, running infrastructure that is actually reliable demands operational guardrails, decoupled storage, immutable baselines, and automated data recovery.&lt;/p&gt;

&lt;p&gt;Over the past few weeks, I built an end-to-end cloud environment on Amazon Web Services (AWS) to understand not just how services run, but how to protect them from human error, configuration drift, and data loss.&lt;/p&gt;

&lt;p&gt;Here is a complete, structured guide covering everything from baseline setup to advanced resilience across Amazon EC2, Amazon EBS, Amazon S3, and Amazon Route 53.&lt;/p&gt;

&lt;p&gt;(Prefer a high-level architectural walkthrough? Check out my companion deep dive on Medium: [INSERT_YOUR_MEDIUM_LINK_HERE])&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Amazon Elastic Compute Cloud (Amazon EC2) &amp;amp; Amazon Elastic Block Store (Amazon EBS)
In modern cloud architecture, compute instances should be treated as ephemeral and disposable, while persistent application state must remain protected and decoupled.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;[User Data Script] ──&amp;gt; [Hardened Security Group] ──&amp;gt; [AMI Creation]&lt;br&gt;
        │                                                    │&lt;br&gt;
        ▼                                                    ▼&lt;br&gt;
[Termination &amp;amp; Stop Protection] ──&amp;gt; [EBS Snapshots] ──&amp;gt; [Launch Template]&lt;br&gt;
Step 1: Automated Bootstrapping via User Data&lt;br&gt;
Manually logging into an instance to install dependencies introduces human error and creates "pet" servers. Instead, I passed a shell script to the User Data field during launch.&lt;/p&gt;

&lt;p&gt;When the Amazon Linux instance boots for the first time, cloud-init runs the script to update the system, install Apache (httpd), start the daemon, and generate a dynamic landing page:&lt;/p&gt;

&lt;p&gt;Bash&lt;/p&gt;

&lt;h1&gt;
  
  
  !/bin/bash
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Update repository packages
&lt;/h1&gt;

&lt;p&gt;yum update -y&lt;/p&gt;

&lt;h1&gt;
  
  
  Install and activate Apache HTTP Server
&lt;/h1&gt;

&lt;p&gt;yum install -y httpd&lt;br&gt;
systemctl start httpd&lt;br&gt;
systemctl enable httpd&lt;/p&gt;

&lt;h1&gt;
  
  
  Deploy health endpoint
&lt;/h1&gt;

&lt;p&gt;echo "&lt;/p&gt;
&lt;h1&gt;Instance Active: Deployed via Automated User Data&lt;/h1&gt;" &amp;gt; /var/www/html/index.html&lt;br&gt;
Step 2: Access Perimeter &amp;amp; Static Networking&lt;br&gt;
Security Groups: Configured virtual firewalls on least-privilege principles. Inbound HTTP (port 80) is open to web traffic, while SSH (port 22) is strictly restricted to trusted administrative IP addresses rather than open to the world (0.0.0.0/0).

&lt;p&gt;Elastic IP Addresses: Associated a dedicated Elastic IP to keep public access endpoints fixed across planned reboots and maintenance cycles.&lt;/p&gt;

&lt;p&gt;Step 3: Operational Guardrails (Stop &amp;amp; Termination Protection)&lt;br&gt;
Accidental deletions and unplanned reboots are major causes of production downtime:&lt;/p&gt;

&lt;p&gt;Termination Protection: Enabled termination protection on primary instances. Any termination request initiated via the AWS Console, AWS CLI, or automated API call is immediately rejected until the flag is explicitly toggled off.&lt;/p&gt;

&lt;p&gt;Stop Protection: Turned on stop protection to prevent accidental shutdowns during routine operational work.&lt;/p&gt;

&lt;p&gt;Vertical Scaling: Practiced safe lifecycle management—stopping workloads, changing instance types to adjust CPU and memory capacity, and restarting without losing underlying configurations.&lt;/p&gt;

&lt;p&gt;Step 4: Storage Decoupling &amp;amp; Disaster Recovery (Amazon EBS)&lt;br&gt;
Compute instances can be destroyed without warning, so persistent data must live independently:&lt;/p&gt;

&lt;p&gt;Dynamic Volume Management: Attached secondary Amazon Elastic Block Store (Amazon EBS) volumes, formatted file systems, and performed hot storage expansions on the fly without unmounting.&lt;/p&gt;

&lt;p&gt;Volume Migration: Tested storage portability by unmounting an EBS volume from one instance and attaching it to another, proving that application state survives compute replacement.&lt;/p&gt;

&lt;p&gt;Snapshot Backups: Captured point-in-time snapshots of live EBS volumes. To test disaster recovery, I provisioned brand-new, mountable volumes directly from these snapshots in alternate Availability Zones—a crucial defense pattern against disk corruption and ransomware.&lt;/p&gt;

&lt;p&gt;Step 5: Golden Images &amp;amp; Launch Templates&lt;br&gt;
To eliminate manual setup forever:&lt;/p&gt;

&lt;p&gt;Custom AMIs (Amazon Machine Images): Converted the fully configured and patched instance into a custom AMI, locking down the operating system and dependencies into an immutable blueprint.&lt;/p&gt;

&lt;p&gt;Launch Templates: Codified all instance settings—including AMI selection, instance type, key pairs, and security groups—into a version-controlled Launch Template. Spinning up an identical, pre-audited node now takes seconds.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Amazon Simple Storage Service (Amazon S3)
Amazon S3 is a globally distributed object store with powerful tools for governance, cost control, and high availability.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 1: Serverless Static Website Hosting &amp;amp; Scoped Policies&lt;br&gt;
Running a dedicated EC2 instance to serve basic HTML and CSS is inefficient. Using an S3 bucket configured for Static Website Hosting eliminates server maintenance.&lt;/p&gt;

&lt;p&gt;To allow public website access safely without exposing private bucket settings, I wrote a surgical JSON Bucket Policy granting s3:GetObject strictly to the web root:&lt;/p&gt;

&lt;p&gt;JSON&lt;br&gt;
{&lt;br&gt;
  "Version": "2012-10-17",&lt;br&gt;
  "Statement": [&lt;br&gt;
    {&lt;br&gt;
      "Sid": "PublicWebsiteReadAccess",&lt;br&gt;
      "Effect": "Allow",&lt;br&gt;
      "Principal": "&lt;em&gt;",&lt;br&gt;
      "Action": "s3:GetObject",&lt;br&gt;
      "Resource": "arn:aws:s3:::your-bucket-name/&lt;/em&gt;"&lt;br&gt;
    }&lt;br&gt;
  ]&lt;br&gt;
}&lt;br&gt;
Step 2: Accidental Deletion Defense (Bucket Versioning)&lt;br&gt;
Enabled Bucket Versioning across the bucket. When files are overwritten or deleted, AWS retains prior revisions under unique version IDs. Accidental deletes only add a removable "delete marker," allowing instant restoration and preventing accidental data loss.&lt;/p&gt;

&lt;p&gt;Step 3: Automated Cost Governance (Lifecycle Rules &amp;amp; Storage Classes)&lt;br&gt;
Leaving all objects in hot storage permanently causes unnecessary cloud spend. I implemented automated Lifecycle Rules that systematically transition data across storage classes based on access frequency:&lt;/p&gt;

&lt;p&gt;S3 Standard: Ingestion and hot access for active daily assets.&lt;/p&gt;

&lt;p&gt;S3 Standard-Infrequent Access (S3 Standard-IA): Moves objects older than 30 days to a lower storage rate while maintaining rapid retrieval times.&lt;/p&gt;

&lt;p&gt;S3 Glacier Flexible Deep Archive: Shifts older audit logs and backups (90+ days) to deep cold storage.&lt;/p&gt;

&lt;p&gt;Automated Expiration: Permanently purges stale data once retention mandates expire.&lt;/p&gt;

&lt;p&gt;Step 4: Geographic Redundancy (Cross-Region Replication)&lt;br&gt;
To prepare for regional disasters, I configured S3 Replication Rules paired with an IAM role. Every versioned object written to the primary bucket is automatically and asynchronously copied to a replica bucket in an independent AWS region.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Amazon Route 53
A resilient backend requires a dependable, low-latency domain routing setup:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set up a Public Hosted Zone in Amazon Route 53 to manage DNS authoritative records.&lt;/p&gt;

&lt;p&gt;Created Alias (A) Records routing root domain queries directly to the Amazon S3 static website endpoint.&lt;/p&gt;

&lt;p&gt;Unlike standard CNAMEs, Route 53 Alias records resolve internally within AWS's network infrastructure, providing built-in health monitoring, lower latency, and seamless domain routing.&lt;/p&gt;

&lt;p&gt;Key Takeaways for Cloud &amp;amp; DevOps Engineers&lt;br&gt;
Guardrails prevent downtime: Turning on Termination Protection, Stop Protection, and EBS snapshots prevents routine human mistakes from escalating into major outages.&lt;/p&gt;

&lt;p&gt;Immutability beats manual patching: Using User Data, custom AMIs, and Launch Templates ensures systems deploy identically and reliably every time.&lt;/p&gt;

&lt;p&gt;Storage requires intentional defense: Scoped Bucket Policies, Bucket Versioning, Lifecycle Rules, and Cross-Region Replication together solve security, compliance, disaster recovery, and cost governance.&lt;/p&gt;

&lt;p&gt;What Are You Building?&lt;br&gt;
What backup or image-management strategies do you rely on in production? Drop your thoughts, questions, or experiences in the comments below!&lt;/p&gt;

&lt;p&gt;🤝 Let's connect on LinkedIn: &lt;br&gt;
&lt;a href="http://www.linkedin.com/in/muhammad-haris-redteam" rel="noopener noreferrer"&gt;www.linkedin.com/in/muhammad-haris-redteam&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>devops</category>
      <category>cybersecurity</category>
    </item>
  </channel>
</rss>
