<?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 Adetomiwa Adewole on Medium]]></title>
        <description><![CDATA[Stories by Adetomiwa Adewole on Medium]]></description>
        <link>https://medium.com/@asarial284?source=rss-19bfac7a7eb4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MJv3xS9Db3LaamnfBVcEaA.png</url>
            <title>Stories by Adetomiwa Adewole on Medium</title>
            <link>https://medium.com/@asarial284?source=rss-19bfac7a7eb4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:53:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asarial284/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[What Happens When Your Backup Server Loses Internet Access?]]></title>
            <link>https://medium.com/@asarial284/what-happens-when-your-backup-server-loses-internet-access-234b037fc114?source=rss-19bfac7a7eb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/234b037fc114</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Adetomiwa Adewole]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 15:26:39 GMT</pubDate>
            <atom:updated>2026-11-22T15:26:39.211Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bM8oL2Gr3fVlAqY5evG3qg.jpeg" /></figure><p>Imagine running an application that generates important data every few seconds. You want to make sure that data is safe, so you set up an automated backup system. Every ten minutes, the application data is compressed and uploaded to cloud storage. Everything works as expected.</p><p>Then you remove the server’s internet connection.</p><p>What happens to the backups?</p><p>At first, it sounds like a straightforward failure. No internet, no uploads. But what if the server doesn’t actually need unrestricted internet access to do what it’s supposed to do?</p><p>That question became one of the most interesting parts of a cloud engineering project I recently worked on.</p><p>The goal was to build an automated backup and audit logging system on Amazon Web Services (AWS). I wanted a private application server that could generate data, back it up automatically to Amazon S3, and keep a record of every new backup using AWS Lambda and DynamoDB.</p><p>But there was another part to the challenge: making sure the application server could upload its backups without depending on a continuously running NAT Gateway.</p><p>Getting all the pieces to work together meant dealing with private networking, IAM permissions, Linux automation, event-driven services, and a few things that didn’t work quite as expected along the way.</p><p>This is how I built it, what I learned, and how I got the backups working even after the NAT Gateway was gone.</p><h3>Before the Backups: Building the Network</h3><p>Before thinking about backup scripts or cloud storage, I needed somewhere to run the application.</p><p>I started by creating a Virtual Private Cloud (VPC), giving the project its own isolated network environment within AWS. I used the CIDR block 10.0.0.0/16, which provided enough room for the resources I needed.</p><p>I then divided the network into two subnets: a public subnet (10.0.1.0/24) and a private subnet (10.0.2.0/24).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7XvVSJXByaBFinLjMVi8Q.png" /><figcaption><strong>VPC resource map</strong></figcaption></figure><p>The distinction was important.</p><p>The public subnet would host a bastion server, which would serve as the entry point for administrative SSH access. The application server, on the other hand, would live in the private subnet without a public IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ8w2OSM8nF1zPNRcOQcHw.png" /><figcaption><em>The bastion host deployed in the public subnet, serving as the controlled entry point into the private network.</em></figcaption></figure><p>I attached an Internet Gateway to the VPC and configured the public route table to direct internet-bound traffic through it. This allowed the bastion server to communicate with the internet while keeping the application server away from direct public exposure.</p><p>For access control, I configured the bastion server’s security group to allow SSH connections only from my own IP address. The application server’s security group was even more restrictive: SSH access was permitted only from the bastion server’s security group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*elHDaFhabx8sktH_XFe7Pw.png" /><figcaption><strong>Application server inbound rules</strong></figcaption></figure><p>This meant I couldn’t simply SSH directly into the application server from my machine. I first had to connect to the bastion host and then make a second SSH connection into the private server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*px7NCGgYZWY3VcyvBvb0ug.png" /><figcaption><em>Connecting to the private application server through the bastion host</em></figcaption></figure><p>That arrangement gave me a controlled route into the private environment without exposing the application server to the public internet.</p><p>At this point, the network foundation was in place. I had a public entry point for administration, a private environment for the application, and the network controls needed to keep them separate.</p><p>Now I could focus on the actual backup process.</p><h3>Making the Backups Happen</h3><p>With the network in place, I moved on to the application server and the actual backup process.</p><p>I needed a simple way to simulate an application that continuously generates data. Rather than introduce an unnecessarily complex application, I wrote a small Bash script that appends a timestamped entry to a log file every 30 seconds.</p><p>I then configured it as a systemd service. This meant the data generator could run in the background, start automatically when the server booted, and restart if it stopped unexpectedly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vkSnk9v0spNaOJ-xXNAjxw.png" /><figcaption>The application data generator running as an active systemd service on the private EC2 instance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*00kBmj97TWQ3-NMnot2U4Q.png" /><figcaption>Timestamped application data being generated and appended to the application log every 30 seconds.</figcaption></figure><p>With the data generation process running, the next step was to automate its protection.</p><p>I wrote another Bash script to collect the application data, compress it into a .tar.gz archive, and upload the resulting file to an Amazon S3 bucket using the AWS CLI. The backup process was scheduled with cron to run every ten minutes.</p><p>Each backup was given a timestamped filename, making it easier to distinguish individual archives. I also configured the script to record successful and failed operations in a log file. Importantly, the local archive was deleted only after a successful upload.</p><p>But getting the script to upload a file was only part of the exercise. My first attempt at uploading to S3 failed because the IAM role did not yet have the required s3:PutObject permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kVgvn-3cwQP1W67RuyB4w.png" /><figcaption><em>An initial S3 upload attempt rejected because the EC2 instance role lacked the required PutObject permission.</em></figcaption></figure><p>This was a useful reminder that having an EC2 instance connected to AWS doesn’t automatically mean it can access every AWS service. Access is determined by the permissions attached to its identity.</p><p>I revisited the IAM policy, added the required upload permission, and restricted its resource to the backups/ prefix of my S3 bucket. After attaching the corrected policy to the EC2 role, the upload worked.</p><p>Instead of storing AWS access keys on the server, I used an IAM role attached directly to the EC2 instance. This allowed the AWS CLI to obtain temporary credentials automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yCMX2AXYwE2zbw4HoTR9ow.png" /><figcaption>The IAM role attached to the application server, providing temporary AWS credentials without requiring hardcoded access keys</figcaption></figure><p>I also tested the limits of the policy by attempting to delete an uploaded backup. AWS returned an Access Denied response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIKBF76Z6Exda50DTay71Q.png" /><figcaption>An attempted deletion of a backup object rejected by AWS, demonstrating the restricted permissions assigned to the EC2 instance role</figcaption></figure><p>That was exactly what I wanted to see.</p><p>The application server could create and upload backups, but it couldn’t remove them. This was a practical demonstration of the principle of least privilege: giving a resource only the permissions required to perform its job.</p><p>At this point, the automated backup process was working. Application data was being generated, compressed, uploaded, and logged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMYb6A0SMLi5T6o7WQOOjA.png" /><figcaption>Successful automated backup execution, with timestamped entries recorded in the backup log</figcaption></figure><p>However, there was still a networking question I wanted to address: did the private server really need a NAT Gateway to keep sending those backups to S3?</p><h3>Private Connectivity Without a NAT Gateway</h3><p>At this point, the backup process was working, but there was still one networking concern I wanted to address.</p><p>The application server was deployed in a private subnet. Initially, I used a NAT Gateway to provide outbound internet access, which allowed the instance to install packages and communicate with external services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NP6vLCz1bWcpcC0dUavsmg.png" /><figcaption><em>The private route table initially configured to route outbound traffic through the NAT Gateway</em></figcaption></figure><p>However, keeping a NAT Gateway running just so the server could upload files to S3 seemed unnecessary. The server didn’t need unrestricted internet access to perform its backup task. It only needed a reliable way to reach Amazon S3.</p><p>This was where an <strong>S3 Gateway VPC Endpoint</strong> came in.</p><p>A VPC endpoint allows resources inside a VPC to communicate with supported AWS services without requiring traffic to pass through the public internet. In this case, I created a Gateway Endpoint for Amazon S3 and associated it with the private route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J96FuRykfLb1nIE7MIUq2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UT514INNHCzAAL8D8266_g.png" /><figcaption><em>Creating an S3 Gateway VPC Endpoint to enable private connectivity between the VPC and Amazon S3.</em></figcaption></figure><p>This added a route for S3 traffic through the endpoint while leaving the NAT Gateway route available for other outbound traffic.</p><p>With the endpoint configured, the private application server now had a dedicated path to S3 through the AWS network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1IEtRjmSaUZXcLEwDeAaEg.png" /><figcaption><em>The private route table showing the S3 prefix-list route through the VPC endpoint alongside the existing NAT Gateway route</em></figcaption></figure><p>But I wanted to test whether this would actually work without the NAT Gateway.</p><p>I first checked that the endpoint was associated with the private route table and that the S3 route was present. Then, I removed the NAT Gateway and tested external connectivity from the application server.</p><p>Running curl -m 5 https://example.com resulted in a connection timeout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRfLYZwRu1NJXQBGS-35zw.png" /><figcaption><em>Testing external connectivity after removing the NAT Gateway. The request to example.com times out as expected.</em></figcaption></figure><p>That was expected. Without the NAT Gateway, the private instance could no longer reach the general public internet.</p><p>Then came the important test.</p><p>I ran the backup script again.</p><p>The backup was successfully uploaded to the S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVHdKLd2GqqE9JL5ctzbEA.png" /><figcaption><em>The VPC architecture after NAT Gateway removal, with the S3 Gateway Endpoint retained for private access to Amazon S3</em></figcaption></figure><p>This confirmed that the VPC endpoint was doing exactly what it was configured to do. The application server had lost its general internet access, but it could still communicate privately with Amazon S3.</p><p>That distinction was important. The goal wasn’t to give the server internet access without a NAT Gateway. It was to provide access to the specific AWS service it needed, without paying to maintain a NAT Gateway for that purpose.</p><p>The backup process could now run without depending on a continuously running NAT Gateway.</p><h3>Building the Backup Audit Log</h3><p>Uploading backups to S3 solved the storage problem, but I also wanted a way to keep track of every new backup.</p><p>Having files in a bucket is useful, but being able to see when each backup was created and identify the object that was uploaded makes the system easier to monitor and audit.</p><p>For this, I used two AWS services: <strong>AWS Lambda and Amazon DynamoDB</strong>.</p><p>I started by creating a DynamoDB table named backup-log. The table uses backup_id as its partition key, with the String data type. I selected on-demand capacity so that DynamoDB could handle requests without requiring me to provision read and write capacity manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1R8Mh_xRqoSsivyzzouWw.png" /><figcaption>The DynamoDB backup-log table configured with backup_id as its String partition key and on-demand capacity</figcaption></figure><p>Next, I created a Lambda function called backup-audit-logger.</p><p>The idea was simple: whenever a new backup file was uploaded to the S3 bucket, an event notification would trigger the Lambda function. The function would extract details from the event and write a corresponding record to DynamoDB.</p><p>I configured the S3 event notification to listen for object creation events under the backups/ prefix. This meant that uploads to the backup folder would trigger the function, rather than every object created anywhere in the bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quhXvfP8vQL63dQ5jsTbJw.png" /><figcaption><em>The backup-audit-logger Lambda function created to process S3 backup upload events</em></figcaption></figure><p>The Lambda function was written in Python. It processes the S3 event, extracts the bucket name, object key, event timestamp, and backup filename, then writes those details into the DynamoDB table.</p><p>I also configured a dedicated IAM execution role for the Lambda function. Its permissions were limited to writing records to the backup-log table and sending execution logs to CloudWatch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGyRntnhSAtPXVWi0OOaYg.png" /></figure><p>Once the trigger was configured, I ran the backup script again.</p><p>This time, the process did more than upload a file. The new S3 object triggered Lambda, and Lambda created a corresponding audit record in DynamoDB.</p><p>I checked the table and confirmed that the new backup had been recorded successfully.</p><p>I also checked the Lambda function’s CloudWatch logs to verify that it had executed without errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QNIRLe2rihduBzK3TrDtDA.png" /></figure><p>At this point, the system had two connected processes: the application server handled backup creation and storage, while Lambda and DynamoDB handled the audit trail.</p><h3>Testing the System and Reviewing the Results</h3><p>With all the components configured, I wanted to verify that the system worked as a complete pipeline rather than just a collection of individual AWS services.</p><p>I checked that the application data generator was running, that the backup script could execute successfully, and that new archives were appearing in the S3 bucket. I also confirmed that the Lambda function was being triggered by new uploads and that corresponding records were being written to DynamoDB.</p><p>One of the most important tests was running the backup process after deleting the NAT Gateway.</p><p>As expected, the application server could no longer reach an external website. However, it could still upload backup archives to S3 through the Gateway VPC Endpoint. This was the central networking objective of the project, and the test confirmed that it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMYb6A0SMLi5T6o7WQOOjA.png" /></figure><p>I also tested the IAM permissions. The application server could upload objects to the designated backup prefix, but an attempt to delete a backup was rejected with an Access Denied response. This confirmed that the EC2 role had limited permissions rather than unrestricted access to the bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIKBF76Z6Exda50DTay71Q.png" /></figure><p>For monitoring, I reviewed the Lambda execution logs in CloudWatch and checked the backup records in DynamoDB. I also configured an AWS Budget with a monthly budget of $5 and an alert threshold at 80% of actual spending to help monitor project costs.</p><p>There was one difference in the final counts: the S3 bucket contained 132 objects, while DynamoDB contained 114 audit records. This was because I configured the S3 event notification after some backup files had already been uploaded. The notification processed subsequent uploads, but it did not automatically create records for older objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEO5Zc06G-FOglMkP1C2lw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHi1Yf1LoAJhwfl4yyJjMA.png" /></figure><p>Overall, the tests showed that the main components were working together as intended: application data was generated, backups were created and uploaded, uploads triggered an audit process, and the system could continue backing up to S3 without a NAT Gateway.</p><h3>Keeping an Eye on Project Costs</h3><p>Since this project involved several AWS services, I also wanted to keep track of the costs while building and testing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGmZ1JcImkRz5vAbYtSW1Q.png" /><figcaption><em>The AWS Budget configured to monitor monthly spending across the project’s AWS services</em></figcaption></figure><p>I configured an AWS Budget with a monthly spending limit of <strong>$5</strong>. I also set an alert threshold at <strong>80% of the budget’s actual cost</strong>, so I could receive an email notification if my spending approached that limit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4488jcGsqmahedqKmGJGOA.png" /><figcaption><em>The monthly budget amount set to $5, with an alert configured at 80% of actual spending</em></figcaption></figure><p>This was particularly important because some of the resources used during development, such as the NAT Gateway, can incur charges while running.</p><p>The budget provided a simple way to monitor spending and receive an early warning before costs exceeded the amount I had allocated for the project.</p><h3>Challenges, Fixes, and What I Would Improve</h3><p>Building the system was not entirely straightforward. Some of the challenges I encountered came from configuration mistakes, while others helped me understand how the different AWS services interact.</p><p><strong>1. S3 Upload Permission Failure</strong></p><p>One of my first challenges was getting the application server to upload backup files to S3. My initial upload attempt failed because the IAM role attached to the EC2 instance did not have the required s3:PutObject permission.</p><p>I revisited the IAM policy, added the missing permission, and restricted it to the backups/ prefix of my S3 bucket. After attaching the corrected policy, the upload succeeded.</p><p>This reinforced the importance of checking IAM permissions carefully and applying the principle of least privilege.</p><p><strong>2. Private Server Connectivity</strong></p><p>The application server was in a private subnet, so it initially depended on a NAT Gateway for outbound internet access. However, I wanted the backup process to work without keeping the NAT Gateway running.</p><p>I solved this by creating an S3 Gateway VPC Endpoint and associating it with the private route table. After removing the NAT Gateway, I tested external connectivity with curl, which timed out as expected. I then ran the backup script and confirmed that the upload to S3 still worked.</p><p>This helped me understand the difference between general internet connectivity and private connectivity to specific AWS services.</p><p><strong>3. SSH Access to the Private Instance</strong></p><p>Another part of the setup that required attention was connecting to the application server. Since it had no public IP address, I couldn’t SSH into it directly from my local machine.</p><p>I configured a bastion host in the public subnet and restricted the application server’s SSH inbound rule to the bastion host’s security group. This allowed me to connect to the bastion first and then establish a second SSH connection to the private instance.</p><p><strong>4. S3 and DynamoDB Record Difference</strong></p><p>During verification, I noticed that the S3 bucket contained 132 objects while DynamoDB had 114 audit records.</p><p>The reason was that I configured the S3 event notification after some backup files had already been uploaded. S3 event notifications do not automatically process objects that existed before the notification was configured.</p><p>The newer uploads were recorded successfully. In a production system, I would account for this by introducing a backfill process or a reconciliation mechanism to identify objects without corresponding audit records.</p><h3>What I Would Improve</h3><p>Although the system met its main objectives, there are several things I would improve before using it in a production environment.</p><ul><li><strong>S3 Versioning and Lifecycle Policies:</strong> I would enable versioning to protect against accidental overwrites and configure lifecycle policies to move older backups to more cost-effective storage classes or expire them according to a defined retention policy.</li><li><strong>Encryption:</strong> I would ensure that backups are encrypted at rest using AWS Key Management Service (KMS), in addition to encryption in transit.</li><li><strong>Monitoring and Alerting:</strong> I would introduce more comprehensive alerts for failed backup uploads, Lambda execution errors, and missing audit records. This would make it easier to detect problems without manually checking logs.</li><li><strong>Backup Integrity and Recovery Testing:</strong> Uploading a backup successfully does not necessarily mean it can be restored. I would introduce automated integrity checks and periodic restoration tests to verify that the archives are usable.</li><li><strong>Improved Audit Reliability:</strong> I would add a reconciliation process to compare S3 objects against DynamoDB records. This would help detect missing audit entries and provide a more complete record of backup activity.</li><li><strong>Infrastructure as Code:</strong> I would use Terraform or AWS CloudFormation to define and deploy the infrastructure. This would make the environment easier to reproduce, maintain, and extend.</li></ul><h3>Project Repository</h3><p>The complete project implementation, including the backup scripts, Lambda function, systemd service configuration, and documentation, is available on GitHub.</p><p>You can <a href="https://github.com/A5AR/aws-automated-backup-and-audit-system">explore the repository here</a>:</p><p><a href="https://github.com/A5AR/aws-automated-backup-and-audit-system">https://github.com/A5AR/aws-automated-backup-and-audit-system</a></p><h3>Final Thoughts</h3><p>At the beginning of this project, the question was simple: could a private application server continue backing up its data to S3 without relying on a NAT Gateway?</p><p>By the end, I had a working system that could do exactly that.</p><p>Along the way, I learned how much goes into building even a relatively small cloud infrastructure solution. Getting the services to work individually was one thing. Making them communicate securely, automating the processes, handling permissions, and testing what happens when part of the infrastructure is removed was a different challenge entirely.</p><p>There are still improvements I would make before considering this production-ready, particularly around backup recovery, monitoring, and audit reliability. But the project gave me something more valuable than simply getting the configuration right: a better understanding of how the pieces of a cloud system fit together.</p><p>And to answer the question that started it all: <strong>when my backup server lost its general internet access, the backups kept going.</strong></p><p>That was the result I set out to achieve.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=234b037fc114" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Bastion Host on AWS to Securely Access a Private EC2 Instance]]></title>
            <link>https://medium.com/@asarial284/how-i-built-a-bastion-host-on-aws-to-securely-access-a-private-ec2-instance-f9ab57a4b097?source=rss-19bfac7a7eb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9ab57a4b097</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Adetomiwa Adewole]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 14:18:53 GMT</pubDate>
            <atom:updated>2026-10-24T14:18:53.966Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When I started learning cloud engineering, I understood that EC2 instances could be launched in public and private subnets. What I wanted to understand better was how to access a server that has no public IP address without exposing it directly to the internet.</p><p>That was the motivation behind this lab.</p><p>A <strong>bastion host</strong>, also known as a jump box, is a server that acts as a controlled entry point into a private network. Instead of allowing SSH access to every server from the internet, we connect to the bastion first and then use it to reach private instances.</p><p>This approach reduces the number of machines directly exposed to external connections and makes it easier to control administrative access.</p><p>In this article, I’ll walk through the AWS resources I configured, how I established the SSH connection, and the challenges I encountered along the way.</p><h3>1. Selecting the VPC and Creating Subnets</h3><p>I began by selecting the default VPC provided by AWS. I then created two subnets and named them alts-public-subnet and alts-private-subnet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TWWrVdb5XoaJOloKSfRVsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYNlYQlXlxk7xdxlQzwGXg.png" /></figure><p>A subnet is a range of IP addresses within a VPC where AWS resources can be deployed. The distinction between a public and private subnet is primarily determined by routing and internet reachability, rather than simply by the subnet’s name.</p><p>Initially, both subnets were associated with the default route table, which contained a route to the Internet Gateway. This meant that the private subnet did not yet have the routing configuration I wanted.</p><p>To correct this, I created a separate route table for the private subnet.</p><h3>2. Configuring the Route Tables</h3><p>The public subnet needs a route to the Internet Gateway so that resources with appropriate public IP addressing and security rules can communicate with the internet.</p><p>The private subnet, on the other hand, should not have a direct route to the Internet Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7O_Dk4HvEFaRm_OXv9n0A.png" /></figure><p>I created a new route table and ensured that its only route was the local VPC route. This route allows communication between resources within the VPC’s IP address range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dcx7NqiJYgS6h90-k5rSwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4Z1EMCIdF2LzbFSSb22lg.png" /><figcaption><strong>Private route table showing the local route</strong></figcaption></figure><p>I then edited the private subnet’s route table association and associated it with the new route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YDi5sMxXz5rpESOcjuSH8w.png" /></figure><p><strong>[Screenshot 2: Public route table showing the Internet Gateway route]</strong></p><p><strong>[Screenshot 3: Private route table showing the local route]</strong></p><p>After making the change, I returned to the VPC resource map to verify the subnet and route table associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlfFMpfD5r_iiqXLH851Eg.png" /><figcaption><strong>VPC resource map showing the network layout</strong></figcaption></figure><p>This taught me an important lesson: creating a subnet does not automatically make it public or private. The route table associated with it is a major part of determining its network connectivity.</p><h3>3. Launching the Bastion Host</h3><p>Next, I created the bastion EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGRBTGFQr_L4w1kF5oAa7A.png" /></figure><p>I selected Ubuntu as the operating system and chose the t3.micro instance type. I also created and downloaded a new SSH key pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQGh5xAF8xP_pXGxMg0FZw.png" /></figure><p>During network configuration, I selected the appropriate VPC and public subnet and enabled the assignment of a public IPv4 address.</p><p>I initially overlooked the public IP setting during an earlier attempt. It took me some time to identify the issue, but it reinforced the importance of checking the network configuration rather than assuming an instance is reachable simply because it has launched successfully.</p><p>I created a security group that allowed inbound SSH traffic over TCP port 22 from my own public IP address only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNQynJgDn7Lfv4r21waJYg.png" /></figure><p>To determine the public IP address from my Vagrant environment, I ran:</p><pre>curl ifconfig.me</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*YJQtnOMTyIpfOkmrXyF-IA.png" /></figure><p>I used the resulting IP address in the security group’s inbound rule. Restricting SSH access to my own IP is preferable to allowing SSH from every IPv4 address on the internet.</p><h3>4. Launching the Private EC2 Instance</h3><p>After configuring the bastion, I launched the private EC2 instance.</p><p>I used Ubuntu again and created a separate key pair for the private instance. Using separate key pairs gave me independent credentials for the two instances.</p><p>I selected the private subnet and disabled the assignment of a public IPv4 address.</p><p>I also configured a separate security group for the private instance. The intended security design was to allow SSH access only through the bastion rather than exposing the private instance directly to the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lAb_7IVjPusylMYc2uOIPQ.png" /></figure><p>This separation is important because the private instance does not need a public IP address to communicate with another instance in the same VPC. The bastion can reach it using its private IPv4 address, provided the routing and security rules allow the connection.</p><h3>5. Preparing SSH Authentication in Vagrant</h3><p>I used a Windows PC for the lab and performed my SSH operations from a Linux environment inside Vagrant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*rai2j226BPlx4e6SQYixtA.png" /></figure><p>I needed to make the downloaded key files accessible to the Linux environment. I created files with the appropriate key filenames and copied the corresponding key contents into them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0q6Hr1JKsv-pKPJ_Y36FNQ.png" /></figure><p>I then restricted their permissions:</p><pre>chmod 400 public-bastion.pem<br>chmod 400 private-instance.pem</pre><p>The chmod 400 command grants the file owner read permission while removing write and execute permissions for everyone. SSH private keys should not be readable by other users.</p><p>Next, I started the SSH authentication agent:</p><pre>eval &quot;$(ssh-agent -s)&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*oQ8hEYJXmYklW5fjn7eBLw.png" /></figure><p>I added both key pairs to the agent:</p><pre>ssh-add public-bastion.pem<br>ssh-add private-instance.pem</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkTwB0-ldLKenYk331Qu7g.png" /></figure><p>To verify that the keys were loaded, I ran:</p><pre>ssh-add -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DvluXesh9SeaaCfaytAmfw.png" /></figure><p>The SSH agent stores access to the loaded keys so that SSH can use them for authentication. This is particularly useful when connecting through a bastion to a private instance.</p><h3>6. Connecting to the Bastion and Private Instance</h3><p>With the keys loaded, I connected to the bastion using:</p><pre>ssh -A -i public-bastion.pem ubuntu@BASTION_PUBLIC_DNS</pre><p>The -i option specifies the identity file, while -A enables SSH agent forwarding.</p><p>Agent forwarding allows the remote bastion session to use my forwarded SSH agent to authenticate to another host. My private key itself does not need to be copied onto the bastion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FSKHyIRq9RPSxiCkZKqYIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*NT-NVkopsECrWR-UiGgHfA.png" /></figure><p>Once connected to the bastion, I initiated the second SSH connection using the private instance’s private IPv4 address:</p><pre>ssh ubuntu@PRIVATE_INSTANCE_IP</pre><p>Because the agent was forwarded from my original SSH session, the private instance could authenticate using the appropriate key available through that agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dv-ICxNLFADnUOILfUc6Mg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*-QT1jd8QBqLwNw0fPxUgeQ.png" /></figure><p>Reaching the private instance confirmed that I had established the intended two-hop administrative connection.</p><p>It is important to understand that agent forwarding and network access solve different problems. The route tables determine where traffic can travel, security groups determine which traffic is permitted, and SSH authentication determines whether the connecting user can log in.</p><p>All three need to work together.</p><h3>7. Challenges and Lessons Learned</h3><p>One of the first challenges was configuring the route tables correctly. Both subnets initially used the default route table, which had an Internet Gateway route. Creating a separate route table and associating it with the private subnet helped me understand how AWS determines subnet routing.</p><p>I also initially forgot to enable public IPv4 assignment for the bastion. This reminded me that an instance can be running successfully without being reachable through the public internet.</p><p>Another important part of the exercise was preparing my SSH keys and configuring the SSH agent in Vagrant. The correct file permissions, loaded identities and agent forwarding configuration were all necessary to establish the connection.</p><p>Finally, I learned that successfully connecting to an instance does not automatically prove that the network satisfies every security requirement. The subnet associations, security group sources and IP address settings must also be verified independently.</p><h3>Conclusion</h3><p>This lab helped me connect several cloud networking concepts that can initially seem unrelated: VPCs, subnets, route tables, Internet Gateways, security groups, EC2 instances and SSH authentication.</p><p>The most important takeaway for me is that securely accessing a private instance is not simply about finding a working SSH command. It requires a network design that limits exposure and an authentication process that protects private credentials.</p><p>As I continue learning cloud engineering, I want to build on this foundation by exploring more advanced network designs, access management and infrastructure automation.</p><p>Building the network myself made the concepts much easier to understand than simply reading about them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9ab57a4b097" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>