<?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"><channel><title><![CDATA[Building a Secure VPC Architecture on AWS Using Terraform]]></title><description><![CDATA[Building a Secure VPC Architecture on AWS Using Terraform]]></description><link>https://threeasignment.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 30 Oct 2026 08:31:05 GMT</lastBuildDate><atom:link href="https://threeasignment.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Building a Secure VPC Architecture on AWS Using Terraform]]></title><description><![CDATA[Github repo: When applications move to the cloud, security becomes just as important as availability and scalability. One of the biggest mistakes beginners…]]></description><link>https://threeasignment.hashnode.dev/building-a-secure-vpc-architecture-on-aws-using-terraform</link><guid isPermaLink="true">https://threeasignment.hashnode.dev/building-a-secure-vpc-architecture-on-aws-using-terraform</guid><dc:creator><![CDATA[Muhammad Hashim]]></dc:creator><pubDate>Thu, 30 Apr 2026 07:33:51 GMT</pubDate><content:encoded><![CDATA[<p><strong>Github repo:</strong> <a href="https://github.com/HashimZaffar/Asignment-3">https://github.com/HashimZaffar/Asignment-3</a></p>
<p>When applications move to the cloud, security becomes just as important as availability and scalability. One of the biggest mistakes beginners make is exposing everything to the internet. In real-world cloud environments, sensitive systems are never directly accessible.</p>
<p>In this project, I built a <strong>secure VPC architecture on AWS using Terraform</strong>, following best practices like private subnets, Bastion Host access, NAT Gateway routing, and restrictive security groups.</p>
<p>This is a <strong>portfolio-level DevOps project</strong> that demonstrates how secure cloud networking is actually designed in production environments.</p>
<hr />
<h1>Project Objective</h1>
<p>The goal of this assignment was to design a secure architecture with:</p>
<ul>
<li><p>Public and private subnets</p>
</li>
<li><p>NAT Gateway for outbound internet access</p>
</li>
<li><p>Bastion Host for controlled SSH access</p>
</li>
<li><p>Private EC2 instances (not publicly exposed)</p>
</li>
<li><p>Restrictive security groups</p>
</li>
<li><p>Clearly defined traffic flow</p>
</li>
</ul>
<p>The main idea is simple:</p>
<blockquote>
<p><strong>Nothing sensitive should be directly accessible from the internet.</strong></p>
</blockquote>
<hr />
<h1>What Problem Are We Solving?</h1>
<p>A basic setup might look like this:</p>
<pre><code class="language-text">Internet → EC2 Instance
</code></pre>
<p>This is risky because:</p>
<ul>
<li><p>Anyone can try to access your server</p>
</li>
<li><p>SSH may be exposed</p>
</li>
<li><p>Attack surface is large</p>
</li>
</ul>
<p>Instead, we design a secure architecture:</p>
<pre><code class="language-text">Internet
   ↓
Bastion Host (Public Subnet)
   ↓
Private EC2 Instances (Private Subnets)
</code></pre>
<p>Now:</p>
<ul>
<li><p>Only the Bastion Host is exposed</p>
</li>
<li><p>Private servers are hidden</p>
</li>
<li><p>Access is controlled</p>
</li>
</ul>
<hr />
<h1>High-Level Architecture</h1>
<pre><code class="language-text">Internet
   ↓
Internet Gateway
   ↓
Public Subnet (Bastion Host)
   ↓
Private Subnets (EC2 Instances)
   ↓
NAT Gateway (Outbound only)
   ↓
Internet
</code></pre>
<hr />
<h1>Project Structure</h1>
<p>The project follows a modular Terraform design:</p>
<pre><code class="language-text">Asignment-3/
├── modules/
│   ├── network/
│   ├── security/
│   └── compute/
└── environments/
    └── dev/
</code></pre>
<p>This structure is important because:</p>
<ul>
<li><p>Modules = reusable components</p>
</li>
<li><p>Environments = separate configurations</p>
</li>
</ul>
<p>This is how real DevOps teams organize infrastructure code.</p>
<hr />
<h1>Core Concepts Explained (Simple Words)</h1>
<h2>VPC (Virtual Private Cloud)</h2>
<p>A VPC is your private network in AWS.</p>
<p>Think of it like your company’s internal network, but in the cloud.</p>
<hr />
<h2>Public vs Private Subnets</h2>
<h3>Public Subnet</h3>
<ul>
<li><p>Connected to the internet</p>
</li>
<li><p>Resources can have public IPs</p>
</li>
</ul>
<p>In this project:</p>
<pre><code class="language-text">Bastion Host lives here
</code></pre>
<hr />
<h3>Private Subnet</h3>
<ul>
<li><p>Not directly accessible from the internet</p>
</li>
<li><p>No public IPs</p>
</li>
</ul>
<p>In this project:</p>
<pre><code class="language-text">Application EC2 instances live here
</code></pre>
<hr />
<h2>Internet Gateway</h2>
<p>Internet Gateway connects your VPC to the internet.</p>
<p>Without it, nothing inside the VPC can talk to the outside world.</p>
<hr />
<h2>NAT Gateway</h2>
<p>NAT Gateway is one of the most important concepts.</p>
<p>It allows:</p>
<pre><code class="language-text">Private EC2 → Internet (allowed)
Internet → Private EC2 (blocked)
</code></pre>
<p>So private servers can:</p>
<ul>
<li><p>Install packages</p>
</li>
<li><p>Download updates</p>
</li>
</ul>
<p>But cannot be accessed directly from outside.</p>
<hr />
<h2>Bastion Host (Jump Server)</h2>
<p>A Bastion Host is a secure entry point.</p>
<p>Instead of connecting directly to private EC2, you do:</p>
<pre><code class="language-text">Your Laptop → Bastion → Private EC2
</code></pre>
<p>This ensures:</p>
<ul>
<li><p>Only one controlled entry point</p>
</li>
<li><p>Better auditing and logging</p>
</li>
<li><p>Reduced attack surface</p>
</li>
</ul>
<hr />
<h2>Security Groups (Firewall)</h2>
<p>Security groups control traffic.</p>
<p>In this project:</p>
<h3>Bastion Host:</h3>
<pre><code class="language-text">Allow SSH only from your IP
</code></pre>
<h3>Private EC2:</h3>
<pre><code class="language-text">Allow SSH only from Bastion Host
</code></pre>
<p>This is called <strong>restrictive security design</strong>.</p>
<hr />
<h1>Terraform Implementation Overview</h1>
<p>This project uses three main modules:</p>
<h2>1. Network Module</h2>
<p>Creates:</p>
<ul>
<li><p>VPC</p>
</li>
<li><p>Public subnets</p>
</li>
<li><p>Private subnets</p>
</li>
<li><p>Internet Gateway</p>
</li>
<li><p>NAT Gateway</p>
</li>
<li><p>Route tables</p>
</li>
</ul>
<p>This defines how traffic flows inside the network.</p>
<hr />
<h2>2. Security Module</h2>
<p>Creates:</p>
<ul>
<li><p>Bastion security group</p>
</li>
<li><p>Private EC2 security group</p>
</li>
</ul>
<p>Key idea:</p>
<pre><code class="language-text">Private EC2 does NOT allow SSH from internet
Only from Bastion
</code></pre>
<hr />
<h2>3. Compute Module</h2>
<p>Creates:</p>
<ul>
<li><p>Bastion Host (public)</p>
</li>
<li><p>Private EC2 instances</p>
</li>
</ul>
<p>Private EC2 instances:</p>
<ul>
<li><p>No public IP</p>
</li>
<li><p>Fully isolated</p>
</li>
</ul>
<hr />
<h1>Traffic Flow Explained (Most Important Part)</h1>
<h2>1. Admin Access Flow</h2>
<pre><code class="language-text">Admin Laptop
   ↓ SSH
Bastion Host
   ↓ SSH
Private EC2
</code></pre>
<p>Explanation:</p>
<ul>
<li><p>You cannot directly SSH into private EC2</p>
</li>
<li><p>You must go through Bastion</p>
</li>
</ul>
<hr />
<h2>2. Internet Access from Private EC2</h2>
<pre><code class="language-text">Private EC2
   ↓
NAT Gateway
   ↓
Internet
</code></pre>
<p>Explanation:</p>
<ul>
<li><p>Private EC2 can download updates</p>
</li>
<li><p>But cannot be accessed from outside</p>
</li>
</ul>
<hr />
<h2>3. Public Internet Access</h2>
<pre><code class="language-text">Internet → Bastion Host only
</code></pre>
<p>Explanation:</p>
<ul>
<li><p>Only Bastion is exposed</p>
</li>
<li><p>Everything else is protected</p>
</li>
</ul>
<hr />
<h1>Deployment Steps</h1>
<p>Run Terraform:</p>
<pre><code class="language-bash">cd environments/dev

terraform init
terraform fmt -recursive
terraform validate
terraform plan
terraform apply
</code></pre>
<p>After deployment, you get:</p>
<ul>
<li><p>Bastion public IP</p>
</li>
<li><p>Private EC2 private IPs</p>
</li>
</ul>
<hr />
<h1>SSH Access</h1>
<p>Step 1: Connect to Bastion</p>
<pre><code class="language-bash">ssh -i your-key.pem ubuntu@&lt;bastion-ip&gt;
</code></pre>
<p>Step 2: Connect to Private EC2</p>
<pre><code class="language-bash">ssh ubuntu@&lt;private-ip&gt;
</code></pre>
<p>Better approach:</p>
<pre><code class="language-bash">ssh -A -i your-key.pem ubuntu@&lt;bastion-ip&gt;
</code></pre>
<hr />
<h1>Why This Architecture is Important</h1>
<p>This design is used in real-world production systems.</p>
<p>It provides:</p>
<ul>
<li><p>Isolation of sensitive systems</p>
</li>
<li><p>Controlled access</p>
</li>
<li><p>Reduced exposure to internet</p>
</li>
<li><p>Better compliance and auditing</p>
</li>
</ul>
<hr />
<h1>DevSecOps Thinking</h1>
<p>To make this even stronger:</p>
<ul>
<li><p>Restrict SSH to your IP (not 0.0.0.0/0)</p>
</li>
<li><p>Use AWS SSM instead of Bastion</p>
</li>
<li><p>Enable VPC flow logs</p>
</li>
<li><p>Use IAM roles instead of static credentials</p>
</li>
<li><p>Add monitoring and alerting</p>
</li>
</ul>
<hr />
<h1>What This Project Demonstrates</h1>
<p>This project proves that you understand:</p>
<ul>
<li><p>Secure AWS network design</p>
</li>
<li><p>Public vs private architecture</p>
</li>
<li><p>NAT Gateway usage</p>
</li>
<li><p>Bastion Host pattern</p>
</li>
<li><p>Terraform modular structure</p>
</li>
<li><p>Infrastructure as Code</p>
</li>
<li><p>Cloud security basics</p>
</li>
</ul>
<p>This is not a beginner-level project.</p>
<p>This is <strong>real-world cloud architecture knowledge</strong>.</p>
<hr />
<h1>Conclusion</h1>
<p>This assignment shows that cloud infrastructure is not just about launching servers. It is about designing systems that are secure, controlled, and scalable.</p>
<p>By using Terraform, we made the infrastructure:</p>
<ul>
<li><p>Reproducible</p>
</li>
<li><p>Version-controlled</p>
</li>
<li><p>Automated</p>
</li>
</ul>
<p>And by using proper AWS architecture, we made it:</p>
<ul>
<li><p>Secure</p>
</li>
<li><p>Isolated</p>
</li>
<li><p>Production-ready</p>
</li>
</ul>
<p>In simple words:</p>
<blockquote>
<p><strong>We built a cloud network where everything important is protected, and access is tightly controlled, exactly how real systems should be designed.</strong></p>
</blockquote>
]]></content:encoded></item></channel></rss>