<?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 AJIM on Medium]]></title>
        <description><![CDATA[Stories by AJIM on Medium]]></description>
        <link>https://medium.com/@ajimbong?source=rss-4fea62d4ee39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LkgsNEAIruh-r5_yZtVxYA.jpeg</url>
            <title>Stories by AJIM on Medium</title>
            <link>https://medium.com/@ajimbong?source=rss-4fea62d4ee39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:01:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajimbong/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[Deploy a Docker Container to Amazon ECS using GitHub Actions]]></title>
            <link>https://ajimbong.medium.com/deploy-a-docker-container-to-amazon-ecs-using-github-actions-fd50261b8e03?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd50261b8e03</guid>
            <category><![CDATA[amazon-ecs]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 16:27:26 GMT</pubDate>
            <atom:updated>2023-08-09T16:27:26.706Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SaVetsCf6qpLHMxkI-ylag.png" /><figcaption>blog featured image</figcaption></figure><p>In this project, we will set up a GitHub Actions CI/CD pipeline that runs each time new changes are pushed to the main GitHub branch. When this action is triggered, a new docker image is built, pushed to Docker Hub, and then deployed to an Amazon ECS cluster.</p><p>This guide assumes you already have some knowledge in AWS, ECS, Docker, and GitHub Actions as the goal is to provide a template you can modify to meet the specific needs of your project.</p><h3>Requirements</h3><p>To follow along with this project, you should have an AWS Account, GitHub account, Docker Hub account(you can optionally use Amazon ECR), and certain software installed in your local environment like:</p><ul><li>Git</li><li>Docker</li><li>VS Code(or any text editor you prefer)</li></ul><p>Lastly, we will need an ECS cluster/ ECS Service up and running that GitHub actions will deploy the updated image to. I already wrote out this infrastructure using Terraform and you can get it here from my GitHub repo =&gt; <a href="https://github.com/ajimbong/terraform-ecs-cicd-project">https://github.com/ajimbong/terraform-ecs-cicd-project</a>. If you are familiar with Terraform, you can use that to automatically create the infrastructure or do it manually. But these are the resources that the Terraform code will create:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6KJEdYb5bhze4_Md0iLKTg.png" /><figcaption>AWS Architecture Diagram for Amazon ECS cluster</figcaption></figure><ul><li>A VPC with 2 public and private subnets distributed across 2 availability zones.</li><li>An Internet Gateway and Two NAT Gateways, one in each availability zone.</li><li>A Fargate ECS Cluster and ECS Service.</li><li>An Application Load Balancer.</li><li>And a Route53 record which you can optionally leave out.</li></ul><h3>Implementation</h3><h3>Clone the Application Code</h3><p>The application used here is a Simple Notes Taking app that was developed using React, it’s purely a frontend application and doesn’t have a backend. Here is the link to clone the code from my repo =&gt; <a href="https://github.com/ajimbong/novo-notes">https://github.com/ajimbong/novo-notes</a>. Optionally, you could still skip this step by using your project.</p><h3>Modify the Workflow file.</h3><p>In this GitHub repo =&gt; <a href="https://github.com/ajimbong/novo-notes">https://github.com/ajimbong/novo-notes</a>, navigate to the directory .github/workflows/ and you will find a main.yml file. This file is a declaration of the tasks GitHub Actions will perform when a &quot;defined event&quot; is triggered.</p><pre>name: Deploy to Amazon ECS<br>on:<br>  push:<br>    branches:<br>      - &quot;main&quot;<br>  workflow_dispatch:<br><br># secrets:<br>#   DOCKER_HUB_USERNAME: <br>#   DOCKER_HUB_PASSWORD: <br>#   AWS_ACCESS_KEY_ID:<br>#   AWS_SECRET_ACCESS_KEY:<br><br>env:<br>  IMAGE_NAME: novo-notes<br>  AWS_REGION: us-east-1                          <br>  ECS_SERVICE: ecs-cicd-ecs-service              <br>  ECS_CLUSTER: ecs-cicd-ecs-cluster              <br>  ECS_TASK_DEFINITION: aws/td.json <br>  CONTAINER_IMAGE: ajimbong/novo-notes<br>  CONTAINER_NAME: novo-notes<br><br>defaults:<br>  run:<br>    shell: bash<br>jobs:<br>  deploy:<br>    name: Deploy<br>    runs-on: ubuntu-latest<br>    permissions:<br>      packages: write<br>      contents: read<br>    steps:<br>        - name: Checkout<br>          uses: actions/checkout@v2<br>        - name: Login to Docker Hub<br>          uses: docker/login-action@v2<br>          with:<br>            username: ${{ secrets.DOCKER_HUB_USERNAME }}<br>            password: ${{ secrets.DOCKER_HUB_PASSWORD }}<br>        - name: Set up Docker Buildx<br>          uses: docker/setup-buildx-action@v2<br>        - name: Build and push<br>          uses: docker/build-push-action@v4<br>          with:<br>            context: .<br>            file: ./Dockerfile<br>            push: true<br>            tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest<br>        - name: Configure AWS credentials<br>          uses: aws-actions/configure-aws-credentials@v1<br>          with:<br>              aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>              aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>              aws-region: ${{ env.AWS_REGION }}<br>        - name: Fill in the new image ID in the Amazon ECS task definition<br>          id: task-def<br>          uses: aws-actions/amazon-ecs-render-task-definition@v1<br>          with:<br>              task-definition: ${{ env.ECS_TASK_DEFINITION }}<br>              container-name: ${{ env.CONTAINER_NAME }}<br>              image: ${{ env.CONTAINER_IMAGE }}<br>        - name: Deploy Amazon ECS task definition<br>          uses: aws-actions/amazon-ecs-deploy-task-definition@v1<br>          with:<br>              task-definition: ${{ steps.task-def.outputs.task-definition }}<br>              service: ${{ env.ECS_SERVICE }}<br>              cluster: ${{ env.ECS_CLUSTER }}<br>              wait-for-service-stability: true</pre><p>Starting from the top and moving down:</p><p>The on: keyword species the events that should trigger the workflow. The events defined here are:</p><ul><li>push: that runs anytime we push changes to the main branch</li><li>workflow_dispatch: that allows us to manually run the workflow.</li></ul><p>The secrets that have been commented out refer to the secrets we manually have to create in our GitHub repository. Ensure that you set them up before proceeding.</p><p>env: is the set of environment variables that will be used during the execution of the workflow. You want to make sure you set the values that are appropriate to your project.</p><ul><li>IMAGE_NAME: is the name of the docker container image.</li><li>AWS_REGION: refers to the AWS region where your resources are deployed to.</li><li>ECS_SERVICE: is the name of your ECS Service</li><li>ECS_CLUSTER: is the name of your ECS cluster</li><li>ECS_TASK_DEFINITION: is the directory to a JSON file containing your task definition template. This JSON code can easily be gotten from your AWS ECS console under Task Definitions, and it should be a Task Definition that was already created.</li><li>CONTAINER_IMAGE: is the URL to your docker container image.</li><li>CONTAINER_NAME: is the name of your docker image. Same as IMAGE_NAME.</li></ul><p>defaults: we&#39;re just defining the default Linux shell that should be used.</p><p>jobs: this is where we define all the execution steps. Again, I already assume you have some familiarity with GitHub actions so I&#39;m not going to explain all the steps as this will be very lengthy.</p><h3>Run the Workflow</h3><p>Now that we’re done modifying the workflow file, it’s time to run it by pushing the changes to the main GitHub branch to trigger the workflow, or we can manually run it from the Actions tab in the GitHub repo.</p><p>Watch closely to ensure that everything goes properly(which I hope it does), else you can try to troubleshoot any failures that occur.</p><p>This is where I will wrap things up, and I hope you found this article helpful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd50261b8e03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Terraform Modules to Deploy a Two Architecture on AWS]]></title>
            <link>https://ajimbong.medium.com/using-terraform-modules-to-deploy-a-two-architecture-on-aws-fd67fe6d1bdc?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd67fe6d1bdc</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 10:56:09 GMT</pubDate>
            <atom:updated>2023-07-21T10:56:09.346Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JILrq9RgxDYLxHkNJJ-yug.png" /></figure><p>This project uses Terraform, a very powerful Infrastructure as Code(IaC) tool to deploy a two-tier Architecture on AWS that contains an Application Load Balancer, Auto Scaling Group, Route53 domain name, etc.</p><p>This project is a redo of my past projects where I created the same Infrastructure using the AWS console instead. Here’s the link to the old project: <a href="https://blog.ajim.me/hosting-a-highly-available-fault-tolerant-website-on-aws">https://blog.ajim.me/hosting-a-highly-available-fault-tolerant-website-on-aws</a>.</p><p>The image below is the reference Architecture Diagram that was used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHmq118Qyc3v8op1pUWViA.png" /></figure><h3>The code structure</h3><p>You can access the source code here on my GitHub: <a href="https://github.com/ajimbong/terraform-modules-project">https://github.com/ajimbong/terraform-modules-project</a>.</p><p>But I’ll walk you through the structure of the project and what makes up the different components:</p><figure><img alt="Terraform modules project — Code structure" src="https://cdn-images-1.medium.com/max/873/1*9RM2SVswdcPSX34CCTIkzQ.png" /></figure><h3>Backend State</h3><p>From the image above, the first folder we have is 📁backend_state which stores the terraform code that creates the remote S3 and DynamoDB table that we will later use to store the state file for our project. So if you want to run this project, you will need to first run the code in that directory to provision those resources; unless you will use the local backend instead.</p><h3>Modules</h3><p>The 📁modules folder contains all the modules for this project in the various sub-folders.</p><h4>1) alb</h4><p>📁alb is the module that is responsible for creating the Application Load Balancer. Like all other modules, it has attributes that have to be provided at the time of creating the module and some attributes depend on the output of other modules.</p><h4>2) asg</h4><p>📁asg is the Auto Scaling Group Module and it contains the Launch Configuration which will be used by the ASG to create EC2 instances. It also has an IAM role to access AWS S3 service which is used to pull down the web files from a defined bucket when launching the EC2 instances; These web files are placed in a directory for the Apache web server to serve.</p><h4>3) nat</h4><p>📁nat module will create two NAT gateways in the public subnet with elastic IP addresses. This module also creates two private route tables that belong to their respective availability zones.</p><h4>4) route53</h4><p>📁rout53 module pulls down an existing hosted zone using the data block and creates a record that will be attached to the Application Load Balancer. This module is not too essential and can be left out if you haven&#39;t bought a domain name with route53.</p><h4>5) security_groups</h4><p>📁security_groups module creates two security groups, one for the Application Location Balancer and the other which is used by the EC2 servers.</p><h4>6) vpc</h4><p>📁vpc modules creates the underlying network stack for the architecture with 2 public subnets, 2 private subnets, 1 internet gateway, and a route table that is used by all the public subnets.</p><h3>Production</h3><p>The 📁production folder is basically where we put it all together and import all the modules to create this architecture. terraform.tfvars is the file we use to pass in the variables needed by all these modules. Note that we can create multiple instances of this architecture probably for Staging, Testing, etc just by importing the modules and passing the required arguments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd67fe6d1bdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy A Full Stack JavaScript Application With Amazon ECS and Docker]]></title>
            <link>https://ajimbong.medium.com/deploy-a-full-stack-javascript-application-with-amazon-ecs-and-docker-7f6b8ab65d5?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f6b8ab65d5</guid>
            <category><![CDATA[ecs-fargate]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 10:57:16 GMT</pubDate>
            <atom:updated>2023-07-06T10:57:16.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CMOhfhWcLfMbxJ2i_zaYJQ.png" /><figcaption>featured image</figcaption></figure><p>Hello! In this guide, we will be walking through the process of deploying a full-stack application that has a database on Amazon ECS.</p><p>What is Amazon ECS? You may ask, ECS stands for Elastic Container Service. It is Amazon’s container orchestration service used for deploying containerized applications and manages the process of creating, destroying, restarting, auto-scaling, and updating your containers. ECS can be used with EC2 instances where you are responsible for managing the underlying servers or serverlessly with Fargate where AWS will be responsible for provisioning and managing the underlying servers. We’ll go with the serverless option in this guide as it is much easier to set up.</p><h3>Objectives</h3><p>The goal is to deploy a docker application on ECS that will be running behind an application load balancer and also use Amazon EFS to persist the data from our database. Here is a quick rundown of all the steps:</p><ul><li>Create the fundamental resources i.e. Security Groups, Load Balancer, EFS Volume.</li><li>Create an ECS Cluster to deploy the application.</li><li>Create the Task Definition that contains the instructions necessary to run the application.</li><li>Starting a new service</li></ul><blockquote>N:B I am using the default VPC for this demo to keep things simple, but feel free to use a custom VPC if that’s what you prefer.</blockquote><h3>1) Setting up the Security Groups, Load Balancer, and EFS Volume</h3><p>In this step, we are focused on creating the resources which will later on be used by our docker application.</p><h4>i) Security Groups</h4><p>We will need 3 security groups in total; one for the application load balancer, the EFS volume, and the ECS task itself. Ensure that all these security groups are created in the VPC where your application will be deployed to. To create the security groups, you can navigate to the EC2 dashboard and you will find Security Groups in the left pane under “Network &amp; Security”</p><ul><li>First, create the Security Group for the Application Load Balancer with HTTP and HTTPS inbound traffic and the source should be the public internet aka 0.0.0.0.</li><li>Secondly, create the ECS task security group which should have HTTP and HTTPS inbound traffic and the source is the Application Load Balancer security group.</li><li>Finally, create the EFS security group with NFS inbound traffic from the ECS task security group.</li></ul><h4>ii) Application Load Balancer</h4><p>Still in the same EC2 dashboard, we can find the option to create the load balancer in the left pane under “Load Balancing”. Before creating the load balancer, we need to create the target group for the load balancer. Create the target group with the following options:</p><ul><li>In the target type, instead of the default option “instances”, select “IP addresses”.</li><li>Under VPC, you can select your custom VPC or leave it as the default.</li><li>Also, give your target group a name and Create the target group.</li></ul><p>Now go ahead and create the application load balancer with these settings:</p><ul><li>Type — Application Load Balancer.</li><li>VPC — Select your custom VPC and subnets or leave it as default.</li><li>Security Group — Select the security group we created earlier for the ALB.</li><li>Listener — Choose the Target Group we just created.</li></ul><h4>iii) EFS</h4><p>In your AWS console, search for EFS and Navigate the EFS Dashboard. Create a new EFS Volume with these options:</p><ul><li>VPC — leave it to the default or select the one you created.</li><li>Assign the EFS Security Group that we created earlier to it.</li><li>All the other settings can be left as default.</li></ul><h3>2) Creating an ECS Cluster</h3><p>Creating an ECS cluster is straightforward, all you need to do is:</p><ul><li>Navigate to the ECS dashboard on the AWS console and click on “Create cluster”.</li><li>Give it a name and select your VPC &amp; Subnets then create the cluster.</li></ul><h3>3) Creating the Task Definition</h3><p>Now here comes the tricky part, creating the task definition. In the ECS dashboard, click on “Task definitions” in the left pane and create a new Task Definition. In the wizard, we have to create 3 containers; MongoDB (the database), the frontend, and the backend. These are the links to public docker images:</p><p>MongoDB: <a href="https://hub.docker.com/_/mongo">https://hub.docker.com/_/mongo</a></p><p>Frontend: <a href="https://hub.docker.com/r/ajimbong/vidly_front_prod">https://hub.docker.com/r/ajimbong/vidly_front_prod</a></p><p>Backend: <a href="https://hub.docker.com/r/ajimbong/vidly_back_prod">https://hub.docker.com/r/ajimbong/vidly_back_prod</a></p><p>First, let’s start with configuring the Mongo Container with the following options:</p><ul><li>Give it the name “mongo” and Image URI “mongo”</li><li>In port mappings, provide the “27017” port number. This is the default port for MongoDB.</li></ul><p>Secondly, configure the backend container:</p><ul><li>The name should be “backend” and Image URI “ajimbong/vidly_back_prod”</li><li>Set “3001” as the port mapping as this is the port the backend is listening on.</li><li>Create an environment variable with key “DB_URL” and value “mongodb://<a href="http://localhost:27017/vidly">localhost:27017/vidly</a>”.</li><li>Scroll down to Startup dependency ordering and select the “mongo” container as a startup dependency.</li></ul><p>Finally, create and configure the frontend container:</p><ul><li>Give the name “frontend” and Image URI “ajimbong/vidly_front_prod”.</li><li>Set port “80” as the port mapping.</li><li>Lastly, set the “backend” container as a Startup dependency.</li></ul><p>The Containers are all set up and the last step now is to configure the storage.</p><ul><li>Click next to navigate to the next page.</li><li>Under Storage click on “Add Volume” and select “EFS” as the volume type.</li><li>Give the Volume a name and select the filesystem we created earlier under “File system ID”.</li><li>Scroll Down and click on “Add mount point”.</li><li>In the mount point, select the “mongo” container and specify the Container path to “/data/db”. This is where MongoDB stores its data by default.</li><li>These are all the settings we need, so now you can create the task definition.</li></ul><h3>4) Starting a Service From the Task Definition</h3><p>The last and final step is to start a service from our task definition and see if everything works properly.</p><ul><li>Go to clusters and select the cluster we created earlier.</li><li>Under Services, click on Create.</li><li>In “Family”, select the task definition we created in the previous step.</li><li>Give the service a name and set the desired instances to “1”.</li><li>Expand the “Networking” drop-down and select your VPC and subnets.</li><li>Also, select the ECS security group we created earlier.</li><li>Expand the Load balancing dropdown and select “Application Load Balancer”.</li><li>Select use an existing load balancer and choose the one we created earlier.</li><li>Also, select use and existing listener and choose the listener with port “80”.</li><li>Again, select the use and existing target group and choose the one that was created earlier.</li><li>Finally, we create the service and wait for AWS to provision the resources.</li></ul><p>If everything works out well, you should be able to copy the public DNS of the application load balancer and test it in the browser.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f6b8ab65d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup WordPress On an EC2 Instance Running Docker]]></title>
            <link>https://ajimbong.medium.com/setup-wordpress-on-an-ec2-instance-running-docker-30dabc4ee696?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/30dabc4ee696</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 16:51:38 GMT</pubDate>
            <atom:updated>2023-06-26T16:51:38.915Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RgfvqJOB_oLtwLf8HW9spw.png" /><figcaption>blog header image</figcaption></figure><p>In this guide, we will walk through setting up a WordPress website on a Linux EC2 instance attached to an EBS volume to back up our data.</p><h3>Objectives</h3><ul><li>Launch EC2 instance with user data to pre-install docker and docker-compose</li><li>Create an EBS volume and attach it to the instance</li><li>Mount EBS volume to ec2 instance</li><li>Run WordPress website with Docker-compose</li></ul><h3>Procedure</h3><h3>1) Launch EC2 instance with docker</h3><p>In your AWS console, navigate to the ec2 dashboard and launch an instance with the following configurations.</p><ul><li>Give it any name of your choice</li><li>Select Amazon Linux AMI</li><li>Create or Select an existing Key Pair as we will need this to connect to our instance later on</li><li>Select a VPC and subnet taking note of the AZ(Availability Zone) as our EBS volume needs to be in the same AZ with the EC2 instance for them to work.</li><li>Create or Select an existing Security Group making sure it allows HTTP, HTTPS, and SSH traffic from the internet.</li><li>Scroll down to the User Data section and provide the following script which will install docker and docker-compose for us.</li></ul><pre>#!/bin/sh<br>sudo su<br>yum update -y <br><br>yum install docker -y <br>service docker start <br><br>usermod -a -G docker ec2-user <br><br>curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose<br><br>chmod +x /usr/local/bin/docker-compose</pre><ul><li>Wait till you get the 2/2 checks.</li><li>Connect to your instance using SSH and run the command below to make sure docker-compose is installed successfully.</li></ul><pre>docker-compose version</pre><h3>2) Create and Attach EBS Volume</h3><ul><li>In the EC2 dashboard, scroll down to where you see “Storage” and click on “Volumes”.</li><li>You should be brought to the page where you see an orange button that says “Create New Volume”</li><li>Click on the button and in the wizard, make sure to select the same Availability Zone that your EC2 instance is in. If you don’t do so, you won’t be able to attach it to the instance.</li><li>Once the volume is done creating, attach it to the EC2 instance you created earlier.</li></ul><h3>3) Mount EBS Volume</h3><p>Now that we have created our EC2 instance and EBS volume, we are almost halfway done with this project. So let&#39;s continue by mounting the volume in our EC2 instance following the steps below.</p><ul><li>SSH into your EC2 instance and use the command below to run as the root user. We need to run as root users as it will help us go faster.</li></ul><pre>#switch to root user<br>sudo su</pre><ul><li>Use the following command to list all the block devices attached to your instance and copy the name of your newly attached EBS Volume.</li></ul><pre># list all block devices and<br># copy the name of the attached ebs volume<br>lsblk</pre><ul><li>The commands below will let you mount the XFS filesystem to the EBS volume and make sure you replace &quot;volume_name&quot; with the name of your EBS volume</li></ul><pre># mount filesystem to ebs volume<br># insert the name of your volume where is says [volume_name]<br>mkfs -t xfs /dev/[volume_name]<br><br>#view the mounted file system<br>file -s /dev/[volume_name]</pre><ul><li>Create a directory and mount the volume to that directory using the commands below.</li></ul><pre># create directory and mount ebs volume to that directory<br>mkdir -p /mnt/ebs<br>mount /dev/[volume_name] /mnt/ebs</pre><ul><li>Now you can list all the devices that are mounted to your instance using the command below.</li></ul><pre># list all the mounted devices<br>df -h</pre><h3>4) Set Up WordPress with Docker-compose file</h3><ul><li>Create a folder in your home directory and inside that folder, create a file called docker-compose.yml .</li><li>Use your preferred text editor (like Nano or Vim) to edit the docker-compose.yml file then copy and paste the following text into it. This is the file that docker-compose will use to automatically set up and run WordPress and MySQL for us.</li></ul><pre>version: &#39;3&#39;<br>services:  <br>   db:  <br>     image: mysql:5.7  <br>     volumes:  <br>       - /mnt/ebs/db:/var/lib/mysql  <br>     restart: always  <br>     environment:  <br>       MYSQL_ROOT_PASSWORD: PASSWORD1  <br>       MYSQL_DATABASE: wordpress  <br>       MYSQL_USER: wordpress  <br>       MYSQL_PASSWORD: PASSWORD1<br><br>    wordpress:  <br>         depends_on:  <br>           - db  <br>         image: wordpress:latest<br>         volumes:<br>           - /mnt/ebs/wordpress:/var/www/html  <br>         ports:  <br>           - &quot;80:80&quot;  <br>         restart: always  <br>         environment:  <br>           WORDPRESS_DB_HOST: db:3306  <br>           WORDPRESS_DB_USER: wordpress  <br>           WORDPRESS_DB_PASSWORD: PASSWORD1  <br>           WORDPRESS_DB_NAME: wordpress  </pre><ul><li>Once you’re done, save the changes and close the file.</li><li>In your terminal, run the following command to start the services. Make sure you are in the same directory that the docker-compose.yml file is in.</li></ul><pre>docker-compose up -d</pre><ul><li>Once all that is done, copy the IP address of your instance and go to port :80 to test if everything is working.</li><li>If you see the WordPress installation screen, Congratulations👏🎉</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30dabc4ee696" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Dynamic WordPress Application on AWS Three-Tier Architecture]]></title>
            <link>https://ajimbong.medium.com/deploying-a-dynamic-wordpress-application-on-aws-three-tier-architecture-5706b4527918?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/5706b4527918</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[three-tier-architecture]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 14:31:25 GMT</pubDate>
            <atom:updated>2023-06-16T14:31:25.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3Qa4_JnxVFB30J5woJyuQ.png" /></figure><h3>Brief</h3><p>This guide will walk through the steps in deploying a dynamic WordPress application on AWS using a three-tier architecture. The process will involve creating:</p><ul><li>A VPC and configuring it</li><li>A database for the WordPress website</li><li>An Elastic File System to store our WordPress files</li><li>Application Load Balancer and EC2 instances to serve the WordPress application</li><li>Registering a domain name and generating an SSL certificate for secure communication</li></ul><p>I implemented this project by following a YouTube series which you can check out here: <a href="https://www.youtube.com/watch?v=63jObzufz9Q&amp;list=PL184oVW5ERMBkf9lhOylB_OzC8Ez9ty2Q&amp;pp=iAQB">https://www.youtube.com/watch?v=63jObzufz9Q&amp;list=PL184oVW5ERMBkf9lhOylB_OzC8Ez9ty2Q&amp;pp=iAQB</a></p><p>Here is the reference architecture diagram for this project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2yvkThaNSe0DEYl0bhNTfg.png" /></figure><h3>Procedure</h3><h3>1) Setting Up and Configuring the VPC</h3><p>Create a custom VPC in any region and assign it a CIDR block of your choice. Six subnets are to be created in total which will be distributed across two Availability Zones(AZ) for high availability. Each AZ should have:</p><ul><li>A Public subnet layer</li><li>A private subnet for the app tier</li><li>And a private subnet for the database tier</li></ul><p>Once this is done, create an Internet Gateway(IGW) and attach it to the VPC, so that we can access our application over the Internet once it is deployed.</p><p>Two NAT gateways should be created and placed in each public subnet. This will allow our instances in the private subnets to access the internet for package installation and updates without making them public.</p><p>The next step is to create route tables for data to flow effectively within and out of the VPC. The two public subnets can share the same route table which should have a route to the Internet Gateway. One route table will also be shared by the Application and Database Tier in the first availability zone which should have a route to the NAT gateway in that particular AZ. And the same process can be followed for creating the other route table in the second AZ.</p><p>Finally, we have to create a Security Group(SG) for the Application Load Balancer(ALB), Web Servers, Database, and Elastic File System(EFS) following these guidelines:</p><ul><li>The ALB SG has two inbound rules for HTTP and HTTPS, and accepts traffic from anywhere.</li><li>The Web Server SG has two inbound rules for HTTP and HTTPS but will only accept traffic from the ALB SG.</li><li>The database SG has an inbound rule for MySQL/Aurora and only accepts traffic from the Web Server SG</li><li>The EFS SG has inbound traffic for NFS and only accepts traffic from the Web Server SG.</li></ul><h3>2) Provisioning the RDS MySQL database</h3><p>To create the database, we first need to create the subnet group in the RDS console. When creating the subnet group, select the VPC that was created earlier and the subnets.</p><p>Now create the database by selecting the following options</p><ul><li>Engine Type: MySQL</li><li>Templates: Free Tier</li><li>Instance Identifier: wordpressdb</li><li>Username: admin</li><li>Password: {provide your password}</li><li>Subnet Group: {select the subnet group that was created earlier}</li><li>Security Group: {select the EFS SG that was created earlier}</li><li>Initial database name: WordPress</li></ul><p>We can leave the rest as default and proceed to create the database.</p><h3>3) Creating an Elastic File System</h3><p>On the AWS console, search EFS and proceed to create an Elastic File System. In the wizard, select the VPC we created earlier and in the mount targets, select the two private subnets in the database tier. Every other thing can be left as default.</p><h3>4) Configure WordPress installation</h3><p>In this step, we have to create a public EC2 instance which we will use to configure the WordPress installation on the EFS and RDS instances. When creating this instance, make sure it is in the public subnet and should have all the security groups(ALB, Web Server, EFS, RDS) and also a custom SG that will permit us to SSH into the instance and configure it.</p><p>This is the script that will be used for this setup</p><pre>#Switch to root user<br>sudo su<br><br>#update System packages<br>yum update -y<br><br>#Install Apache Web Server<br>yum install -y httpd<br><br>#Install PHP interpreter<br>yum install php php8.1-mysqlnd.x86_64 -y<br><br>#Create and mount EFS to /var/www/html directory<br>#This mount command will be different for you<br>#You have to yours from the EFS dashboard making sure<br>#The last part of the command ends with /var/www/html<br>mkdir -p /var/www/html<br>sudo mount -t nfs4 -o {your efs mount command} /var/www/html<br><br>#Get WordPress files<br>cd /var/www/html<br>wget https://wordpress.org/latest.zip<br>unzip latest.zip<br>rm -rf latest.zip<br>cp -r wordpress/* /var/www/html<br>rm -rf wordpress/<br><br>#configure wordpress installation<br>cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php<br>#edit this file and provide details for your RDS database<br>nano /var/www/html/wp-config.php<br><br>#start Apacher server<br>systemctl enable httpd<br>systemctl start httpd</pre><h3>5) Create Web Servers</h3><p>The next step is to create two web servers in the application tier private subnets and provide them with the Web Server Security Group. We will also use the user data below to bootstrap our instances.</p><pre>#!/bin/bash<br><br>sudo su<br>yum update -y<br>yum install -y httpd<br>yum install php php8.1-mysqlnd.x86_64 -y<br>sudo mount -t nfs4 -o {your efs mount command} /var/www/html<br>systemctl enable httpd<br>systemctl start httpd</pre><p>Make sure you modify the command used to mount the file system.</p><h3>6) Create an Application Load Balancer</h3><p>To create the Application load balancer, we need to, first of all, create a target group that will contain both of our Web Servers. Then we should be able to create the load balancer in the public subnets and select the target group.</p><p>To test if everything is working well, we can copy the DNS name of the ALB and load it in a new browser tab. If we don’t see any errors, that means everything went successfully.</p><h3>7) Register Domain Name and Generate SSL certificate</h3><p>Use Router53 to buy a custom domain name for your WordPress application. In your hosted zone, add an alias record that points to your Applications Load Balancer.</p><p>Navigate to AWS Certificate Manager and generate an SSL Certificate for your particular domain name.</p><p>To make sure your ALB</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5706b4527918" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting A Highly Available, Fault Tolerant Website On AWS]]></title>
            <link>https://ajimbong.medium.com/hosting-a-highly-available-fault-tolerant-website-on-aws-916b747b2bc6?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/916b747b2bc6</guid>
            <category><![CDATA[static-website-hosting]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Mon, 29 May 2023 12:38:47 GMT</pubDate>
            <atom:updated>2023-05-29T12:38:47.947Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_t78cut8Z3pWzp15SWSDg.png" /></figure><p>Hello friends! In this short article, I will be walking you through the process of how I deployed a static website on AWS using auto-scaling groups and elastic load balancing to ensure high availability and fault tolerance. This project was accomplished by following a tutorial series on the AOS Notes YouTube channel. You can access that here: 👉 <a href="https://lnkd.in/eu6V_mG6">https://lnkd.in/eu6V_mG6</a></p><p>This article is only an overview of the steps involved in realizing this project, I wouldn’t be going into details as that can be accessed from the video series.</p><h3>Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHmq118Qyc3v8op1pUWViA.png" /></figure><p>Above is the architecture diagram I designed for this project. It shows all the AWS resources we will use and how they are connected together.</p><h3>Steps</h3><ol><li>Create a VPC with 2 public and 2 private subnets distributed over 2 availability zones for high availability.</li><li>Attach an Internet Gateway(IGW) to the public subnets for the instances to be accessed over the Internet. Don’t forget to add a route to the IGW in the public subnet’s route table.</li><li>Create NAT gateways for the instances in the private subnet to access the internet for software updates</li><li>Create an Auto Scaling Group (ASG) that will launch instances in the private subnet and add scaling policies to dynamically add or remove instances based on CPU utilization.</li><li>The instances are pre-configured with user data to get the static web pages from an s3 bucket and are placed in a directory that will be served by the web server</li><li>Create a load balancer that is attached to the ASG that will help to distribute the traffic across instances behind the ASG.</li></ol><p>Once all that is done, your project should be live and working 🥳 Told you it was going to be a short one right? Please do well to check out the YouTube Playlist as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=916b747b2bc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing A Modern CI/CD Pipeline with GitHub Actions & AWS]]></title>
            <link>https://ajimbong.medium.com/implementing-a-modern-ci-cd-pipeline-with-github-actions-aws-4a0bb320bdb1?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a0bb320bdb1</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Sat, 27 May 2023 19:52:48 GMT</pubDate>
            <atom:updated>2023-05-27T19:52:48.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLMCeUcXGvvCRKI8JwLSvA.png" /></figure><p>In this article, we will walk through the steps of setting up a CI/CD pipeline that builds a docker image and deploys it to Amazon ECR(Elastic Container Registry) anytime changes are made to the main branch of our GitHub repository.<br>This project was inspired by a hands-on project from <a href="https://www.meetup.com/aws-user-group-yaounde/">AWS User Group Yaounde</a>, so we will work with the resources they provided.</p><p>Also, this is just an overview of the different steps involved in creating the pipeline not necessarily an in-depth walkthrough.</p><h3>Requirements</h3><p>These are some things you need to have in order to complete this project;<br>- <a href="https://aws.amazon.com/console/">AWS</a> account.<br>- <a href="https://github.com/">GitHub</a> account<br>- <a href="https://git-scm.com/">Git </a>installed on your computer<br>- Any code editor of your choice. Personally, I use <a href="https://code.visualstudio.com/">Visual Studio Code</a></p><p>This project uses Python and Docker, but you don’t need those installed on your computer as the aim is to create a working pipeline not necessarily build and run the code locally. With that out of the way, let us start building!!🛠</p><h3>Steps</h3><h4>1) Getting the Project’s Source Code</h4><p>First of all, visit this link <a href="https://github.com/jordybayo/github-cicd">https://github.com/jordybayo/github-cicd</a> to fork the project and create a copy in your GitHub account. Once that is done, you can now clone the project locally to your computer.</p><h4>2) Create an AWS IAM user.</h4><p>We need to create an IAM user for this project because that will grant GitHub actions programmatic access to perform actions in our AWS account. And that cannot be done by using the root user only.</p><p>You can still use any IAM user you already have, but make sure you add a policy that gives them access to the AWS ECR service.</p><h4>3) Generate Access Keys</h4><p>As mentioned in the previous step, access keys will enable GitHub actions to perform actions(no pun intended) in our AWS account. These are the steps to follow in order to generate your access keys:<br>- In your IAM dashboard, click on `Users`<br>- You will be taken to a page that lists all the users in your account, you want to click on the IAM user you are creating access keys for.<br>- Now click on `Security Credentials` and scroll down to where you see `Access Keys`.<br>- Click on `Create Access key` and you will be asked to select the type of Access key you want; select `Third-party service`.<br>- Once that is done, you can create the key and download it for later use.</p><h4>4) Add Access Keys to GitHub</h4><p>Now that we have our access keys, we have to provide them to our GitHub project for it to use when running the actions. To do so:<br>- Go to the project you forked and navigate to `Settings`.<br>- Under settings, scroll down and expand `Secrets and Variables` then click on `actions`.<br>- Click on `New repository secret` and give it the name “AWS_ACCESS_KEY_ID” and under secret, provide the value to your access key ID you created earlier.<br>- Follow the same procedure to create a secret for your secret access key, by giving the name “AWS_SECRET_ACCESS_KEY”.</p><h4>5) Enable GitHub Actions</h4><p>For this project, you may have to enable GitHub actions if you haven’t already. This can easily be done by:<br>- Navigating to the forked project in your GitHub account.<br>- Click on `Actions` and then click on `Enable GitHub Actions For This Project`.<br>We are doing this for GitHub actions to run automatically anytime we push changes to our main branch.</p><h4>6) Create ECR Repository and Update GitHub Action File</h4><p>We need to create an ECR repository where Github actions will deploy our docker image to. Make sure you are creating this repository in the “us-east-1” or “N. Virginia” region.</p><p>Once that is done, we have to update our GitHub actions file with the name of our ECR repository. This file can be found in the project we cloned, in the directory `.github/workflows/main.yml`. Inside the `main.yml` file, look for the key that says “ECR_REPOSITORY” and update its value with the name of your ECR repository.</p><h4>7) Push and Deploy</h4><p>Now if everything was configured well, we should be able to push the current changes to our GitHub repository, and GitHub actions will run and deploy our image successfully.</p><p>You can go to the actions tab in GitHub to make sure everything ran successfully, and also check your Amazon ECR Repository to make sure that you see the docker image.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a0bb320bdb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Joi for data Validation in NodeJS]]></title>
            <link>https://ajimbong.medium.com/how-to-use-joi-for-data-validation-in-nodejs-c055b7bdbb11?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/c055b7bdbb11</guid>
            <category><![CDATA[joi]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[validation]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Sat, 18 Feb 2023 22:56:00 GMT</pubDate>
            <atom:updated>2023-02-18T22:56:00.962Z</atom:updated>
            <content:encoded><![CDATA[<p>When developing backend applications or APIs, there is always a need to do some data validation in order to be sure that our users are sending us the correct data. Writing all this validation logic manually can be time-consuming and tedious, and there are already NPM packages to help us with this. Today we will be looking at a package called Joi which is used for data validation.</p><h3>Setup</h3><p>First of all, we will install Joi in our project directory using this command:</p><pre>npm i joi</pre><p>Then let’s go ahead and import it into our JavaScript file.</p><pre>cosnt Joi = require(&#39;joi&#39;);</pre><h3>Usage</h3><p>Here, we have to create a Joi schema which is an object that contains all the property names of our data and also the data type/constraints as the value of those properties. Let’s check out the example below:</p><pre>cosnt Joi = require(&#39;joi&#39;);<br><br>const schema = Joi.object({<br>  username: Joi.string().required().min(5).max(30),<br>  age: Joi.number().min(10).max(50).required(),<br>  email: Joi.string().email().required(),<br>  password: Joi.string().pattern(/^[a-zA-Z0-9]{3,30}$/).required(),<br>  repeat_password: Joi.ref(&quot;password&quot;),<br>  isAdmin: Joi.boolean().default(false)<br>})</pre><p>In the code above, we create a variable called schema which is of a Joi object type, then we have the various properties such as [username, age, email...] and their corresponding values that specify the data types and constraints. Some data types that exist in Joi are [string, number, object, boolean etc. We also have constraints for setting the default value default(), making a field required required(), checking if an email is a valid email email(), using regular expressions to check the password strength password() etc.</p><pre>cosnt Joi = require(&#39;joi&#39;);<br><br>const schema = Joi.object({<br>  username: Joi.string().required().min(5).max(30),<br>  age: Joi.number().min(10).max(50).required(),<br>  email: Joi.string().email().required(),<br>  password: Joi.string().pattern(/^[a-zA-Z0-9]{3,30}$/).required(),<br>  repeat_password: Joi.ref(&quot;password&quot;),<br>  isAdmin: Joi.boolean().default(false)<br>})<br>const {error, value} = schema.validate({<br>  username: &#39;Ajims&#39;,<br>  age: &#39;20&#39;,<br>  email: &#39;a@b.co&#39;,<br>  password: &#39;h4Rct5A&#39;,<br>  repeat_password: &#39;4Rct5A&#39;<br>})<br>if(error) console.error(error.details[0].message)<br>console.log(value)</pre><p>Here, we are validating our data against the schema which returns an error if the data doesn’t match our schema specification and a value(a value is always returned even if there is an error). If there is a problem, the error message is logged to the console else the value (which is basically the data we passed in) will be logged.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c055b7bdbb11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple guide to configuring Express applications]]></title>
            <link>https://ajimbong.medium.com/a-simple-guide-to-configuring-express-applications-4ccb50a088d9?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ccb50a088d9</guid>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[express]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Sat, 11 Feb 2023 11:19:35 GMT</pubDate>
            <atom:updated>2023-02-11T11:19:35.171Z</atom:updated>
            <content:encoded><![CDATA[<h3>A simple guide for configuring Express applications</h3><p>In your Express applications, there is usually a need to set different configuration values for connecting to a database, getting the port number for your server to run on and even just saving API secrets. It is possible to do all this with a .env file but when your application grows this becomes cumbersome and difficult to manage. That is why I will be introducing you to a node package called &#39;config&#39; which makes it easy to manage your configuration variables and access them easily from your application.</p><h3>Setup</h3><p>First of all, make sure you have Node running on your computer and in your project directory install the config package using this command:</p><pre>npm i config</pre><p>Then create a folder called config in that same directory. This is where all your config files will be saved.</p><pre>mkdir config<br><br>touch default.json</pre><p>All the common configurations will be stored in default.json and you can create specific configuration files for different environments e.g production.json, development.json . Also, there is a special file type called custom-environment-variable.json which can load environment variables, we will have a look at this later in this guide.</p><h3>Usage</h3><p>Let’s consider that we have a simple application where we are to provide database configuration details both for our production and development environments. Then on the server, the port is to be provided from an environment variable . In our config directory, we have 4 files (default.json, production.json, development.json, custom-environment-variables.json) with the following content:</p><p><em>default.json</em></p><pre>{<br>	&quot;dbConfig&quot;: {<br>		&quot;host&quot;: &quot;localhost&quot;,<br>		&quot;port&quot;: &quot;3607&quot;,<br>		&quot;dbName&quot;: &quot;&quot;<br>	},<br>	&quot;app&quot;:{<br>		&quot;port&quot; : &quot;&quot;<br>	}<br>}</pre><p><em>development.json</em></p><pre>{<br>	&quot;dbConfig&quot;: {<br>		&quot;host&quot;: &quot;&quot;,<br>		&quot;port&quot;: &quot;&quot;,<br>		&quot;dbName&quot;: &quot;customers&quot;<br>	},<br>	&quot;app&quot;:{<br>		&quot;port&quot; : &quot;&quot;<br>	}<br>}</pre><p><em>custom-environment-variables.json</em></p><pre>{<br>	&quot;dbConfig&quot;: {<br>		&quot;host&quot;: &quot;&quot;,<br>		&quot;port&quot;: &quot;&quot;,<br>		&quot;dbName&quot;: &quot;&quot;<br>	},<br>	&quot;app&quot;:{<br>		&quot;port&quot; : &quot;PORT&quot;<br>	}<br>}</pre><blockquote><em>Note that “PORT” will be read from the environment variables.</em></blockquote><p>Now that we have set all our configuration data, let’s now use it in our application. In index.js:</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const mongoose = require(&#39;mongoose&#39;);<br><br>//This cofig variable is what we will use to access our config data<br>const config = require(&#39;config&#39;);<br><br>const dbHost = config.get(&#39;dbConfig.host&#39;);<br>const dbPort = config.get(&#39;dbConfig.port&#39;);<br>const dbName = confit.get(&#39;dbConfig.dbName&#39;);<br><br>mongoose.connect(`mongodb://${dbHost}:${dbPort}/${dbName}`);<br>app.get(&#39;/&#39;, (req, res)=&gt;{<br> res.send(&quot;Hello World&quot;);<br>})<br><br>if(config.has(&#39;app.port&#39;)){<br> const port = config.get(&#39;app.port&#39;);<br> app.listen(port);<br>} else{<br> console.log(&#39;Cannot start server without a port number&#39;);<br>}</pre><p>From the code example above, config.get(&#39;variable.name&#39;) is used to get a specific value from the configuration file and it uses the dot notation to access nested properties, meanwhile config.has(&#39;app.port&#39;) is used to check if a property is set and will return true if is set and false otherwise. Note that this is a very basic explanation of this package as this article was just meant to provide the essentials, there is more to it than I have covered here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ccb50a088d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The three work environments in git]]></title>
            <link>https://ajimbong.medium.com/the-three-work-environments-in-git-dc22cbfdedf6?source=rss-4fea62d4ee39------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc22cbfdedf6</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[repositories]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[AJIM]]></dc:creator>
            <pubDate>Sun, 05 Feb 2023 10:53:47 GMT</pubDate>
            <atom:updated>2023-02-05T10:53:47.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="git working directory, staging area and repository" src="https://cdn-images-1.medium.com/max/296/1*PGjc4jO8pFz-dh7lyD3Ocg.png" /></figure><p>When working with a git repository, your project constantly cycles between these three environments:</p><ul><li>Working directory</li><li>Staging Area</li><li>Repository</li></ul><h3>Working Directory</h3><p>In the working directory, the changes you make to files and folders aren’t recorded by your version control software (git). For git to track the changes you make, you need to use the command git add [filename(s)] which will move your changes to the staging area.</p><h3>Staging Area</h3><p>The staging area also referred to as the ‘index’ is a collection of files and folders that git is tracking and includes changes that will eventually be committed.</p><h3>Repository</h3><p>The repository stores all the commits you have ever made in your project and you can quickly revert back to any commit you made in the past. From the staging area, use the command git commit -m &#39;your commit message&#39; to create a new commit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc22cbfdedf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>