<?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 Saksham Singh on Medium]]></title>
        <description><![CDATA[Stories by Saksham Singh on Medium]]></description>
        <link>https://medium.com/@sakshamsingh8784?source=rss-a637b37f059a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3NuhUlFaYndlTNQCRd11Fw.jpeg</url>
            <title>Stories by Saksham Singh on Medium</title>
            <link>https://medium.com/@sakshamsingh8784?source=rss-a637b37f059a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 16:52:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sakshamsingh8784/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[Kubernetes Architecture]]></title>
            <link>https://medium.com/@sakshamsingh8784/kubernetes-architecture-d901486782a8?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d901486782a8</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[sre]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 09:33:36 GMT</pubDate>
            <atom:updated>2026-04-15T09:34:22.490Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re diving into <strong>Cloud, DevOps, or Kubernetes</strong>, understanding <strong>Kubernetes</strong> architecture is a must. But let’s be honest — most explanations feel too robotic or overly complex.</p><p>So in this blog, I’ll break down <strong>Kubernetes architecture in a clean, practical, and beginner-friendly way</strong>.</p><h3>What is a Kubernetes Cluster?</h3><p>At its core, Kubernetes is all about managing containers across multiple machines.</p><p>A <strong>Kubernetes Cluster</strong> = <em>a group of machines working together to run applications.</em></p><p>It consists of:</p><ul><li>🧠 <strong>Control Plane (Master Node)</strong> → Brain of the system</li><li>💪 <strong>Worker Nodes</strong> → Where your apps actually run</li></ul><p>A <strong>Kubernetes Cluster</strong> is simply:</p><blockquote><em>Multiple machines working together to run containerized applications efficiently</em></blockquote><h3>K8S architecture</h3><p>Kubernetes comes with a <strong>client-server</strong> architecture. It consists of <strong>master</strong> and <strong>worker nodes</strong>, with the master being installed on a single or multiple Linux system and the nodes on many Linux workstations. The master node, contains the components such as <strong>API Server</strong>, <strong>controller manager</strong>, <strong>scheduler</strong>, and <strong>etcd database</strong> for state storage. <strong>kubelet</strong> to communicate with the master, the <strong>kube-proxy</strong> for networking, and a container runtime such as <strong>Docker</strong> to manage containers.</p><h3>Kubernetes Components</h3><p><strong>Kubernetes</strong> is composed of a number of components, each of which plays a specific role in the overall system. These components can be divided into two categories:</p><p><strong>Kubernetes</strong> follows a <strong>control–execution model</strong>:</p><p><strong><em>Control Plane</em></strong> <strong>→</strong> Decides &amp; Manages</p><p><strong><em>Worker Nodes</em></strong> <strong>→</strong> Execute Workloads</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JZ3MZXSgiCC6CozP.jpg" /></figure><h3>1. Control Plane</h3><p>The <strong>Control Plane</strong> is responsible for <strong>managing the entire cluster</strong>.<br>It <strong>does not run application containers</strong> — it makes decisions and enforces the desired state.</p><h3>Main Components of the Control Plane</h3><h4>1️⃣ API Server (kube-apiserver)</h4><p>The Kubernetes API server (kube-apiserver) is the frontend of the Kubernetes control plane and the central management entity of the entire cluster. It exposes the Kubernetes API, which is a RESTful API over HTTP, and all internal and external components communicate with the cluster through this single, consistent interface.</p><p>If API Server is down → cluster cannot be managed</p><p><strong>Kubernetes</strong> <strong>API Server</strong> is the <strong>central communication hub</strong> of the cluster.</p><blockquote>📌 <strong>All communication in Kubernetes happens through the API Server.</strong></blockquote><h4><strong>The API Server handles communication between:</strong></h4><p><strong>🔹 Clients → Cluster</strong></p><ul><li>kubectl</li><li>Jenkins / CI-CD</li><li>Kubernetes Dashboard</li><li>REST API calls</li></ul><p><em>kubectl → API Server</em></p><p><strong>🔹 Control Plane Components</strong></p><ul><li>Scheduler</li><li>Controller Manager</li><li>etcd</li></ul><p><strong><em>Scheduler ↔ API Server ↔ etcd</em></strong></p><p><strong>🔹 Worker Nodes → Control Plane</strong></p><ul><li>kubelet reports pod status</li><li>Node health updates</li></ul><p><strong><em>kubelet → API Server</em></strong></p><p>📌 <strong>Components never talk to each other directly</strong> — everything goes through the API Server.</p><p><strong>🔐 Security Perspective</strong></p><ul><li>API Server exposure = major attack surface</li><li>Needs:</li><li>TLS</li><li>Authentication</li><li>RBAC</li><li>Network restrictions</li></ul><p><em>Many real-world Kubernetes breaches start with </em><strong><em>exposed API servers</em></strong><em>.</em></p><h4>2️⃣ Scheduler (kube-scheduler)</h4><p>When API Server receives a request for Scheduling Pods then the request is passed on to the Scheduler. It intelligently <strong>decides on which node to schedule the pod</strong> for better efficiency of the cluster.</p><p><strong><em>📌 Scheduler assigns pods, it does NOT run them</em></strong></p><h4>3️⃣ Controller Manager (kube-controller-manager)</h4><p>In <strong>Kubernetes</strong>, the <strong>Controller Manager</strong> is responsible for <strong>continuously ensuring that the cluster’s<em> actual state matches the desired state</em></strong><em> </em>— in other words, it makes sure <strong>everything keeps working as expected</strong>.</p><p><strong>Example:</strong></p><p>Desired pods = 3</p><p>Actual pods = 2</p><p>→ Controller creates 1 new pod</p><p>✔ This is where <strong>self-healing</strong> happens</p><h4>4️⃣ etcd (Cluster Database: for state storage)</h4><ul><li>Distributed <strong>key-value store</strong></li><li>Stores:</li><li>Cluster state</li><li>Pods, Services</li><li>Secrets &amp; ConfigMaps</li><li>RBAC policies</li></ul><p><strong>Role of Control Plane (Summary)</strong></p><p>✔ Manages cluster state<br> ✔ Makes scheduling decisions<br> ✔ Handles failures automatically<br> ✔ Enforces policies &amp; security</p><h3>2. 🧑‍🏭 Worker Node (Execution Engine)</h3><p>A <strong>Worker Node</strong> is where:</p><ul><li>Application containers actually run</li><li>Pods are executed</li><li>Traffic is handled</li></ul><p>A cluster can have <strong>many worker nodes</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*MnVX6W1c0D7gXduv.png" /></figure><p><strong>1️⃣ kubelet</strong></p><p>An agent on each node that ensures containers in Pods are running and healthy, communicating with the control plane.</p><ul><li><strong>Responsibilities:</strong></li><li>Create pods</li><li>Start containers</li><li>Monitor health</li><li>Report status</li></ul><p>📌 If kubelet stops → pods on that node fail</p><h4>2️⃣ Container Runtime</h4><p>Software (like containerd, CRI-O, Docker Engine) responsible for running containers, interacting with the Kubelet.</p><ul><li>Runs containers inside pods</li><li><strong>Examples:</strong></li><li>Docker</li><li>containerd</li><li>CRI-O</li></ul><p><em>📌 Kubernetes talks to runtime via </em><strong><em>CRI (Container Runtime Interface)</em></strong></p><h4>3️⃣ kube-proxy</h4><p>kube-proxy(a network proxy) is a critical Kubernetes component that runs on every node to manage network rules and enable communication between Pods and Services.</p><ul><li>Handles <strong>networking</strong></li><li>Routes traffic:</li><li>Service → Pod</li><li>Uses iptables / IPVS rules</li></ul><p><strong><em>📌 Without kube-proxy → Services won’t work</em></strong></p><p><strong>4️⃣ Pods</strong></p><p>The smallest deployable units, grouping one or more containers that share resources. <em>Rather than deploying containers directly onto nodes, Kubernetes wraps one or more tightly coupled containers into a Pod, which provides a shared environment and an abstraction layer for the control plane to manage.</em></p><h3>Bottom: CNI Network</h3><p>CNI: Weave Net, Calico, etc.</p><ul><li>Provides pod-to-pod networking</li><li>Every pod gets its own IP</li><li>Enables communication across nodes</li></ul><p><strong><em>📌 Kubernetes networking is plugin-based</em></strong></p><h3>Kubernetes — Kubectl</h3><p>Kubectl is <strong>command-line</strong> software that helps to run commands in the Kubernetes Cluster. It acts as a bridge between clients and the Kubernetes cluster providing communication through API requests using http or https protocols. It converts the commands entered in the command line from a user into API requests and passes them to the API server of the Kubernetes master Node with proper Authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/0*aWYjxIR_dlwiHIL2.png" /></figure><h3>🔗 Connect With Me</h3><p>If you found this article helpful or have any questions about <strong>AWS, cloud architecture, or DevOps</strong>, feel free to connect with me.</p><p>💼 <strong>LinkedIn:</strong><br><a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/"><strong>https://www.linkedin.com/in/saksham-singh-aa31ba271/</strong></a></p><p>💻 <strong>GitHub:</strong><br><a href="https://github.com/Saksham8784"><strong>https://github.com/Saksham8784</strong></a></p><p>I regularly share projects and insights about <strong>DevOPS, Cloud Computing, Cybersecurity, and Infrastructure Engineering</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d901486782a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Production-Ready 3-Tier Web Application Infrastructure on AWS]]></title>
            <link>https://medium.com/@sakshamsingh8784/building-a-production-ready-3-tier-web-application-infrastructure-on-aws-2313db46cd77?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2313db46cd77</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Sat, 07 Mar 2026 05:55:49 GMT</pubDate>
            <atom:updated>2026-03-07T05:55:49.208Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern web applications must be <strong>scalable, secure, and fault tolerant</strong>. As traffic grows, a single server architecture quickly becomes unreliable and difficult to maintain. This is where the <strong>3-Tier Architecture pattern</strong> becomes essential.</p><p>In this article, I’ll walk through how I deployed a <strong>production-ready 3-tier web application infrastructure on AWS</strong> using services like <strong>CloudFront, AWS WAF, EC2, Auto Scaling, Application Load Balancers, and RDS Multi-AZ</strong>.</p><p>This architecture simulates <strong>how real production applications are designed in the cloud</strong> to handle traffic spikes, failures, and security threats while maintaining high availability.</p><h3>What is a 3-Tier Architecture?</h3><p>A <strong>3-Tier Architecture</strong> separates an application into three logical layers:</p><h3>1️⃣ Web Tier (Presentation Layer)</h3><p>Handles incoming user requests and serves the frontend interface.</p><h3>2️⃣ Application Tier (Logic Layer)</h3><p>Processes business logic and backend APIs.</p><h3>3️⃣ Database Tier (Data Layer)</h3><p>Stores and manages application data securely.</p><p>This separation improves:</p><ul><li>Scalability</li><li>Security</li><li>Maintainability</li><li>Fault tolerance</li></ul><h3>Architecture Diagram</h3><p>The architecture works as follows:</p><p>1️⃣ Users access the application through <strong>Amazon CloudFront and AWS WAF</strong>, which filter and distribute incoming traffic to an <strong>external Application Load Balancer</strong> within an AWS VPC.</p><p>2️⃣ The <strong>web tier</strong> runs EC2 instances in public subnets and forwards API requests to the <strong>application tier</strong> through an <strong>internal load balancer</strong>.</p><p>3️⃣ The <strong>application tier</strong> runs backend services in private subnets and securely connects to a <strong>highly available Amazon RDS database deployed across multiple Availability Zones</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6BYYiJVhwxQriWc1Hvvzw.gif" /></figure><h3>Architecture Overview</h3><p>This project demonstrates the deployment of a <strong>highly available 3-Tier Web Application Architecture on AWS</strong> designed for scalability, security, and fault tolerance.</p><p>The architecture consists of three layers:</p><ul><li><strong>Web Tier</strong></li><li><strong>Application Tier</strong></li><li><strong>Database Tier</strong></li></ul><p>User requests are first handled by <strong>Amazon CloudFront and AWS WAF</strong>, which filter and distribute incoming traffic to an <strong>external Application Load Balancer</strong> that routes requests to web servers running on <strong>EC2 instances in public subnets</strong>.</p><p>The web tier communicates with the <strong>application tier running Node.js on EC2 instances in private subnets</strong>, where the backend processes business logic.</p><p>The application tier connects to <strong>Amazon RDS deployed in Multi-AZ private subnets</strong>, ensuring high availability and automatic failover.</p><p>Additional AWS services such as <strong>VPC, IAM, S3, NAT Gateway, and Auto Scaling</strong> are used to build a <strong>secure, scalable, and resilient cloud infrastructure</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eurAuN2oNEw_yiihje9TcQ.png" /><figcaption>Flowchart</figcaption></figure><h3>Technology Stack</h3><h3>☁️ Cloud Platform</h3><ul><li>Amazon Web Services (AWS)</li></ul><h3>🌐 Networking &amp; Infrastructure</h3><ul><li>Amazon VPC</li><li>Public and Private Subnets</li><li>Internet Gateway</li><li>NAT Gateway</li><li>Route Tables</li></ul><h3>🖥️ Compute</h3><ul><li>Amazon EC2</li><li>Auto Scaling Groups</li></ul><h3>⚖️ Load Balancing</h3><ul><li>External Application Load Balancer</li><li>Internal Application Load Balancer</li></ul><h3>🗄️ Database</h3><ul><li>Amazon RDS MySQL (Multi-AZ)</li></ul><h3>📦 Storage</h3><ul><li>Amazon S3</li></ul><h3>🔒 CDN &amp; Security</h3><ul><li>Amazon CloudFront</li><li>AWS WAF</li><li>AWS IAM</li></ul><h3>🧑‍💻 Application Stack</h3><p>Frontend:</p><ul><li>React.js</li></ul><p>Backend:</p><ul><li>Node.js</li><li>PM2 Process Manager</li></ul><p>Web Server:</p><ul><li>Nginx</li></ul><p>Operating System:</p><ul><li>Ubuntu 24.04 LTS</li></ul><p>Version Control:</p><ul><li>Git</li><li>GitHub</li></ul><h3>Steps to reproduce</h3><h3>1️⃣ Create VPC Infrastructure</h3><h3>Create VPC</h3><p>Go to VPC → Create VPC</p><p>Configuration:</p><p>Name: three-tier-vpc<br>IPv4 CIDR: 10.0.0.0/16</p><h3>Create Subnets</h3><p>Create 6 subnets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GAY2DFztPWZdgHNbijLcaQ.png" /></figure><p>Create Internet Gateway</p><p>Go to VPC → Internet Gateway</p><p>Name: three-tier-igw</p><p>Attach to your VPC.</p><h3>Create Route Tables</h3><h3>Public Route Table</h3><p>Routes:</p><p>0.0.0.0/0 → Internet Gateway</p><p>Associate with:</p><p>web-subnet-1<br>web-subnet-2</p><h3>Private Route Table</h3><p>Private subnets will use NAT Gateway.</p><p>Associate:</p><p>app-subnet-1</p><p>app-subnet-2</p><p>db-subnet-1</p><p>db-subnet-2</p><h3>Create NAT Gateway</h3><p>Go to VPC → NAT Gateway</p><p>Create NAT in web-subnet-1</p><p>Allocate Elastic IP</p><p>Then update private route table:</p><p>0.0.0.0/0 → NAT Gateway</p><p>Associate with:</p><p>app-subnet-1</p><p>app-subnet-2</p><p>db-subnet-1</p><p>db-subnet-2</p><h3>2️⃣ Create S3 Bucket + IAM Role</h3><h3>Create S3 Bucket</h3><p>Example name:</p><p>demo-3tier-project-saksham</p><p>Upload repo content.</p><p>Structure should look like:</p><p>application-code/<br>app-tier/<br>web-tier/<br>nginx.conf<br>nginx-Without-SSL.conf</p><p>The Amazon S3 bucket is used to store the application source code and configuration files for the web tier and application tier. Instead of manually copying files to every EC2 instance, the instances can download the code directly from the S3 bucket, making deployment easier and more scalable. It also acts as a central storage location for the project files.</p><h3>Create IAM Role for EC2</h3><p>Go to:</p><p>IAM → Roles → Create Role</p><p>Trusted entity:</p><p>EC2</p><p>Attach policies:</p><p>AmazonS3ReadOnlyAccess<br>AmazonSSMManagedInstanceCore<br>Or<br>AmazonEC2RoleforSSM</p><p>Name:</p><p>EC2-SSM</p><p>We create an IAM Role(EC2-S3-Access-Role) because the Application Tier EC2 instances are in private subnets and need secure access to AWS services like S3 to download the application code.</p><h3>3️⃣ Create Security Groups</h3><p>SG NameInbound RulesPurposesg-alb80 / 443 from 0.0.0.0/0Public Internet-facing Load Balancersg-web80 / 443 from sg-alb onlyWeb tier EC2 instancessg-internal-alb80 / 443 from sg-web onlyInternal Load Balancer between web and app tierssg-app4000 (or app port) from sg-internal-alb onlyInternal application layersg-db3306 (MySQL) or 5432 (Postgres) from sg-app onlyRDS database tier</p><h3>Traffic Flow for now</h3><p>Internet<br>↓<br>Public ALB (sg-alb)<br>↓<br>Web EC2 (sg-web)<br>↓<br>Internal ALB (sg-internal-alb)<br>↓<br>App EC2 (sg-app)<br>↓<br>RDS (sg-db)</p><h3>4️⃣ Create RDS Subnet Group</h3><p>Go to:</p><p>RDS → Subnet Groups → Create DB Subnet Group</p><p>Configuration:</p><p>Name : db-subnet-group<br>VPC : three-tier-vpc<br>Subnets : db-subnet-1, db-subnet-2<br>AZs : ap-south-1a, ap-south-1b (or any two)</p><p>This enables Multi-AZ placement.</p><h3>Create RDS MySQL (Multi-AZ Enabled)</h3><p>Go to:</p><p>RDS → Create Database</p><h3>Engine</h3><p>Engine type : MySQL<br>Version : Default (8.x)</p><h3>Templates</h3><p>Template : Production</p><p>Do NOT choose Free Tier<br>Free Tier does NOT support Multi-AZ.</p><h3>Availability &amp; Durability (IMPORTANT)</h3><p>Deployment option : Multi-AZ DB instance</p><p>AWS will automatically create:</p><ul><li>1 Primary DB</li><li>1 Standby DB (in different AZ)</li></ul><h3>DB Settings</h3><p>DB instance identifier : webapp-db<br>Master username : admin<br>Master password : your-password<br>DB name : webappdb</p><h3>Instance Configuration</h3><p>DB instance class : db.t3.micro (minimum)<br>Storage : gp2 / gp3<br>Storage autoscaling : Enabled</p><h3>Connectivity</h3><p>VPC : three-tier-vpc<br>DB Subnet Group : db-subnet-group<br>Public access : No</p><h3>Security Group</h3><p>Select sg-db</p><h3>Additional Configuration</h3><p>Backup retention : 7 days<br>Deletion protection : Enable</p><h3>Create Database</h3><p>Takes ~8–10 minutes (Multi-AZ is slower).</p><h3>Understand the Endpoint</h3><p>After DB is ready, copy Endpoint:</p><p>Example:</p><p>webapp-db.c380a08uukyc.ap-south-1.rds.amazonaws.com</p><h3>Key Point</h3><ul><li>This endpoint automatically switches to standby during failure</li><li>You DO NOT change anything in app code</li><li>Your NodeJS app remains unaffected</li></ul><h3>Configure Database Connection Settings</h3><h4>Update DbConfig.js (NO CHANGE LOGICALLY)</h4><p>File:</p><p>application-code/app-tier/DbConfig.js<br>This is a simple Node.js configuration file used to store AWS RDS database connection settings.</p><p>module.exports = Object.freeze({<br>DB_HOST : ‘YOUR_RDS_ENDPOINT_rds.amazonaws.com’,<br>DB_USER : ‘admin’,<br>DB_PWD : ‘RDSDB_PASSWORD’,<br>DB_DATABASE : ‘webappdb’<br>});</p><p>Clone Project Repository from GitHub</p><p>Clone the project repository from GitHub to your local system. This repository contains the web tier, application tier, and configuration files required for deployment.</p><p>Navigate into the project directory:</p><p>cd 3TierArchitectureApp</p><p>The repository structure will look like this:</p><p>application-code/</p><p>app-tier/</p><p>web-tier/</p><p>nginx.conf</p><p>nginx-Without-SSL.conf</p><p>Now these files will be uploaded to the S3 bucket so EC2 instances can download them during deployment.</p><p>Upload updated file to S3:</p><p>S3 → application-code/app-tier/<br>Upload the file to s3 in application-code/app-tier/ no need to delete first then upload s3 will automatically remove the old one</p><h3>5️⃣ Create App Tier EC2 Instance</h3><p>Launch instance.</p><p>Configuration:</p><p>AMI: Ubuntu 24.04<br>Instance: t2.micro<br>Subnet: app-subnet-1<br>Auto assign public IP: Disabled<br>Key pair (login): Proceed without a key pair<br>IAM Role: EC2-SSM</p><h3>6️⃣ Configure APP Tier</h3><p>Connect to App tier via SSM Session Manager</p><p>Ubuntu uses apt not yum</p><p>sudo apt update<br>sudo apt install mysql-client -y</p><p>Connect to RDS:</p><p>mysql -h &lt;RDS-ENDPOINT&gt; -u admin -p</p><p>Example:</p><p>mysql -h database-1.xxxxx.ap-south-1.rds.amazonaws.com -u admin -p</p><p>Enter password: your-password (RDS)</p><h3>Create Database</h3><p>CREATE DATABASE webappdb;<br>SHOW DATABASES;<br>USE webappdb;</p><h3>Create Table</h3><p>CREATE TABLE IF NOT EXISTS transactions(<br>id INT NOT NULL AUTO_INCREMENT,<br>amount DECIMAL(10,2),<br>description VARCHAR(100),<br>PRIMARY KEY(id)<br>);</p><h3>Insert Data</h3><p>INSERT INTO transactions (amount, description)<br>VALUES (‘400’, ‘groceries’);</p><p>Check: SELECT * FROM transactions;</p><p>Exit: exit</p><h3>Install NodeJS (Ubuntu)</h3><p>Run:</p><p>curl -o- <a href="https://raw.githubusercontent.com/avizway1/aws%5C_3tier%5C_architecture/main/install.sh">https://raw.githubusercontent.com/avizway1/aws\_3tier\_architecture/main/install.sh</a> | bash</p><p>Then:</p><p>source ~/.bashrc</p><p>Install node:</p><p>nvm install 16<br>nvm use 16</p><p>Check:</p><p>node -v</p><h3>Install PM2</h3><p>npm install -g pm2</p><h3>Install AWS CLI</h3><p>Ubuntu may not have AWS CLI.</p><p>Install:</p><p>sudo apt install awscli -y</p><p>Verify:</p><p>aws — version</p><h3>Download App Code from S3:</h3><p>Example:<br>aws s3 cp s3://demo-3tier-project-saksham/application-code/app-tier/ app-tier — recursive</p><p>Go to directory:</p><p>cd app-tier</p><p>Install dependencies:</p><p>npm install</p><h3>Start Node Application:</h3><p>pm2 start index.js</p><p>Check:</p><p>pm2 status</p><p>Logs:</p><p>pm2 logs</p><p>Enable startup:</p><p>pm2 startup<br>pm2 save</p><h3>Test Application:</h3><p>curl <a href="http://localhost:4000/health">http://localhost:4000/health</a></p><p>Expected output:</p><p>This is the health check</p><h3>7️⃣ Create Internal Load Balancer (App Tier)</h3><p>Create:</p><p>Internal Application Load Balancer</p><p>Listener:</p><p>HTTP : 80</p><p>Target group:</p><p>Protocol: HTTP</p><p>Port: 4000</p><p>Health check: /health</p><p>Attach App Tier instances.</p><h3>Update nginx.conf</h3><p>Open:</p><p>nginx.conf</p><p>Replace:</p><p>proxy_pass <a href="http://[REPLACE-WITH-INTERNAL-LB-DNS]:80/;">http://[REPLACE-WITH-INTERNAL-LB-DNS]:80/;</a></p><p>Example:</p><p>proxy_pass <a href="http://internal-app-alb-xxxxx.ap-south-1.elb.amazonaws.com/">http://internal-app-alb-xxxxx.ap-south-1.elb.amazonaws.com:80/</a>;</p><p>Upload updated file to S3.</p><h3>8️⃣ Create Web Tier EC2</h3><p>Launch instance:</p><p>Ubuntu 24.04<br>Subnet: web-subnet<br>Key pair (login): Proceed without a key pair<br>Public IP: Enabled<br>IAM Role: EC2-S3-Access</p><h3>Install NodeJS</h3><p>curl -o- <a href="https://raw.githubusercontent.com/avizway1/aws%5C_3tier%5C_architecture/main/install.sh">https://raw.githubusercontent.com/avizway1/aws\_3tier\_architecture/main/install.sh</a> | bash<br>source ~/.bashrc<br>nvm install 16<br>nvm use 16</p><h3>Download Web Code</h3><p>aws s3 cp s3://demo-3tier-project-saksham/application-code/web-tier/ web-tier — recursive</p><p>Go to folder:</p><p>cd web-tier</p><p>Install dependencies:</p><p>npm install</p><p>Build frontend:</p><p>npm run build</p><h3>Install Nginx</h3><p>command:</p><p>sudo apt install nginx -y</p><h3>Configure Nginx</h3><p>Go to config:</p><p>cd /etc/nginx</p><p>Remove old config:</p><p>sudo rm nginx.conf</p><p>Download from S3:</p><p>sudo aws s3 cp s3://demo-3tier-project-saksham/application-code/nginx.conf .</p><p>Restart nginx:</p><p>sudo systemctl restart nginx</p><p>Enable startup:</p><p>chmod -R 755 /working dir<br>sudo systemctl enable nginx</p><h3>Test</h3><p>Open browser:</p><p>http://&lt;Web-Tier-Public-IP&gt;</p><p>If everything is correct you will see the Transaction App UI.</p><h3>9️⃣ Create External Load Balancer</h3><p>Create Application Load Balancer</p><p>Type:</p><p>Internet Facing</p><p>Subnets:</p><p>web-subnet-1<br>web-subnet-2</p><p>Listener:</p><p>HTTP 80</p><p>Target group:</p><p>web-tier-target</p><p>Register web instances.</p><h3>Test Application with alb</h3><p>Open browser:</p><p>http://&lt;ALB-DNS&gt;</p><p>Example:</p><p><a href="http://3tier-web-alb-xxxxx.ap-south-1.elb.amazonaws.com/">http://3tier-web-alb-xxxxx.ap-south-1.elb.amazonaws.com</a></p><h3>🔟 Create Auto Scaling Groups</h3><h3>Create image from the App tier instance</h3><p>Enter:<br>Image name, description<br>Click on create image</p><h3>Similarly for Web tier instance</h3><p><strong>Go to launch template</strong></p><h3><strong>create launch template for APP-Tier:</strong></h3><p>Enter<br>Template name:App-Tier-LT<br>Template Version description: v1<br>Enable autoscaling guidance<br>Application and OS image: Select App-tier AMI in My AMI<br>Instance type: t3.micro<br>Security Group: sg-app<br>IAM Role: EC2-SSM</p><p>Similarly for Web-Tier<br>Go to autoscaling group</p><h3>Create Web Tier ASG</h3><p>Attach:</p><p>Web Launch Template<br>Web Target Group</p><p>Configuration:</p><p>Min: 2<br>Desired: 2<br>Max: 4</p><h3>Create App Tier ASG</h3><p>Attach:</p><p>App Launch Template<br>App Target Group</p><p>Configuration:</p><p>Min: 2<br>Desired: 2<br>Max: 4</p><h3>1️⃣1️⃣ Add CloudFront CDN</h3><p>Go to CloudFront → Create Distribution</p><p>Origin:</p><p>frontend-alb-dns (external alb)</p><p>Enable Security:WAF</p><p>Enable Rate Limiting</p><p>SQL Protection (if using pro plan for cloudfront)</p><p>Make sure Settings:</p><p>Origin protocol: HTTP Only</p><p>Open CloudFront domain:</p><p><a href="https://xxxx.cloudfront.net/">https://xxxx.cloudfront.net</a></p><h3>Key Benefits of This Architecture</h3><p>✔ High availability using <strong>Multi-AZ and Auto Scaling</strong></p><p>✔ Improved performance with <strong>CloudFront CDN</strong></p><p>✔ Security with <strong>AWS WAF and private subnets</strong></p><p>✔ Scalability with <strong>load balancing</strong></p><p>✔ Separation of concerns with <strong>3-tier architecture</strong></p><h3>🧹 Cleanup</h3><p>To avoid AWS charges, delete resources in this order:</p><ol><li>Auto Scaling Groups</li><li>Load Balancers</li><li>Target Groups</li><li>EC2 Instances</li><li>RDS Database</li><li>S3 Bucket</li><li>NAT Gateway</li><li>VPC</li></ol><h3>Final Thoughts</h3><p>Building a <strong>production-grade architecture on AWS</strong> teaches you more than just deploying servers.</p><p>You learn:</p><ul><li>Cloud networking</li><li>High availability design</li><li>Load balancing</li><li>Security best practices</li><li>Infrastructure scalability</li></ul><p>This 3-tier architecture is one of the <strong>most important foundational patterns used in real cloud environments</strong>.</p><p>💻 If you found this useful, feel free to <strong>check out the full project on GitHub</strong> and experiment with building your own cloud infrastructure.</p><p><strong>🖇️ </strong><a href="https://github.com/Saksham8784/Production-Ready-3-Tier-Web-Application-Infrastructure-on-AWS"><strong>https://github.com/Saksham8784/Production-Ready-3-Tier-Web- Application-Infrastructure-on-AWS</strong></a></p><h3>🔗 Connect With Me</h3><p>If you found this article helpful or have any questions about <strong>AWS, cloud architecture, or DevOps</strong>, feel free to connect with me.</p><p>💼 <strong>LinkedIn:</strong><br><a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/"><strong>https://www.linkedin.com/in/saksham-singh-aa31ba271/</strong></a></p><p>💻 <strong>GitHub:</strong><br><strong> </strong><a href="https://github.com/Saksham8784"><strong>https://github.com/Saksham8784</strong></a></p><p>I regularly share projects and insights about <strong>cloud computing, cybersecurity, and infrastructure engineering</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2313db46cd77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployed a Reddit Clone on Kubernetes with Ingress Enabled]]></title>
            <link>https://medium.com/@sakshamsingh8784/deployed-a-reddit-clone-on-kubernetes-with-ingress-enabled-22ea10e48cb2?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/22ea10e48cb2</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 14:15:51 GMT</pubDate>
            <atom:updated>2026-02-23T14:15:51.265Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Welcome to the practical world of DevOps ⚙️ where containerization meets orchestration and real-world deployments become smooth and scalable.</em></strong></p><p><strong>In this project, I deployed a Reddit Clone (Node.js application) on Kubernetes using:</strong></p><ul><li><strong>🐳 Docker for containerization</strong></li><li><strong>☸️ Kubernetes for orchestration</strong></li><li><strong>🌐 Service &amp; Ingress for networking</strong></li><li><strong>📦 DockerHub for image storage</strong></li></ul><p><strong>The Docker image used in this deployment:</strong></p><pre>saksham1111/reddit-clone</pre><p><strong>Let’s walk through the complete step-by-step implementation.</strong></p><h3><strong>Project Objective</strong></h3><p><strong>The goal of this project is to:</strong></p><ul><li><strong>Containerize a Node.js Reddit clone application</strong></li><li><strong>Deploy it on a Kubernetes cluster</strong></li><li><strong>Expose it using a Service</strong></li><li><strong>Configure Ingress for domain-based routing</strong></li></ul><p><strong>This project demonstrates real-world DevOps workflow from development to production-style deployment.</strong></p><h3><strong>Architecture Description — Reddit Clone Deployment</strong></h3><p><strong>This architecture represents the end-to-end deployment of the Reddit Clone application using Docker, DockerHub, AWS, and Kubernetes. The developer first pushes the source code to GitHub and builds a Docker image locally, which is then pushed to DockerHub (</strong><strong>saksham1111/reddit-clone). An AWS EC2 instance pulls this image from DockerHub and runs it inside a Kubernetes cluster. Kubernetes manages the pods and services, while Ingress handles external traffic routing to the application. This setup ensures containerized deployment, scalability, high availability, and proper traffic management in a cloud-native environment.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*l-4wYfGh1h9XMA1AOJ0rqQ.gif" /></figure><h3><strong>Step 1: Clone the Source Code</strong></h3><p><strong>First, clone the GitHub repository:</strong></p><pre>git clone https://github.com/LondheShubham153/reddit-clone-k8s-ingress.git<br>cd reddit-clone-k8s-ingress</pre><p><strong>Now we have the Node.js application ready for containerization.</strong></p><h3><strong>Step 2: Containerize the Application Using Docker</strong></h3><p><strong>Create a </strong><strong>Dockerfile:</strong></p><pre>FROM node:19-alpine3.15<br>WORKDIR /reddit-clone<br>COPY . /reddit-clone<br>RUN npm install <br>EXPOSE 3000<br>CMD [&quot;npm&quot;,&quot;run&quot;,&quot;dev&quot;]</pre><h3><strong>Explanation:</strong></h3><ul><li><strong>FROM → Uses lightweight Alpine Node.js base image</strong></li><li><strong>WORKDIR → Sets working directory inside container</strong></li><li><strong>COPY → Copies app source code</strong></li><li><strong>RUN npm install → Installs dependencies</strong></li><li><strong>EXPOSE 3000 → App runs on port 3000</strong></li><li><strong>CMD → Starts development server</strong></li></ul><h3><strong>Step 3: Build Docker Image</strong></h3><p><strong>Build the Docker image:</strong></p><pre>docker build -t saksham1111/reddit-clone .</pre><p><strong>This creates a local image ready for deployment.</strong></p><h3><strong>Step 4: Push Image to DockerHub</strong></h3><p><strong>Login to DockerHub:</strong></p><pre>docker login</pre><p><strong>Push the image:</strong></p><pre>docker push saksham1111/reddit-clone</pre><p><strong>Now Kubernetes can pull the image from DockerHub.</strong></p><h3><strong>Step 5: Create Kubernetes Deployment</strong></h3><p><strong>Create </strong><strong>Deployment.yml:</strong></p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: reddit-clone-deployment<br>  labels:<br>    app: reddit-clone<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: reddit-clone<br>  template:<br>    metadata:<br>      labels:<br>        app: reddit-clone<br>    spec:<br>      containers:<br>      - name: reddit-clone<br>        image: saksham1111/reddit-clone<br>        ports:<br>        - containerPort: 3000</pre><h3><strong>Why Deployment?</strong></h3><ul><li><strong>Maintains desired number of replicas (2 pods)</strong></li><li><strong>Provides high availability</strong></li><li><strong>Automatically restarts failed pods</strong></li><li><strong>Supports rolling updates</strong></li></ul><p><strong>Apply it:</strong></p><pre>kubectl apply -f Deployment.yml</pre><h3><strong>Step 6: Create Kubernetes Service</strong></h3><p><strong>Create </strong><strong>Service.yml:</strong></p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: reddit-clone-service<br>  labels:<br>    app: reddit-clone<br>spec:<br>  type: NodePort<br>  ports:<br>  - port: 3000<br>    targetPort: 3000<br>    nodePort: 31000<br>  selector:<br>    app: reddit-clone</pre><h3><strong>Why Service?</strong></h3><ul><li><strong>Pods have dynamic IP addresses</strong></li><li><strong>Service provides stable internal endpoint</strong></li><li><strong>Load balances traffic between pods</strong></li></ul><p><strong>Apply it:</strong></p><pre>kubectl apply -f Service.yml</pre><p><strong>Test using:</strong></p><pre>kubectl get services</pre><p><strong>You can access the app via:</strong></p><pre>http://&lt;Minikube-IP&gt;:31000</pre><h3><strong>Step 7: Configure Ingress</strong></h3><h3><strong>Why Ingress?</strong></h3><p><strong>Without Ingress:</strong></p><ul><li><strong>Every service needs a separate NodePort</strong></li><li><strong>Port management becomes messy</strong></li><li><strong>No domain-based routing</strong></li></ul><p><strong>Ingress solves this by acting as a Layer 7 reverse proxy.</strong></p><h3><strong>Enable Ingress in Minikube</strong></h3><p>minikube addons enable ingress</p><h3><strong>Create </strong><strong>ingress.yml</strong></h3><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: ingress-reddit-app<br>spec:<br>  rules:<br>  - host: &quot;domain.com&quot;<br>    http:<br>      paths:<br>      - pathType: Prefix<br>        path: &quot;/test&quot;<br>        backend:<br>          service:<br>            name: reddit-clone-service<br>            port:<br>              number: 3000<br>  - host: &quot;*.domain.com&quot;<br>    http:<br>      paths:<br>      - pathType: Prefix<br>        path: &quot;/test&quot;<br>        backend:<br>          service:<br>            name: reddit-clone-service<br>            port:<br>              number: 3000</pre><p><strong>Apply it:</strong></p><pre>kubectl apply -f ingress.yml</pre><p><strong>Verify:</strong></p><pre>kubectl get ingress</pre><h3>Step 8: Test the Application</h3><p>Test NodePort and Ingress::</p><pre>curl -L http://&lt;minikube-ip&gt;:31000 Ingress:</pre><pre>curl -L http://domain.com/test</pre><p>If configured correctly, traffic will flow through Ingress → Service → Pods → Application.</p><h3>Conclusion</h3><p>This project demonstrates a complete cloud-native deployment workflow for a Reddit Clone application using Docker and Kubernetes. Starting from containerizing the Node.js application, pushing the image (saksham1111/reddit-clone) to DockerHub, and deploying it on a Kubernetes cluster, the setup showcases real-world DevOps practices. By using Deployments for scalability, Services for internal networking, and Ingress for external traffic routing, the application is made highly available, organized, and production-ready in structure.</p><p>Overall, this project strengthens hands-on skills in containerization, orchestration, cloud deployment, and Kubernetes networking — building a strong foundation for modern DevOps and cloud engineering roles.</p><h3>🔗 GitHub Repository</h3><p>👉 <a href="https://github.com/Saksham8784/reddit-clone-kubernetes-ingress">https://github.com/Saksham8784/reddit-clone-kubernetes-ingress</a></p><p>🔗 LinkedIn</p><p>👉 <a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/">https://www.linkedin.com/in/saksham-singh-aa31ba271/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22ea10e48cb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secure AWS Serverless Web Application with CloudFront, WAF, Lambda, and DynamoDB]]></title>
            <link>https://medium.com/@sakshamsingh8784/building-a-secure-aws-serverless-web-application-with-cloudfront-waf-lambda-and-dynamodb-c4f8195134d5?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4f8195134d5</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 11:14:58 GMT</pubDate>
            <atom:updated>2026-01-31T11:14:58.267Z</atom:updated>
            <content:encoded><![CDATA[<p>Serverless architecture has become one of the most popular approaches for building modern cloud applications. It allows developers to focus on application logic without worrying about server provisioning, scaling, or maintenance. In this article, I’ll walk through how I built a <strong>secure serverless web application on AWS</strong> that manages student data using fully managed services.</p><p>The goal of this project was to design a <strong>production-ready serverless application</strong> that is scalable, cost-efficient, and secure by default.</p><h3>Project Overview</h3><p>The application allows users to:</p><ul><li>Add student records</li><li>View stored student records</li></ul><p>The entire application is built using <strong>AWS managed services</strong>, with no EC2 instances or servers involved. Security was a key focus, so HTTPS enforcement and web attack protection were integrated from the beginning.</p><h3>Architecture Overview</h3><p>The application follows a <strong>fully serverless architecture</strong>:</p><ol><li>The frontend is hosted as a <strong>static website on Amazon S3</strong></li><li><strong>Amazon CloudFront</strong> is used as a CDN to deliver content securely over HTTPS</li><li><strong>AWS WAF (Web Application Firewall)</strong> is attached to CloudFront to protect against common web attacks</li><li><strong>Amazon API Gateway</strong> exposes REST APIs for backend communication</li><li><strong>AWS Lambda</strong> handles business logic</li><li><strong>Amazon DynamoDB</strong> stores student data in a scalable NoSQL database</li></ol><p>This design ensures high availability, automatic scaling, and a pay-as-you-use pricing model.</p><h3>Why CloudFront and WAF?</h3><blockquote><em>Hosting a static website directly on Amazon S3 exposes the bucket publicly and serves content over HTTP, which does not meet modern security best practices for production applications.</em></blockquote><p>By placing <strong>CloudFront</strong> in front of S3:</p><ul><li>HTTPS is enforced</li><li>Direct access to S3 is hidden</li><li>Content is cached globally for better performance</li></ul><p>Adding <strong>AWS WAF</strong> further enhances security by protecting the application from:</p><ul><li>SQL Injection</li><li>Cross-Site Scripting (XSS)</li><li>Malicious IP traffic</li><li>Automated bots</li></ul><p>This combination turns a basic static website into a <strong>secure, production-grade frontend</strong>.</p><h3>🧰 Tech Stack</h3><h3>☁️ Cloud Platform</h3><ul><li><strong>Amazon Web Services (AWS)</strong></li></ul><h3>🖥️ Frontend</h3><ul><li><strong>HTML</strong> — Structure of the web interface</li><li><strong>JavaScript</strong> — Client-side logic and API calls</li><li><strong>Amazon S3 (Static Website Hosting)</strong> — Hosts frontend files</li><li><strong>Amazon CloudFront</strong> — CDN for HTTPS delivery and caching</li></ul><h3>🔐 Security</h3><ul><li><strong>AWS WAF (Web Application Firewall)</strong> — Protects against common web attacks</li><li><strong>AWS IAM</strong> — Role-based access control for Lambda</li><li><strong>CORS (API Gateway)</strong> — Secure frontend-to-backend communication</li></ul><h3>🔗 Backend</h3><ul><li><strong>Amazon API Gateway (REST API)</strong> — Exposes GET and POST endpoints</li><li><strong>AWS Lambda (Python 3.12)</strong> — Serverless backend logic</li></ul><h3>🗄️ Database</h3><ul><li><strong>Amazon DynamoDB</strong> — NoSQL database for storing student records</li></ul><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MG9egl70VXT7BB8CJiBqBg.gif" /></figure><h3>Benefits of This Serverless Approach</h3><ul><li><strong>No servers to manage</strong></li><li><strong>Automatic scaling</strong></li><li><strong>High availability</strong></li><li><strong>Pay-as-you-use pricing</strong></li><li><strong>Built-in security and monitoring</strong></li></ul><p>Even under low traffic, the application incurs minimal cost, making it ideal for learning, startups, and production workloads.</p><h3>Steps to Design</h3><h3>1️⃣ CREATE DYNAMODB TABLE</h3><h4><strong>Step 1: Open DynamoDB</strong></h4><p>AWS Console → DynamoDB → Create table</p><h4><strong>Step 2: Table configuration</strong></h4><ul><li>Table name: studentData</li><li>Partition key:</li><li>Name: studentID</li><li>Sort Key: Leave it</li><li>Table Setting: Default</li><li>Create table</li></ul><p>✅ Table status must be ACTIVE</p><h3>2️⃣ CREATE IAM ROLE FOR LAMBDA</h3><h4>Step 1: IAM → Roles → Create role</h4><ul><li>Trusted entity: AWS service</li><li>Service: Lambda</li></ul><h4>Step 2: Attach policies</h4><p>Attach:</p><ul><li>AWSLambdaBasicExecutionRole</li><li>AWSDynamoDBFulless</li></ul><p>Role name:</p><p>lambda-dynamoDB-role</p><h3>3️⃣ CREATE LAMBDA FUNCTIONS</h3><h4>A. GET STUDENTS LAMBDA</h4><h4>Step 1: Create Lambda</h4><ul><li>Name: getStudents</li><li>Runtime: Python 3.12</li><li>Role: lambda-dynamoDB-role</li><li>Click on create function</li></ul><h4>Step 2: Paste the following Code</h4><p>import json</p><p>import boto3</p><p>from decimal import Decimal</p><p>class DecimalEncoder(json.JSONEncoder):</p><p>def default(self, obj): if isinstance(obj, Decimal): # convert Decimal → int or float return int(obj) if obj % 1 == 0 else float(obj) return super(DecimalEncoder, self).default(obj)</p><p>def lambda_handler(event, context):</p><p>dynamodb = boto3.resource(‘dynamodb’)</p><p>table = dynamodb.Table(‘studentData’)</p><p>response = table.scan()</p><p>data = response[‘Items’]</p><p>return { “statusCode”: 200, “headers”: { “Content-Type”: “application/json” }, “body”: json.dumps(data, cls=DecimalEncoder) }</p><ul><li>Click on Deploy</li><li>Create a test</li><li>Name: myTest</li><li>Use existing template to test</li></ul><blockquote>{</blockquote><blockquote>“key1”: “value1”,</blockquote><blockquote>“key2”: “value2”,</blockquote><blockquote>“key3”: “value3”</blockquote><blockquote>}</blockquote><ul><li>Click on Test Button</li></ul><p><em>When we click on Test Button this will invoke the lambda function and this lambda function will go to retrieve data from dynamoDB table</em></p><p>Response:</p><p>[ ]</p><p>Empty list because there is nothing what we test for as we have not inserted anything in our table yet.</p><h4>B. POST STUDENT LAMBDA</h4><h4>Step 1: Create Lambda</h4><ul><li>Name: postStudent</li><li>Runtime: Python 3.12</li><li>Role: lambda-dynamoDB-role</li><li>Click on create function</li></ul><h4><strong>Step 2: Paste the following Code</strong></h4><p>import json</p><p>import boto3</p><p>dynamodb = boto3.resource(‘dynamodb’)</p><p>table = dynamodb.Table(‘studentData’)</p><p>def lambda_handler(event, context):</p><p>body = json.loads(event[‘body’]) if ‘body’ in event else event</p><p>table.put_item( Item={ ‘studentID’: body[‘studentID’], ‘name’: body[‘name’], ‘class’: body[‘class’], ‘age’: int(body[‘age’]) }</p><p>)</p><p># IMPORTANT: return RAW JSON (same style as GET)</p><p>return { “message”: “Student data saved successfully” }</p><ul><li>Click on Deploy</li><li>Create a test for postStudentlambda function</li><li>Name: myTest</li><li>Add</li></ul><blockquote>{</blockquote><blockquote>&quot;studentID&quot;: &quot;1&quot;,** **&quot;name&quot;: &quot;Ram&quot;,** **&quot;class&quot;: &quot;10&quot;,** **&quot;age&quot;: 15</blockquote><blockquote>}</blockquote><ul><li>Click on Test Button</li></ul><p>Response:</p><p>{</p><p>“message”: “Student data saved successfully”</p><p>}</p><h3>4️⃣ CREATE API GATEWAY (REST API)</h3><h4>Step 1: Create API</h4><p>API Gateway → Create API → REST API → Build</p><ul><li>New Api</li><li>API name: StudentData</li><li>API endpoint: Edge-optimized (allow user from around the world)</li></ul><p>Now we will need to create <em>GET</em> and <em>POST</em> methods</p><ul><li>Method Type: GET</li><li>Integration Type: Lambda Function</li><li>Region: Same Region</li><li>Lambda Function: getStudents type</li><li>Click on create method</li></ul><p>To check whether it is correctly configured or not click on test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4EUMa6c00URBfLq-" /></figure><p>You will get:</p><p>Status: 200</p><p>Response body: Data from table</p><p>Similarly for</p><p>Post method</p><ul><li>Method Type: GET</li><li>Integration Type: Lambda Function</li><li>Region: Same Region</li><li>Lambda Function: postStudents type</li><li>Click on create method</li></ul><h4>Step 2: Enable CORS</h4><p>In resources click on root i.e / then click on enable cors</p><h4>Step 3: Deploy API</h4><p>If we want that our application works it must be deployed</p><p>Actions → Deploy API</p><ul><li>Select a new stage</li><li>Stage name: prod</li></ul><p><strong>Your API endpoint :</strong></p><p><a href="https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/prod">https://XXXXXXXX.execute-api.us-east-1.amazonaws.com/prod</a></p><p>This url will invoke our lambda function</p><h3>5️⃣ CREATE S3 STATIC WEBSITE</h3><h4>Step 1: Create S3 bucket</h4><ul><li>Bucket name: studentdata-serverless-deployment-30jan</li><li>Disable block public access</li><li>Click on Create Bucket</li><li>Upload the index.html and scripts.js</li><li>Enable static website hosting</li><li>Index document: index.html</li><li>Save Change</li><li>You will get 1 url but when you access you will get 403 access denied</li><li>We need to give a policy</li><li>Go to AWS Policy Generator generate a policy for your bucket</li><li>Apply this /* just after your resource like “Resource”: “arn:aws:s3:::studentdata-serverless-deployment-30jan/*”</li><li>Refresh the page now you will get the site</li></ul><p>Now if we save the students data then we will get a message :</p><p>Student Data Saved!</p><p>Click on View all students and you will get the data of the saved students.</p><h3>6️⃣ TESTING CHECKLIST</h3><ul><li>✔ Save student → DynamoDB item created</li><li>✔ View students → table populated</li><li>✔ No CORS errors</li><li>✔ No undefined values</li></ul><h3>7️⃣ Now we will configure with Cloudfront Why?</h3><p><a href="http://studentdata-serverless-deployment-30jan.s3-website-us-east-1.amazonaws.com/">http://studentdata-serverless-deployment-30jan.s3-website-us-east-1.amazonaws.com</a></p><p>If we look at our S3 url then we come to know that : it is using http in this case our bucket is exposed to the public which is not a good practice so we need cloudfront.</p><p>What will happen when we use cloudfront?</p><ul><li>Users never access S3 directly</li><li>All traffic goes through CloudFront</li><li>HTTPS enforced</li><li>S3 access controlled</li></ul><h3>Steps</h3><ul><li>AWS Console → CloudFront</li><li>Choose a plan according to budget free (recommended)</li><li>Click Create Distribution</li><li>Choose: Web distribution (default)</li><li>Distribution Name: studentsData</li><li>Distribution Name: Single website or app</li><li>Origin type: S3</li><li>Choose S3 WEBSITE ENDPOINT, NOT S3 REST endpoint.<br>✅ Correct:<br>studentdata-serverless-deployment-30jan.s3-website-us-east-1.amazonaws.com<br>❌ Wrong:<br>studentdata-serverless-deployment-30jan.s3.amazonaws.com</li><li>Leave setting default and click next</li><li>Enable AWS WAF</li><li>Warning : WAF Will charge so enable wisely</li><li>Review and create</li></ul><p>In a moment you will get a domain name like: <a href="https://d24w9ih428mn84.cloudfront.net/">https://d24w9ih428mn84.cloudfront.net/</a></p><h4>Then access it using the same domain.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xEW6K-dfaQwmL5o4" /></figure><h3>Conclusion</h3><p>This project demonstrates how AWS managed services can be combined to build a <strong>secure, scalable, and production-ready serverless web application</strong>. By leveraging S3, CloudFront, WAF, API Gateway, Lambda, and DynamoDB, it is possible to create robust applications without managing infrastructure.</p><p>Serverless architecture is not just about cost savings — it’s about building systems that are resilient, secure, and easy to scale. This project was a practical step toward understanding real-world cloud architectures.</p><h3>🔗 GitHub Repository</h3><p>👉 <a href="https://github.com/Saksham8784/Secure-AWS-Serverless-App">https://github.com/Saksham8784/Secure-AWS-Serverless-App</a></p><h3>🔗 LinkedIn</h3><p>👉 <a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/">https://www.linkedin.com/in/saksham-singh-aa31ba271/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4f8195134d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Build a Production-Ready DevSecOps CI/CD Pipeline]]></title>
            <link>https://medium.com/@sakshamsingh8784/how-i-build-a-production-ready-devsecops-ci-cd-pipeline-d64cec488e86?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d64cec488e86</guid>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Wed, 14 Jan 2026 07:01:21 GMT</pubDate>
            <atom:updated>2026-01-14T07:01:21.092Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In today’s fast-paced software development environment, security can no longer be an afterthought. DevSecOps focuses on integrating security checks directly into the CI/CD pipeline to identify vulnerabilities early and deliver secure applications faster.</p><p>In this blog, I will walk through how I built an <strong>end-to-end DevSecOps CI/CD pipeline</strong> using <strong>Jenkins on AWS EC2</strong>, integrating <strong>SonarQube for code quality</strong>, <strong>OWASP Dependency-Check for dependency scanning</strong>, <strong>Trivy for container security</strong>, and <strong>Docker for application deployment</strong>. This project demonstrates a practical, real-world approach to implementing security-first CI/CD automation.</p><h3>Pipeline Stages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ULppRpTCQmkP2hs_tSCyKQ.png" /></figure><ol><li><strong>Code Checkout</strong><br> Jenkins pulls the latest source code from GitHub whenever the pipeline is triggered.</li><li><strong>Static Code Analysis (SonarQube)</strong><br> SonarQube analyzes the source code to identify bugs, code smells, and security vulnerabilities.</li><li><strong>Quality Gate Validation</strong><br> The pipeline waits for the SonarQube quality gate result to ensure the code meets defined quality standards.</li><li><strong>Dependency Installation</strong><br> Application dependencies are installed using npm.</li><li><strong>Dependency Vulnerability Scan (OWASP Dependency-Check)</strong><br> Third-party libraries are scanned for known vulnerabilities (CVEs).</li><li><strong>File System Scan (Trivy)</strong><br> Trivy scans the project file system to detect vulnerabilities and misconfigurations.</li><li><strong>Docker Image Build</strong><br> A Docker image of the application is built using a Dockerfile.</li><li><strong>Docker Image Security Scan (Trivy)</strong><br> The Docker image is scanned for OS-level and application-level vulnerabilities.</li><li><strong>Container Deployment</strong><br> The secure Docker image is deployed as a running container.</li></ol><h3>Tech Stack</h3><p>This project uses a carefully selected set of tools to build a <strong>secure, automated, and production-like DevSecOps CI/CD pipeline</strong>. Each tool was chosen based on its real-world usage and ability to integrate security into the pipeline.</p><ul><li><strong>Amazon Web Services (EC2)</strong> — Hosting Jenkins server</li><li><strong>Jenkins</strong> — CI/CD pipeline orchestration</li><li><strong>GitHub</strong> — Source code management</li><li><strong>SonarQube </strong>— Static code analysis &amp; quality gate</li><li><strong>OWASP Dependency-Check</strong> — Dependency vulnerability scanning</li><li><strong>Trivy </strong>— File system &amp; Docker image vulnerability scanning</li><li><strong>Docker</strong> — Application containerization &amp; deployment</li><li><strong>Node.js </strong>— Application runtime</li><li><strong>JDK </strong>— Required for Jenkins &amp; SonarQube scanner</li></ul><h3>Step-by-Step Pipeline Implementation</h3><h4>Step 1: Jenkins Setup on AWS EC2</h4><p>Jenkins is installed on an AWS EC2 instance and configured with required tools like JDK, Node.js, Docker, SonarQube Scanner, OWASP Dependency-Check, and Trivy.</p><p>✔ Jenkins acts as the <strong>central CI/CD engine</strong></p><h4>Step 2: Define Pipeline as Code (Jenkinsfile)</h4><pre>pipeline {<br>    agent any</pre><pre>    tools {<br>        jdk &#39;jdk&#39;<br>        nodejs &#39;node25&#39;<br>    }</pre><pre>    environment {<br>        SONAR_HOME = tool &quot;Sonar&quot;<br>    }</pre><p>This ensures:</p><ul><li>Tool consistency</li><li>Version control</li><li>Reproducible pipelines</li></ul><h4>Step 3: Code Checkout from GitHub</h4><pre>stage(&#39;Code&#39;) {<br>    steps {<br>        echo &quot;Cloning code from GitHub&quot;<br>        git url: &#39;https://github.com/KastroVKiran/DevOps-Project-Swiggy&#39;,<br>            branch: &#39;master&#39;<br>    }<br>}</pre><p>Jenkins pulls the latest source code whenever the pipeline runs.</p><h4>Step 4: Static Code Analysis using SonarQube</h4><pre>stage(&quot;SonarQube Quality Analysis&quot;) {<br>            steps {<br>                withSonarQubeEnv(&quot;Sonar&quot;) {<br>                    sh &quot;$SONAR_HOME/bin/sonar-scanner -Dsonar.projectName=Swiggy -Dsonar.projectKey=Swiggy&quot;<br>                }<br>            }<br>        }</pre><p>✔ Detects:</p><ul><li>Bugs</li><li>Code smells</li><li>Security vulnerabilities</li></ul><h4>Step 5: SonarQube Quality Gate Validation</h4><pre>stage(&quot;Sonar Quality Gate Scan&quot;) {<br>    steps {<br>        timeout(time: 2, unit: &#39;MINUTES&#39;) {<br>            waitForQualityGate abortPipeline: false<br>        }<br>    }<br>}</pre><p>This ensures that <strong>only quality-approved code</strong> moves forward.</p><h4>Step 6: Install Application Dependencies</h4><pre>stage(&#39;Install Dependencies&#39;) {<br>    steps {<br>        sh &quot;npm install&quot;<br>    }<br>}</pre><p>Installs all Node.js dependencies required for the application.</p><h4>Step 7: OWASP Dependency Vulnerability Scan</h4><pre>stage(&#39;OWASP FS SCAN&#39;) {<br>    steps {<br>        dependencyCheck additionalArguments: &#39;--scan ./ --disableYarnAudit --disableNodeAudit&#39;,<br>                        odcInstallation: &#39;owasp&#39;<br>        dependencyCheckPublisher pattern: &#39;**/dependency-check-report.xml&#39;<br>    }<br>}</pre><p>✔ Identifies known CVEs in third-party libraries<br>✔ Prevents supply-chain attacks</p><h4>Step 8: Trivy File System Scan</h4><pre>stage(&quot;Trivy File System Scan&quot;) {<br>    steps {<br>        sh &quot;trivy fs . --format table -o trivy-fs-report.html&quot;<br>    }<br>}</pre><p>✔ Scans source files for:</p><ul><li>Vulnerabilities</li><li>Misconfigurations</li><li>Exposed secrets</li></ul><h4>Step 9: Docker Image Build</h4><pre>stage(&#39;Build&#39;) {<br>    steps {<br>        sh &quot;/usr/local/bin/docker build -t swiggy .&quot;<br>    }<br>}</pre><p>The application is packaged into a Docker image for consistent deployment.</p><h4>Step 10: Trivy Docker Image Scan</h4><pre>stage(&quot;TRIVY Image Scan&quot;) {<br>    steps {<br>        sh &quot;trivy image swiggy:latest &gt; trivy.txt&quot;<br>    }<br>}</pre><p>✔ Scans OS-level &amp; application-level vulnerabilities inside the container image.</p><h4>Step 11: Deploy Application Container</h4><pre>stage(&#39;Deploy to container&#39;) {<br>    steps {<br>        sh &quot;docker run -d --name swiggy -p 3000:3000 swiggy:latest&quot;<br>    }<br>}</pre><p>The secure Docker image is deployed as a running container.</p><h4>Step 12: Access the Application</h4><p>Once the container is successfully deployed, the application becomes accessible via the browser using the public IP of the AWS EC2 instance.</p><pre>http://&lt;EC2-Public-IP&gt;:3000</pre><p>This confirms that the CI/CD pipeline has successfully built, scanned, and deployed the application.</p><blockquote><em>At this stage, the end-to-end DevSecOps pipeline completes successfully, and the application is live and accessible on port </em><strong><em>3000</em></strong><em>.</em></blockquote><h3>Jenkins Pipeline Code (Jenkinsfile)</h3><pre>pipeline {<br>    agent any<br><br>    tools {<br>        jdk &#39;jdk&#39;<br>        nodejs &#39;node25&#39;<br>    }<br><br>    environment {<br>        SONAR_HOME = tool &quot;Sonar&quot;<br>    }<br><br>    stages {<br><br>        stage(&#39;Code&#39;) {<br>            steps {<br>                echo &quot;cloning code from github&quot;<br>                git url: &#39;https://github.com/KastroVKiran/DevOps-Project-Swiggy&#39;, branch: &#39;master&#39;<br>            }<br>        }<br><br>        stage(&quot;SonarQube Quality Analysis&quot;) {<br>            steps {<br>                withSonarQubeEnv(&quot;Sonar&quot;) {<br>                    sh &quot;$SONAR_HOME/bin/sonar-scanner -Dsonar.projectName=Swiggy -Dsonar.projectKey=Swiggy&quot;<br>                }<br>            }<br>        }<br><br>        stage(&quot;Sonar Quality Gate Scan&quot;) {<br>            steps {<br>                timeout(time: 2, unit: &quot;MINUTES&quot;) {<br>                    waitForQualityGate abortPipeline: false<br>                }<br>            }<br>        }<br><br>        stage(&#39;Install Dependencies&#39;) {<br>            steps {<br>                sh &quot;npm install&quot;<br>            }<br>        }<br><br>        stage(&#39;OWASP FS SCAN&#39;) {<br>            steps {<br>                dependencyCheck additionalArguments: &#39;--scan ./ --disableYarnAudit --disableNodeAudit&#39;,<br>                                odcInstallation: &#39;owasp&#39;<br>                dependencyCheckPublisher pattern: &#39;**/dependency-check-report.xml&#39;<br>            }<br>        }<br><br>        stage(&quot;Trivy File System Scan&quot;) {<br>            steps {<br>                sh &quot;trivy fs . --format table -o trivy-fs-report.html&quot;<br>            }<br>        }<br>        <br>         stage(&#39;Build&#39;) {<br>            steps {<br>                echo &#39;This is building&#39;<br>                sh &quot;/usr/local/bin/docker build -t swiggy .&quot;<br>                echo &quot;build successful&quot;<br>            }<br>        }<br>  <br>        stage(&quot;TRIVY Image Scan&quot;) {<br>            steps {<br>                sh &quot;trivy image swiggy:latest &gt; trivy.txt&quot;<br>            }<br>        }<br><br>        stage(&#39;Deploy to container&#39;) {<br>            steps {<br>                sh &#39;docker run -d --name swiggy -p 3000:3000 swiggy:latest&#39;<br>            }<br>        }<br>    }<br>}</pre><h3>🙌 Connect With Me</h3><p>Follow me for more Security related contents and also <strong>👥 Connect with me on LinkedIn</strong>:<a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/"> https://www.linkedin.com/in/saksham-singh-aa31ba271/ </a>— I’d love to connect and discuss more about cybersecurity and cloudsecurity!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d64cec488e86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Data Loss Prevention System (DLP) in AWS]]></title>
            <link>https://medium.com/@sakshamsingh8784/serverless-data-loss-prevention-system-dlp-in-aws-88bf97c82c79?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/88bf97c82c79</guid>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 17:45:09 GMT</pubDate>
            <atom:updated>2025-12-08T17:45:09.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXWyVdE0cuhLGwVvgbkuIQ.png" /></figure><p>Modern cloud applications deal with tons of user-generated data — documents, CSV files, logs, images, uploads and more.<br> But with that convenience comes risk:</p><ul><li>Exposure of <strong>PII, passwords, financial info</strong></li><li>Employees accidentally uploading <strong>customer data</strong></li><li><strong>Compliance violations</strong> (GDPR, HIPAA, PCI)</li><li>Insider threats or misconfigurations</li><li>Sensitive files sitting unnoticed in S3 buckets 😬</li></ul><blockquote>To solve this, I built a <strong>fully automated, serverless DLP (Data Loss Prevention) pipeline</strong> using AWS:</blockquote><p>✔ <strong>Amazon Macie </strong>— detects sensitive data in S3<br> ✔ <strong>EventBridge </strong>— routes detection events<br> ✔ <strong>AWS Lambda</strong> — quarantines sensitive files<br> ✔<strong> SNS</strong> — sends real-time alerts<br> ✔ <strong>CloudWatch</strong> — logs &amp; monitoring<br> ✔<strong> Amazon S3</strong> — source + quarantine storage</p><h3>☁️ Architecture Overview</h3><p>This architecture automatically:</p><ol><li>Detects sensitive data in S3 using <strong>Amazon Macie</strong></li><li>Sends findings to <strong>EventBridge</strong></li><li>Triggers:</li></ol><ul><li><strong>SNS Alert</strong> → Email notification</li><li><strong>Lambda Function</strong> → Copies file to quarantine bucket + deletes original</li></ul><p>4. Logs events in <strong>CloudWatch</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hVMH_QfUtmbk1KV6Fk6GwQ.png" /></figure><h3>💡 Real-World Use Cases</h3><h4>1. Automatic Data Loss Prevention</h4><p>Sensitive files are instantly isolated before causing damage.</p><h4>2. Regulatory Compliance</h4><p>GDPR, HIPAA, PCI-DSS, and India’s DPDP Act require monitoring of sensitive data.</p><h4>3. Secured File Upload Systems</h4><p>For apps where people upload documents: banking, HR, e-commerce, fintech.</p><h4>4. Insider Threat Protection</h4><p>Prevents accidental or intentional internal data leaks.</p><h4>5. Automated Incident Response</h4><p>Human-free auto-remediation.</p><h4>6. Enterprise Risk Reduction</h4><p>No more “oops, I uploaded the customer list” moments.</p><h3>🛠️ Tech Stack</h3><ul><li><strong>Amazon S3</strong> — Source + quarantine buckets</li><li><strong>Amazon Macie</strong> — Sensitive data detection</li><li><strong>AWS Lambda</strong> — Automated quarantine logic</li><li><strong>Amazon EventBridge</strong> — Event routing</li><li><strong>SNS</strong> — Email notifications</li><li><strong>IAM</strong> — Permissions</li><li><strong>CloudWatch</strong> — Logs</li><li><strong>Python</strong> — Lambda code</li></ul><h3>🚀 Implementation</h3><h3>Setup Steps (BEGINNING → END)</h3><h3>AWS Macie — Sensitive Data Detection + Auto Remediation + Alerts</h3><h4>STEP 1 — Create Source S3 Bucket (User Upload Bucket)</h4><p>Open S3 → Create Bucket<br> Name:<br> macie-source-bucket-yourname<br> Block Public Access → ON<br> Enable Server-Side Encryption (SSE-S3)<br> Create bucket<br> This is where users will upload files.</p><h4>STEP 2 — Create Quarantine S3 Bucket</h4><p>Create another bucket:<br> macie-quarantine-bucket-yourname<br> Block Public Access → ON<br> Enable versioning (recommended)<br> SSE-S3 encryption ON<br> This bucket stores sensitive files when lambda triggers.</p><h4>STEP 3 — Enable Amazon Macie</h4><p>Open AWS Macie console<br> Click Enable Macie<br> Select region (same as S3)<br> Macie is now active.</p><h4>STEP 4 — Create Macie Classification Job</h4><p>Macie needs a job to scan your S3 bucket.</p><p>Go to Macie → Jobs → Create Job<br> Select your source S3 bucket<br> Scope → Scheduled job Update frequency Daily or One time job as per your requirement<br> Managed Data Identifiers →<br> ✔ Choose Custom(Use specific managed data identifiers) (166 identifiers)<br> OR<br> ✔ Recommended (35 identifiers)<br> Name:<br> Macie-Sensitive-Data-Scan<br> Review and Create.</p><h4>STEP 5 — Create SNS Topic for Alerts</h4><p>Go to SNS → Topics → Create topic<br> Type: Standard<br> Name:<br> macie-alerts-topic<br> Create<br> Create Subscription:<br> Protocol: Email<br> Endpoint: your email<br> Confirm email<br> SNS ready.</p><h4>STEP 6 — Create EventBridge Rule #1 (SNS Alerts)</h4><p>This will generate email alerts for ANY Macie finding.</p><p>Go to EventBridge → Rules → Create Rule<br> Name:<br> macie-sns-alert-rule<br> Event bus: default.<br> Event Pattern: Custom pattern</p><p>Event Pattern JSON:</p><pre>{<br>&quot;source&quot;: [&quot;aws.macie&quot;],<br>&quot;detail-type&quot;: [&quot;Macie Finding&quot;]<br>}</pre><p>Target Type: AWS Service<br> Target → SNS topic<br> Select <strong>macie-alerts-topic</strong><br> Save<br> SNS alert system DONE.</p><h4>STEP 7 — Create a Lambda Function to Process Macie SensitiveData Findings</h4><h4>Create IAM Role for Lambda</h4><p>Open IAM → Create role.</p><p>Trusted entity: AWS service.<br> Use case: Lambda.</p><p>Attach policy: <strong>AWSLambdaBasicExecutionRole</strong></p><p>Name the role:<br> QuarantineS3-Lambda-Role.</p><p>After creating goto QuarantineS3-Lambda-Role again → Add Permission → Create inline policy → Attach this policy</p><p><strong>Policy 1 (S3 Access Policy)</strong></p><pre>{<br>&quot;Version&quot;: &quot;2012-10-17&quot;,<br>&quot;Statement&quot;: [<br>{<br>&quot;Effect&quot;: &quot;Allow&quot;,<br>&quot;Action&quot;: [<br>&quot;s3:GetObject&quot;,<br>&quot;s3:PutObject&quot;,<br>&quot;s3:DeleteObject&quot;<br>],<br>&quot;Resource&quot;: &quot;arn:aws:s3:::*/*&quot;<br>}<br>]<br>}<br><br>Policy 2 (Write CloudWatch Logs)<br>Attach AWS Managed Policy:<br>✔ AWSLambdaBasicExecutionRole (already attached)</pre><h4>Create the Lambda Function</h4><p>Open the Lambda console.<br> Create a new function.</p><p>Choose:<br> Name: <strong>Automated-QuarantineS3</strong><br> Runtime: <strong>Python 3.13</strong><br> Architecture: x86_64<br> Permissions: “Use existing role” → select the IAM role created above</p><p>Create the function.</p><p>Paste the Python code into the function (<strong>provided Lambda_Code.py</strong>).</p><p>Click Deploy.</p><p>Lambda ready.</p><h4>STEP 8 — Create EventBridge Rule #2 (Lambda Auto-Remediation)</h4><p>Triggers only for SensitiveData findings.</p><p>Go to EventBridge → Create Rule<br> Name:<br> macie-lambda-quarantine-rule<br> Event bus: default.<br> Event Pattern: Custom pattern</p><p>Event Pattern JSON:</p><pre>{<br>&quot;source&quot;: [&quot;aws.macie&quot;],<br>&quot;detail-type&quot;: [&quot;Macie Finding&quot;],<br>&quot;detail&quot;: {<br>&quot;type&quot;: [{<br>&quot;prefix&quot;: &quot;SensitiveData:&quot;<br>}]<br>}<br>}</pre><pre>Target → Lambda<br>Select macie-quarantine-function<br>Done.</pre><h4>STEP 9 — Upload Test Files</h4><p>Upload sample files (provided) to the source bucket:</p><ul><li>customers.csv</li><li>creditcards.txt</li><li>passwords.txt</li><li>employee_details.json</li><li>medical_records.doc.txt</li><li>credentials.xlsx</li></ul><p>Wait 1 minute.</p><h4>STEP 10 — Validate Results</h4><p>✔ Check Quarantine Bucket<br> Sensitive files should appear here.</p><p>✔ Check Email<br> SNS alert arrives:<br> <strong>“Sensitive Data Detected”</strong></p><p>✔ Check CloudWatch Logs<br> Lambda logs visible.</p><p>✔ Check Security Hub<br> Findings appear under Sensitive Data.</p><p>Everything is working.</p><h4>STEP 11 — Final Outcome</h4><p>Your pipeline is now LIVE:</p><p><strong>User Upload → Macie Scan → Sensitive Finding → EventBridge → SNS Alert + Lambda Quarantine → CloudWatch Logs</strong></p><p>You will see that the Sensitive Data Detected files are quarantined in Quarantine S3 Bucket.</p><h3>🎉 Conclusion</h3><p>With just a few AWS services, you can build a <strong>fully automated, scalable Data Loss Prevention system</strong> — no servers, no agents, no manual checks.</p><p>This solution is:</p><ul><li>🔐 Secure</li><li>⚡ Real-time</li><li>☁️ Fully serverless</li><li>🧩 Easy to extend</li><li>💼 Production-ready</li></ul><h3>🙌 Connect With Me</h3><p>Follow me for more Security related contents and also <strong>👥 Connect with me on LinkedIn</strong>:<a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/"> https://www.linkedin.com/in/saksham-singh-aa31ba271/ </a>— I’d love to connect and discuss more about cybersecurity and cloudsecurity!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88bf97c82c79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real Time Malware Detection System for AWS-S3 Bucket]]></title>
            <link>https://medium.com/@sakshamsingh8784/real-time-malware-detection-system-for-aws-s3-bucket-423a1f824326?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/423a1f824326</guid>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[aws-s3-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 16:58:10 GMT</pubDate>
            <atom:updated>2025-11-21T16:58:10.465Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Modern cloud applications frequently rely on Amazon S3 for storing user-generated content such as documents, images, and file uploads. However, this introduces a critical security challenge — malicious files can be uploaded and stored inside S3 buckets, putting your cloud environment at risk.</p><p>To solve this security gap, AWS provides GuardDuty Malware Protection for S3, a fully managed detection service that automatically scans objects for malware the moment they are uploaded.</p><p>In this Cloud Security guide, we’ll build a <strong>real-time malware detection system</strong> for Amazon S3 using AWS-native tools.</p><p><strong><em>Lets goooooooo!</em></strong></p><h3>Techstack</h3><p>This project demonstrates how to build a real-time malware detection system using:</p><ul><li><a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html">Amazon S3</a> — file storage</li><li><a href="https://docs.aws.amazon.com/guardduty/latest/ug/gdu-malware-protection-s3.html">Amazon GuardDuty Malware Protection</a> — automatic malware scanning</li><li><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html">Amazon EventBridge</a> — event routing</li><li><a href="https://docs.aws.amazon.com/sns/latest/dg/welcome.html">Amazon SNS</a> — email notifications</li></ul><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aPCXpJDyk8RyIHhw" /></figure><h3>Steps — AWS Malware Detection for S3 Bucket</h3><h4>1️⃣ Create an S3 Bucket</h4><ol><li>Open Amazon S3 in the AWS Console.</li><li>Click Create bucket.</li><li>Name the bucket like:<br>my-bucket-01-2025</li><li>Keep Block Public Access → ON</li><li>Enable Default Encryption → AES-256 (SSE-S3)</li><li>Click Create bucket</li></ol><h4>2️⃣ Enable GuardDuty Malware Protection</h4><ol><li>Go to Amazon GuardDuty</li><li>Click Enable GuardDuty</li><li>In the left menu → Settings</li><li>Inside Malware Protection</li></ol><ul><li>Enable: S3 Malware Protection</li><li>Enter bucket details, service access and click on enable</li></ul><p>GuardDuty now automatically scans files uploaded to your S3 bucket.</p><h4>3️⃣ Create an SNS Topic for Notifications</h4><ol><li>Open Amazon SNS → left navigation panel → Topics → Create topic.</li><li>Choose type “Standard”.</li><li>Enter topic name like: GuardDuty-Threat-Alerts.</li><li>Create the topic.</li><li>Create a subscription:</li></ol><ul><li>Protocol: Email</li><li>Endpoint: your email address</li><li>Confirm subscription by clicking the link sent to your email. Or you can directly right click on(Confirm subscription) in mail which you got and copy that and paste it in confirm subscriptions.</li></ul><p>SNS is now ready for sending alert messages.</p><h4>4️⃣ Create EventBridge Rule (Trigger on Malware Detection)</h4><ol><li>Open EventBridge → Rules → Create rule.</li><li>Name: GuardDutyFindings.</li><li>Event bus: default.</li><li>Rule type: “Rule with event pattern”.</li><li>Event source: AWS services → GuardDuty.</li><li>Event type: GuardDuty Finding.</li><li>Use this event pattern:</li></ol><p><strong>Event Pattern JSON</strong></p><p>Paste this:</p><p>{<br>&quot;source&quot;: [&quot;aws.guardduty&quot;],<br>&quot;detail-type&quot;: [&quot;GuardDuty Finding&quot;],<br>&quot;detail&quot;: {<br>&quot;type&quot;: [{<br>&quot;contains&quot;: &quot;MaliciousFile&quot;<br>}]<br>}<br>}</p><p><strong>Select Target</strong></p><ul><li>Target types: AWS Service</li><li>Select a target: SNS topic</li><li>Topic: S3UploadAlertTopic</li></ul><p>Click Create rule.</p><h4>5️⃣ Test Malware Detection</h4><ol><li>Use the EICAR.txt file provided to test. <strong>(</strong><a href="https://github.com/Saksham8784/Malware-Detection-System-for-AWS-S3-Bucket/blob/main/eicar.txt"><strong><em>link</em></strong></a><strong>)</strong></li><li>Upload it to your S3 bucket:<br>my-bucket-01-2025</li><li>Wait few seconds</li></ol><p>You will receive an email like:</p><p>A malware scan on your S3 object eicar.txt has detected a security risk.</p><p>Your malware detection pipeline is working!</p><p>You can also find it in your GuardDuty findings.</p><p>For full code, step-by-step implementation, and configuration files, check out the GitHub repository: <a href="https://github.com/Saksham8784/Malware-Detection-System-for-AWS-S3-Bucket?utm_source=chatgpt.com">github.com/Saksham8784/Malware-Detection-System-for-AWS-S3-Bucket</a>.</p><h3>🙌 Connect With Me</h3><p>Follow me for more Security related contents and also <strong>👥 Connect with me on LinkedIn</strong>:<a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/"> https://www.linkedin.com/in/saksham-singh-aa31ba271/ </a>— I’d love to connect and discuss more about cybersecurity and cloudsecurity!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=423a1f824326" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing AWS-S3 Bucket]]></title>
            <link>https://medium.com/@sakshamsingh8784/securing-aws-s3-bucket-b02293838520?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b02293838520</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Sun, 09 Nov 2025 11:14:16 GMT</pubDate>
            <atom:updated>2025-11-09T11:14:16.714Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, in this cloud security blog we are going to understand how to secure a S3 bucket and why it is important for organisations to secure their S3 bucket.</p><p>Before we deep dive in S3 bucket security let us understand the basics of AWS-S3.</p><h3><strong>What is AWS-S3(</strong>Simple Storage Service)</h3><p>So, Amazon S3 is a Simple Storage Service in AWS that <strong>stores</strong> files of different types like <strong>Photos, Audio, </strong>and<strong> Videos </strong>as<strong> Objects</strong> providing more <strong>scalability</strong> and <strong>security</strong> to.</p><p>The following are a few Wide Usages of Amazon S3 service.</p><ul><li><strong>Data Storage: </strong>Amazon s3 acts as the best option for scaling both small and large storage(5 TB max) applications. It helps in storing and retrieving the data-intensitive applications as per needs in ideal time.</li><li><strong>Backup and Recovery: </strong>Many Organizations are using Amazon S3 to backup their critical data and maintain the data durability and availability for recovery needs.</li><li><strong>Hosting Static Websites: </strong>Amazon S3 facilitates in storing HTML, CSS and other web content from Users/developers allowing them for hosting Static Websites benefiting with low-latency access and cost-effectiveness.</li><li><strong>Data Archiving: </strong>Amazon S3 Glacier service integration helps as a cost-effective solution for long-term data storing which are less frequently accessed applications.</li><li><strong>Big Data Analytics: </strong>Amazon S3 is often considered as data lake because of its capacity to store large amounts of both structured and unstructured data offering seamless integration with other AWS Analytics and AWS Machine Learning Services.</li><li><strong>Integration with Event-Driven Architectures</strong>S3 can <strong>trigger events</strong> when objects are created, updated, or deleted:</li><li><em>Send events to </em><strong><em>AWS Lambda</em></strong><em> for serverless processing.</em></li><li><em>Send to </em><strong><em>SNS or SQS</em></strong><em> for messaging pipelines.</em></li><li>Automate workflows (e.g., auto-resize uploaded images, scan for viruses). So, S3 is part of a <strong>serverless compute ecosystem</strong>, not just a disk.</li></ul><h4>Why S3 is more than storage?</h4><p>Because it’s:</p><ul><li><strong>Security</strong> (encryption, IAM, versioning)</li><li><strong>Hosting</strong> (websites, media delivery)</li><li><strong>Analytics and dashboarding</strong> (Athena, Glue, Redshift)</li><li><strong>Compute Triggers</strong> (Lambda, events)</li><li><strong>Backup/Recovery</strong> (replication, Glacier)</li></ul><h4>Key characteristics:</h4><ul><li><strong>Durable:</strong> 99.999999999% (11 9’s) durability.</li><li><strong>Highly available:</strong> 99.99% availability.</li><li><strong>Scalable:</strong> Automatically scales as storage needs grow.</li><li><strong>Secure:</strong> Supports encryption, access policies, and logging.</li><li><strong>Cost-effective:</strong> Pay for what you use.</li></ul><h4>Key Components of S3</h4><p><strong>1. Buckets:</strong></p><p>An <strong>S3 bucket</strong> is like a <strong>container</strong> for storing objects (files, images, backups, logs).</p><ul><li>Buckets are the fundamental containers for storing data in S3.</li><li>They are globally unique namespaces, meaning each bucket name must be unique across all of AWS.</li><li>Buckets are created within a specific AWS region, and the data stored within them resides in that region.</li></ul><p><strong>2. Objects:</strong></p><p>Objects are the actual data units stored within S3 buckets.An object consists of the data itself (e.g., a file, image, document) and its associated metadata. Metadata includes information like the object’s creation date, size, and custom user-defined metadata.</p><p><strong>3. Storage Classes:</strong></p><p>S3 offers various storage classes designed for different use cases and access patterns, optimizing for cost and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*intrbEcOXUuxZnZaZYRddg.png" /><figcaption>Different Storage classes</figcaption></figure><p><strong>4. Access Points:</strong></p><p>S3 Access Points are network endpoints that simplify managing data access at scale for applications and services.</p><p>They provide a dedicated hostname and access policy for specific applications, allowing for fine-grained control over permissions without modifying the bucket policy directly.</p><p><strong>5.Region</strong></p><p>An <strong>AWS Region</strong> is a <strong>geographical area</strong> where Amazon has multiple data centres (called <strong>Availability Zones — AZs</strong>). When you create a <strong>bucket in S3</strong>, you must select a region.</p><p>Once created, a bucket is <strong>tied to that region permanently</strong> (you can’t move it, but you can copy objects to another region).</p><h3>Lets us start with Securing S3 buckets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*W9CBKd_SJnH_zaxEXYh8yA.gif" /></figure><p>Securing the S3 buckets refers to all the <strong>mechanisms, configurations, and best practices</strong> used to <strong>protect data stored in Amazon S3-Bucket </strong>from unauthorized access, data leaks, or loss.</p><p><strong>In simpler words:</strong></p><p>It’s about <strong>keeping your S3 data safe — from the wrong people, wrong permissions, and wrong configurations.</strong></p><h4>Why need to secure the S3-Buckets</h4><p>Amazon S3 is one of the <strong>most used services in AWS</strong> — it stores everything from user data, source code, backups, to logs and sensitive information.<br>So, <strong>any security mistake here can expose an entire company’s data</strong> to the world.</p><p><strong>Accenture (2017), U.S. Voter Records (2017), Capital One (2019), Pegasus Airlines (2022), Sisense (2024) </strong>etc are some example of S3 misconfigurations that lead to bucket leak.</p><p><strong>AWS Shared Responsibility Model for Bucket Security:</strong></p><p>In AWS:</p><ul><li><strong>AWS</strong> secures the <em>infrastructure</em> (servers, networking, storage).</li><li><strong>You</strong> secure your <em>data, configurations, and access policies.</em></li></ul><p>So, <strong>you are responsible</strong> for securing:</p><ul><li>Who can access your buckets (IAM, policies, ACLs)</li><li>How data is encrypted</li><li>Logging &amp; monitoring</li><li>Versioning &amp; lifecycle</li></ul><h3>How to Secure your Bucket</h3><h4>1. Access Control (The Heart of S3 Security)</h4><p>S3 offers <strong>multiple layers of access control</strong> — you should know how they interact.</p><p><strong>A. Block Public Access (Enable Always)</strong></p><p>This is your <strong>first defense</strong>.</p><p>✅ Keep all four public access settings enabled:</p><ul><li>Enable S3 Block Public Access at both the account and individual bucket levels. This setting prevents accidental or intentional public access grants through ACLs or bucket policies.</li><li>Ensure all four “Block Public Access” settings are enabled to block public access from both new and existing permissions.</li></ul><p><strong>Purpose:</strong> Prevents accidental exposure via bucket policies or ACLs.</p><p><strong>B. Use Bucket Policies (Least Privilege Principle)</strong></p><p>Bucket policies define <strong>who</strong> (IAM users, roles, or AWS accounts) can perform <strong>what actions</strong>.</p><p><strong>✅ Best Practice:</strong></p><ul><li>Use <em>Allow</em> statements only for specific principals.</li><li>Avoid Principal: “*” (anonymous/public access).</li><li>Avoid Action: “s3:*” — restrict to only needed actions like GetObject or PutObject.</li></ul><p><strong>C. IAM Policies (User or Role Permissions)</strong></p><p>Attach <strong>IAM policies</strong> to users or roles to define access.</p><p>📌 Combine <strong>IAM policies + bucket policies</strong> carefully; they are both evaluated together.</p><p><strong>D. Access Control Lists (ACLs) — Turned Off by Default</strong></p><p>ACLs are legacy.<br>Modern best practice: <strong>keep ACLs disabled</strong> (bucket-owner-enforced mode).<br> Use IAM and bucket policies instead.</p><h4>2.Encryption (Protecting Data at Rest and in Transit)</h4><p><strong>A. At Rest</strong></p><p>All new S3 objects are now encrypted <strong>by default (SSE-S3)</strong> using AES-256.</p><p>You can use stronger, more controlled encryption if needed:</p><ul><li><strong>SSE-S3:</strong> AWS managed keys <strong>(by default)</strong></li><li><strong>SSE-KMS:</strong> AWS KMS keys (more control)</li><li><strong>SSE-C:</strong> Customer provided keys</li></ul><p><strong>B. In Transit</strong></p><p>AWS always uses <strong>HTTPS (TLS)</strong> for data transfer.</p><p>Even though TLS is used by default:</p><ul><li>Some clients or tools (like curl or older SDKs) can still connect via <a href="http://s3.amazonaws.com/..."><strong>http://s3.amazonaws.com/...</strong></a></li><li>If anyone inside your organization or a third-party integration mistakenly uses HTTP, AWS will <strong>accept it unless you deny it</strong>.</li></ul><p>To prevent that:<br> You explicitly add a bucket policy like this 👇</p><p>{</p><p>“Sid”: “DenyInsecureConnections”,</p><p>“Effect”: “Deny”,</p><p>“Principal”: “*”,</p><p>“Action”: “s3:*”,</p><p>“Resource”: [“arn:aws:s3:::my-bucket”, “arn:aws:s3:::my-bucket/*”],</p><p>“Condition”: {</p><p>“Bool”: {“aws:SecureTransport”: “false”}</p><p>}</p><p>}</p><h4>3. Network-Level Security</h4><p><strong>A. Restrict Access with VPC Endpoints</strong></p><p>Create an <strong>S3 VPC Endpoint (Gateway Endpoint)</strong> so traffic stays inside AWS’s private network.</p><p>✅ Benefit:</p><ul><li>No internet exposure.</li><li>Data never leaves AWS’s internal network.</li></ul><h4>4. Logging, Monitoring, and Auditing</h4><p><strong>A. Enable S3 Server Access Logging</strong></p><p>Tracks all access requests to your bucket.</p><p><strong>B. Enable CloudTrail Data Events</strong></p><p>Tracks object-level actions (like GetObject, PutObject, DeleteObject).</p><p><strong>C. Enable AWS Config</strong></p><p>Monitors compliance — e.g., alerts if a bucket becomes public.</p><p><strong>D. Use GuardDuty + Security Hub</strong></p><p>Detect suspicious S3 access patterns (e.g., from unusual IPs or geolocations).</p><h4>5. Versioning &amp; Lifecycle Management</h4><p><strong>A. Enable Versioning</strong></p><p>Prevents data loss from accidental deletions or overwrites.</p><p><strong>B. Add Lifecycle Rules</strong></p><p>Automatically move old data to cheaper storage (Glacier) or delete expired versions.</p><h4>6. Other Security Enhancements</h4><ul><li><strong><em>Object Lock:</em></strong><em> Prevents deletion/modification for compliance.</em></li><li><strong><em>Replication with Encryption:</em></strong><em> If replicating between buckets, use SSE-KMS.</em></li><li><strong><em>CORS Policy:</em></strong><em> Allow only trusted domains.</em></li><li><strong><em>MFA Delete:</em></strong><em> Protects from accidental/malicious deletions.</em></li></ul><h4>7.Common Misconfigurations to Avoid</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MtICYqZkkUceQuwJ43idQ.png" /></figure><h4>8. Security Checklist for Every Bucket</h4><p>✅ Block all public access<br> ✅ Use least-privilege IAM and bucket policies<br> ✅ Enforce HTTPS (SecureTransport)<br> ✅ Encrypt data at rest (SSE-S3 or SSE-KMS)<br> ✅ Enable versioning<br> ✅ Enable logging and CloudTrail<br> ✅ Monitor with AWS Config &amp; GuardDuty<br> ✅ Use VPC endpoints if possible<br> ✅ Enable lifecycle rules<br> ✅ Review permissions regularly</p><h3>Conclusion</h3><p>Securing Amazon S3 buckets is not just a best practice — it’s a necessity. Misconfigured buckets have led to some of the largest data breaches in recent years, proving that even a single oversight can expose sensitive data and damage an organization’s reputation.</p><p>By applying <strong>the principle of least privilege</strong>, enforcing <strong>encryption (at rest and in transit)</strong>, enabling <strong>logging and monitoring</strong>, and leveraging <strong>VPC endpoints</strong>, organizations can significantly strengthen their data protection posture.</p><p>AWS provides powerful tools to help you maintain a secure environment — but under the <strong>Shared Responsibility Model</strong>, it’s your duty to configure, manage, and audit your S3 security settings properly.</p><p>✅ Always remember this simple rule:</p><blockquote><em>“If your data doesn’t need to be public, it shouldn’t be.”</em></blockquote><p>Implementing these security best practices ensures that your S3 buckets remain <strong>private, resilient, compliant, and protected against unauthorized access</strong>.</p><p>With strong access control, encryption, continuous monitoring, and automated compliance checks — your S3 storage can be both <strong>secure and scalable</strong>, truly embodying the spirit of <strong>cloud security done right</strong>. ☁️</p><p>Follow me for more Security related contents and also <strong>👥 Connect with me on LinkedIn</strong>: <a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/">https://www.linkedin.com/in/saksham-singh-aa31ba271/</a> — I’d love to connect and discuss more about cybersecurity and cloudsecurity!</p><p>Implementing these security best practices ensures that your S3 buckets remain <strong>private, resilient, compliant, and protected against unauthorized access</strong>.</p><p>With strong access control, encryption, continuous monitoring, and automated compliance checks — your S3 storage can be both <strong>secure and scalable</strong>, truly embodying the spirit of <strong>cloud security done right</strong>. ☁️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b02293838520" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Path traversal(directory traversal)]]></title>
            <link>https://medium.com/@sakshamsingh8784/path-traversal-directory-traversal-5d2e810486d4?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d2e810486d4</guid>
            <category><![CDATA[path-traversal]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[directory-traversal]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 09:20:19 GMT</pubDate>
            <atom:updated>2025-09-25T09:20:19.824Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone in this security blog we will discuss about Path Traversal vulnerability along with my methodology.</p><p>Path Traversal, also known as Directory Traversal, is a critical web security vulnerability that allows attackers to access files and directories that are <strong>outside the intended scope </strong>of the web application’s root directory by manipulating input.</p><p>Path Traversal is an <strong>HTTP attack</strong> which allows attackers to access restricted directories and execute commands outside of the web server’s root directory.</p><p>This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.</p><h4>🗂️ What is the “Intended Directory”?</h4><p>When developers build a web application, they often <strong>restrict file access to a specific folder</strong>.</p><p><strong>For example:</strong></p><p>Imagine a website that lets users read documents stored in this folder:</p><p>/var/www/html/docs/</p><p>The code might look like this:</p><p><em>$filename = $_GET[‘file’]; // user input</em></p><p><em>$content = file_get_contents(“/var/www/html/docs/” . $filename);</em></p><p><em>echo $content;</em></p><p>This means:</p><ul><li>If a user requests: ?file=report1.txt</li><li>The server reads: /var/www/html/docs/report1.txt ✅</li></ul><p>🟩 <strong>This is the intended behavior</strong> — users should only access files inside /docs/.</p><h4><strong>🚨 What does “Outside the Intended Directory” Mean?</strong></h4><p>If the application does <strong>not properly validate user input</strong>, an attacker can <strong>manipulate the path</strong> to break out of /docs/.</p><p>By using:</p><p>?file=../../../../etc/passwd</p><p>The path becomes:</p><p>/var/www/html/docs/../../../../etc/passwd</p><p>After resolving the .. (parent directories), the <strong>real path becomes</strong>:</p><p>/etc/passwd</p><p><strong>For example:</strong></p><p>If a site is designed to serve:</p><p>/var/www/html/pages/</p><p>It <strong>should only</strong> serve files like:</p><p>/var/www/html/pages/about.html</p><p>/var/www/html/pages/contact.html</p><p><strong>Outside the intended scope</strong> means accessing files like:</p><p>/etc/passwd ← System file (Linux)</p><p>/var/www/html/../config.php ← App config file</p><p>C:\Windows\win.ini ← Windows config file</p><p>These files lie <strong>outside the “safe zone”</strong> — they’re part of the server or app internals, not the public-facing web content.</p><p>🟥 <strong>That’s outside the intended directory</strong>.</p><p>So now, instead of reading a document, the app is reading a system file.</p><h4>🔁 Why This Happens?</h4><p>Because ../ means “go up one folder”. Chained together:</p><ul><li>../ = go up once</li><li>../../ = go up two levels</li><li>../../../ = go up three levels</li></ul><p>The attacker uses these to “escape” the safe folder and access <strong>arbitrary files on the server</strong>.</p><h4>📁 Common Target Files by OS</h4><p><strong>On Linux:</strong></p><ul><li>/etc/passwd — user info file (not passwords, but still useful).</li><li>/etc/shadow — actual hashed passwords (usually protected).</li><li>/var/log/apache2/access.log — access logs.</li><li>.ssh/id_rsa — SSH private keys.</li></ul><p><strong>On Windows:</strong></p><ul><li>C:\boot.ini or C:\Windows\win.ini</li><li>Application .config files</li></ul><h4>Consequences of Path Traversal</h4><p>Following are the consequences of Path Traversal Vulnerability:</p><p><strong>1. Sensitive Information Disclosure 📂</strong></p><ul><li>Attackers can Access files such as:</li><li>/etc/passwd (Linux user accounts info)</li><li>C:\Windows\win.ini (Windows config)</li><li>Application config files (config.php, .env) containing <strong>API keys, DB credentials, tokens</strong>.</li><li>This can lead to credential theft and lateral attacks.</li></ul><p><strong>2. Source Code Exposure 👨‍💻</strong></p><ul><li>Attackers may read source code files (.php, .py, .js, etc.).</li><li>This exposes business logic and hidden endpoints, enabling further exploitation like SQLi, RCE, or authentication bypass.</li></ul><p><strong>3. Credential Theft 🔑</strong></p><ul><li>Accessing SSH keys, database credentials, or secret tokens.</li><li>Example: reading /home/user/.ssh/id_rsa.</li></ul><p><strong>4. System’s Reconnaissance 🕵️</strong></p><ul><li>Reading system logs (/var/log/), cron jobs, or network config files.</li><li>It helps attackers map the environment for privilege escalation or persistence.</li></ul><p><strong>5. Denial of Service (DoS) 🚫</strong></p><ul><li>If it is combined with file inclusion or reading large system files, it can crash the application.</li><li>Example: /dev/urandom or /proc/self/mem could overwhelm memory/CPU.</li></ul><p><strong>6. Privilege Escalation / Lateral Movement 🚀</strong></p><ul><li>Once an attacker finds sensitive data (like DB creds), they may:</li><li>Connect to the database directly.</li><li>Pivot into other systems.</li><li>Gain admin access within the app.</li></ul><p>7. Remote Code Execution (RCE) 💥 (in severe cases)</p><ul><li>If path traversal is combined with <strong>file upload</strong> or <strong>local file inclusion (LFI)</strong>, attackers can upload a malicious script and execute it.</li><li>Example: upload a .php webshell and access it using path traversal.</li></ul><h3>Ok let’s move to my methodology for Path traversal:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*f3lT9QTlcJmtu1LHv-bWJA.gif" /></figure><h4>📚 Directory Traversal Testing — Step-by-Step</h4><p><strong>✅ Step 1: Look for File-Related Parameters</strong></p><p>Look for parameters/paths in requests such as:</p><ul><li>?file=, ?path=, ?download=, ?view=, ?template=, ?doc=, direct file paths in JSON or headers.</li></ul><p><strong>Tools:<em> ParamSpider, gau, Burp Suite (proxy, history).</em></strong></p><p><strong>🧪 2. Craft Initial Payloads</strong></p><p>Start with basic payload:</p><p>../../../../etc/passwd<br>../../etc/passwd<br>../etc/passwd</p><p><strong>🧨 3. Test Common Bypass Variants</strong></p><p><strong>Try Payloads :</strong></p><p><strong><em>URL Encoding</em></strong></p><p>%2e%2e%2fetc%2fpasswd</p><p><strong><em>Double Encoding</em></strong></p><p>%252e%252e%252fetc%252fpaswd</p><p><strong><em>Mixed slashes</em></strong></p><p>..%2f..%5cetc%2fpasswd</p><p><strong><em>Obfuscation</em></strong></p><p>….//….//etc/passwd</p><p><strong><em>Null Byte (older apps)</em></strong></p><p>../../../etc/passwd%00.png</p><p><strong><em>Path Normalization tricks</em></strong></p><p>var/www/html/docs/../../../../etc/passwd (test absolute + relative combos)</p><p><strong>🧑‍💻 4. Use Burp Suite Repeater</strong></p><p><strong>Steps:</strong></p><ol><li>Send a file-related request to Repeater.</li><li>Replace the parameter with crafted payloads.</li><li>Observe the response:</li></ol><ul><li>200 OK</li><li>Content size increases</li><li>Look for keywords in response: root:, /bin/bash, DB_PASSWORD, define(&#39;DB_PASSWORD</li><li>root:x:0:0, bin/bash, etc.</li><li>root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin etc</li></ul><p><strong>✅ Step 5: Automate with Burp Intruder</strong></p><p><strong>Burp Intruder:</strong></p><ol><li><strong>Use the Fuzzing — Path Traversal list</strong></li><li><strong>Position payload in filename=§FUZZ§</strong></li><li>Load a wordlist like:</li></ol><ul><li><strong>SecLists/Fuzzing/LFI/LFI-Jhaddix.txt</strong></li><li>Custom traversal payloads</li></ul><p><strong>Detection indicators</strong></p><ul><li>Response contains OS file markers (root:x, bash, Administrator, MACHINE, DB_PASSWORD).</li><li>Unusual content length differences.</li><li>Files with config or code snippets returned (HTML/JS that was never supposed to be public).</li><li>500 Internal Server Error or stack traces that leak file paths.</li></ul><h4>Preventive measures &amp; secure coding patterns ✅</h4><p><strong>1) Canonicalize then check</strong></p><p>Resolve the requested path to an absolute path and ensure it lives under allowed root.</p><p><strong>PHP example</strong></p><p><em>$root = &#39;/var/www/html/docs/&#39;;<br>$user_input = $_GET[&#39;file&#39;];<br>$path = realpath($root . $user_input);</em></p><p><em>if ($path === false || strpos($path, realpath($root)) !== 0) {<br> http_response_code(403);<br> echo &quot;Access denied&quot;;<br> exit;<br>}</em></p><p><em>echo file_get_contents($path);</em></p><p><strong>Python (Flask) example</strong></p><p><em>from flask import send_file, abort<br>import os</em></p><p><em>ROOT = &#39;/var/www/html/docs/&#39;def safe_join(root, *paths):<br> root = os.path.realpath(root)<br> path = os.path.realpath(os.path.join(root, *paths))<br> if os.path.commonpath([root, path]) != root:<br> return None<br> return pathfilename = request.args.get(&#39;file&#39;)<br>path = safe_join(ROOT, filename)<br>if not path:<br> abort(403)<br>return send_file(path)</em></p><p><strong>2) Use an allowlist (preferred)</strong></p><p>Only serve files that are in a known list (IDs mapped to filenames) or use database records rather than direct file paths:</p><p><em>/download?id=123 -&gt; lookup filename from DB, then serve safe path</em></p><p><strong>3) Remove dangerous characters</strong></p><p>Sanitize input to remove .., null bytes, control chars — but do not rely on this alone. Canonicalization + allowlist is stronger.</p><p><strong>4) Configure server safely</strong></p><ul><li>Disable directory listing.</li><li>Limit file read operations to allowed types/extensions.</li><li>Run the web server with least privilege so leaked files are limited.</li></ul><p><strong>5) Monitoring &amp; alerts</strong></p><ul><li>Alert on requests containing ../, %2e%2e, long path traversal sequences.</li><li>Log high-frequency file requests and large file reads.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d2e810486d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subdomain Takeover]]></title>
            <link>https://medium.com/@sakshamsingh8784/subdomain-takeover-aa39585575c6?source=rss-a637b37f059a------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa39585575c6</guid>
            <category><![CDATA[subdomain-takeover]]></category>
            <category><![CDATA[vapt]]></category>
            <category><![CDATA[websec]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Saksham Singh]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 08:32:32 GMT</pubDate>
            <atom:updated>2025-09-16T08:32:32.102Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Hello everyone, in this security blog we will be discussing subdomain vulnerability and the methodology to check for takeovers.</p><p>First, let us understand about what is a subdomain</p><p>A<strong> Subdomain </strong>is a subset or a section of larger domain for e.g., info.abc.com is subdomain of the domain abc.com .Subdomains are used to organise different section of a website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0It7MlAnZkeE56CdGHFTA.png" /></figure><p>A subdomain takeover is an attack where an attacker gains control over a website’s subdomain.</p><p>A <strong>subdomain takeover vulnerability </strong>occurs when an attacker takes control of an unused or unconfigured subdomain within a domain. It typically happens when a domain has a subdomain that points to an external service (like a cloud hosting provider (AWS S3), or a content delivery network, github, Heroku, azure frontdoor etc), but that<strong> service no longer exists or has been deleted</strong>, <strong>leaving the subdomain unconfigured</strong>(means that the DNS record for that subdomain still existing) or remained dangling.</p><p>To understand this more clearly let us consider a scenario-</p><p><strong>Scenario: Subdomain Takeover on media.company.com</strong></p><p>Original Setup: A marketing team for company.com uses an Amazon S3 bucket service to host media files.</p><p>They create a DNS record:</p><p>media.company.com. CNAME media-bucket.s3.amazonaws.com</p><p>❌ S3 Bucket Deleted</p><p>Later, the team deletes the media-bucket from Amazon S3 but forgets to remove the DNS record for media.company.com.</p><p>Now, media.company.com points to a non-existent S3 bucket.</p><p>👾 Attacker Comes In</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*-agBkavyptCa84GXk1ZQrg.png" /></figure><ul><li>The attacker checks the DNS and finds media.company.com pointing to a now-missing S3 bucket.</li><li>They create a new S3 bucket named media-bucket in their own AWS account.</li><li>They upload custom (or malicious) content to the bucket and make it publicly accessible.</li></ul><p>Now, <strong>visiting media.company.com serves content from the attacker’s bucket</strong>.</p><p>That’s the essence of a subdomain takeover. The attacker exploits a forgotten DNS configuration and gains control over a trusted subdomain.</p><p>Not necessarily all the 3rd party services are vulnerable you can check which 3rd party servies are vulnerable to subdomain takeover:</p><p><a href="https://github.com/EdOverflow/can-i-take-over-xyz">GitHub - EdOverflow/can-i-take-over-xyz: &quot;Can I take over XYZ?&quot; - a list of services and how to claim (sub)domains with dangling DNS records.</a></p><blockquote>This repository lists services and how to claim subdomains with dangling DNS records.</blockquote><p><strong>Impact</strong></p><ul><li>The attacker could:</li><li>Serve phishing pages</li><li>Inject malware</li><li>Capture cookies or credentials</li><li>Harm brand reputation</li></ul><h3>Hunting Methodlogy</h3><p>Subdomain Takeovers are gold mines for bug hunters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*-Vfo8Q2jNrw1R6VY6JUYwQ.png" /></figure><h4><strong>1️⃣ Subdomain Enumeration</strong></h4><p>Subdomain Enumeration plays a crucial role in finding subdoamin takeover vulnerability. “Thing is simple as more the subdomains you have more the chance of finding the subdomain takeover bug”.</p><p>Different <strong>tools</strong> i use for subdomain enumeration:</p><p><strong>amass: </strong>amass enum -d target.com -o amass.txt</p><p><strong>subfinder: </strong>subfinder -d target.com -o subfinder.txt</p><p><strong>assetfinder: </strong>assetfinder — subs-only target.com | tee assetfinder.txt</p><p><strong>crt.sh: </strong><a href="http://crt.sh/"><strong>crt.sh</strong></a><strong> from command line- </strong>curl -s “https://crt.sh/?q=%.target.com&amp;output=json&quot; | jq -r ‘.[].name_value’ | sort -u &gt; crt_sh.txt</p><p><strong>waybackurls: </strong>echo target.com | waybackurls &gt; waybackurls.txt</p><p><strong>findomain: </strong>findomain -t target.com &gt; findomain.txt</p><p><strong>Merge and dedupe results:</strong><br>cat amass.txt subfinder.txt assetfinder.txt crt_sh.txt waybackurls.txt findomain.txt | sort -u &gt; subdomains.txt</p><p><strong>1 Linear bash command for subdomain enumeration</strong></p><p>You can use this <strong>1 Linear bash command </strong>for sudomain eumeration and dedupe results.</p><p>TARGET=”example.com”; \</p><p>subfinder -d $TARGET -silent -o subfinder.txt; \</p><p>assetfinder — subs-only $TARGET | tee assetfinder.txt; \</p><p>findomain -t $TARGET -q &gt; findomain.txt; \</p><p>curl -s “https://crt.sh/?q=%25.$TARGET&amp;output=json&quot; | jq -r ‘.[].name_value’ | sed ‘s/\*\.//g’ | tee crtsh.txt; \</p><p>waybackurls $TARGET | awk -F/ ‘{print $3}’ | tee waybackurls.txt; \</p><p>amass enum -d $TARGET -o amass.txt; \</p><p>cat subfinder.txt assetfinder.txt findomain.txt crtsh.txt waybackurls.txt amass.txt | sort -u &gt; all_subdomains.txt &amp;&amp; \</p><p>echo “[✔] Found $(wc -l &lt; all_subdomains.txt) unique subdomains saved in all_subdomains.txt”</p><h4><strong>2️⃣ Manual Check for DNS Resolution</strong></h4><p>In the context of <strong>subdomain takeover</strong>, when we say <strong>“DNS resolution”</strong>, we are primarily using it to:</p><p><strong>👉 Find the CNAME Record of a subdomain</strong></p><p>Because:</p><p><strong>CNAME records</strong> often point to <strong>third-party services</strong> like Heroku, GitHub Pages, S3, Azure, etc.<br> If the third-party resource is <strong>unclaimed</strong>, you can potentially take it over.</p><p><strong>dnsx, dig tools are used for this purpose:</strong></p><p><strong>Example:</strong></p><p>Suppose you’re checking this subdomain:<br> blog.target.com</p><p>You run:</p><p>dig -f blog.target.com CNAME +short</p><p>You get:</p><p>unclaimedsite.github.io.</p><p>✅ This tells you:</p><ul><li>The DNS <strong>resolves</strong></li><li>The subdomain is pointing to <strong>GitHub Pages</strong></li><li>You can now check if unclaimedsite.github.io is available to claim</li></ul><p>➡️ This is how <strong>DNS resolution is used to find CNAME.</strong></p><p>You can now check it by visiting the site blog.target.com manually and if <em>blog.target.com → It redirects (or shows a 404) from </em><em>unclaimedsite.github.io</em></p><p>If the page shows a <strong>404 not found</strong> or GitHub’s <strong>“There isn’t a GitHub Pages site here”</strong> message, it means the GitHub Pages site is <strong>unclaimed</strong></p><p>Then g<strong>o to </strong><a href="https://github.com/"><strong>GitHub</strong></a> and log in (or create an account).</p><ul><li><strong>Create a new repository</strong> named <strong>unclaimedsite</strong> (must match the subdomain prefix).</li><li>Inside the repository:</li><li>Add an index.html file with your test content (e.g., Hello from takeover test!).</li><li><strong>Enable GitHub Pages</strong>:</li><li>Go to <strong>Settings → Pages</strong>.</li><li>Select the branch (e.g., main) and folder (/root) for GitHub Pages.</li><li>Save and wait a few seconds.</li><li><strong>Now visit</strong> blog.target.com.</li></ul><p>✅ If your test page shows up, the subdomain was <strong>successfully taken over</strong>.</p><p>Similarly you can test for other services also e.g., AWS S3, GitHub Pages, Heroku, Azure.</p><h4><strong>3️⃣ Automation using tools</strong></h4><p>You can use subzy, subjack, nuclei to Detect Potential Takeovers</p><p><strong>Using Subjack</strong></p><p>subjack -w subdomains.txt -t 100 -timeout 10 -ssl -v -o subjack_results.txt</p><p><strong>Using subzy</strong></p><p>subzy -targets subdomains.txt -timeout 10 -json -o subzy_results.json</p><p><strong>Using Nuclei</strong></p><p>cat subdomains.txt | nuclei -t takeovers</p><h3>Conclusion</h3><p>Subdomain takeovers are a real threat and also a great opportunity for bug hunters. By combining subdomain enumeration, manual checks, and automated scanning, you can uncover vulnerabilities and help secure websites.</p><p>Always ensure you have proper authorization before scanning or testing domains.</p><p>Happy hunting!</p><p><strong>👥 Connect with me on LinkedIn</strong>: <a href="https://www.linkedin.com/in/saksham-singh-aa31ba271/">https://www.linkedin.com/in/saksham-singh-aa31ba271/</a> — I’d love to connect and discuss more about cybersecurity!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa39585575c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>