<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: etiifiok udofiah</title>
    <description>The latest articles on DEV Community by etiifiok udofiah (@etiifiok_udofiah_eb450b4b).</description>
    <link>https://dev.to/etiifiok_udofiah_eb450b4b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2136822%2Faf42231a-3b02-4531-aec3-c95a1df60aff.png</url>
      <title>DEV Community: etiifiok udofiah</title>
      <link>https://dev.to/etiifiok_udofiah_eb450b4b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/etiifiok_udofiah_eb450b4b"/>
    <language>en</language>
    <item>
      <title>Deploying an NGINX Web Server on AWS EC2: HNG DevOps Stage 0</title>
      <dc:creator>etiifiok udofiah</dc:creator>
      <pubDate>Wed, 29 Jan 2025 18:23:06 +0000</pubDate>
      <link>https://dev.to/etiifiok_udofiah_eb450b4b/deploying-an-nginx-web-server-on-aws-ec2-hng-devops-stage-0-5hh</link>
      <guid>https://dev.to/etiifiok_udofiah_eb450b4b/deploying-an-nginx-web-server-on-aws-ec2-hng-devops-stage-0-5hh</guid>
      <description>&lt;p&gt;To progress from level 0 to level 1 in the HNG Internship for devops, we were require to set up and configure an NGINX web server on a fresh Ubuntu instance. This task is to test my ability to configure basic web server and ensuring it was publicly accessible. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP TO TAKE&lt;/strong&gt;&lt;br&gt;
Log into AWS Management Console&lt;br&gt;
Go to AWS Management Console.&lt;br&gt;
Log in using your credentials.&lt;br&gt;
Launch an EC2 Instance in the Default VPC&lt;br&gt;
Navigate to EC2 Dashboard:&lt;/p&gt;

&lt;p&gt;In the AWS Management Console, go to Services and select EC2 under Compute.&lt;br&gt;
Select “Launch Instance”:&lt;/p&gt;

&lt;p&gt;Click on Launch Instance to start the EC2 instance creation process.&lt;br&gt;
Choose an Amazon Machine Image (AMI):&lt;/p&gt;

&lt;p&gt;Select an AMI (Amazon Machine Image). For example, you can choose:&lt;br&gt;
Ubuntu Server 24.04 (HVM), SSD Volume Type for a Linux-based instance.&lt;br&gt;
Click Select for your desired AMI.&lt;br&gt;
Choose an Instance Type:&lt;/p&gt;

&lt;p&gt;Select an instance type that fits your needs. For testing purposes, you can start with the t2.micro instance type (eligible for the Free Tier).&lt;br&gt;
Click Next: Configure Instance Details.&lt;br&gt;
&lt;strong&gt;Configure Instance Details&lt;/strong&gt;&lt;br&gt;
Network: Select default for the VPC (this is the default VPC created for you when your AWS account was set up).&lt;br&gt;
Subnet: Select an available subnet (this can be any default subnet in the VPC).&lt;br&gt;
Auto-assign Public IP: Ensure this is set to Enable to get a public IP address for your instance.&lt;br&gt;
Leave other settings as is, unless you need specific configurations.&lt;br&gt;
Click Next: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configure Security Group.&lt;/strong&gt;&lt;br&gt;
Create a new security group:&lt;br&gt;
Security Group Name: Example MyEC2SecurityGroup.&lt;br&gt;
Type: Select SSH for Linux instances or RDP for Windows instances.&lt;br&gt;
Source: Select Anywhere (0.0.0.0/0) for public access (or restrict to specific IPs for security).&lt;br&gt;
For SSH, port 22 should be open for Linux instances.&lt;br&gt;
For RDP, port 3389 should be open for Windows instances.&lt;br&gt;
Click Review and Launch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Review and Launch&lt;/strong&gt;&lt;br&gt;
Review all the details.&lt;br&gt;
Click Launch.&lt;br&gt;
When prompted to select a key pair, either create a new key pair or choose an existing one:&lt;br&gt;
If creating a new key pair, download the .pem file and keep it safe. This file is required to SSH into your EC2 instance.&lt;br&gt;
If using an existing key pair, select it and acknowledge the key pair checkbox.&lt;br&gt;
Click Launch Instances.&lt;br&gt;
Access Your EC2 Instance&lt;br&gt;
Wait for the instance to launch: It will take a few minutes to launch the instance.&lt;/p&gt;

&lt;p&gt;View Instance:&lt;/p&gt;

&lt;p&gt;Once you have successfully SSH into the instance using the instructions provided by AWS open git bash on your local pc &lt;/p&gt;

&lt;p&gt;install nginx&lt;br&gt;
&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y&lt;br&gt;
 sudo apt install nginx -y&lt;/code&gt;&lt;br&gt;
check for nginx status if it is active&lt;br&gt;
&lt;code&gt;sudo systemctl status nginx&lt;/code&gt;&lt;br&gt;
if it is not active type&lt;br&gt;
&lt;code&gt;sudo systemctl start nginx&lt;/code&gt;&lt;br&gt;
then confirm if it is still active&lt;/p&gt;

&lt;p&gt;create a html folder by typing &lt;code&gt;sudo mkdir -p /var/www/html&lt;/code&gt;&lt;br&gt;
grant permission by typing &lt;code&gt;sudo chown -R $root:$root /var/www/html&lt;/code&gt;&lt;br&gt;
add your html content&lt;br&gt;
&lt;code&gt;sudo nano /var/www/html/index.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   &amp;lt;!DOCTYPE html&amp;gt;
   &amp;lt;html lang="en"&amp;gt;
   &amp;lt;head&amp;gt;
       &amp;lt;meta charset="UTF-8"&amp;gt;
       &amp;lt;title&amp;gt;DevOps Stage 0&amp;lt;/title&amp;gt;
   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
       &amp;lt;h1&amp;gt;Welcome to DevOps Stage 0 - [Your Name]/[SlackName]&amp;lt;/h1&amp;gt;
   &amp;lt;/body&amp;gt;
   &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;save and exit using ctrl + X&lt;br&gt;
click y - yes&lt;br&gt;
then click enter to exit&lt;/p&gt;

&lt;p&gt;verify the index.html file exit by typing &lt;br&gt;
&lt;code&gt;ls -l /var/www/html/index.html&lt;/code&gt;&lt;br&gt;
or&lt;br&gt;
&lt;code&gt;cat /var/www/html/index.html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;restart nginx to apply changes&lt;br&gt;
&lt;code&gt;sudo systemctl restart nginx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;test your setup with&lt;br&gt;
&lt;code&gt;http://&amp;lt;your-ec2-public-ip&amp;gt;/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges faced and solution&lt;/strong&gt;&lt;br&gt;
My server wasn't serving my index.html  file, but i could see the file. It was displaying this content shown in the diagram below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdym8s73tbvj2ahjhbdxc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdym8s73tbvj2ahjhbdxc.jpeg" alt="Image description" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had to check if my server was serving my index.html file by typing &lt;code&gt;curl http://localhost&lt;/code&gt;&lt;br&gt;
then i check the configuration file &lt;br&gt;
&lt;code&gt;sudo nano /etc/nginx/nginx.conf&lt;/code&gt;&lt;br&gt;
I looked out for the path to the root configuration and i made the necessary changes to /var/www/html&lt;br&gt;
Saved and exited.&lt;br&gt;
Proceeded to test the nginx configuration with &lt;br&gt;
&lt;code&gt;sudo nginx -t&lt;/code&gt;&lt;br&gt;
and i noticed it was corrected and displayed the /var/www/html path&lt;br&gt;
I checked for file permission with &lt;code&gt;ls -l /var/www/html/index.html&lt;/code&gt;&lt;br&gt;
Adjusted the file permission using &lt;code&gt;sudo chown nginx /var/www/html/index.html&lt;/code&gt;&lt;br&gt;
Then restart nginx &lt;code&gt;sudo systemctl restart nginx&lt;/code&gt;&lt;br&gt;
refreshed my web page from my browser and it worked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This task taught me several important lessons:&lt;/p&gt;

&lt;p&gt;✅ How to launch an EC2 instance and configure it for web hosting.&lt;/p&gt;

&lt;p&gt;✅ Setting up a basic web server using NGINX.&lt;/p&gt;

&lt;p&gt;✅ Managing AWS security settings to allow public access.&lt;/p&gt;

&lt;p&gt;✅ Troubleshooting connectivity issues related to nginx configurations&lt;br&gt;
Deploying NGINX on AWS EC2 was a valuable hands-on experience it helped me in troubleshoot issues ihad with my server displaying my web content as this will be a common issues i will experience in becoming a DevOps Engineer &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hng.tech/hire/devops-engineers" rel="noopener noreferrer"&gt;Devops Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/cloud-engineers" rel="noopener noreferrer"&gt;Cloud Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/site-reliability-engineers" rel="noopener noreferrer"&gt;Site Reliability Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/platform-engineers" rel="noopener noreferrer"&gt;Platform Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/infrastructure-engineers" rel="noopener noreferrer"&gt;Infrastructure Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/kubernetes-specialists" rel="noopener noreferrer"&gt;Kubernetes Specialists&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/aws-solutions-architects" rel="noopener noreferrer"&gt;AWS Solutions Architects&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/azure-devops-engineers" rel="noopener noreferrer"&gt;Azure DevOps Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/google-cloud-engineers" rel="noopener noreferrer"&gt;Google Cloud Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/ci-cd-pipeline-engineers" rel="noopener noreferrer"&gt;CI/CD Pipeline Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/monitoring-observability-engineers" rel="noopener noreferrer"&gt;Monitoring/Observability Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/automation-engineers" rel="noopener noreferrer"&gt;Automation Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/docker-specialists" rel="noopener noreferrer"&gt;Docker Specialists&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/linux-developers" rel="noopener noreferrer"&gt;Linux Developers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/postgresql-developers" rel="noopener noreferrer"&gt;PostgreSQL Developers&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploying Your First Server with Terraform</title>
      <dc:creator>etiifiok udofiah</dc:creator>
      <pubDate>Tue, 03 Dec 2024 20:47:18 +0000</pubDate>
      <link>https://dev.to/etiifiok_udofiah_eb450b4b/deploying-your-first-server-with-terraform-4i5m</link>
      <guid>https://dev.to/etiifiok_udofiah_eb450b4b/deploying-your-first-server-with-terraform-4i5m</guid>
      <description>&lt;p&gt;To create a simple basic EC2 Instance using terraform. Below are the step needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Directory Structure&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Create a new project directory and files:&lt;/p&gt;

&lt;p&gt;web-server-terraform/: this is a folder&lt;br&gt;
├ main.tf&lt;br&gt;
├ variables.tf&lt;br&gt;
├ outputs.tf&lt;/p&gt;

&lt;p&gt;main.tf&lt;br&gt;
This file contains the main infrastructure definition. Copy ad paste this code into the main.tf file&lt;/p&gt;

&lt;h1&gt;
  
  
  Provider Configuration
&lt;/h1&gt;

&lt;p&gt;provider "aws" {&lt;br&gt;
  region = "us-east-1" # Replace with your preferred region&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  VPC
&lt;/h1&gt;

&lt;p&gt;resource "aws_vpc" "main" {&lt;br&gt;
  cidr_block           = "10.0.0.0/16"&lt;br&gt;
  enable_dns_support   = true&lt;br&gt;
  enable_dns_hostnames = true&lt;br&gt;
  tags = {&lt;br&gt;
    Name = "web-server-vpc"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Subnet
&lt;/h1&gt;

&lt;p&gt;resource "aws_subnet" "public_subnet" {&lt;br&gt;
  vpc_id                  = aws_vpc.main.id&lt;br&gt;
  cidr_block              = "10.0.1.0/24"&lt;br&gt;
  map_public_ip_on_launch = true&lt;br&gt;
  availability_zone       = "us-east-1a" # Replace as needed&lt;br&gt;
  tags = {&lt;br&gt;
    Name = "web-server-subnet"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Internet Gateway
&lt;/h1&gt;

&lt;p&gt;resource "aws_internet_gateway" "igw" {&lt;br&gt;
  vpc_id = aws_vpc.main.id&lt;br&gt;
  tags = {&lt;br&gt;
    Name = "web-server-igw"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Route Table
&lt;/h1&gt;

&lt;p&gt;resource "aws_route_table" "public_route_table" {&lt;br&gt;
  vpc_id = aws_vpc.main.id&lt;br&gt;
  tags = {&lt;br&gt;
    Name = "public-route-table"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Associate Route Table with Subnet
&lt;/h1&gt;

&lt;p&gt;resource "aws_route_table_association" "public_association" {&lt;br&gt;
  subnet_id      = aws_subnet.public_subnet.id&lt;br&gt;
  route_table_id = aws_route_table.public_route_table.id&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Route for Internet Access
&lt;/h1&gt;

&lt;p&gt;resource "aws_route" "public_route" {&lt;br&gt;
  route_table_id         = aws_route_table.public_route_table.id&lt;br&gt;
  destination_cidr_block = "0.0.0.0/0"&lt;br&gt;
  gateway_id             = aws_internet_gateway.igw.id&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Security Group
&lt;/h1&gt;

&lt;p&gt;resource "aws_security_group" "web_sg" {&lt;br&gt;
  vpc_id = aws_vpc.main.id&lt;br&gt;
  ingress {&lt;br&gt;
    from_port   = 80&lt;br&gt;
    to_port     = 80&lt;br&gt;
    protocol    = "tcp"&lt;br&gt;
    cidr_blocks = ["0.0.0.0/0"]&lt;br&gt;
  }&lt;br&gt;
  ingress {&lt;br&gt;
    from_port   = 22&lt;br&gt;
    to_port     = 22&lt;br&gt;
    protocol    = "tcp"&lt;br&gt;
    cidr_blocks = ["0.0.0.0/0"]&lt;br&gt;
  }&lt;br&gt;
  egress {&lt;br&gt;
    from_port   = 0&lt;br&gt;
    to_port     = 0&lt;br&gt;
    protocol    = "-1"&lt;br&gt;
    cidr_blocks = ["0.0.0.0/0"]&lt;br&gt;
  }&lt;br&gt;
  tags = {&lt;br&gt;
    Name = "web-server-sg"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  EC2 Instance
&lt;/h1&gt;

&lt;p&gt;resource "aws_instance" "web_server" {&lt;br&gt;
  ami           = "ami-08c40ec9ead489470" # Replace with a valid AMI ID for your region&lt;br&gt;
  instance_type = "t2.micro"&lt;/p&gt;

&lt;p&gt;subnet_id              = aws_subnet.public_subnet.id&lt;br&gt;
  security_groups        = [aws_security_group.web_sg.name]&lt;br&gt;
  associate_public_ip_address = true&lt;/p&gt;

&lt;p&gt;user_data = &amp;lt;&amp;lt;-EOF&lt;br&gt;
              #!/bin/bash&lt;br&gt;
              yum update -y&lt;br&gt;
              yum install -y httpd&lt;br&gt;
              systemctl start httpd&lt;br&gt;
              systemctl enable httpd&lt;br&gt;
              echo "Hello, World!" &amp;gt; /var/www/html/index.html&lt;br&gt;
              EOF&lt;/p&gt;

&lt;p&gt;tags = {&lt;br&gt;
    Name = "web-server"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;variables.tf&lt;br&gt;
Define variables for your configuration (optional for better reusability).&lt;/p&gt;

&lt;p&gt;variable "region" {&lt;br&gt;
  description = "AWS region to deploy resources"&lt;br&gt;
  default     = "us-east-1"&lt;br&gt;
}&lt;br&gt;
outputs.tf&lt;br&gt;
Outputs to display useful information after deployment.&lt;/p&gt;

&lt;p&gt;output "web_server_public_ip" {&lt;br&gt;
  description = "Public IP of the web server"&lt;br&gt;
  value       = aws_instance.web_server.public_ip&lt;br&gt;
}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deploy Using Terraform
Initialize Terraform
Run this command in the project directory to initialize Terraform and download the AWS provider:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;bash&lt;br&gt;
Copy code&lt;br&gt;
terraform init&lt;br&gt;
Validate Configuration&lt;br&gt;
Check for syntax or configuration errors:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
Copy code&lt;br&gt;
terraform validate&lt;br&gt;
Preview Changes&lt;br&gt;
View the resources Terraform will create:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
Copy code&lt;br&gt;
terraform plan&lt;br&gt;
Apply the Configuration&lt;br&gt;
Deploy the infrastructure:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
Copy code&lt;br&gt;
terraform apply&lt;br&gt;
Type yes when prompted.&lt;/p&gt;

&lt;p&gt;**4. Access the Web Server&lt;br&gt;
**After Terraform completes, it will output the public IP of the EC2 instance. Open a browser and visit: http://&lt;br&gt;
You should see the "Hello, World!" page.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cleanup
To destroy the resources created by Terraform type:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;terraform destroy&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
