<?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 Jamesadewara on Medium]]></title>
        <description><![CDATA[Stories by Jamesadewara on Medium]]></description>
        <link>https://medium.com/@jamesadewara1?source=rss-573fa73b0515------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hqSKZ0SghQFVMYTd8iL4Tg.png</url>
            <title>Stories by Jamesadewara on Medium</title>
            <link>https://medium.com/@jamesadewara1?source=rss-573fa73b0515------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:57:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jamesadewara1/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[Cracking the STAR Method:> How I Saved My EKS Cluster from Free-Tier Resource Starvation]]></title>
            <link>https://medium.com/@jamesadewara1/cracking-the-star-method-how-i-saved-my-eks-cluster-from-free-tier-resource-starvation-6f866f5d5d1a?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f866f5d5d1a</guid>
            <category><![CDATA[altschool-africa]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 14:43:50 GMT</pubDate>
            <atom:updated>2026-06-06T14:43:50.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zRzaxoo_wtMovXpjg2_oXw.png" /><figcaption>Cracking the STAR Method: How I Saved My EKS Cluster from Free-Tier Resource Starvation</figcaption></figure><p>As a student at AltSchool Africa, I’ve spent months diving deep into the world of Cloud Engineering and DevOps. If there is one core takeaway from my journey so far, it’s this: <strong>learning in-demand technical skills is only half the battle. The other half is knowing how to position yourself and communicate your technical decisions effectively.</strong></p><p>In engineering, it is not enough to just write code; you need to be able to articulate <em>why</em> you made a choice and <em>how</em> you solved a complex problem.</p><p>One of the most valuable frameworks I picked up to bridge this gap is the <strong>STAR method</strong> (Situation, Task, Action, Result). It’s a structuring tool typically used in interviews, but it’s just as powerful for technical documentation and architectural post-mortems.</p><p>To show you what it looks like in practice, here is a real-world scenario from a challenge I faced during my capstone graduation project: <a href="https://github.com/jamesadewara/project-bedrock-karatu-2025-capstone">jamesadewara/project-bedrock-karatu-2025-capstone</a>.</p><p><em>(And if you check out the repository and wonder about the 68 commits — let’s be honest, the real work started way before that first commit hit GitHub. It took days of mapping out architecture diagrams and scratching my head before the whole picture finally came together!)</em></p><p>Here is how a frustrating deployment failure turned into a masterclass in infrastructure optimization, told through the lens of the STAR method.</p><h3>📍 Situation:-&gt; The Sandbox Wall vs. Managed Add-ons</h3><p>For my capstone project, I was deploying a production-grade microservices application on Amazon Elastic Kubernetes Service (EKS). Because this was a sandbox project, I initially tried to operate under strict AWS Free Tier constraints, utilizing small t2.micro and t3.micro EC2 worker nodes. <em>(Though, as a quick side note: I did later have to upgrade these to </em>t3.small<em> instances because the microservice pods simply needed more breathing room to handle the workload—but stick with me for a minute!)</em></p><p>To meet production-grade infrastructure criteria, I needed cluster visibility, so I used Terraform to enable the managed AWS amazon-cloudwatch-observability EKS add-on.</p><p>The moment the pipeline ran, everything broke.</p><p>Under the hood, that managed add-on deploys heavy metric collection and logging components. On a massive enterprise cluster, it’s great. On constrained instances? It was a disaster. The observability agents immediately choked the cluster, causing severe resource starvation. The worker nodes entered a fatal, continuous boot loop, which completely halted my automated Terraform deployment pipeline with an indefinite timeout error.</p><h3>🎯 Task:-&gt; The Guardrails and Requirements</h3><p>The objective was clear, but the constraints were tight:</p><ol><li><strong>Observability:</strong> I still had to implement centralized container logging to Amazon CloudWatch to satisfy the core project deliverables.</li><li><strong>Compliance:</strong> The solution had to deploy reliably via Terraform without violating strict Service Control Policies (SCPs) or exceeding account budgets.</li><li><strong>Efficiency:</strong> Infrastructure provisioning needed to complete within a standard, predictable deployment window rather than hanging indefinitely.</li></ol><h3>🛠️ Action:&gt; Stripping the Weight and Going Custom</h3><p>I realized that relying on a heavy, pre-packaged cloud provider add-on wasn’t going to cut it for a resource-conscious sandbox environment. I needed to separate my logging requirements from heavy cluster metric scraping.</p><p>I went back to my Infrastructure-as-Code (IaC) files and completely refactored the design:</p><ul><li><strong>The Extraction:-&gt;</strong> I stripped out the heavy amazon-cloudwatch-observability managed add-on entirely from my Terraform configuration.</li><li><strong>The Lightweight Alternative:-&gt;</strong> In its place, I introduced the standalone, ultra-lightweight <strong>AWS for Fluent Bit</strong> daemonset. Instead of a cloud add-on, I opted to manage this natively via the Terraform helm_release provider.</li><li><strong>Namespace Isolation &amp; IRSA:-&gt;</strong> I set up the release to provision inside the dedicated amazon-cloudwatch namespace, handled the service account token annotations, and mapped the required IAM Role for Service Accounts (IRSA) to grant precise CloudWatch permissions.</li><li><strong>Resource Fine-Tuning:-&gt;</strong> To guarantee that the logging agent wouldn’t bully my application microservices out of their CPU and memory, I dynamically injected strict resource constraints directly into the Helm chart configuration values. I restricted the Fluent Bit pods to a tiny memory allocation request limit of <strong>50Mi</strong> and capped limits at <strong>100Mi</strong>.</li></ul><p>Here is how I structured the final solution in my <a href="https://github.com/jamesadewara/project-bedrock-karatu-2025-capstone/blob/main/terraform/modules/eks/main.tf">Terraform codebase</a>:</p><pre># Deploy aws-fluent-bit via Helm (lightweight alternative to managed addon)<br>resource &quot;helm_release&quot; &quot;fluent_bit&quot; {<br>  name             = &quot;aws-fluent-bit&quot;<br>  repository       = &quot;https://aws.github.io/eks-charts&quot;<br>  chart            = &quot;aws-for-fluent-bit&quot;<br>  namespace        = &quot;amazon-cloudwatch&quot;<br>  create_namespace = true<br>  version          = &quot;0.1.33&quot;<br><br>  set {<br>    name  = &quot;serviceAccount.name&quot;<br>    value = &quot;fluent-bit&quot;<br>  }<br>  set {<br>    name  = &quot;serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn&quot;<br>    value = aws_iam_role.fluent_bit.arn<br>  }<br>  set {<br>    name  = &quot;cloudWatchLogs.enabled&quot;<br>    value = &quot;true&quot;<br>  }<br>  set {<br>    name  = &quot;cloudWatchLogs.region&quot;<br>    value = data.aws_region.current.name<br>  }<br>  set {<br>    name  = &quot;cloudWatchLogs.logGroupName&quot;<br>    value = aws_cloudwatch_log_group.container_logs.name<br>  }<br>  set {<br>    name  = &quot;cloudWatchLogs.autoCreateGroup&quot;<br>    value = &quot;false&quot;<br>  }<br>  # Minimal resource constraints for Free Tier nodes<br>  set {<br>    name  = &quot;resources.requests.cpu&quot;<br>    value = &quot;50m&quot;<br>  }<br>  set {<br>    name  = &quot;resources.requests.memory&quot;<br>    value = &quot;50Mi&quot;<br>  }<br>  set {<br>    name  = &quot;resources.limits.cpu&quot;<br>    value = &quot;100m&quot;<br>  }<br>  set {<br>    name  = &quot;resources.limits.memory&quot;<br>    value = &quot;100Mi&quot;<br>  }<br>  depends_on = [<br>    null_resource.api_ready, # Wait for K8s API to be reachable<br>    aws_iam_role_policy_attachment.fluent_bit,<br>    aws_cloudwatch_log_group.container_logs<br>  ]<br>}</pre><h3>🚀 Result:&gt; Smooth Deployments and Zero Costs</h3><p>By pivoting from the heavy managed agent to a tailored, constrained Fluent Bit daemonset, the infrastructure behavior changed instantly:</p><ul><li><strong>Resource Stability:</strong> The lightweight Fluent Bit pods scheduled perfectly alongside my application pods, successfully staying under the instance memory ceilings.</li><li><strong>Pipeline Speed:</strong> The total infrastructure provisioning time plunged from an indefinite, <strong>18+ minute timeout loop down to a clean, predictable 3–5 minute deployment.</strong></li><li><strong>Cost Efficiency:</strong> The entire cluster satisfies every logging and observability criteria required by the capstone evaluation team, all while remaining completely inside a zero-cost Free Tier footprint for the logging architecture.</li></ul><h3>Engineering is About Trade-offs</h3><p>Hard skills allow us to write the Terraform code and spin up EKS clusters. But frameworks like the STAR method give us the tools to explain <em>why</em> we made those choices.</p><p>This experience taught me that production-ready engineering isn’t about using the biggest, most expensive tool available; it’s about understanding your environment, recognizing constraints, and configuring your stack to match your reality.</p><blockquote><em>Have you ever run into intense resource limitations while building out sandboxes or dev environments? How did you optimize your cluster components to stay under budget? Let’s talk about it in the comments below!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f866f5d5d1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t use Le Console use Terraform]]></title>
            <link>https://medium.com/@jamesadewara1/dont-use-le-console-use-terraform-ba315dfc5373?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba315dfc5373</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Sat, 07 Mar 2026 15:13:57 GMT</pubDate>
            <atom:updated>2026-04-01T09:55:19.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CflNeuD_1p2rScSi6TSq5g.png" /><figcaption>terraform ≥ console</figcaption></figure><p>As a cloud beginner, one of the first interfaces you make use of is the cloud console, like the AWS console. This serves as a proxy between you and your cloud infrastructure. While it is good for learning, it is not ideal in the professional tech industry where every log and piece of information counts.</p><p>This is why using Terraform provides you with cloud-native infrastructure, helping you write and deploy cloud infrastructure through code.</p><p>Terraform is a tool that lets you build, change, and manage your infrastructure like servers, databases, and networks using code instead of manual clicking. When paired with Ansible, it makes for a great combo! You can click here to check how to use Ansible <em>:-&gt;</em> <a href="https://medium.com/@jamesadewara1/why-ansible-c20b0dd1edaf">Why Ansible?</a></p><p>Terraform has 3 main stages: <strong>Write, Plan, and Apply</strong>. But without wasting any more time, let’s jump right back into the main course of this article: <strong>Don’t use the console use terraform</strong>.</p><h3>How to set up Terraform and start using it</h3><h3>1. Install Terraform</h3><p>I am using <strong>Vagrant (Ubuntu Focal)</strong> on <strong>Oracle VirtualBox</strong> via an <strong>AMD64 DELL laptop</strong>. You can find the official installation guide here: <a href="https://developer.hashicorp.com/terraform/install">Terraform Install</a>.</p><h4>The Repository Approach :&gt;</h4><p>On my local Vagrant machine, I first tried the standard HashiCorp repository method:</p><pre>echo &quot;deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main&quot; | sudo tee /etc/apt/sources.list.d/hashicorp.list</pre><pre>echo &quot;deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main&quot; | sudo tee /etc/apt/sources.list.d/hashicorp.list</pre><pre>sudo apt update &amp;&amp; sudo apt install terraform</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4gRZXdbAhPBb1N06hDs9Ug.png" /><figcaption>🥲🥲🥲</figcaption></figure><p><strong>Note :-&gt;</strong> This may fail due to <strong>Vagrant network MTU settings</strong>. In some environments, the large HashiCorp package list becomes fragmented and is dropped during the download, causing an “Unable to locate package” error.</p><p>Uhm! so I switched to Plan B <em>:-&gt;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/0*IlJ4N4NXp6Mr9uJQ" /></figure><p>Manual Installation (The /opt Method)</p><p>If the repository method fails, you can download the binary manually. We will place it in the /opt/ directory, which is the standard Linux location for optional, self-contained third-party software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WXQxwta2Pyf3upQ7pBc0g.png" /><figcaption>downloaded the AMD64 for my Vagrant Ubuntu Linux</figcaption></figure><p><strong>1. Extract and Move the Binary :-&gt;</strong> After downloading the .zip file from the official site, unzip it and move the executable:</p><pre># Unzip the downloaded package<br>unzip terraform_*.zip</pre><pre># Create the directory and move the binary<br>sudo mkdir -p /opt/terraform<br>sudo mv terraform /opt/terraform/<br>sudo chmod +x /opt/terraform/terraform</pre><p><strong>2. Create a Symlink for Convenience:</strong> Since /opt/terraform isn&#39;t in your system $PATH by default, create a symbolic link to /usr/local/bin. This allows you to run the terraform command from any directory:</p><pre>sudo ln -s /opt/terraform/terraform /usr/local/bin/terraform</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSGJjNplKcbAGOZi0xBu3w.png" /></figure><h4>Why use /opt for Terraform?</h4><ul><li><strong>Version Control :-&gt;</strong> It makes managing multiple versions easy. You can store different binaries in folders like /opt/terraform_1.5/ and simply update the symlink to switch between them.</li><li><strong>System Cleanliness :-&gt;</strong> It keeps third-party binaries isolated from core system files, ensuring your /usr/local/bin remains uncluttered.</li></ul><h3>2. Writing Our .TF Files</h3><p>Now, let’s create our aws-with-terraform folder. We’ll be using <strong>Infrastructure as Code (IaC)</strong> to build an AWS EC2 instance. For better management, we are splitting our main.tf into three files i.e. (<strong>variables.tf, outputs.tf, main.tf).</strong> Here is a quick diagram showing how Terraform codes looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*n7r6gj0XoBkRaiPADTwP5A.png" /></figure><h4>First :-&gt; Generate your SSH Key</h4><p>Terraform needs to “hand” a key to AWS so you can log in later. You generate this <strong>on your local machine</strong>:</p><pre>ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa<br># This creates two files: id_rsa (Private) and id_rsa.pub (Public)</pre><h4>Second :-&gt; Write your variables.tf (Inputs)</h4><pre>variable &quot;region&quot; { <br>  default = &quot;us-west-2&quot; <br>}<br><br>variable &quot;ami_id&quot; { <br>  default = &quot;ami-0e5e1413a3bf2d262&quot; <br>}</pre><p>And now you might wonder 😖, what is ami-0e5e1413a3bf2d262, I was also startled when I saw some random characters starting with “ami”, did some <strong>googling </strong>and <strong>ai`</strong>ing and now understands what they mean</p><p>ami-0cf2b4e02406b4739 means</p><p><strong><em>ami(Amazon Machine Image)-…</em></strong> in AWS is like a postal code, a template that contains the Operating System and any pre-installed software.</p><p>To easily find the ami id to use you can either go through <a href="https://cloud-images.ubuntu.com/locator/ec2/"><strong><em>AWS AMI documentation</em></strong></a> or use this prompt on Gemini (or Claude, etc.), you can edit the prompt to match what region and ubuntu Linux version in need of,</p><pre>List the latest official Ubuntu 24.04 LTS (Noble) x86_64 AMI IDs for every AWS region. Present them in a table. Additionally, provide the AWS CLI command to fetch the current &#39;Noble&#39; AMI ID using the SSM Parameter Store for the us-west-2 region.</pre><p>or go through the <a href="https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#AMICatalog"><strong><em>AWS AMI CATALOG</em></strong></a> if you are already logged in to the AWS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJZPVjOqLYe_3RiOxKNr0A.png" /></figure><h4>Third :-&gt; main.tf (The Resources &amp; Provisioner)</h4><p>This code uploads your <strong>Public Key</strong> to AWS and uses a <strong>Provisioner</strong> to run commands inside the Linux machine after it starts.</p><pre>provider &quot;aws&quot; { <br>  region = var.region <br>}<br><br># 1 :&gt; Create a Custom VPC<br>resource &quot;aws_vpc&quot; &quot;main&quot; {<br>  cidr_block           = &quot;10.0.0.0/16&quot;<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true<br>  tags = { Name = &quot;article-vpc&quot; }<br>}<br><br># 2 :&gt; Create a Subnet within that VPC<br>resource &quot;aws_subnet&quot; &quot;public&quot; {<br>  vpc_id                  = aws_vpc.main.id<br>  cidr_block              = &quot;10.0.1.0/24&quot;<br>  map_public_ip_on_launch = true # Critical so you can SSH into it<br>  availability_zone       = &quot;${var.region}a&quot; # i.e. us-west-2a<br>  tags = { Name = &quot;article-subnet&quot; }<br>}<br><br># 3 :&gt; Create an Internet Gateway (Required for Public Subnets)<br>resource &quot;aws_internet_gateway&quot; &quot;gw&quot; {<br>  vpc_id = aws_vpc.main.id<br>}<br><br># 4 :&gt; Create a Route Table to allow internet access<br>resource &quot;aws_route_table&quot; &quot;rt&quot; {<br>  vpc_id = aws_vpc.main.id<br>  route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = aws_internet_gateway.gw.id<br>  }<br>}<br><br>resource &quot;aws_route_table_association&quot; &quot;a&quot; {<br>  subnet_id      = aws_subnet.public.id<br>  route_table_id = aws_route_table.rt.id<br>}<br><br># 5 :&gt; Uploads your local public key to AWS<br>resource &quot;aws_key_pair&quot; &quot;hero_key&quot; {<br>  key_name   = &quot;terraform-key&quot;<br>  public_key = file(&quot;~/.ssh/id_rsa.pub&quot;) <br>}<br><br># 6 :&gt; The EC2 Instance<br>resource &quot;aws_instance&quot; &quot;web&quot; {<br>  ami           = var.ami_id<br>  instance_type = &quot;t3.micro&quot;<br>  <br>  # Connection to the network we just built!<br>  subnet_id     = aws_subnet.public.id<br>  key_name      = aws_key_pair.hero_key.key_name<br><br>  tags = { Name = &quot;article-server&quot; }<br><br>  # Provisioner: Updates Ubuntu and creates a text file<br>  provisioner &quot;remote-exec&quot; {<br>    inline = [<br>      &quot;sudo apt-get update -y&quot;,<br>      &quot;echo &#39;Terraform Created This&#39; &gt; ~/success.txt&quot;<br>    ]<br><br>    connection {<br>      type        = &quot;ssh&quot;<br>      user        = &quot;ubuntu&quot;<br>      private_key = file(&quot;~/.ssh/id_rsa&quot;)<br>      host        = self.public_ip<br>    }<br>  }<br>}</pre><p>Notice that the first BLOCK_LABEL following the BLOCK_TYPE refers to the AWS resource type, while the second BLOCK_LABEL defines the specific resource name. The var. prefix is used to pass in the value of a Terraform variable. Note that Terraform variable names follow standard programming conventions, similar to Python<em>:-&gt;</em> they cannot contain spaces and should use either camelCase or snake_case.</p><h4>Fourth :-&gt; outputs.tf</h4><pre>output &quot;ec2_public_ip&quot; {<br>  description = &quot;The public IP of the web server&quot;<br>  value       = aws_instance.web_server.public_ip<br>}<br><br>output &quot;ec2_private_ip&quot; {<br>  description = &quot;The private IP of the web server&quot;<br>  value       = aws_instance.web_server.private_ip<br>}</pre><h3>4. Init, Plan, and Apply</h3><p>Before we “Init” u know “what I&#39;m saying”, we need to cross check our Terraform code for any syntax error and ensure that the code style format is in standard canonical terraform style format using</p><pre>terraform fmt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*I_lgQZci627WjuUK2dykMA.png" /><figcaption>syntax error and what needs to be fixed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKwSKUymMsEZMlN0q_oc2g.png" /><figcaption>before terraform fmt, after terraform fmt</figcaption></figure><p>Now we init using</p><pre>terraform init</pre><p>When you run terraform init, Terraform identifies the required provider versions (like AWS) from your code and downloads them into a hidden .terraform directory. Crucially, it creates a <strong>Dependency Lock File</strong> (.terraform.lock.hcl) that records the exact version and checksum of the provider used. This ensures that even if a newer version of the provider is released or if terraform itself is updated, your project remains stable and consistent by using the same “locked” version every time you re-initialize.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0Ia_Ii5ld0RmMftw_G0Ig.png" /></figure><p>Then</p><pre>terraform validate</pre><p>This command performs a deep dive into the <strong>structure</strong> of your code. It checks if you’ve used the correct attribute names for a resource and if your variable types match up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQhjuReLXJ45jBNoJ1bGIQ.png" /></figure><p>Based on the screenshot error, you’ll notice that after running</p><p>terraform validate, Terraform caught a <strong>logical naming error</strong> that terraform fmt ignored. While fmt only cared about the &quot;look&quot; of your code (fixing those messy closing braces), validate checked the actual &quot;wiring&quot; of your infrastructure. This happened because the outputs.tf file was trying to find a resource named aws_instance.web_server, but in my main.tf, I had named that same resource aws_instance.web. This proves that validate is essential for catching naming mismatches and syntax logic that formatting alone cannot find, so we will have to edit the “outputs.tf” file with</p><pre>output &quot;ec2_public_ip&quot; {<br>  description = &quot;The public IP of the web server&quot;<br>  value       = aws_instance.web.public_ip<br>}<br><br>output &quot;ec2_private_ip&quot; {<br>  description = &quot;The private IP of the web server&quot;<br>  value       = aws_instance.web.private_ip<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2pJLUBgZ7M_CbtiMzCxDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_hedUBgcQ29o-ddjqt6yw.png" /><figcaption>now it works, how i like my stuffs to be like 🤓</figcaption></figure><p>Now that we have the green light from our validation check 😊, it’s time to set up the <strong>Environment Variables</strong> that allow Terraform to talk to AWS.</p><p>To authenticate, you need to configure your terminal with your <strong>IAM user credentials</strong>. Remember, Terraform can only manage the resources that your IAM user has permission to access. If you haven’t set up a user yet, check out my step-by-step guide on creating an IAM user with administrative privileges <a href="https://medium.com/@jamesadewara1/dangers-of-root-users-in-aws-69383f957eeb">here</a></p><p>Run these commands in your terminal (replacing the placeholders with your actual keys)</p><p>You might be wandering how do I get my “access_key_id” and “secret_access_key”, well look no further here are the steps to that</p><p><strong>STEP 1 =&gt; Open the IAM Console :-&gt;</strong> Sign in to the <a href="https://console.aws.amazon.com/">AWS Management Console</a> and type <strong>IAM</strong> in the search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ekwj3Lq4uE9rBfSD2JhepA.png" /></figure><p><strong>STEP 2 =&gt; Select Your User :-&gt;</strong> In the left sidebar, click <strong>Users</strong> and then click the specific <strong>Username</strong> you want to create keys for</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kewSdsKkqsyYq5KCSOUtAg.png" /></figure><p><strong>STEP 3 =&gt; Security Credentials Tab :-&gt;</strong> Click on the <strong>Security credentials</strong> tab (usually found in the middle of the user details page). Then scroll down to the <strong>Access keys</strong> section and click the <strong>Create access key</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jv3ce48ysCbe4jkr4R4e5Q.png" /></figure><p><strong>STEP 4 =&gt; Choose Use Case AND Retrieve Keys :-&gt;</strong> Select <strong>Application running outside AWS </strong>and <strong>o</strong>n the final screen, you will see your <strong>Access Key ID</strong> and your <strong>Secret Access Key</strong>. Ensure you click <strong>Download .csv file</strong> immediately as this is your only copy of the <strong>secret key.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCOgrtMv9C5LadwZ-ixRsg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtTPZp2jttx3uvhrPDUvSw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnzQL5E83FuaoLcHC3srCQ.png" /><figcaption>download as .csv this is crucial</figcaption></figure><p>and pass the keys to Linux as environment variables.</p><pre>export AWS_ACCESS_KEY_ID=&quot;your_access_key_id&quot;<br>export AWS_SECRET_ACCESS_KEY=&quot;your_secret_access_key&quot;</pre><p>something like that, it is important to note that the environment variable names used here AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY follow a strict industry standard. Terraform automatically looks for these specific names to securely authenticate with AWS, ensuring you don&#39;t have to hardcode sensitive credentials directly into your code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BooLTfrRyZwWlNhHg2bZow.png" /></figure><blockquote><strong><em>Pro Tip:</em></strong><em> Avoid using Root account keys! Check out my guide on the </em><a href="https://medium.com/@jamesadewara1/dangers-of-root-users-in-aws-69383f957eeb"><strong><em>Dangers of Root Users in AWS</em></strong></a><em> to ensure you’re following security best practices.</em></blockquote><p>Now that we are almost done, what remains now is to plan and apply.</p><p>To plan we use this command</p><pre>terraform plan</pre><p>terraform plan is a “look before you leap” preview that shows all proposed infrastructure changes and compares your code to your actual cloud environment to show exactly what will happen before you commit (i.e. terraform apply). It generates a preview list of actions</p><ul><li><strong>plus (+) -:&gt;</strong>for things it will create,</li><li><strong>tilde (~) -:&gt;</strong> for things it will update,</li><li>and <strong>minus (-) -:&gt; </strong>for things it will delete</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3YdgZyvPXBEjAPudPnwo2w.png" /><figcaption>kind of tiny to see, u might need to zoom in a bit</figcaption></figure><p>as scope from the terraform plan you can see a list of identifiers for aws based on the block type you declared. If its green, hit</p><pre>terraform apply</pre><p>Terraform will request an input (yes/no) from you. When terraform applies, take note of the <strong>Plan: </strong>section, it tells you what was changed and what resources was destroyed on your Cloud Providers through Terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJTT62ZWSnXFbtj_XLoKDg.png" /></figure><p>Terraform writes data to terraform.tfstate. This file manages your resources over their lifecycle. Use</p><pre>terraform state list</pre><p>to see what you have created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwHe2vvRp_VH3d8s87k2HQ.png" /></figure><p>and then to see your created resources output as declared</p><pre>terraform output</pre><h3>5. Selective vs Full Infrastructure Cleanup</h3><p>To remove resources, you can comment them out and hit,</p><pre>terraform apply </pre><p>In Terraform, if you comment out a resource, you’re telling it to delete it. Since the code is gone, Terraform assumes the resource should no longer exist and will destroy it during the apply, or to remove everything all at once, use</p><pre>terraform destroy</pre><p>Remember that exported environment variables are temporary. If you restart your system or open a new shell, you must re-run the export commands to restore your AWS connection.</p><pre>export AWS_ACCESS_KEY_ID=&quot;your_access_key_id&quot;<br>export AWS_SECRET_ACCESS_KEY=&quot;your_secret_access_key&quot;</pre><p>And there you have it! This is why you need to work with Terraform for IaC instead of manual AWS Console interactions. Companies in Fintech and beyond need to comply with security standards like PCI and maintain logs. Terraform makes it easy to create IaC, monitor what is happening, and manage resources natively in the cloud.</p><p><em>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; = &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</em></p><blockquote>Let me challenge you. Check this article on how to create an infrastructure using AWS console manually <a href="https://medium.com/@jamesadewara1/secure-web-application-deployment-on-aws-using-ansible-and-load-balancing-c1fc718db461">Secure Web App Deployment Guide</a> and try recreating yours using Terraform, I will be rooting out for you, 💪.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba315dfc5373" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure Web Application Deployment on AWS using Ansible and Load Balancing]]></title>
            <link>https://medium.com/@jamesadewara1/secure-web-application-deployment-on-aws-using-ansible-and-load-balancing-c1fc718db461?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1fc718db461</guid>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[aws-load-balancer]]></category>
            <category><![CDATA[aws-subnet]]></category>
            <category><![CDATA[aws-ec2-instance]]></category>
            <category><![CDATA[bastion-host]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Fri, 13 Feb 2026 21:13:58 GMT</pubDate>
            <atom:updated>2026-02-27T08:01:56.215Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*dF7VS4XXMS-ZG1sGG1-xsQ.png" /></figure><p>Assuming the role of a Cloud Engineer, I was tasked with deploying a secure, automated and simple web application for a small growing company. This article prioritizes the “Three Pillars of Cloud Infrastructure” i.e. <strong>Security, Automation, and Scalability.</strong></p><p><strong>Amazon Web Services (AWS), </strong>founded in<strong> 2006 </strong>(coincidentally my birth year!), remains the global leader in cloud computing with a <strong>32% market share as of 2026</strong>. Leveraging AWS allows us to build “Enterprise-Grade” infrastructure with lower costs.</p><p>To deploy this solution, I moved away from “auto-generated” defaults to manually connect the dots of a custom <strong>VPC (</strong>Virtual Private Cloud).</p><p>While my previous article, provided a thorough guide on <a href="https://medium.com/@jamesadewara1/why-ansible-c20b0dd1edaf">why Ansible is important</a>, this project addresses the question:</p><h4><strong>Why use a Bastion Host?</strong></h4><p>In a Zero-Trust environment, our web servers reside in <strong>Private Subnets</strong> without public IP addresses, making them invisible to the internet. However, they still need to be managed. This is where a <strong>Bastion Host</strong> acts as a secure “Jump Server”. The <strong>Bastion Host </strong>is the only <strong>EC2 </strong>instance with</p><ul><li>Public Access,</li><li>acts as a single, hardened gatekeeper for SSH management.</li><li>and by restricting SSH access to the Bastion only from <strong>My IP</strong> address, I minimize the attack surface significantly.</li></ul><p>Manual configuration is prone to human error and does not scale. <strong>Ansible </strong>transformed the setup into “Infrastructure as Code”, ensuring</p><ul><li><strong>Consistency :-&gt;</strong> It ensured <strong>Nginx </strong>was installed and configured identically on both <strong>Private EC2 servers.</strong></li><li><strong>Tunneling :-&gt; </strong>Using the ProxyJump in my inventory.ini file, Ansible safely “tunnels” through the Bastion to reach the isolated private servers.</li><li><strong>Speed :-&gt;</strong> What would take 20 minutes or more, manually took seconds with an <strong>Ansible Playbook.</strong></li></ul><h4>Why use a Load Balancer instead of a Direct EC2 Access</h4><p>Using a <strong>Load Balancer (</strong>like AWS ALB or CLB<strong>) </strong>instead of <strong>direct EC2 instances</strong> access improves security by hiding servers, increase availability through automatic failover, and enables seamless scaling behind a single <strong>DNS </strong>name.</p><p><strong>Note :&gt;</strong> Before starting, I assume you have foundational knowledge of <strong>AWS EC2</strong> and have worked with <strong>Ansible playbooks</strong>. Without further <strong>ado</strong>, let’s jump <strong>into</strong> the step-by-step implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*dF7VS4XXMS-ZG1sGG1-xsQ.png" /><figcaption><strong>Architecture Diagram for the Secure Web Application Deployment</strong></figcaption></figure><h3>STEP 1: Set Up Networking and Connectivity</h3><ul><li>I first created a <strong>custom VPC only</strong> and established a Public Subnet dedicated to the Bastion host and Load Balancer, ensuring that the <strong>enable auto-assign public IPv4 address</strong> setting was activated to provide the <strong>Bastion EC2</strong> with a necessary public entry point; alongside this, I built a single <strong>Private Subnet</strong> for the two <strong>Private Web servers</strong> to follow, purposefully completing all networking and connectivity configurations before launching the actual EC2 instances.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*5h3otzFFTWIT6RLTOyCOuw.png" /><figcaption>a screenshot of how the VPC settings should look like</figcaption></figure><p>When configuring the VPC, ensure the <strong>CIDR (Classless Inter-Domain Routing)</strong> block is set to a <strong>/16</strong> range (e.g., 10.0.0.0/16). This provides a large enough IP pool to accommodate multiple <strong>10.0.1.0/24 </strong>or <strong>10.0.2.0/24 </strong>subnets without risk of <strong>IP </strong>overlap or exhaustion. The Public and Private Subnet will be using the <strong>VPC </strong>I created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*qw5bwwVE8ssft-mzoud17A.png" /><figcaption>a screenshot of how the public and private subnet should look like</figcaption></figure><ul><li>I implemented a <strong>Regional NAT Gateway</strong> within the <strong>Public Subnet</strong> to act as a “Secure Bridge,” enabling the <strong>private servers</strong> to securely download necessary <strong>Nginx </strong>updates and patches while remaining completely hidden and unexposed to the public internet. It is crucial to ensure you are working within a single <strong>Region</strong> (such as <strong>us-east-1</strong>) while creating your instances and resources; you can verify this at the top right of the AWS console to ensure you haven’t accidentally switched, as resources in different regions, like us-east-1 and us-west-1, will not communicate with each other in this setup.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*PqMoszjRxAJ7AHitUNkJjg.png" /><figcaption>my <strong>nat</strong> gateway configuration</figcaption></figure><ul><li>I configured the Route Tables to manage traffic flow by directing the <strong>Public Route</strong> Table’s 0.0.0.0/0 traffic through the <strong>Internet Gateway (IGW)</strong> for external access, while the <strong>Private Route</strong> Table was set to route 0.0.0.0/0 traffic through the <strong>NAT Gateway</strong> to maintain security; as a vital budget tip for fellow engineers, remember that <strong>NAT Gateways</strong> cost approximately <strong>$0.045/hour</strong>, so ensure you delete them immediately after finishing your lab to avoid unnecessary charges.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xHHKh61qTxaF82H5NmeO9A.png" /><figcaption>create the IGW for the public route first and then attach it to the custom <strong>VPC</strong>, then</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHiQqMBQcqK2v3l21KmhZQ.png" /><figcaption>create the public route table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6WA_-XiLM_JZWoWL-PERXA.png" /><figcaption>edit the public route table route</figcaption></figure><p>The same approach in creating the <strong>public-route-table</strong> would also be used to create the <strong>private-route-table</strong> the only difference is the routing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrCYp-_Lz1hSinOxn5LK_w.png" /><figcaption>a screenshot of the private-route-table edit route settings</figcaption></figure><h3>STEP 2 =&gt; Security Group Chain</h3><p>To establish a robust security posture, I utilized <strong>custom Security Group IDS </strong>referencing to create a strict “chain of trust” rather than relying on static IP addresses. This allowed me to define rules based on resource relationships, ensuring that only authorized components could communicate with one another. The Security Groups are as followed</p><h4><strong>Web Server Security Group (SG for short) :-&gt; The “Inner Sanctum”</strong></h4><p>The <strong>Web Server SG </strong>protects the private EC2 instances, ensuring they never talk directly to the internet. The inbound and outbound rules for the SG are as following,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xADJjuYywoyNdiGZsgdfSQ.png" /><figcaption>always use the same VPC</figcaption></figure><p><strong>Inbound Rules</strong></p><ul><li><strong>HTTP Traffic :-&gt; Port 80 :-&gt;</strong> Only Accepted from the <strong>ALB SG</strong> ID (soon to be created after creating our <strong>Bastion SG)</strong></li><li><strong>SSH Traffic :-&gt; Port 22 :-&gt;</strong> Only Accepted from the <strong>Bastion Security Group ID</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kRHKwukrkA_e1nUOJYfgEg.png" /></figure><p><strong>Outbound Rule</strong></p><ul><li><strong>All Traffic :-&gt; </strong><strong>0.0.0.0/0 :-&gt;</strong> specifically to allow these <strong>Private EC2 Servers</strong> to reach out through the <strong>NAT Gateway </strong>we created<strong> </strong>to download <strong>Nginx </strong>updates and security patches.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTNywKiwnVeeHyJSQMQu6w.png" /></figure><h4>Bastion Security Group =&gt; The “Staff Entrance”</h4><p>For administrative access, the <strong>Bastion Security Group</strong> acts as the secure “staff entrance” for maintenance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6eqbJHDgPxmQtBweLMVX6g.png" /></figure><p><strong>The Inbound Rule</strong></p><ul><li><strong>SSH Traffic :-&gt; Port 22 :-&gt; </strong>strictly from My IP address dropdown in the <strong>Source </strong>field. You can also use this command</li></ul><pre>curl ifconfig.me</pre><p>to ensure AWS correctly identified your machine&#39;s public IP address, If you are following along.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z2JK-mTYLO2sYmU47bzUyw.png" /><figcaption>from my local machine using Ansible</figcaption></figure><p><strong>The Outbound Rule</strong></p><ul><li><strong>SSH Traffic :-&gt; Port 22 :-&gt;</strong> is restricted only to the <strong>Web Server Security Group ID</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yULyFKe_sIEskmSgwDPyRw.png" /></figure><h4>ALB Security Group :-&gt; The “Front Gate”</h4><p>The <strong>ALB Security Group</strong> serves as the outer perimeter, facing the public internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uw5qnUMRJ4I6hwwOG-MXLg.png" /></figure><p><strong>Inbound Rule</strong></p><ul><li><strong>HTTP Traffic :-&gt; Port 80 :-&gt;</strong> from <strong>Source </strong>0.0.0.0/0, permitting public access to the website.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vr8j64A6PReWaJsuKCw7Tw.png" /><figcaption>allow visitors to view the websites handled by AWS LB CLB</figcaption></figure><p><strong>Outbound Rule</strong></p><ul><li><strong>HTTP Traffic :-&gt; Port 80 :-&gt;</strong> the rule is highly restricted, destined exclusively for the <strong>Web Server Security Group ID</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCKFhL1a1_RPNpVi2Z3w5A.png" /><figcaption>ALB connects to Private EC2 Web servers</figcaption></figure><h4>STEP 3 =&gt; Provisioning EC2 Instances &amp; The Load Balancer</h4><p>In this stage, I began launching the compute resources for the <strong>Bastion</strong>, Two <strong>Private Web Servers</strong>, and the <strong>Application Load Balancer</strong>.</p><p><strong>For Bastion EC2 Server</strong></p><ul><li><strong>Instance Type:</strong> t3.micro</li><li><strong>OS Image:</strong> Ubuntu</li><li><strong>Security Group:</strong> Selected the existing <strong>Bastion Security Group</strong></li><li><strong>Network:</strong> Enabled <strong>“Auto-assign public IPv4 address”</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*kKnJLx1G3_v1E8H4-Qqi4A.png" /></figure><p><strong>For the 2 Private EC2 Web Server</strong></p><ul><li><strong>Instance Type:</strong> t3.micro</li><li><strong>OS Image:</strong> Ubuntu</li><li><strong>Security Group:</strong> Selected the existing <strong>Web Server SG</strong></li><li><strong>Network:</strong> Did not assign a public IP Address.</li><li><strong>Launch Setting:</strong> Increased the instance field from <strong>1 to 2</strong> during launch to ensure identical configurations for both private servers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*qxx4kfQE0VFyZGnhLOK2xA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53MWbsu1d5XZs7i4rpk-Aw.png" /><figcaption>ensure the 3 ec2 servers are running</figcaption></figure><p>Now for the Load Balancer setup 🥱. During this stage, I hit a roadblock when I discovered my account was restricted from creating an <strong>Application Load Balancer (ALB)</strong>. I contacted AWS Support immediately; the representative was very helpful and informed me that she would escalate the issue to the service team.</p><p>To keep the project moving, I pivoted to a <strong>Classic Load Balancer (CLB)</strong>. This turned into a great learning moment, as the <strong>CLB </strong>allowed me to work with both <strong>Layer 4 (Transport Layer/TCP)</strong> and <strong>Layer 7 (Application Layer/HTTP)</strong> traffic. Since a Load Balancer requires at least two public subnets in different <strong>Availability Zones (AZs)</strong> for high availability, I created a second Public Subnet in a different AZ with the same settings as the first. I also updated the rules in the <strong>Public Route Table</strong> to include this new subnet and successfully launched the CLB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3V2iGJKa17BCghGFW2G8Q.png" /><figcaption>ensure the second public subnet is available</figcaption></figure><p>Now we associate our Public Subnets to the Public Route Table same goes for the Private Subnet in Private Route Table Association</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKNeX-P7739G4lURIqhNSQ.png" /><figcaption>Select the public route table, click <strong>Actions</strong>, and choose <strong>Edit subnet associations</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpCdYiHthU-gIqcfQnEtOA.png" /><figcaption>Select the private route table, click <strong>Actions</strong>, and choose <strong>Edit subnet associations</strong>.</figcaption></figure><p>and then I created the <strong>CLB </strong>selecting the two public subnets with the different Regions and selecting the two private ec2 web servers as instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*cGVOYIIyYI7YNrPl7R9beQ.png" /><figcaption>screenshot on how the CLB is to be configured</figcaption></figure><h4>STEP 4 =&gt; Setting up Ansible</h4><p>With the infrastructure live, I turned to automation. <strong>Ansible</strong> allows us to manage these servers efficiently without the need to log into each one manually. To prepare for this, I ensured that the private key .pem files for both my Bastion host and the Private Web Servers were ready in the same directory where I created my inventory.ini and deploy.yaml playbook files.</p><p><strong>The Inventory </strong><strong>inventory.ini</strong></p><p>In the inventory, I configured Ansible to “tunnel” through the Public Bastion host to reach the Private Servers</p><pre>[bastion]<br># Replace &lt;BASTION_PUBLIC_IP&gt; with the Public IP of your Bastion instance<br># Replace &lt;PATH_TO_BASTION_KEY&gt; with the actual path to your .pem file<br>bastion_host ansible_host=&lt;BASTION_PUBLIC_IP&gt; ansible_user=ubuntu ansible_ssh_private_key_file=&lt;PATH_TO_BASTION_KEY&gt;.pem ansible_python_interpreter=/usr/bin/python3<br><br>[webservers]<br># Replace these with the Private IPs of your two web servers<br>web1 ansible_host=&lt;PRIVATE_IP_SERVER_1&gt;<br>web2 ansible_host=&lt;PRIVATE_IP_SERVER_2&gt;<br><br>[webservers:vars]<br>ansible_user=ubuntu<br>ansible_ssh_private_key_file=&lt;PATH_TO_PRIVATE_KEY&gt;.pem<br>ansible_python_interpreter=/usr/bin/python3<br><br># The &quot;Magic Line&quot; 😅 This ProxyJump tells Ansible to use the Bastion host as a tunnel to reach the private web servers.<br># Ensure the IP address matches your Bastion&#39;s public IP.<br>ansible_ssh_common_args=&#39;-o ConnectTimeout=60 -o ServerAliveInterval=30 -o ProxyJump=ubuntu@&lt;BASTION_PUBLIC_IP&gt;&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*AjMDcMtFxutR65SVU9Cjew.png" /><figcaption>a screenshot of my inventory.ini</figcaption></figure><p><strong>The Webpage </strong><strong>index.html.j2</strong></p><p>The <strong>Jinja2</strong> templating engine uses the {{ }} syntax to access <strong>Ansible facts</strong>, such as ansible_hostname and ansible_default_ipv4.address. These variables are dynamically injected into the HTML during deployment, allowing us to identify which specific private server is responding to a request when accessed through the Load Balancer. The <strong>index.html</strong> file, powered by a <strong>Jinja2 template</strong>, displays my name (<strong>James Adewara</strong>), a brief “About Me” section, and critical server metadata like the instance hostname and private IP address dynamically.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Secure App - {{ ansible_hostname }}&lt;/title&gt;<br>    &lt;style&gt;<br>        body { font-family: sans-serif; text-align: center; padding: 50px; background-color: #f4f4f4; }<br>        .card { <br>            background: white; <br>            padding: 20px; <br>            border-radius: 10px; <br>            box-shadow: 0 4px 8px rgba(0,0,0,0.1); <br>            display: inline-block;<br>        }<br>        h1 { color: #232f3e; }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div class=&quot;card&quot;&gt;<br>        &lt;h1&gt;Hello, I am James Adewara!&lt;/h1&gt;<br>        &lt;p&gt;&lt;strong&gt;Instance Hostname:&lt;/strong&gt; {{ ansible_hostname }}&lt;/p&gt;<br>        &lt;p&gt;&lt;strong&gt;Private IP Address:&lt;/strong&gt; {{ ansible_default_ipv4.address }}&lt;/p&gt;<br>        &lt;hr&gt;<br>        &lt;h3&gt;About Me&lt;/h3&gt;<br>        &lt;p&gt;I am a Junior Cloud Engineer student at AltSchool Africa, specializing in AWS and Automation.&lt;/p&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>The Playbook </strong><strong>deploy.yaml</strong></p><pre>- name: Deploy Secure Web Application<br>  hosts: webservers # the group name for the private ec2 web servers in the `inventory.ini` file<br>  become: yes  # Run as sudo<br>  tasks:<br>    - name: Update apt cache<br>      apt:<br>        update_cache: yes<br>        cache_valid_time: 3600<br><br>    - name: Install Nginx<br>      apt:<br>        name: nginx<br>        state: present<br><br>    - name: Ensure Nginx starts on boot<br>      service:<br>        name: nginx<br>        state: started<br>        enabled: yes<br><br>    - name: Deploy Custom HTML Page<br>      template:<br>        src: index.html.j2<br>        dest: /var/www/html/index.html<br>        mode: &#39;0644&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NNPZ4hN9jqkrMbRgJZL3dg.png" /><figcaption>screenshot of how the playbook yaml file looks like</figcaption></figure><h4>STEP 5 =&gt; Verification &amp; Deployment</h4><p>Before running the full deployment, I had to verify that my “Tunnel” was working correctly using these commands. You can access the source code for this article through my <a href="https://github.com/jamesadewara/aws-secure-web-deployment.git">GitHub link here</a></p><pre># Set key permissions<br>chmod 400 ./bastion-key.pem <br>chmod 400 ./private-key.pem<br><br># 1. Verify the inventory<br>ansible-inventory -i inventory.ini --list<br><br># 2. Ping the Bastion (Public)<br>ansible bastion -m ping -i inventory.ini<br><br># 3. Ping the Web Servers (Private) via the Tunnel<br>ansible webservers -m ping -i inventory.ini<br><br># 4. Run the Deployment Playbook<br>ansible-playbook -i inventory.ini deploy.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1M5IJbJmAxo2_7GURIMrg.png" /><figcaption>ensure the permissions for the ssh keys are set to read only for the owner and other users have no permissions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADQToa5oxLskVq1ggl0mUg.png" /><figcaption>green means go</figcaption></figure><h4>STEP 6 =&gt; Final Testing 😮‍💨 Are thou Working?</h4><p>After a <strong>successful</strong> deployment, it was time to see the results in the real world.</p><p>I navigated to the <strong>EC2 console</strong>, scrolled down, and clicked on the <strong>Load Balancers</strong> menu. I copied the <strong>DNS Name</strong> of my created <strong>CLB</strong> (e.g., http://alb-524782485.us-east-1.elb.amazonaws.com) and opened it in my web browser. Because I used a <strong>Jinja2</strong> HTML template index.html.j2, the webpage dynamically displayed the private IP address of the specific server currently handling the request. To double-check the service across all servers at once, I used this Ansible ad-hoc command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oogR1lLbOHasG5ICn5zAjg.png" /><figcaption>currently using the second private web server accessed from the <strong>DNS url</strong> in my CLB resource</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SrHYgwOcNTqyteRoJ8ij8g.png" /><figcaption>another webpage using the 1st private web server from the <strong>CLB DNS</strong> url</figcaption></figure><pre>ansible webservers -i inventory.ini -m shell -a &quot;systemctl status nginx | grep Active&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1TYxbBmL-50rDYYCahW8w.png" /></figure><p>Uhm! 😌 while setting all this up for the first time, I felt puzzled (“My brain dey do gaga” as my people would say it) when it came to configuring the subnets, route tables, and NAT Gateway without relying on AWS’s “auto-generate” wizards. However, creating them from scratch and manually “connecting the dots” made the architecture visible and much clearer. I now know exactly which tools and resources are being used, making them much easier to maintain and troubleshoot.</p><p>And for the finale😎</p><p>I can now say, by combining AWS’s secure <strong>VPC </strong>architecture with Ansible’s automation, I’ve built a web deployment that is hidden from the public but accessible and scalable for users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1fc718db461" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Ansible?]]></title>
            <link>https://medium.com/@jamesadewara1/why-ansible-c20b0dd1edaf?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/c20b0dd1edaf</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[ssh]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 15:52:30 GMT</pubDate>
            <atom:updated>2026-02-13T14:03:37.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TLf2gfsnhnt8f6CgXS6Lw.png" /><figcaption>why ansible?</figcaption></figure><p>Ansible is an agentless automation tool that uses <strong>SSH </strong>to connect to remote servers, making it an efficient way to control and manage your nodes (i.e. your remote servers). It uses an <strong>Inventory </strong>to add IP addresses i.e. the hosts you want to control (45.84.47.23, 192.23.43.1) and <strong>Playbooks, </strong>which contains instructions for the tasks you want to execute on your managed nodes. It also features <strong>Idempotency, </strong>meaning you can run the same playbook multiple times and achieve the same result. Ansible works by connecting to your nodes and pushing out small programs called <strong>Ansible Modules.</strong> It is agentless and uses ssh, meaning it ensures secured connections and you don’t need to install any special software on the targeted servers.</p><h3>How to start making use of Ansible</h3><h4>STEP 1 =&gt; Install Ansible</h4><p>On your Linux local device, run on your bash terminal</p><pre>sudo apt install ansible</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*VVGfSvcViSyBaWG3YJd5Dg.png" /><figcaption>use an appropriate directory for this article tutorial</figcaption></figure><h4>STEP 2 =&gt; Initialize and create at least two <strong>EC2 </strong>instances on <strong>AWS</strong></h4><p>We would be making use of <strong>AWS EC2</strong> for our remote servers, or you can use any cloud platform (azure, gcp, digital ocean) of your choice or use your own <strong>Virtual Linux Machine</strong> on your device using <strong>Oracle VM</strong>. Make sure you have an AWS account; search for “EC2” in the search bar and click and create <strong>EC2 </strong>instance using ubuntu Linux as your VM<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrhsOp3XI75k0mKbGyESxQ.png" /><figcaption>create an account and search for ec2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lCrGy90XgvUZ_TYruTcCyQ.png" /><figcaption>add the server name and select the ubuntu VM</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*DDOehSVoqa4xrcvjBtL5hw.png" /><figcaption>ensure you create the ssh key and reuse the key for the 2 or more instances</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1aubgaGFVJBgoHebjknH6A.png" /><figcaption>at least 2 of aws ec2 instances running on ubuntu VM</figcaption></figure><h4>STEP 3 =&gt; Create a file named &quot;inventory.ini&quot;</h4><p>In your inventory.ini file copy the <strong>Public IP Address</strong> found in your running <strong>EC2 instances</strong> on <strong>AWS </strong>only</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PlHT5O561luuLZOAEAHemw.png" /><figcaption>copy the public IP address</figcaption></figure><p>and add it into the inventory.ini file. The [name] is used for grouping hosts; choose any group name related to what you are doing, it must not have spaces; instead of a space, use an underscore _. Ansible is case-sensitive. In this article we will be using inventory.ini and for group name [aws_ec2_servers]. <strong>For ease of sake</strong>, make sure you store the “*.pem” key file sent to you from AWS in the same directory with your ansible inventory.ini and playbook.yaml, we will need this key to ssh to AWS EC2 remoter servers and also make sure the access to the key is read only for the owner and the group and others as no access.</p><pre>chmod 400 /path/to/your/key.pem</pre><pre>[aws_ec2_servers]<br>45.84.47.23 ansible_user=ubuntu ansible_ssh_private_key_file=/path/to/your/key.pem ansible_python_interpreter=/usr/bin/python3<br>192.72.47.21 ansible_user=ubuntu ansible_ssh_private_key_file=/path/to/your/key.pem ansible_python_interpreter=/usr/bin/python3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9E2oLWCuGcahfJ0he8vBQ.png" /><figcaption>using nano to create the “inventory.ini” file</figcaption></figure><h4>STEP 4 =&gt; Verify your Inventory</h4><p>We will be using</p><pre>ansible-inventory -i inventory.ini --list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*G0cJ9RcSS31Bjsz0HE5zHg.png" /><figcaption>It will show a red error message if it did not work</figcaption></figure><p>to verify, and</p><pre>ansible aws_ec2_servers -m ping -i inventory.ini</pre><p>to check if the hosts are active, but before you ping, we need to update our current local Linux machine to ensure that the ansible version is <strong>UpToDate </strong>and its correlate with our <strong>python3 </strong>to avoid any connection error</p><pre>sudo apt update<br>sudo apt install software-properties-common -y<br>sudo add-apt-repository --yes --update ppa:ansible/ansible<br>sudo apt install ansible -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AfGixBUn1DLVt1UjbYP8w.png" /><figcaption>if it pings successfully, it means connection is secured and its connected, green means go</figcaption></figure><h4><strong>STEP 5 =&gt; Creating a “playbook.yaml”</strong></h4><p>The playbook.yaml is the name of the file we want to use; you can use any filename of your choice as long as it has the <strong>YAML </strong>file extension. When we run the Ansible playbook, the next argument that follows should be your <strong>YAML </strong>file. <strong>YAML </strong>stands for “YAML Ain’t Markup Language”, which is human-readable and used as a configuration file.</p><pre>- name: System Update and File Creation<br>  hosts: aws_ec2_servers # all<br>  become: yes  # Needed for system updates and creating folders in /home<br>  tasks:<br>    - name: Update apt cache and upgrade all packages<br>      apt:<br>        update_cache: yes<br>        upgrade: dist<br><br>    - name: Ensure the DEMO directory exists<br>      file:<br>        path: /home/DEMO<br>        state: directory<br>        mode: &#39;0755&#39;<br><br>    - name: Create connected.txt with content &quot;Why Ansible?\n&quot;<br>      copy:<br>        content: &quot;Why Ansible?&quot;<br>        dest: /home/DEMO/connected.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*8FhmSrvJ_HUopZWHodd7Zg.png" /><figcaption>a screenshot of my playbook.yaml using linux nano</figcaption></figure><p>In a YAML file, the # symbol is used as <strong>comments</strong>. In an Ansible playbook, comments are used to describe or explain configurations, such as <strong>modules </strong>and <strong>tasks</strong>.</p><p>Let’s enumerate the contents shall we:</p><ul><li><strong>The parent&#39;s </strong><strong>name:=&gt; </strong>This represents the name of our <strong>Play</strong>.</li><li><strong>hosts:=&gt; </strong>This is accessed by the ansible-playbook command when we run the playbook. It points to a specific group of hosts or uses all to denote every host present in the inventory.</li><li><strong>apt:=&gt;</strong> This module performs the equivalent of apt update or sudo apt update and upgrade.</li><li><strong>file:=&gt;</strong> This module is used for tasks similar to mkdir in Linux Bash.</li><li><strong>copy:=&gt;</strong> This module can be used to create files, similar to the touch command in Linux Bash.</li></ul><p>Ansible is <strong>declarative</strong>. Instead of writing Linux Bash commands like</p><pre>touch connected.txt</pre><p>we use <strong>Ansible Modules</strong> like apt and copy. If that is the case, how do we know which <strong>Ansible Module</strong> to use for a specific command or task? We can either search through the [Index of all for Ansible Modules] (<a href="https://docs.ansible.com/ansible/latest/collections/index_module.html">https://docs.ansible.com/ansible/latest/collections/index_module.html</a>) in the Ansible Community Documentation or use <strong>Gemini AI (or Grok AI, ChatGPT, Claude, etc.) </strong>to assist with finding the right module name for the task. <strong>Modules </strong>in <strong>Ansible </strong>are <strong>small programs t</strong>hat help our declarative <strong>YAML </strong>playbooks function effectively.</p><h4>STEP 6 =&gt; Run the Playbook</h4><p>Using this command to run our ansible playbook</p><pre>ansible-playbook -i inventory.ini playbook.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*eetg0EvSbUu5OawHqVVC6A.png" /><figcaption>green always means go (it’s working).</figcaption></figure><p>The <strong>playbook recap </strong>shows the host and the status of the host, whether it connected successfully (e.g., “OK”) or if there was a failure. It also shows if anything was “changed”, which reflects idempotency.</p><p>And to check it out on your AWS EC2 Instances select an instance and click connect it will open a terminal for you to access your ubuntu VM, once its connected run</p><pre>cat /home/DEMO/connected.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xsPN9VgL9Av_-OOr8bTR3g.png" /><figcaption>after connecting, it will open a new AWS terminal tab</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vX_zlmJb-g6hUWfEEm-8gg.png" /><figcaption>try this for the second or remaining ec2 instances you created</figcaption></figure><p><strong>NOTE -&gt; </strong>Since you are specifying the file path for your inventory (e.g., inventory.ini) and playbook (e.g., playbook.yaml, remember those names are not fixed; they are just commonly used in the world of ansible. Feel free to use any filename with the appropriate file extensions, but make sure that when running ansible-playbook, you specify the actual file paths and names you created.</p><p>I have provided a GitHub repository containing the configuration files for this project. You can clone the repo and follow along by updating the inventory file with your own IP addresses and group names <a href="https://github.com/jamesadewara/ansible-init.git">Click Here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c20b0dd1edaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Think `. env` Files are Secure? Think Again]]></title>
            <link>https://medium.com/@jamesadewara1/think-env-files-are-secure-think-again-201b8f4ed8ad?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/201b8f4ed8ad</guid>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[env]]></category>
            <category><![CDATA[gpg]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 00:50:36 GMT</pubDate>
            <atom:updated>2026-02-08T00:50:36.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLwwdfRlp3ioFrtCWK8XuQ.png" /><figcaption>make your .env secure, avoid attacks</figcaption></figure><p>Let me guess, you probably think using a .env file is enough to secure your credentials for local and online deployment.</p><p>I used to believe that using .env alone would secure my web applications simple because the files are “hidden”. I recently realized I was wrong. While using .env is good practice, it is ultimately just a hidden text file. Anyone with basic server permissions not just the sudo user can read it.</p><p>Now, I have adopted a better practice, i.e. using <strong>GPG (GNU Privacy Guard). </strong>This adds a high level of protection by encyrpting your environment variables (<strong>.env =&gt; </strong><strong>.env.gpg</strong>). These secrets are then decrypted <strong>in-memory. </strong>This means your credentials only exists in the<strong> RAM </strong>while your app is running; if the app shuts down, the decrypted data vanishes.</p><p><strong>I</strong>n this article, we will cover how to set up <strong>GPG </strong>and use it with a simple <strong>Fast API</strong> backend to ensure your encrypted variables are working exactly as they should.</p><h4>Prerequisites</h4><p>This guide assumes you have basic knowledge of <strong>Python, Git, and the Linux Bash Terminal</strong>. If you are new to these, I have included helpful links at each step.</p><p><strong>NOTE -&gt;</strong> While GPG is a fantastic security layer, for enterprise-scale cloud applications (AWS, GCP, etc.), I recommend using a dedicated <strong>Secret Manager</strong>. Just keep in mind that cloud secret managers usually come with a price tag!</p><h4><strong>STEP 1 :&gt; Install GPG</strong></h4><p>First, ensure GPG is installed on your system.</p><ul><li>Linux (Ubuntu/Debian): run sudo apt install gnupg.</li><li>Windows: Install git for windows <a href="https://gitforwindows.org/">https://gitforwindows.org/</a> to get Git Linux Bash and download and <a href="https://gpg4win.org/">https://gpg4win.org/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*BILoEg3ZEcbxLvYwRBZedA.png" /><figcaption>a screenshot of the installation on linux</figcaption></figure><h4>STEP 2 :&gt; Generate Your Key Pair</h4><p>Run the following command to create your <strong>gpg</strong> identity</p><pre>gpg --full-generate-key</pre><ul><li>Select <strong>(1) RSA and RSA</strong>.</li><li><strong>Key size</strong> of <strong>4096</strong> bits.</li><li>Enter your <strong>name</strong>, and a strong <strong>passphrase</strong>. (Think of the passphrase as the master password for your keys).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wkB0tv7-ZrZqUGuaMBFDcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ar7zn1qRCFYj8NHyhNJXLQ.png" /></figure><p>To verify your keys were created, use</p><pre>gpg --list-keys</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*XcgfAI4_ZFbdXeF8LHPTfQ.png" /></figure><h4>STEP 3 =&gt; Clone the Repository</h4><p>Clone this demo project to follow along</p><pre>git clone https://github.com/jamesadewara/gpg-security-test.git</pre><p>Ensure you read the <strong>README.md</strong>. Don’t worry too much about the Python code itself; our goal is to prove the encrypted .env works as expected.</p><h4>STEP 4 =&gt; Initial Test</h4><p>Before encrypting, verify the app runs. Activate your virtual environment, install the dependencies with</p><pre>pip install -r requirements.txt</pre><p>, and start the server using</p><pre>uvicorn main:app --reload</pre><p>Visit “<a href="http://127.0.0.1:8000/get-developer-info">http://127.0.0.1:8000/get-developer-info</a>” in your web browser. You should see the info pulled from the plain-text .env file.</p><p>To know how to use virtual environment in python you can access this YouTube tutorial <strong>=&gt; </strong><a href="https://www.youtube.com/watch?v=Y21OR1OPC9A"><strong>https://www.youtube.com/watch?v=Y21OR1OPC9A</strong></a></p><h4>STEP 5 =&gt; Encrypt the `.env` File</h4><p>Now, let’s secure it. Encrypt the file using the email address you used in <strong>STEP 2 ‸</strong></p><pre>gpg --yes --batch --encrypt --recipient &quot;your-email@example.com&quot; .env </pre><p>Why do this? On Linux, a simple ls won’t show a .env file because it’s hidden. However, anyone running ls -al can reveal it and read your secrets. By converting it to .env.gpg, your credentials stay secure even if someone manages to download the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*4-f2W6gd1SdG1Y3EXmT5mA.png" /><figcaption>.env file is exposed</figcaption></figure><h4>STEP 6 =&gt; In-Memory Decryption and Deployment</h4><p>Once .env.gpg is created, you can safely delete the original plain-text file rm .env.</p><p>Now, we wil decrypt the file and “inject” the secrets directly into the FastAPI process memory. Run this command (Works in Linux or Git Bash on windows)</p><pre>export $(gpg --decrypt .env.gpg | tr -d &#39;\r&#39; | xargs) &amp;&amp; uvicorn main:app --reload</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XetOLxTJD2BUGEgX-h_aw.png" /></figure><p>NOTE =&gt; If your key has a passphrase, GPG wil prompt you for it the first time. Once decrypted, the variables are exported to the environment, and Fast API picks them up without any plain-text file ever touching your disk!</p><p>By using GPG, you have added a robust layer of security to your workflow. Even if your server is compromised, your actual credentials aren’t sitting in a visible text file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=201b8f4ed8ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dangers Of Root Users In AWS]]></title>
            <link>https://medium.com/@jamesadewara1/dangers-of-root-users-in-aws-69383f957eeb?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/69383f957eeb</guid>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[sudo]]></category>
            <category><![CDATA[admin]]></category>
            <category><![CDATA[roots]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Fri, 06 Feb 2026 13:10:10 GMT</pubDate>
            <atom:updated>2026-02-06T13:13:20.102Z</atom:updated>
            <content:encoded><![CDATA[<p>As a beginner diving into the world of cloud computing, you might not know this yet.</p><p>Here are important things you need to take note of when you sign in to your <strong>aws</strong> account.</p><p><em>Never continue signing in as a </em><strong><em>root user </em></strong><em>in</em><strong><em> AWS </em></strong><em>or any other cloud platforms (</em><strong><em>GCP, AZURE, etc.</em></strong><em>) as this increases the risk of compromise and insecurity, which can put your whole company’s resources in jeopardy.</em></p><ul><li><strong>STEP 1 :&gt;</strong> Make sure you are currently logged in as a <strong>root user</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qD36CxUcCrLuUIdx2GR0ow.png" /><figcaption><strong>aws</strong> signing page :&gt; <a href="https://console.aws.amazon.com/console/home?nc2=h_ct&amp;src=header-signin">https://console.aws.amazon.com/console/home?nc2=h_ct&amp;src=header-signin</a></figcaption></figure><ul><li><strong>STEP 2 :&gt; </strong>Go to the search button and search for<strong> IAM</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uo3qf41sErbUJnQ-xyxkpg.png" /><figcaption><strong>aws</strong> search dialog for IAM</figcaption></figure><ul><li><strong>STEP 3 :&gt;</strong> After clicking on the <strong>IAM</strong>, create a user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eXZhoNFM8Hu9ObA2E9DQHA.png" /><figcaption><strong>aws IAM </strong>users&#39; page</figcaption></figure><ul><li><strong>STEP 4 :&gt;</strong> After adding your <strong>name</strong>, click on the <strong>Next button </strong>and <strong>create </strong>and <strong>assign </strong>a <strong>group </strong>(e.g. <em>administrators</em> <strong>&lt;:</strong> <strong>group </strong>and <em>monday </em><strong><em>&lt;</em>:</strong> <strong>user</strong>).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8CgA5ilhBJNQVl5hicoJw.png" /><figcaption>follow the numbers as seen from the screenshot</figcaption></figure><ul><li><strong>STEP 5 :&gt;</strong> While not compulsory, it is a best practice to add <strong>tags </strong>to <strong>categorize </strong>your <strong>aws resources</strong> e.g. <strong>aws</strong> IAM <strong>group</strong>, as this acts as an extra metadata (<strong>Tag Name :&gt;</strong> <em>Role</em>, <strong>Key :&gt;</strong> <em>admin).</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vYgjxJ-JlRVPeHQ6-Lcvyw.png" /><figcaption>after adding tag(s) click the create user button</figcaption></figure><ul><li><strong>STEP 6 :&gt; </strong>Click on the created user, view the user info, and go to the <strong>Security Credentials</strong> tab. <strong>Enable Console Access. </strong>In Console Access, you can auto-generate a password and use the credentials to log in, after which AWS will prompt you to change the password, or alternatively, you can choose to use a custom password. When creating the password, collect the credentials for the user, as you will use them to access your AWS console as a sudo user 🤫. The Administrative user created is similar to a sudo user in <strong>Linux.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QofrpdyyHWv_L4shlSfng.png" /><figcaption>enable console access in the user’s page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*VB8aL-FYyIjtzT5UqdWQiA.png" /><figcaption>enable `user must create new password at next sign-in` it’s for best practice</figcaption></figure><ul><li><strong>STEP 7 :&gt;</strong> You will use the credentials to log in again. You can either download the credentials as a CSV file and keep it safe, or copy the <strong>console sign-in URL</strong>, <strong>username</strong>, and <strong>password</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*mizg0vTNqJneSZ8EQ_dPSg.png" /><figcaption>do not close until you have the credentials with you</figcaption></figure><ul><li><strong>STEP 8 :&gt;</strong> Use the <strong>console sign-in URL</strong> in any of your web browsers and fill in the credential name and password. <strong>Take note</strong> that if you use the URL in the same browser where you are logged in as a root user, you will be logged out from the root user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATPIbqnI8G_ma9f-AL_vtA.png" /><figcaption>console signing URL should look like this `<a href="https://839026370596.signin.aws.amazon.com/console">https://&lt;alias or acct id&gt;. signin.aws.amazon.com/console</a>`</figcaption></figure><ul><li><strong>STEP 9 :&gt;</strong> Since we used <strong>auto-generated password</strong>, we will be prompted to change our password. This is necessary when you want to give other users different kinds of access and allow them to change their passwords as a user in your AWS account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*i0TZMJDnUoNGRcljrT7Oyw.png" /><figcaption>aws password reset page</figcaption></figure><p>In this way, you have prevented your AWS account from being compromised 🪪 ✅.</p><p><strong>NOTE :&gt;</strong> The <strong>root </strong>user has <strong>overall privileges </strong>and it is quite difficult to trace who logged in as a root user. With <strong>IAM </strong>users, you can control who has access to your cloud, what functions they contribute to, and limit or grant certain privileges to different users in any group, all working under your cloud infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69383f957eeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating the Clouds My AWS S3 Journey with AltSchool Africa]]></title>
            <link>https://medium.com/@jamesadewara1/navigating-the-clouds-my-aws-s3-journey-with-altschool-africa-c928a1eba286?source=rss-573fa73b0515------2</link>
            <guid isPermaLink="false">https://medium.com/p/c928a1eba286</guid>
            <category><![CDATA[amazon-s3-bucket]]></category>
            <category><![CDATA[altschool-africa]]></category>
            <category><![CDATA[cloud-engineering]]></category>
            <category><![CDATA[cloud-computing-solutions]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Jamesadewara]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 07:20:15 GMT</pubDate>
            <atom:updated>2026-02-05T07:20:15.922Z</atom:updated>
            <content:encoded><![CDATA[<p>As a Cloud Engineering student at <strong>AltSchool Africa</strong>, I recently moved from local virtual environments into the vast world of <strong>Amazon Web Services (AWS)</strong>. My latest mission? Setting up a publicly accessible storage system using <strong>Amazon S3</strong>.</p><p>Here is how I built it and the “<strong><em>Access Denied</em></strong>” hurdles I cleared along the way.</p><h3>The Mission</h3><p>The assignment required me to:</p><ol><li>Create a unique S3 bucket.</li><li>Upload a file (an image).</li><li>Ensure the file is accessible to the public via a static URL.</li></ol><h4>Step 1 :&gt; Bucket Creation &amp; Global Uniqueness</h4><p>I headed to the S3 console and initiated the “<strong><em>Create Bucket</em></strong>” wizard. I named my bucket `<strong>james-global-bucket</strong>`.</p><p><strong>Pro-Tip:</strong> S3 bucket names must be globally unique. I chose the `<em>eu-north-1</em>` (Stockholm) region to host my data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnqKISEaOUF025H3ZdsrjQ.png" /><figcaption>s3-bucket-created</figcaption></figure><h4>Step 2 :&gt; The “Permission Denied” Mystery</h4><p>After uploading my image, `<em>20260103_132828.jpg</em>`, I tried to access its public URL. Instead of my photo, I was greeted by a cold XML error: <strong>Access Denied</strong>.</p><p>I had already “<strong><em>Unblocked Public Access</em></strong>” in the bucket settings, so why was it still failing? This led me to a deep dive into <strong>Security Layers.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfNNw8-u5H_ipd9vSOyUyA.png" /><figcaption>cold XML error Screenshot</figcaption></figure><h4>Step 3 :&gt; Troubleshooting the Access Layers</h4><p>This was the biggest challenge of the project. I learned that AWS has a “<strong><em>Security by Default</em></strong>” posture. To make my file public, I had to clear three distinct gates:</p><ul><li><strong>Gate 1 :&gt; Block Public Access (Bucket Level)</strong></li></ul><p>I had to go to the <strong>Permissions</strong> tab and turn off the “<strong><em>Block all public access</em></strong>” setting. This opened the “Front Door” of the bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wf2YnDq8VOlYEvlyWpj6vg.png" /><figcaption><strong><em>Block all public access Screenshot</em></strong></figcaption></figure><ul><li><strong>Gate 2 :&gt; Object Ownership (The ACL Trap)</strong></li></ul><p>Even with the door open, the “<strong><em>Make public via ACL</em></strong>” button was disabled (<strong>greyed out</strong>). I discovered that modern AWS buckets default to <strong>Bucket Owner Enforced</strong>, which disables all manual file permissions.</p><p><strong>The Fix</strong>: I had to edit <strong>Object Ownership</strong> and switch it to <strong>ACLs enabled</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WU0n3izXd7-4Exy1J_nwqA.png" /><figcaption><strong>Bucket Owner Enforced Screenshot</strong></figcaption></figure><ul><li><strong>Gate 3 :&gt; Individual Object Permissions</strong></li></ul><p>Finally, I navigated back to my file, clicked <strong>Actions</strong>, and selected <strong>Make public via ACL</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsnhEqvIKO76WDRpemTmRQ.png" /><figcaption>Object ACL Enabled</figcaption></figure><h4>The Result :&gt; It’s Alive!</h4><p>Once those three layers were aligned, the static URL finally worked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gDWv_YbTZ0h3LVytc2ebEg.png" /><figcaption>No XML Error this time</figcaption></figure><p>I no longer needed a long “<strong><em>Presigned</em></strong>” token; the image was truly live on the web!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c928a1eba286" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>