<?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 Kelvin Onyango on Medium]]></title>
        <description><![CDATA[Stories by Kelvin Onyango on Medium]]></description>
        <link>https://medium.com/@kelvinonyango22?source=rss-dcd0f4860d54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xPSchg-FWi_7Vw_3</url>
            <title>Stories by Kelvin Onyango on Medium</title>
            <link>https://medium.com/@kelvinonyango22?source=rss-dcd0f4860d54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:43:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kelvinonyango22/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[Building a Secure AWS VPC: A Step-by-Step Guide to Deploying a Web Server with Terraform]]></title>
            <link>https://medium.com/@kelvinonyango22/building-a-secure-aws-vpc-a-step-by-step-guide-to-deploying-a-web-server-with-terraform-9d215a72002a?source=rss-dcd0f4860d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d215a72002a</guid>
            <category><![CDATA[aws-vpc]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[cloud-networking]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <dc:creator><![CDATA[Kelvin Onyango]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 14:07:42 GMT</pubDate>
            <atom:updated>2025-02-20T14:07:42.611Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*Z9iS_AkhmxXOLNFICz1GzA.jpeg" /></figure><p>Amazon <strong>Virtual Private Cloud (VPC)</strong> allows you to create a secure and isolated network environment in AWS. We can <strong>automate VPC creation, subnets, internet gateways, NAT gateways, security groups, and EC2 instances using Terraform.</strong></p><p>Setting up a <strong>secure, scalable AWS Virtual Private Cloud (VPC)</strong> is essential for any cloud-based infrastructure. In this guide, we will walk through <strong>automating the creation of a VPC, subnets, security groups and launching an EC2 web server using Terraform</strong>. By the end, you’ll have a <strong>fully functional web server in a secure network environment</strong>, ready to handle real-world traffic.</p><p>In this guide, we’ll cover:<br>1. How to create a <strong>VPC with public and private subnets</strong>.<br>2. Configuring an <strong>Internet Gateway and NAT Gateway</strong> for secure access.<br>3. Setting up a <strong>Security Group</strong> to control incoming traffic.<br>4. Launching an <strong>EC2 instance as a web server</strong>.<br>5. Automating everything using <strong>Terraform Infrastructure as Code (IaC)</strong>.</p><h3>Step 1: Setting Up Terraform for AWS VPC</h3><p>Before we start, ensure you have:</p><ul><li><strong>Terraform installed</strong> (<a href="https://developer.hashicorp.com/terraform/install">Download Here</a>)</li><li><strong>AWS CLI configured</strong> (aws configure)</li><li><strong>IAM user with appropriate permissions</strong></li></ul><h3>Create Your Terraform Project</h3><p>During your AWS CLI configuration , you will prompted to enter:</p><ul><li><strong>AWS Access Key ID</strong></li><li><strong>AWS Secret Access Key</strong></li><li><strong>Default region name</strong> (e.g., us-east-1)</li><li><strong>Output format</strong> (leave blank or use json)</li></ul><p>Once configured, Terraform will <strong>automatically use these credentials</strong>. Your credentials will be stored in ~/.aws/credentials (Linux/macOS) or C:\Users\YourName\.aws\credentials (Windows).</p><p>Create a directory or folder for this project on your machine (<em>aws-vpc-setup), </em>then locate the directory or folder on your machine inside your CLI/CMD.</p><p>You have to use <strong><em>cd</em></strong> together with the <strong>path to your directory</strong> as shown in the example below</p><pre>(Linux/macOS)<br>cd ~/aws-vpc-setup <br><br><br>(Windows)<br>cd C:\Users\YourName\aws-vpc-setup</pre><p>You can <strong>either continue using the same terminal used to configure aws </strong>or open a new terminal to run Terraform.</p><h3>Step 2: Automate AWS VPC Creation Using Terraform</h3><p>Instead of manually configuring VPC components, we’ll define everything in <strong>Terraform</strong>.</p><p>Create the main.tf file in aws-vpc-setup directory. Using you IDE, Add the following to main Terraform configuration file (main.tf)</p><h3>Main Terraform Configuration (main.tf)</h3><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><br># Create VPC<br>resource &quot;aws_vpc&quot; &quot;main_vpc&quot; {<br>  cidr_block = &quot;10.0.0.0/16&quot;<br>  enable_dns_support = true<br>  enable_dns_hostnames = true<br>  tags = {<br>    Name = &quot;lab-vpc&quot;<br>  }<br>}<br><br># Create Public Subnet<br>resource &quot;aws_subnet&quot; &quot;public_subnet&quot; {<br>  vpc_id = aws_vpc.main_vpc.id<br>  cidr_block = &quot;10.0.0.0/24&quot;<br>  availability_zone = &quot;us-east-1a&quot;<br>  map_public_ip_on_launch = true<br>  tags = {<br>    Name = &quot;lab-subnet-public&quot;<br>  }<br>}<br><br># Create Private Subnet<br>resource &quot;aws_subnet&quot; &quot;private_subnet&quot; {<br>  vpc_id = aws_vpc.main_vpc.id<br>  cidr_block = &quot;10.0.1.0/24&quot;<br>  availability_zone = &quot;us-east-1a&quot;<br>  tags = {<br>    Name = &quot;lab-subnet-private&quot;<br>  }<br>}<br><br># Create Internet Gateway<br>resource &quot;aws_internet_gateway&quot; &quot;igw&quot; {<br>  vpc_id = aws_vpc.main_vpc.id<br>  tags = {<br>    Name = &quot;lab-igw&quot;<br>  }<br>}<br><br># Create Route Table for Public Subnet<br>resource &quot;aws_route_table&quot; &quot;public_rt&quot; {<br>  vpc_id = aws_vpc.main_vpc.id<br>  tags = {<br>    Name = &quot;lab-rtb-public&quot;<br>  }<br>}<br><br># Associate Public Subnet with Route Table<br>resource &quot;aws_route_table_association&quot; &quot;public_assoc&quot; {<br>  subnet_id      = aws_subnet.public_subnet.id<br>  route_table_id = aws_route_table.public_rt.id<br>}<br><br># Create NAT Gateway for Private Subnet<br>resource &quot;aws_nat_gateway&quot; &quot;nat_gw&quot; {<br>  allocation_id = aws_eip.nat.id<br>  subnet_id     = aws_subnet.public_subnet.id<br>  tags = {<br>    Name = &quot;lab-nat-gateway&quot;<br>  }<br>}<br><br># Create EIP for NAT Gateway<br>resource &quot;aws_eip&quot; &quot;nat&quot; {<br>  vpc = true<br>}<br><br># Route Table for Private Subnet<br>resource &quot;aws_route_table&quot; &quot;private_rt&quot; {<br>  vpc_id = aws_vpc.main_vpc.id<br>  tags = {<br>    Name = &quot;lab-rtb-private&quot;<br>  }<br>}<br><br># Associate Private Subnet with Route Table<br>resource &quot;aws_route_table_association&quot; &quot;private_assoc&quot; {<br>  subnet_id      = aws_subnet.private_subnet.id<br>  route_table_id = aws_route_table.private_rt.id<br>}</pre><p>This script will create a VPC, subnets, an internet gateway, and NAT gateway automatically.</p><h3>Step 3: Configure Security Groups</h3><p>A <strong>security group</strong> acts as a <strong>firewall</strong>, controlling access to our web server.</p><p>Create the security_group.tf file in aws-vpc-setup directory. Using you IDE, Add the following to Security Group Terraform configuration file (security_group.tf)</p><pre>resource &quot;aws_security_group&quot; &quot;web_sg&quot; {<br>  vpc_id = aws_vpc.main_vpc.id<br>  name   = &quot;web-security-group&quot;<br><br>  # Allow HTTP traffic from anywhere<br>  ingress {<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  # Allow SSH for administration (only allow YOUR IP for security)<br>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;YOUR_IP/32&quot;]<br>  }<br><br>  # Allow all outbound traffic<br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  tags = {<br>    Name = &quot;web-security-group&quot;<br>  }<br>}</pre><p>This security group allows HTTP access from anywhere and SSH only from your IP.</p><h3>Step 4: Launch an EC2 Instance with a Web Server</h3><p>Create the launch_instance.tf file in aws-vpc-setup directory. Using you IDE, Add the following to Launch Instance Terraform configuration file (launch_instance.tf)</p><p>Now, let’s launch an EC2 instance in the <strong>public subnet</strong> and install a <strong>web server</strong>.</p><pre>resource &quot;aws_instance&quot; &quot;web_server&quot; {<br>  ami             = &quot;ami-0c55b159cbfafe1f0&quot; # Amazon Linux 2023 AMI ID<br>  instance_type   = &quot;t2.micro&quot;<br>  subnet_id       = aws_subnet.public_subnet.id<br>  security_groups = [aws_security_group.web_sg.name]<br><br>  user_data = &lt;&lt;-EOF<br>    #!/bin/bash<br>    yum install -y httpd<br>    systemctl start httpd<br>    systemctl enable httpd<br>    echo &quot;&lt;h1&gt;Deployed via Terraform&lt;/h1&gt;&quot; &gt; /var/www/html/index.html<br>  EOF<br><br>  tags = {<br>    Name = &quot;Web Server&quot;<br>  }<br>}</pre><p>This script:</p><ul><li>Launches an EC2 instance in the public subnet</li><li>Installs Apache Web Server</li><li>Deploys a test HTML page</li></ul><h3>Step 4: Deploy IAM Resources and Add Security on AWS</h3><p>Run the following Terraform commands</p><h3>1. Initialize Terraform</h3><pre>terraform init</pre><p>This sets up Terraform and downloads necessary AWS plugins.</p><h3>2. Preview Changes</h3><pre>terraform plan</pre><p>Terraform will display what changes it plans to make.</p><h3>3. Apply the Configuration</h3><pre>terraform apply -auto-approve</pre><h3>Step 5: Destroying Resources (If Needed)</h3><p>If you need to <strong>remove everything</strong>, run:</p><pre>terraform destroy -auto-approve</pre><p>Deploys the VPC, security group, and EC2 web server</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d215a72002a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Secure AWS IAM: Guide to Role-Based Access with Terraform]]></title>
            <link>https://medium.com/@kelvinonyango22/mastering-secure-aws-iam-guide-to-role-based-access-with-terraform-49eca413f4b4?source=rss-dcd0f4860d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/49eca413f4b4</guid>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Kelvin Onyango]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 19:36:51 GMT</pubDate>
            <atom:updated>2025-02-20T13:45:47.111Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*8eAVd-s-k7CWbo6LdGP3mg.png" /></figure><p>AWS Identity and Access Management (IAM) is the backbone of security in the cloud. Manually managing users, groups, and permissions can be inefficient and risky. In this guide, we will walk through <strong>automating secure IAM role-based access management using Terraform. </strong>This will help you enforce best practices, minimize security risks, and scale access control efficiently.</p><p>Managing <strong>AWS IAM manually</strong> can quickly become overwhelming, especially as your organization grows. Your cloud environment becomes vulnerable to unauthorized access and security misconfigurations without proper <strong>role-based access control (RBAC), multi-factor authentication (MFA), and audit logging.</strong></p><p>In this guide, we’ll cover:<br>1. How to structure IAM <strong>roles, groups, and policies</strong> for different user needs.<br>2. Automating IAM user management using <strong>Terraform</strong> (Infrastructure as Code).<br>3. Enforcing security best practices like <strong>MFA, password policies, and CloudTrail logging</strong>.<br>4. A <strong>hands-on walkthrough</strong> of deploying IAM resources step by step.</p><h3>Step 1: Setting Up Terraform for AWS IAM</h3><p>Before we begin, ensure you have <strong>Terraform</strong> and <strong>AWS CLI</strong> installed and configured.</p><h3>1. Install Terraform</h3><h4>Mac &amp; Linux:</h4><pre>brew install terraform</pre><h4>Windows:</h4><ol><li>Download from <a href="https://developer.hashicorp.com/terraform/install">Terraform’s official website</a>.</li><li>Extract and add it to your <strong>System PATH</strong>.</li></ol><p>Verify installation:</p><pre>terraform -v</pre><p><strong>If Terraform is installed correctly, you should see the version number.</strong></p><h3>Step 2: Configure AWS CLI</h3><p>Before we start, ensure you have:</p><ul><li><strong>AWS CLI configured</strong> (aws configure)</li><li><strong>IAM user with appropriate permissions</strong></li></ul><h3>Create Your Terraform Project</h3><p>During your AWS CLI configuration , you will prompted to enter:</p><ul><li><strong>AWS Access Key ID</strong></li><li><strong>AWS Secret Access Key</strong></li><li><strong>Default region name</strong> (e.g., us-east-1)</li><li><strong>Output format</strong> (leave blank or use json)</li></ul><p>Once configured, Terraform will <strong>automatically use these credentials</strong>. Your credentials will be stored in ~/.aws/credentials (Linux/macOS) or C:\Users\YourName\.aws\credentials (Windows).</p><p>Create a directory or folder for this project on your machine (<em>aws-iam-setup), </em>then locate the directory or folder on your machine inside your CLI/CMD.</p><p>You have to use <strong><em>cd</em></strong> together with the <strong>path to your directory</strong> as shown in the example below</p><pre>(Linux/macOS)<br>cd ~/aws-iam-setup <br></pre><pre>(Windows)<br>cd C:\Users\YourName\aws-iam-setup</pre><p>You can <strong>either continue using the same terminal used to configure aws </strong>or open a new terminal to run Terraform.</p><p>Using you IDE, Add the main Terraform configuration file (main.tf) to aws-iam-setup</p><h3>Step 2: Automating IAM Role-Based Access with Terraform</h3><p>Instead of manually creating users, groups, and policies, we’ll define everything in <strong>Terraform</strong>.</p><p>Main Terraform Configuration (main.tf)</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><br># IAM Groups<br>resource &quot;aws_iam_group&quot; &quot;s3_support&quot; {<br>  name = &quot;S3-Support&quot;<br>}<br><br>resource &quot;aws_iam_group&quot; &quot;ec2_support&quot; {<br>  name = &quot;EC2-Support&quot;<br>}<br><br>resource &quot;aws_iam_group&quot; &quot;ec2_admin&quot; {<br>  name = &quot;EC2-Admin&quot;<br>}<br><br># Attach IAM Policies to Groups<br>resource &quot;aws_iam_group_policy_attachment&quot; &quot;s3_support_policy&quot; {<br>  group      = aws_iam_group.s3_support.name<br>  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess&quot;<br>}<br><br>resource &quot;aws_iam_group_policy_attachment&quot; &quot;ec2_support_policy&quot; {<br>  group      = aws_iam_group.ec2_support.name<br>  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess&quot;<br>}<br><br>resource &quot;aws_iam_group_policy_attachment&quot; &quot;ec2_admin_policy&quot; {<br>  group      = aws_iam_group.ec2_admin.name<br>  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEC2FullAccess&quot;<br>}<br><br># IAM Users<br>resource &quot;aws_iam_user&quot; &quot;user1&quot; {<br>  name = &quot;user-1&quot;<br>}<br><br>resource &quot;aws_iam_user&quot; &quot;user2&quot; {<br>  name = &quot;user-2&quot;<br>}<br><br>resource &quot;aws_iam_user&quot; &quot;user3&quot; {<br>  name = &quot;user-3&quot;<br>}<br><br># Assign Users to Groups<br>resource &quot;aws_iam_user_group_membership&quot; &quot;user1_group&quot; {<br>  user   = aws_iam_user.user1.name<br>  groups = [aws_iam_group.s3_support.name]<br>}<br><br>resource &quot;aws_iam_user_group_membership&quot; &quot;user2_group&quot; {<br>  user   = aws_iam_user.user2.name<br>  groups = [aws_iam_group.ec2_support.name]<br>}<br><br>resource &quot;aws_iam_user_group_membership&quot; &quot;user3_group&quot; {<br>  user   = aws_iam_user.user3.name<br>  groups = [aws_iam_group.ec2_admin.name]<br>}</pre><h3>Step 4: Enforcing Security Best Practices</h3><p>We can add security measures like:</p><h3>1. Enforcing MFA for IAM Users</h3><p>MFA terraform configuration (mfa.tf)</p><pre>resource &quot;aws_iam_user_login_profile&quot; &quot;user1_mfa&quot; {<br>  user = aws_iam_user.user1.name<br>  password_reset_required = true<br>}</pre><p>This ensures users must <strong>set up MFA on their first login.</strong></p><h3>2. Enable CloudTrail for IAM Auditing</h3><p>CloudTrail terraform configuration (cloudtrail.tf)</p><pre>resource &quot;aws_cloudtrail&quot; &quot;iam_trail&quot; {<br>  name                          = &quot;IAM-Audit-Trail&quot;<br>  s3_bucket_name                = aws_s3_bucket.trail_bucket.id<br>  include_global_service_events = true<br>  is_multi_region_trail         = true<br>  enable_logging                = true<br>}</pre><p>Now, all IAM activity is logged for security monitoring.</p><h3>Step 4: Deploy IAM Resources and Add Security on AWS</h3><p>Run the following Terraform commands to <strong>deploy IAM users, groups, and policies</strong> automatically:</p><h3>1. Initialize Terraform</h3><pre>terraform init</pre><p>This sets up Terraform and downloads necessary AWS plugins.</p><h3>2. Preview Changes</h3><pre>terraform plan</pre><p>Terraform will display what changes it plans to make.</p><h3>3. Apply the Configuration</h3><pre>terraform apply -auto-approve</pre><p>Terraform will now <strong>create IAM users, groups, and permissions</strong> in AWS</p><h3>Step 5: Destroying Resources (If Needed)</h3><p>If you need to <strong>remove everything</strong>, run:</p><pre>terraform destroy -auto-approve</pre><p>This deletes all <strong>IAM users, groups, and policies</strong> created.</p><h3>Best Practices for IAM Security</h3><ol><li><strong>Follow the Principle of Least Privilege:</strong> Only grant users the permissions they absolutely need.</li><li><strong>Use IAM Roles Instead of Users Where Possible:</strong> Roles are more secure than long-lived IAM user credentials.</li><li><strong>Enable Multi-Factor Authentication (MFA):</strong> Protect user logins from credential theft.</li><li><strong>Regularly Rotate Access Keys:</strong> Avoid long-term AWS credentials.</li><li><strong>Monitor IAM Activity with AWS CloudTrail:</strong> Track who is doing what in IAM.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49eca413f4b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Virtual Private Cloud (VPC) From Setup to Website!]]></title>
            <link>https://medium.com/@kelvinonyango22/aws-virtual-private-cloud-vpc-from-setup-to-website-e26f345786cd?source=rss-dcd0f4860d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/e26f345786cd</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <dc:creator><![CDATA[Kelvin Onyango]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 11:50:18 GMT</pubDate>
            <atom:updated>2024-01-14T11:50:18.283Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*NLpNPvYQj3m7Z_lA2a1SUA.jpeg" /></figure><p>Greetings, tech enthusiasts! Imagine your online services as a fleet of high-tech cars parked in a futuristic parking lot. Make one wrong move, and your car could end up isolated from its buddies or, even worse, exposed to internet mischief! In the realm of Amazon Web Services (AWS), every service needs to hang out in a VIP area called Virtual Private Cloud (VPC). So, let’s embark on a journey to demystify AWS VPC — the superhero that keeps your services safe from internet chaos. Picture VPC as the guardian wall around your digital assets, shielding them from the unpredictable internet world.</p><p>Think of it like this: your VPC is a secure parking lot, walls and all. Cars inside are safe from outside shenanigans, just like your AWS resources are shielded from internet troublemakers.</p><h3>Seven Steps to Create an AWS VPC</h3><h3>Step 1: Create the VPC</h3><p>Now, let’s get creative and build our very own VPC. Let’s call it the Kelvin-VPC (because why not add a dash of mystery?). Head to the AWS console, search for “VPC,” and create your own VPC with a cool name and address range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*ALn5Nj4_i4OKgjQBpBNfmQ.jpeg" /></figure><ol><li>In the VPC dashboard, click on the “Create VPC” button.</li><li>Fill in the details, including a name (e.g., Kelvin-VPC) and a CIDR range (e.g., 10.5.0.0/16).</li><li>Click on “Create VPC” to generate an empty VPC with the specified CIDR range.</li></ol><h3>Step 2: Create Subnets</h3><p>Next up, meet the “subnets.” Imagine dividing your parking lot into sections. Maybe one for visitors, another for employees, and a hidden one for top-secret company carts. Similarly, in VPC, we create subnets for different resources, each with its own purpose. Some subnets party with the internet (public), while others stay incognito (private).</p><p>Just like Parking Lot A, B, and C were for different folks, public subnets have a direct route to the internet, while private ones are more like secret hideouts with no direct internet access.</p><p>Why the secrecy, you ask? Well, imagine a parking lot where only certain carts can access the outside world. Your databases are like these carts — they need protection from the chaos outside.</p><p>Enough chit-chat, let’s roll up our sleeves and create two subnets. One for the internet party and another for the secret society. Got it? Good!</p><ol><li>Access the “Subnets” section on the left pane of the VPC dashboard.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*r0tXjORfj6Lh9_unOp_6bw.jpeg" /></figure><p>2. Click on “Create Subnet” and provide a name for the subnet (e.g., public subnet) along with a CIDR block range within the VPC CIDR (e.g., 10.5.2.0/24).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*syk1GfHDUhy81nWMhtPoAA.jpeg" /></figure><p>3. Repeat the process to create a private subnet with a different CIDR block range (e.g., 10.5.1.0/24).</p><h3>Step 3: Set Up Internet Gateway</h3><p>Now, let’s talk about the Internet Gateway — the gate to the internet for our parking lots A, B, and C. We’ll create our own “Kelvin-IGW” and connect it to our VPC. Without it, no one in the VPC can talk to the internet, and vice versa.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*Bd0JETHTMHKz-fpTHPohSg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*reSxnD_Xk5BAnlLKiM-Eiw.jpeg" /></figure><ol><li>Navigate to the “Internet Gateways” section on the left pane of the VPC dashboard.</li><li>Click on “Create Internet Gateway” and name it (e.g., Kelvin-IGW).</li><li>After creation, attach the Internet Gateway to your VPC by selecting the VPC and clicking “Attach Internet Gateway.”</li></ol><h3>Step 4: Create and Configure Route Tables</h3><p>But hey, attaching the gate isn’t enough! We need roads from each parking lot to the gate. In VPC lingo, we use “route tables” to define these paths. Let’s configure our main route table to access the internet via the Internet Gateway.</p><ol><li>Go to the “Route Tables” section in the VPC dashboard. Create a Public and Private Route table.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*EbX0tydbQc8SAvalDNhMTg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*JqFNRsO2BbA9mdj5eLVOeA.jpeg" /></figure><p>2. Now we need to add an Internet Gateway to the public route. You will click on Edit Route, pick a destination as 0.0.0.0/0 and target as Kelvin-IGW.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z36JNROe7sr4w58-o7vXlA.jpeg" /></figure><p>3. Add the public subnet to the public route. You will click on subnet associations and edit them. On the check box, choose your public subnet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qoKKiJp_9pcwxXg8yO8gSQ.jpeg" /></figure><h3>Step 5: Create a Security Group</h3><p>Imagine Security Groups as the vigilant bouncers at the entrance of a fancy club. They decide who gets in and who’s left out. These digital bouncers protect your EC2 instances by managing inbound and outbound traffic. It’s like having a VIP list — only those on the list get access!</p><p>Let’s create our own digital bouncer squad. In the AWS console, head to “Security Groups.” Click on “Create Security Group,” give it a cool name, and choose the VPC it’s guarding. Now, set the inbound rules — what kind of traffic is allowed to enter? For a website, you might allow HTTP, HTTPS, and SSH traffic. Also, specify where this traffic can come from — maybe the entire internet (0.0.0.0/0).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYJHUTucXk_F7J-9eKuZsQ.jpeg" /></figure><p>Remember, Security Groups are “stateful,” meaning if you allow inbound traffic, outbound traffic is automatically allowed too. It’s like if someone is invited to the party, they’re also allowed to leave!</p><h3>Step 6: Create Network Access Control Lists (NACLs)</h3><p>Now, let’s talk about Access Control Lists or ACLs. Think of ACLs as the ushers at each parking lot entrance. They direct traffic within the entire subnet, deciding who goes where. Unlike Security Groups, ACLs secure the whole parking lot, not just specific cars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*PTbe_iX1FdbbS_TzM3qdOg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*VrOnrcKqpxhPJc8QcsSPbQ.jpeg" /></figure><ol><li>To configure NACLs, navigate to the “Network ACLs” section under “Security” on the left pane of the VPC dashboard.</li><li>Select the default NACL associated with your VPC.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBGgsn7YQ0ef1OB7_GugAg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JA1__O8caCbbk4qYm5McA.jpeg" /></figure><p>3. Edit the inbound rules to allow or deny specific types of traffic. Remember that NACLs are stateless and require both inbound and outbound rules to be explicitly defined.</p><p>ACLs are “stateless,” which means you must configure inbound and outbound rules separately. If you allow inbound traffic, you need to configure outbound traffic separately.</p><p>For example, you can set rules to allow or deny traffic based on protocols, ports, or IP addresses. Want to test your ACLs? Deny all traffic and see if your website still loads — it’s like telling the ushers to let no one in!</p><h3>Step 7: Create an EC2 Instance: Your Digital Ride</h3><p>In the AWS console, let’s navigate to the EC2 section and click on “Launch Instance.” This is where the magic happens. Choose an Amazon Machine Image (AMI) — it’s like picking the model of your car. Different AMIs have different pre-installed software and configurations.</p><p>Next up, you’ll choose an instance type. Think of this as choosing the engine for your car — more powerful instances mean a smoother ride, but they might cost more. For now, let’s stick to the basics and choose a t2.micro instance type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*42QJanemBL7B4we0MHCQaw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*zjJdmB_PitMdQoLjiUI8Cg.jpeg" /></figure><p>Now, configure the instance details. Here’s where we select the subnet. Remember our parking lot analogy? Subnets are like different sections in the lot. Choose the one that fits your needs — maybe the public one if you want your instance to talk to the internet or the private one for sensitive resources. Also, enable “<strong>Auto-Assign Public IP</strong>” — this is like giving your car a license plate visible to the world.</p><p>In the next section, add storage. This is where you decide how much trunk space your digital vehicle gets. You can also attach additional volumes if needed.</p><p>Now, add tags to your instance. Think of tags as personalized license plates for each car in the parking lot — easy identification.</p><p>Moving on to the Security Group step, choose the group you created earlier. This is like assigning a bouncer squad to watch over your car. Specify rules for inbound and outbound traffic — maybe allow SSH, HTTP, and HTTPS traffic for a start.</p><p>Now scroll down to the advanced section and paste the following bash command in the user data section</p><pre>#!/bin/bash<br><br># Update Amazon Linux<br>sudo yum update -y<br><br># Install Apache server<br>sudo yum install httpd -y<br><br># Start Apache server<br>sudo systemctl start httpd<br><br># Install Git<br>sudo yum install git -y<br><br># get home <br>cd /home/ec2-user<br><br># Clone the GitHub repository<br>git clone https://github.com/abirhasn07/T-House.git</pre><p>Finally, review your settings and hit “Launch.” Now, you’ll need to create or choose an existing key pair. This is like having a physical key to your car. Save it securely — losing it means you can’t access your EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*UYiyQEUkaPr-h2jhVM4E0Q.jpeg" /></figure><p>Voila! Your EC2 instance is up and running, parked in the subnet you selected. Now, if you’ve set up everything correctly, you can copy the public IP address of your instance and paste it into your browser. If all goes well, you should see a website or whatever you configured on your EC2 instance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e26f345786cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>