Posts

Showing posts from July, 2025

🚀 Creating an EC2 Instance from Scratch with Terraform

Image
 By Raees Qazi | DevOps Engineer | Learner | Mentor | Creator Today, we’re going to create an EC2 instance from scratch using Terraform . We’ll go step-by-step and learn how to: ✅ Generate an SSH key  ✅ Create a key pair, VPC, and security group  ✅ Launch an EC2 instance  ✅ Use interpolation to extract values  ✅ Control instance state (stop/start) with Terraform Let’s get started — in the simplest and most practical way possible. ✅ Prerequisites Before jumping into code, make sure: You have already created the Terraform provider file Terraform is initialized ( terraform init ) AWS CLI is configured with an IAM user All set? Great! Let’s begin. 🔑 Step 1: Generate SSH Key Pair ssh-keygen # Name it: terra- key - auto This will generate two files: terra-key-auto (private key) terra-key-auto.pub (public key) We’ll use these to access our EC2 machine. ✍️ Step 2: Write ec2.tf  File Let’s write all our resources step by step in one file: # ec2.tf # 1. Creat...

Understanding Interpolation in Terraform with EC2 Example

Image
 By Raees Qazi | DevOps Engineer | Learner | Mentor | Creator Today, let’s understand what interpolation is and how we can create an EC2 instance using Terraform while extracting values using interpolation. This guide is going to be simple and practical — no jargon, just real working code. 💡 Prerequisites Before we begin, I’m assuming: You have already created the provider.tf file. Terraform is initialized ( terraform init already run). AWS CLI is configured with an IAM user. If all of the above is done, let’s move to the next step. 🛠 Create EC2 Instance with Terraform Now, we’ll create a file named ec2.tf and write our resource configuration. # ec2.tf resource "aws_instance" "my_instance" { count = 2 # How many machines you want to create ami = "ami-xxxxxxxxxxxxxxxxx" # Replace with a valid AMI ID for your region instance_type = "t2.micro" # Type of instance key_name ...

GitLab Project-Setting Up CI/CD for Node.js To-Do App on a Self-Hosted GitLab Runner

Image
  Step 1: Clone the Project to GitLab Go to GitLab and click on  Import Project . Copy the GitHub repository URL for  node-todo-cicd  (search for  shubham londhe  on GitHub). Paste the URL into GitLab and start the import process. Once imported, you’ll see the project on your GitLab homepage. Step 2: Configure GitLab Runner Go to  Groups  >  Settings  >  CI/CD . Find  Runners  and click  Project Runner . Click  New Project Runner . Add a tag (e.g.,  dev )—this is similar to labels in Jenkins. Click  Create Runner . Step 3: Install GitLab Runner on an EC2 Instance Copy the installation commands from GitLab (look for  How to Install…  section). SSH into your EC2 instance and run the commands as a superuser ( sudo su ). Choose the appropriate architecture (e.g.,  amd64 ). Once installed, start the service: sudo gitlab-runner status # Verify it's running Step 4: Register GitLab Runner R...

Setting Up a Self-Hosted GitLab Runner on EC2 Linux

Image
  GitLab provides its own runners to execute CI/CD jobs. However, if you want to run jobs on your own machine, GitLab allows you to set up a self-hosted runner. In this guide, we will go through the step-by-step process to set up a self-hosted GitLab runner and configure it to deploy a project. Step 1: Configure a Self-Hosted Runner in GitLab Go to the GitLab Homepage. Navigate to your  Group Settings  and go to  CI/CD  settings. Find the  Runners  section and click on  Project Runner . Click  New Project Runner . Assign a  Tag  (e.g.,  dev ). This works like a label in Jenkins. Click  Create Runner . The runner is now set up in GitLab. Step 2: Install the Runner on an EC2 Linux Instance Click on  “How to install”  in the GitLab Runner setup page. Copy the provided commands and execute them in your Linux terminal as a superuser: sudo su # Paste the GitLab-provided installation commands 3. Choose the appropriate a...