<?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 Isikapalei on Medium]]></title>
        <description><![CDATA[Stories by Isikapalei on Medium]]></description>
        <link>https://medium.com/@isikapalei05?source=rss-d29a2f6d57e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1i8j3Z4W0jAXiYDe</url>
            <title>Stories by Isikapalei on Medium</title>
            <link>https://medium.com/@isikapalei05?source=rss-d29a2f6d57e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:55:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isikapalei05/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[Project 3:Amazon App Deployment: A DevSecOps Approach with Terraform and Jenkins CI/CD]]></title>
            <link>https://medium.com/@isikapalei05/amazon-app-deployment-a-devsecops-approach-with-terraform-and-jenkins-ci-cd-9a36970f7aba?source=rss-d29a2f6d57e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a36970f7aba</guid>
            <dc:creator><![CDATA[Isikapalei]]></dc:creator>
            <pubDate>Fri, 19 Jul 2024 16:43:03 GMT</pubDate>
            <atom:updated>2024-07-19T16:45:20.754Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*x9blqeP-P9NGH3hwmUeFuA.jpeg" /></figure><p>Welcome to our guide on deploying an Amazon app with a focus on security using a DevSecOps approach. In today’s digital landscape, it’s crucial to ensure both speed and security in application development. DevSecOps integrates development, security, and operations into a seamless process. In this post, we will use Terraform, Jenkins CI/CD, SonarQube, and Trivy to build a secure and efficient deployment pipeline for applications on Amazon Web Services (AWS).</p><h4>Key Tools:</h4><ul><li><strong>Terraform</strong>: Infrastructure as Code (IaC) tool for provisioning AWS resources.</li><li><strong>Jenkins CI/CD</strong>: Automation server for continuous integration and continuous deployment.</li><li><strong>SonarQube</strong>: Code quality and security analysis tool.</li><li><strong>Trivy</strong>: Vulnerability scanner for containers.</li></ul><h4>Steps to Secure Deployment:</h4><ol><li><strong>Set Up Terraform</strong>: Define and provision your AWS infrastructure using Terraform scripts.</li><li><strong>Configure Jenkins</strong>: Create a CI/CD pipeline in Jenkins to automate your build and deployment process.</li><li><strong>Integrate SonarQube</strong>: Incorporate SonarQube into the Jenkins pipeline to ensure code quality and security checks.</li><li><strong>Scan with Trivy</strong>: Use Trivy to scan Docker images for vulnerabilities before deployment.</li></ol><h4>Why DevSecOps?</h4><p>DevSecOps ensures that security is a continuous, integrated part of the development process, rather than an afterthought. By automating security checks and incorporating them into the CI/CD pipeline, we can catch and address vulnerabilities early, resulting in more secure and reliable applications. Whether you’re an experienced developer looking to enhance your DevSecOps skills or a newcomer eager to explore this exciting field, this guide will help you safeguard your Amazon app while ensuring smooth and efficient deployment.</p><h4>Step 1: Create an IAM User</h4><p><strong>Navigate to AWS Console</strong>: Open your browser and go to the <a href="https://aws.amazon.com/console/">AWS Management Console</a>.</p><p><strong>Search for IAM</strong>: In the search bar, type “IAM” and select it.</p><p><strong>Click “Users”</strong>: In the IAM dashboard, click on “Users”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TVMYaMTz9Cyf-9ebdiyKXQ.png" /></figure><p><strong>Click “Add users”</strong>: Click the “Add users” button.</p><p><strong>Enter User Name</strong>: Fill in the “User name” field.</p><p><strong>Click “Next”</strong>: Click the “Next” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*tDp7LzXcdSneTDCkh9rmPg.png" /></figure><p><strong>Attach Policies Directly</strong>: Select “Attach policies directly”.</p><p><strong>Select AdministratorAccess</strong>: Check the “AdministratorAccess” checkbox.</p><p><strong>Click “Next”</strong>: Click the “Next” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ioCmbCkhL8DNjIlpSyykSg.png" /></figure><p><strong>Create User</strong>: Click the “Create user” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ioCmbCkhL8DNjIlpSyykSg.png" /></figure><p><strong>Select Newly Created User</strong>: Click on the newly created user.</p><p><strong>Go to Security Credentials</strong>: Click the “Security credentials” tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*selQcfIQYdmDuqxBtoFaNQ.png" /></figure><p><strong>Create Access Key</strong>: Click “Create access key”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*zum21x7-I1hQ0O2uve5Sjg.png" /></figure><p><strong>Select CLI Option</strong>: Select the “CLI” radio button.</p><p><strong>Agree to Terms</strong>: Agree to the terms.</p><p><strong>Click “Next”</strong>: Click the “Next” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZEImIYWIhhjsIeVrvqrI9g.png" /></figure><p><strong>Create Access Key</strong>: Click “Create access key”.</p><p><strong>Download .csv File</strong>: Download the .csv file containing the Access Key and Secret Access Key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*e4c97T3SJ4LhInXSYBai1A.png" /></figure><h4>Step 2: Configure AWS CLI</h4><p><strong>Launch Terminal or Command Prompt</strong>: Open a terminal or command prompt on your local machine. If AWS CLI is not installed, install it using the following command:</p><pre>sudo apt-get install awscli</pre><p><strong>Configure AWS CLI</strong>: Run the following command to configure AWS CLI:</p><pre>aws configure</pre><p><strong>Provide AWS Credentials</strong>: Enter the Access Key and Secret Access Key from the .csv file when prompted:</p><pre>AWS Access Key ID [None]: &lt;Your Access Key&gt;<br>AWS Secret Access Key [None]: &lt;Your Secret Access Key&gt;<br>Default region name [None]: us-east-1<br>Default output format [None]: json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*dFwSSO1uWt8BxLinGrifLQ.png" /></figure><h3>Step 3: Clone the GitHub Repository and Create Terraform Files</h3><p><strong>Clone the GitHub repository:</strong></p><p>Open your terminal and run:</p><pre>git clone https://github.com/ISIKA2002/AMAZON-FE.git</pre><pre>cd AMAZON-FE <br>cd JENKINS-TF</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*WHoCVmbhGb-gm0WruPNbtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZLMMl7taef_kCe7JHLVAHA.png" /></figure><p><strong>Create the following Terraform files:</strong></p><p><strong>main.tf:</strong></p><pre>resource &quot;aws_security_group&quot; &quot;Jenkins-sg&quot; {<br>  name        = &quot;Jenkins-Security Group&quot;<br>  description = &quot;Open 22,443,80,8080,9000&quot;<br><br>  ingress = [<br>    for port in [22, 80, 443, 8080, 9000, 3000] : {<br>      description      = &quot;TLS from VPC&quot;<br>      from_port        = port<br>      to_port          = port<br>      protocol         = &quot;tcp&quot;<br>      cidr_blocks      = [&quot;0.0.0.0/0&quot;]<br>    }<br>  ]<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  tags = {<br>    Name = &quot;Jenkins-sg&quot;<br>  }<br>}<br><br>resource &quot;aws_instance&quot; &quot;web&quot; {<br>  ami                    = &quot;ami-0a0e5d9c7acc336f1&quot;<br>  instance_type          = &quot;t2.large&quot;<br>  key_name               = &quot;17key&quot;<br>  vpc_security_group_ids = [aws_security_group.Jenkins-sg.id]<br>  user_data              = templatefile(&quot;./install_jenkins.sh&quot;, {})<br><br>  tags = {<br>    Name = &quot;Jenkins-sonar&quot;<br>  }<br><br>  root_block_device {<br>    volume_size = 30<br>  }<br>}</pre><p><strong>provider.tf:</strong></p><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 5.0&quot;<br>    }<br>  }<br>}<br><br>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}</pre><p><strong>install_jenkins.sh:</strong></p><pre>#!/bin/bash<br>sudo apt update -y<br><br># Install Java<br>wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc<br>echo &quot;deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= &#39;/^VERSION_CODENAME/{print$2}&#39; /etc/os-release) main&quot; | sudo tee /etc/apt/sources.list.d/adoptium.list<br>sudo apt update -y<br>sudo apt install temurin-17-jdk -y<br>/usr/bin/java --version<br><br># Install Jenkins<br>curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null<br>echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list &gt; /dev/null<br>sudo apt-get update -y<br>sudo apt-get install jenkins -y<br>sudo systemctl start jenkins<br>sudo systemctl status jenkins<br><br># Install Docker<br>sudo apt-get update<br>sudo apt-get install docker.io -y<br>sudo usermod -aG docker ubuntu  <br>newgrp docker<br>sudo chmod 777 /var/run/docker.sock<br>docker run -d --name sonar -p 9000:9000 sonarqube:lts-community<br><br># Install Trivy<br>sudo apt-get install wget apt-transport-https gnupg lsb-release -y<br>wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg &gt; /dev/null<br>echo &quot;deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main&quot; | sudo tee -a /etc/apt/sources.list.d/trivy.list<br>sudo apt-get update<br>sudo apt-get install trivy -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZAcjMVwMtcLTdKY2_Sn9Kg.png" /></figure><p><strong>Initialize and apply the Terraform configuration:</strong></p><p>Install Terraform if not already installed, then run the following commands:</p><pre>terraform init<br>terraform validate<br>terraform plan<br>terraform apply</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*C7Vbw0WMoclQElkNDq3-Uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FCF0aoLX5jCPV-pejR3xVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*JABiV4loWTSlocxM-rUoRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Z_UPaXuz4caOXgTtgMRTzg.png" /></figure><p>Verify that the installation has been successfully launched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*oWiCDfq_5sh3NgpUuoKKyA.png" /></figure><p><strong>Step 4: Access Jenkins</strong></p><pre>http://&lt;instance-ip&gt;:8080</pre><p>Retrieve the Jenkins initial admin password:</p><pre>sudo cat /var/lib/jenkins/secrets/initialAdminPassword</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*qz12kQpQxmUa8SQJ_RHZ4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Bqfkweexm0CpzIoMZdf6Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*57jIR6BokpxDvUIFiycl9g.png" /></figure><p><strong>Step 5: Access SonarQube</strong></p><p>Access SonarQube:</p><pre>http://&lt;instance-public-ip&gt;:9000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*3C_Az5fBDcmP4qQjWesb-Q.png" /></figure><p>Log in with the default credentials (admin / admin) and change the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*WzXPZsxdHpoGO9HerzDjWA.png" /></figure><p><strong>Step 6: Check Trivy Version</strong></p><pre>trivy --version</pre><h4>Step 7: Install Jenkins Plugins</h4><p>Install the following plugins in Jenkins:</p><ol><li><strong>Eclipse Temurin Installer</strong></li><li><strong>SonarQube Scanner</strong></li><li><strong>NodeJs Plugin</strong></li><li><strong>OWASP Dependency-Check</strong></li><li><strong>Docker</strong></li><li><strong>Docker Commons</strong></li><li><strong>Docker Pipeline</strong></li><li><strong>Docker API</strong></li><li><strong>Docker Build Step</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*rG2wROBfxct-Ae2mGGzVag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*jVNMsG0IM-1LasSOAUYC8A.png" /></figure><p><strong>Configure the tools:</strong></p><ul><li><strong>Java</strong>: Go to <strong>Manage Jenkins → Tools → JDK</strong>. Add JDK 17.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FSVTOuyLJ9e39qI6Bdo8cw.png" /></figure><ul><li><strong>SonarQube Scanner</strong>: Go to <strong>Manage Jenkins → Tools → SonarQube Scanner</strong>. Add the scanner.</li><li><strong>NodeJs</strong>: Go to <strong>Manage Jenkins → Tools → NodeJS</strong>. Add NodeJS 16.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*7BBrqkTE-ukEAfi65oDsSw.png" /></figure><ul><li><strong>OWASP Dependency-Check</strong>: Go to <strong>Manage Jenkins → Tools → OWASP Dependency-Check</strong>. Add Dependency-Check.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*orhSI8-e7lXfPMDzqnPf0w.png" /></figure><ul><li><strong>Docker</strong>: Go to <strong>Manage Jenkins → Tools → Docker</strong>. Add Docker.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Vej3pIpS0uwMQWnGwEZyYw.png" /></figure><h4>Step 8: Configure SonarQube</h4><p>Generate a token in SonarQube:</p><ol><li>Go to <strong>Administration → Security → Users → Tokens</strong>.</li><li>Click <strong>Tokens</strong>.</li><li>Generate and save the token.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*x3zGqbiIXbeO7IYpgvLfag.png" /></figure><p><strong>Generate Token</strong>: Provide a name for the token and click on Generate.</p><p><strong>Copy Token</strong>: Save the generated token securely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*AswSwcvpLFbmOinTs05__Q.png" /></figure><p><strong>Add a webhook in SonarQube:</strong></p><ol><li>Go to <strong>Administration → Configuration → Webhooks</strong>.</li><li>Create a webhook with the URL: http://&lt;Jenkins_IP&gt;:&lt;Jenkins_Port&gt;/sonarqube-webhook/</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*NeYmsiU5qDyJ_hcHvVud5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ku5jDwJQnryj8Bj196xDKQ.png" /></figure><h4>Step 9: Add Credentials in Jenkins</h4><p>Add the SonarQube token:</p><ol><li>Go to <strong>Manage Jenkins → Credentials</strong>.</li><li>Add a new <strong>Secret text</strong> with the token.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Q20YdH5z30Tw89i3iaV05A.png" /></figure><p>Add DockerHub credentials:</p><ol><li>Go to <strong>Manage Jenkins → Credentials</strong>.</li><li>Add a new <strong>Username with password</strong> for DockerHub.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Rrb___bgYFOE-7PNa2GP2A.png" /></figure><p>Add the SonarQube server in Jenkins:</p><ol><li>Go to <strong>Manage Jenkins → System</strong>.</li><li>Add a new SonarQube server with the URL and token.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*V-aasGABmj0HGL5C6-Mdbw.png" /></figure><p>Click on Apply and Save</p><h4>Step 10: Add Webhook in GitHub</h4><ol><li>Go to your GitHub repository.</li><li>Navigate to <strong>Settings → Webhooks</strong>.</li><li>Add a webhook with the payload URL: <a href="http://jenkins-public-ip:8080/github-webhook/">http://jenkins-public-ip:8080/github-webhook/</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*bD1YxCfvFy7ql8bsRE-ukg.png" /></figure><h4>Step 11: Create Project in SonarQube</h4><ol><li>Go to the SonarQube dashboard.</li><li>Create a new project with a name and unique identifier.</li><li>Set up the project for the desired branch.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*1koQHSvTD1nZnIfknuyg7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*pyvcLkVu6fCoFYCQ74YBwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*dFaFAzrx8fovZcIy9lJLEg.png" /></figure><h4>Step 12: Create a Jenkins Pipeline</h4><p>Create a new pipeline item in Jenkins:</p><ol><li>Go to the Jenkins dashboard.</li><li>Click <strong>New Item</strong>.</li><li>Enter a name and select <strong>Pipeline</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*JdqFNsJnpDOZjIec6XpsnQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*S7IhvB_Lr5ZDh-PDZlPNyg.png" /></figure><p>Select <strong>GitHub project</strong> and add the project url of github repository(like : git clone <a href="https://github.com/ISIKA2002/AMAZON-FE.git">https://github.com/ISIKA2002/AMAZON-FE.git</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*YNz2N1ZDLf6DVdTCRPLmCg.png" /></figure><p>In the Build Triggers Select <strong>GitHUb hook trigger for GITScm polling</strong>.</p><p>Configure the pipeline with the following script:</p><p><strong>Pipeline Script:</strong></p><pre>pipeline {<br>  agent any<br>  tools {<br>    jdk &#39;jdk17&#39;<br>    nodejs &#39;node16&#39;<br>  }<br>  environment {<br>    SCANNER_HOME = tool &#39;sonar-scanner&#39;<br>  }<br>  stages {<br>    stage(&#39;Checkout from Git&#39;) {<br>      steps {<br>        git branch: &#39;main&#39;, url: &#39;https://github.com/ISIKA2002/AMAZON-FE.git&#39;<br>      }<br>    }<br>    stage(&#39;Install Dependencies&#39;) {<br>      steps {<br>        sh &quot;npm install&quot;<br>      }<br>    }<br>    stage(&#39;SonarQube Analysis&#39;) {<br>      steps {<br>        withSonarQubeEnv(&#39;sonar-server&#39;) {<br>          sh &#39;&#39;&#39; $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Amazon \<br>          -Dsonar.projectKey=Amazon &#39;&#39;&#39;<br>        }<br>      }<br>    }<br>    stage(&#39;Quality Gate&#39;) {<br>      steps {<br>        script {<br>          waitForQualityGate abortPipeline: false, credentialsId: &#39;Sonar-token&#39;<br>        }<br>      }<br>    }<br>    stage(&#39;OWASP FS SCAN&#39;) {<br>      steps {<br>        dependencyCheck additionalArguments: &#39;--scan ./ --disableYarnAudit --disableNodeAudit&#39;, odcInstallation: &#39;DP-Check&#39;<br>        dependencyCheckPublisher pattern: &#39;**/dependency-check-report.xml&#39;<br>      }<br>    }<br>    stage(&#39;TRIVY FS SCAN&#39;) {<br>      steps {<br>        sh &quot;trivy fs . &gt; trivyfs.json&quot;<br>      }<br>    }<br>    stage(&#39;Docker Build &amp; Push&#39;) {<br>      steps {<br>        script {<br>          withDockerRegistry(credentialsId: &#39;docker&#39;, toolName: &#39;docker&#39;) {<br>            sh &quot;docker build -t amazon .&quot;<br>            sh &quot;docker tag amazon isika05/amazon:latest&quot;<br>            sh &quot;docker push isika05/amazon:latest&quot;<br>          }<br>        }<br>      }<br>    }<br>    stage(&#39;TRIVY&#39;) {<br>      steps {<br>        sh &quot;trivy image isika05/amazon:latest &gt; trivy.json&quot;<br>      }<br>    }<br>    stage(&#39;Remove container&#39;) {<br>      steps {<br>        sh &quot;docker stop amazon || true&quot;<br>        sh &quot;docker rm amazon || true&quot;<br>      }<br>    }<br>    stage(&#39;Deploy to container&#39;) {<br>      steps {<br>        sh &#39;docker run -d --name amazon -p 3000:3000 isika05/amazon:latest&#39;<br>      }<br>    }<br>  }<br>}</pre><p><em>NOTE:</em> You can mention the names of each tool as per your details given in the Jenkins management console tool (e.g., JDK 17, NodeJS 16, SonarQube Scanner, Dependency-Check, Docker).</p><h3>Step 13: Run the Pipeline</h3><p><strong>Trigger the Pipeline</strong>:</p><ul><li>Go to your Jenkins Dashboard.</li><li>Click on your job (e.g., Amazon).</li><li>Click <strong>Build Now</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*pkpgAv1l-SGcPV3IqPnO8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*RzW3upLTvQPApYG0QGSEBw.png" /></figure><p><strong>Jenkins Pipeline Steps</strong></p><p><strong>Git Checkout</strong>:</p><ul><li>The pipeline starts with checking out the code from the specified Git repository.</li></ul><p><strong>Tool Install</strong>:</p><ul><li>Necessary tools like JDK and NodeJS are installed using Jenkins’ tool management.</li></ul><p><strong>Git Pull</strong>:</p><ul><li>Updates the local repository with any changes from the remote repository.</li></ul><p><strong>NPM Install</strong>:</p><ul><li>Installs dependencies specified in the package.json file using npm.</li></ul><p><strong>SonarQube Analysis</strong>:</p><ul><li>Conducts static code analysis using SonarQube to evaluate code quality and security issues.</li></ul><p><strong>Quality Gate</strong>:</p><ul><li>Checks if the defined quality gate criteria are met before proceeding further.</li></ul><p><strong>OWASP Dependency Check</strong>:</p><ul><li>Scans for known vulnerabilities in project dependencies using OWASP Dependency Check.</li></ul><p><strong>Trivy Filesystem Scan (FS)</strong>:</p><ul><li>Scans the filesystem for vulnerabilities using Trivy.</li></ul><p><strong>Docker Build and Push</strong>:</p><ul><li>Builds the Docker image for the application and pushes it to DockerHub or another registry.</li></ul><p><strong>Trivy Image Scan and Deploy to Docker</strong>:</p><ul><li>Scans the Docker image for vulnerabilities using Trivy and deploys it to Docker, ensuring security compliance.</li></ul><p>This sequence illustrates the workflow of your Jenkins pipeline from code checkout to deployment, ensuring comprehensive testing and security checks throughout the process.</p><h3>Step 14: View SonarQube Results</h3><p>After the pipeline runs, you can view the SonarQube analysis results directly in the SonarQube dashboard. The SonarQube dashboard will display detailed metrics, including code quality, bugs, vulnerabilities, code smells, and coverage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*VFs9KANdcf73_QfgsAS99w.png" /></figure><p>Here is the dependency-check Trend and Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*gIPSbd4LBkms5u9hPh2CpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*pPRslY9K4LmOvIYQ4XKx4Q.png" /></figure><p>The image is successfully pushed to Docker Hub:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*eL9Al3Ey_V8T7TkQYSIpxA.png" /></figure><p>Now you can see the result using `&lt;instance-public-ip:3000&gt;`</p><p>You will get this output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*CesNL2FB2qmoP5oRM8VQeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*5jeBHAPnBuh0clGKr0oheQ.png" /></figure><p>Let’s destroy everything.</p><p>Go to VS Code and provide the below command (or go to the path where you provisioned the EC2 instance):</p><pre>terraform destroy --auto-approve</pre><p><em>By following these steps, you’ve successfully created a secure and efficient CI/CD pipeline for deploying your Amazon app using Terraform, Jenkins, SonarQube, and Trivy. This DevSecOps approach ensures that security is integrated into every stage of your development process, helping you deliver high-quality, secure applications faster. Happy deploying!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a36970f7aba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project 2: Infrastructure as Code (IaC) for AWS Deployments with Python]]></title>
            <link>https://medium.com/@isikapalei05/project-2-infrastructure-as-code-iac-for-aws-deployments-with-python-72e5655eab5d?source=rss-d29a2f6d57e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/72e5655eab5d</guid>
            <dc:creator><![CDATA[Isikapalei]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 16:31:08 GMT</pubDate>
            <atom:updated>2024-07-05T16:31:08.697Z</atom:updated>
            <content:encoded><![CDATA[<p>The steps to create a project that uses Infrastructure as Code (IaC) to automate AWS deployments with Python. We&#39;ll use AWS CloudFormation for IaC and set up a CI/CD pipeline with GitHub Actions for automated deployment.</p><h3>Prerequisites</h3><ol><li>AWS Account</li><li>AWS CLI installed and configured</li><li>Python installed</li><li>Git installed</li><li>GitHub account</li></ol><h3>Step-by-Step Process</h3><h4>1. Setting Up Your Local Development Environment</h4><p>1.1 Install AWS CLI</p><ul><li>Follow the official <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html">AWS CLI installation guide</a>. or</li><li>Installing AWS CLI on Ubuntu</li></ul><p>The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. Here are the detailed steps to install AWS CLI on an Ubuntu system:</p><h4>Step 1: Update the Package List</h4><p>It&#39;s a good practice to update the package list to ensure you have the latest information about available packages.</p><pre>sudo apt update</pre><h4>Step 2: Install Required Packages</h4><p>You&#39;ll need unzip and curl to download and extract the AWS CLI package.</p><pre>sudo apt install unzip curl -y</pre><h4>Step 3: Download the AWS CLI Installation Package</h4><p>Use curl to download the AWS CLI installation package from the AWS website.</p><pre>curl &quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot; -o &quot;awscliv2.zip&quot;</pre><h4>Step 4: Unzip the Package</h4><p>Extract the downloaded ZIP file.</p><pre>unzip awscliv2.zip</pre><h4>Step 5: Run the Installation Script</h4><p>Run the installation script to install AWS CLI.</p><pre>sudo ./aws/install</pre><h4>Step 6: Verify the Installation</h4><p>Check the installed version of AWS CLI to verify that the installation was successful.</p><pre>aws --version</pre><p>You should see an output similar to this, confirming the installation:</p><pre>aws-cli/2.7.24 Python/3.8.8 Linux/4.15.0-142-generic exe/x86_64.ubuntu.20</pre><h4>Step 7: Clean Up</h4><p>(Optional) Remove the downloaded ZIP file and the extracted directory to clean up.</p><pre>rm -rf awscliv2.zip aws</pre><h3>Summary</h3><p>You have now installed the AWS CLI on your Ubuntu system. The AWS CLI is ready to use for managing your AWS services. Remember to configure the CLI with your AWS credentials by running aws configure:</p><pre>aws configure</pre><p>You&#39;ll be prompted to enter your AWS Access Key ID, Secret Access Key, default region, and output format.</p><p>1.2 Configure AWS CLI</p><ul><li>Run aws configure and enter your AWS credentials.</li></ul><pre>aws configure</pre><p>1.3 Set Up Project Directory</p><ul><li>Create a project directory and navigate into it.</li></ul><pre>mkdir aws-iac-project<br>cd aws-iac-project</pre><p>1.4 Set Up a Virtual Environment</p><ul><li>Create and activate a Python virtual environment.</li></ul><pre>python -m venv venv<br>source venv/bin/activate  # On Windows: venv\Scripts\activate</pre><h4>2. Writing Infrastructure as Code with AWS CloudFormation</h4><p>2.1 Create a CloudFormation Template</p><ul><li>Create a directory for your CloudFormation templates and add a basic template.</li></ul><pre>mkdir cloudformation<br>touch cloudformation/main.yaml</pre><ul><li>Add the following content to cloudformation/main.yaml to create a VPC, Subnets, and an EC2 instance:</li></ul><pre>AWSTemplateFormatVersion: &#39;2010-09-09&#39;<br>Description: AWS Infrastructure as Code Project<br><br>Resources:<br>  MyVPC:<br>    Type: AWS::EC2::VPC<br>    Properties:<br>      CidrBlock: 10.0.0.0/16<br>      EnableDnsSupport: true<br>      EnableDnsHostnames: true<br><br>  PublicSubnet:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      VpcId: !Ref MyVPC<br>      CidrBlock: 10.0.1.0/24<br>      MapPublicIpOnLaunch: true<br><br>  MyEC2Instance:<br>    Type: AWS::EC2::Instance<br>    Properties:<br>      InstanceType: t2.micro<br>      ImageId: ami-0c55b159cbfafe1f0  # Amazon Linux 2 AMI<br>      SubnetId: !Ref PublicSubnet<br>      KeyName: my-key-pair</pre><p>2.2 Create a Python Script for Deployment</p><ul><li>Create a script to deploy the CloudFormation stack using the AWS SDK for Python (Boto3).</li></ul><pre>touch deploy.py</pre><ul><li>Add the following content to deploy.py:</li></ul><pre>import boto3<br>import time<br><br>def deploy_stack(stack_name, template_file):<br>    with open(template_file, &#39;r&#39;) as file:<br>        template_body = file.read()<br><br>    client = boto3.client(&#39;cloudformation&#39;)<br>    response = client.create_stack(<br>        StackName=stack_name,<br>        TemplateBody=template_body,<br>        Capabilities=[&#39;CAPABILITY_IAM&#39;]<br>    )<br><br>    waiter = client.get_waiter(&#39;stack_create_complete&#39;)<br>    waiter.wait(StackName=stack_name)<br><br>    print(f&quot;Stack {stack_name} created successfully.&quot;)<br><br>if __name__ == &#39;__main__&#39;:<br>    deploy_stack(&#39;my-iac-stack&#39;, &#39;cloudformation/main.yaml&#39;)</pre><p>2.3 Install Boto3</p><ul><li>Install Boto3 in your virtual environment.</li></ul><pre>pip install boto3</pre><h4>3. Version Control with GitHub</h4><p>3.1 Initialize Git Repository</p><ul><li>Initialize a git repository in your project directory.</li></ul><pre>git init</pre><ul><li>git init</li></ul><p>3.2 Create .gitignore</p><ul><li>Create a .gitignore file to exclude unnecessary files.</li></ul><pre>touch .gitignore<br>echo &quot;venv/&quot; &gt;&gt; .gitignore<br>echo &quot;*.pyc&quot; &gt;&gt; .gitignore<br>echo &quot;__pycache__/&quot; &gt;&gt; .gitignore</pre><p>3.3 Commit Code</p><ul><li>Commit your code to the repository.</li></ul><pre>git add .<br>git commit -m &quot;Initial commit&quot;</pre><p>3.4 Push to GitHub</p><ul><li>Create a new repository on GitHub and push your code.</li></ul><pre>git remote add origin https://github.com/your-username/aws-iac-project.git<br>git branch -M main<br>git push -u origin main</pre><h4>4. Setting Up CI/CD Pipeline with GitHub Actions</h4><p>4.1 Create GitHub Actions Workflow</p><ul><li>Create a directory for GitHub Actions workflows.</li></ul><pre>mkdir -p .github/workflows<br>touch .github/workflows/deploy.yml</pre><ul><li>mkdir -p .github/workflows touch .github/workflows/deploy.yml</li></ul><p>4.2 Define the Workflow</p><ul><li>Add the following content to deploy.yml to define the deployment pipeline:</li></ul><pre>name: Deploy Infrastructure<br><br>on:<br>  push:<br>    branches:<br>      - main<br><br>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v2<br><br>      - name: Set up Python<br>        uses: actions/setup-python@v2<br>        with:<br>          python-version: &#39;3.x&#39;<br><br>      - name: Install dependencies<br>        run: |<br>          python -m venv venv<br>          source venv/bin/activate<br>          pip install boto3<br><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: us-east-1<br><br>      - name: Deploy CloudFormation stack<br>        run: |<br>          source venv/bin/activate<br>          python deploy.py</pre><p>4.3 Configure GitHub Secrets</p><ul><li>Go to your GitHub repository settings and configure the following secrets:</li><li>AWS_ACCESS_KEY_ID: Your AWS access key ID.</li><li>AWS_SECRET_ACCESS_KEY: Your AWS secret access key.</li></ul><p>4.4 Push Changes to GitHub</p><ul><li>Commit and push the workflow file to trigger the pipeline.</li></ul><pre>git add .github/workflows/deploy.yml<br>git commit -m &quot;Add GitHub Actions workflow for deployment&quot;<br>git push</pre><h3>Summary</h3><p>By following these steps, you have set up an automated deployment pipeline for AWS infrastructure using Python and Infrastructure as Code (IaC) principles. You can now manage and deploy AWS resources in a consistent and automated manner, ensuring that your infrastructure is versioned, repeatable, and reliable.</p><p><strong>Architecture Diagram</strong></p><pre>                          +-----------------------+<br>                          |      Developer        |<br>                          |      Workstation      |<br>                          +-----------+-----------+<br>                                      |<br>                                      | Python Code (IaC scripts)<br>                                      |<br>                          +-----------v-----------+<br>                          |        IDE/Editor     |<br>                          +-----------+-----------+<br>                                      |<br>                                      |<br>                          +-----------v-----------+<br>                          |     Version Control   |<br>                          |      (GitHub/GitLab)  |<br>                          +-----------+-----------+<br>                                      |<br>                                      | git push<br>                                      |<br>                          +-----------v-----------+<br>                          |  CI/CD Pipeline       |<br>                          | (e.g., Jenkins, GitHub|<br>                          |  Actions, GitLab CI)  |<br>                          +-----------+-----------+<br>                                      |<br>                                      | Deploy IaC Scripts<br>                                      |<br>                          +-----------v-----------+<br>                          |     AWS CloudFormation|<br>                          |        (or Terraform) |<br>                          +-----------+-----------+<br>                                      |<br>                                      |<br>                                      |<br>+-------------------------------------v-----------------------------------+<br>|                               AWS Account                              |<br>|                                                                         |<br>| +-------------------+      +-----------------+      +-----------------+ |<br>| |   Networking      |      |   Compute       |      |   Storage       | |<br>| |   (VPC, Subnets,  |      |   (EC2, Lambda) |      |   (S3, EBS)     | |<br>| |   Route Tables)   |      +-----------------+      +-----------------+ |<br>| +-------------------+                                                | |<br>|                                                                         |<br>| +---------------------+   +-----------------+     +------------------+  |<br>| |  Database Services  |   |  Security       |     |  Monitoring      |  |<br>| |  (RDS, DynamoDB)    |   |  (IAM, Security |     |  (CloudWatch,    |  |<br>| |                     |   |   Groups,       |     |   CloudTrail)    |  |<br>| +---------------------+   |   Policies)     |     +------------------+  |<br>|                           +-----------------+                            |<br>+-------------------------------------------------------------------------+</pre><p>Git repository link: [<a href="https://github.com/ISIKA2002/Iac-project-python.git](https://github.com/ISIKA2002/Iac-project-python.git)">https://github.com/ISIKA2002/Iac-project-python.git](https://github.com/ISIKA2002/Iac-project-python.git)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72e5655eab5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project 1 :CI/CD Pipeline for Uptime-Kuma: Real-Time Call Alerts for Server Downtime]]></title>
            <link>https://medium.com/@isikapalei05/project-1-ci-cd-pipeline-for-uptime-kuma-real-time-call-alerts-for-server-downtime-e0735c18ad87?source=rss-d29a2f6d57e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0735c18ad87</guid>
            <dc:creator><![CDATA[Isikapalei]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 13:30:44 GMT</pubDate>
            <atom:updated>2024-07-11T05:57:02.761Z</atom:updated>
            <content:encoded><![CDATA[<h3>Project 1 :CI/CD Pipeline for Uptime-Kuma: Real-Time Call Alerts for Server Downtime</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4i6a__cCtF-OpblU4tNOw.jpeg" /></figure><h3>Overview of Uptime-Kuma</h3><p>Uptime-Kuma is an open-source, self-hosted monitoring tool designed to track the uptime and performance of websites, services, and APIs. It offers real-time monitoring with customizable intervals, alerts via multiple channels (email, Slack, Telegram, etc.), historical data and uptime statistics, and a user-friendly interface.</p><h3>Steps to Set Up and Utilize Uptime-Kuma in a CI/CD Pipeline</h3><h3>1. AWS Account and Login</h3><ul><li><strong>Sign Up and Login</strong>: If you don’t have an AWS account, sign up at <a href="https://aws.amazon.com/">AWS Sign Up</a>.</li><li><strong>Login</strong>: Log in to the AWS Management Console.</li></ul><h3>2. Launch an EC2 Instance</h3><ul><li><strong>Navigate to EC2 Dashboard</strong>: Go to the EC2 Dashboard.</li><li><strong>Choose an AMI</strong>: Click “Launch Instance” and search for “Ubuntu 24.04”.</li><li><strong>Choose an Instance Type</strong>: Select the t2.large instance type and click “Next: Configure Instance Details”.</li><li><strong>Configure Instance Details</strong>: Use the default settings, ensure the correct VPC and subnet, and click “Next: Add Storage”.</li><li><strong>Add Storage</strong>: Modify the root volume size to 30 GB and click “Next: Add Tags”.</li><li><strong>Add Tags</strong>: (Optional) Add tags for better management and click “Next: Configure Security Group”.</li><li><strong>Configure Security Group</strong>: Create a new security group, set the security group name and description, and add rules to allow necessary traffic (ports: 22, 80, 443, 8080, 9000, 3001, 5000).</li><li><strong>Review and Launch</strong>: Review all configurations, click “Launch”.</li><li><strong>Select/Create a Key Pair</strong>: Select “Create a new key pair”, name it, download the .pem file, and click “Launch Instances”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*lrqnvU7Wgga2Y6YpZgAFWQ.png" /></figure><h3>3. Install Jenkins, Docker, and Trivy</h3><h4>Install Jenkins</h4><pre>sudo nano jenkins_install.sh</pre><pre>#!/bin/bash<br>sudo apt update -y<br>wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc<br>echo &quot;deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= &#39;/^VERSION_CODENAME/{print$2}&#39; /etc/os-release) main&quot; | sudo tee /etc/apt/sources.list.d/adoptium.list<br>sudo apt update -y<br>sudo apt install temurin-17-jdk -y<br>/usr/bin/java -version<br>curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null<br>echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list &gt; /dev/null<br>sudo apt-get update -y<br>sudo apt-get install jenkins -y<br>sudo systemctl start jenkins<br>sudo systemctl status jenkins</pre><ul><li><strong>Run Docker Installation Script</strong>: bash jenkins_install.sh</li><li><strong>Open Inbound Port 8080</strong>: Go to your AWS EC2 Security Group and open Inbound Port 8080. Access Jenkins at &lt;EC2 Public IP Address:8080&gt;.</li></ul><p><strong>Install Docker</strong></p><pre>sudo nano docker_install.sh</pre><pre>#!/bin/bash<br>sudo apt-get update<br>sudo apt-get install ca-certificates curl<br>sudo install -m 0755 -d /etc/apt/keyrings<br>sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc<br>sudo chmod a+r /etc/apt/keyrings/docker.asc<br>echo \<br>&quot;deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \<br>$(. /etc/os-release &amp;&amp; echo &quot;$VERSION_CODENAME&quot;) stable&quot; | \<br>sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null<br>sudo apt-get update<br>sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y<br>sudo usermod -aG docker ubuntu<br>newgrp docker<br>sudo systemctl status docker</pre><ul><li><strong>Run Docker Installation Script</strong>: bash docker_install.sh</li><li><strong>Create SonarQube Container</strong>: Ensure port 9000 is open in the security group.</li></ul><pre>sudo chmod 777 /var/run/docker.sock<br>docker run -d --name sonar -p 9000:9000 sonarqube:lts-community</pre><ul><li><strong>Access SonarQube</strong>: &lt;Public IP&gt;:9000</li></ul><h4>Install Trivy</h4><pre>sudo nano trivy_install.sh</pre><pre>#!/bin/bash<br>sudo apt-get install wget apt-transport-https gnupg lsb-release<br>wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg &gt; /dev/null<br>echo &quot;deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main&quot; | sudo tee -a /etc/apt/sources.list.d/trivy.list<br>sudo apt-get update<br>sudo apt-get install trivy -y</pre><ul><li><strong>Run Trivy Installation Script</strong>: bash trivy_install.sh</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*zX5QA_KOVnKC9oSEKPVCVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*S5MKdp5ir6Eu_sbObFGM_Q.png" /><figcaption>Jenkins</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*SkQMVYrovIxEJWp14S3TAw.png" /><figcaption>SonarQube</figcaption></figure><h3>4. Configure Jenkins</h3><h4>Install Plugins</h4><ul><li><strong>Plugins</strong>: Install the following plugins from Manage Jenkins → Plugins → Available Plugins:</li><li>Eclipse Temurin Installer</li><li>SonarQube Scanner</li><li>NodeJs Plugin</li><li>Docker</li><li>Docker Commons</li><li>Docker Pipeline</li><li>Docker API</li><li>Docker Build Step</li><li>OWASP Dependency Check</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*5uD69yqOk662Wv0gLMW34A.png" /></figure><h4>Configure Jenkins System and Tools</h4><p>Configure Java in Global Tool Configuration</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Tools → JDK.</li><li><strong>Install JDK (17)</strong>: Add a new JDK installation, select JDK 17, and click on Apply and Save.</li></ul><p>Configure SonarQube Scanner</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Tools → SonarQube Scanner.</li><li><strong>Install SonarQube Scanner</strong>: Add a new SonarQube Scanner installation, and click on Apply and Save.</li></ul><p>Configure NodeJs</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Tools → NodeJS.</li><li><strong>Install NodeJS (18)</strong>: Add a new NodeJS installation, select NodeJS 18, and click on Apply and Save.</li></ul><p>Configure OWASP Dependency-Check</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Tools → OWASP Dependency-Check.</li><li><strong>Install Dependency-Check</strong>: Add a new Dependency-Check installation, and click on Apply and Save.</li></ul><p>Configure Docker</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Tools → Docker.</li><li><strong>Install Docker</strong>: Add a new Docker installation, and click on Apply and Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*H8Th_M5QLE15fqwovJRwFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Yx--xsdzqt3B8pJfTeQB-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*mW47rddPVt1wDFIHUCXXPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*BgHSlRThCvdnMt9flBO7Rw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*W-P36pr7kpQRqWygOYnQUw.png" /></figure><p><strong>Configure SonarQube</strong></p><p>Generate Token</p><ul><li><strong>Go to SonarQube Server</strong>: Navigate to your SonarQube instance.</li><li><strong>Administration → Security → Users → Tokens</strong>:</li><li>Click on Tokens.</li><li><strong>Generate Token</strong>: Provide a name for the token and click on Generate.</li><li><strong>Copy Token</strong>: Save the generated token securely.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*pJ7WxUra_mXbJFeRWKAfRA.png" /></figure><p>Add Webhook in SonarQube</p><ul><li><strong>Go to SonarQube Administration</strong>: Navigate to Administration → Configuration → Webhooks.</li><li><strong>Create Webhook</strong>:</li><li>Click on Create.</li><li><strong>Name</strong>: Enter Jenkins.</li><li><strong>URL</strong>: Enter http://&lt;Jenkins_IP&gt;:&lt;Jenkins_Port&gt;/sonarqube-webhook/.</li><li>Click Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*_bzggLkER51a-iUNAtkMUg.png" /></figure><p>Add Credentials in Jenkins</p><p><strong>Add Secret Text</strong>:</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Credentials.</li><li><strong>Add Secret Text</strong>:</li><li>Click on Global → Add Credentials.</li><li><strong>Kind</strong>: Select Secret text.</li><li><strong>Secret</strong>: Paste the copied SonarQube token.</li><li><strong>ID</strong>: Provide a unique ID (e.g., Sonar-token).</li><li><strong>Description</strong>: Add a description (e.g., SonarQube Token).</li><li>Click OK.</li></ul><p><strong>Add DockerHub Credentials</strong>:</p><ul><li><strong>Add Username and Password</strong>:</li><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → Credentials.</li><li><strong>Add Credentials</strong>:</li><li>Click on Global → Add Credentials.</li><li><strong>Kind</strong>: Select Username with password.</li><li><strong>Username</strong>: Enter your DockerHub username.</li><li><strong>Password</strong>: Enter your DockerHub password.</li><li><strong>ID</strong>: Provide a unique ID (e.g., docker).</li><li><strong>Description</strong>: Add a description (e.g., DockerHub Credentials).</li><li>Click OK.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*oXm8QSHIVM0k43mO3JMjZA.png" /></figure><p><strong>Add SonarQube Server in Jenkins</strong>:</p><ul><li><strong>Navigate to Jenkins Dashboard</strong>: Go to Manage Jenkins → System.</li><li><strong>SonarQube Servers</strong>:</li><li><strong>Add SonarQube Server</strong>: Click on Add SonarQube.</li><li><strong>Name</strong>: Provide a name for the server (e.g., sonar-server).</li><li>Enter the SonarQube server URL (e.g., http://&lt;SonarQube_IP&gt;:&lt;SonarQube_Port&gt;).</li><li><strong>Server Authentication Token</strong>: Select the SonarQube token added earlier.</li><li>Click Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*9_y6dMHuTMSz9QMCTu9sog.png" /></figure><h3>5. Add Webhook in GitHub</h3><ol><li><strong>Navigate to Your Repository</strong>: Go to your GitHub repository.</li><li><strong>Settings → Webhooks</strong>:</li></ol><ul><li>Click on <strong>Add webhook</strong>.</li><li><strong>Payload URL</strong>: Enter the URL for the webhook endpoint (e.g., <a href="http://jenkins-public-ip:8080/github-webhook/).">http://jenkins-public-ip:8080/github-webhook/).</a></li><li><strong>Content type</strong>: Select application/json.</li><li><strong>Secret</strong>: (Optional) Provide a secret for added security.</li><li><strong>Which events would you like to trigger this webhook?</strong>: Choose Just the push event or select events as per your requirement.</li><li>Click <strong>Add webhook</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*4KBf0n8P7N1CWtY4eRc9-w.png" /></figure><h3>6. Create Project in SonarQube</h3><p><strong>Go to SonarQube Dashboard</strong>:</p><p>Navigate to your SonarQube instance.</p><p><strong>Manual Project Creation</strong>:</p><ul><li>Click on <strong>Projects</strong> in the top navigation bar.</li><li>Click on <strong>Create Project</strong>.</li><li><strong>Name</strong>: Enter a name for your project.</li><li><strong>Project Key</strong>: Provide a unique identifier for your project.</li><li><strong>Branch</strong>: Select the branch you want to analyze (e.g., main).</li><li>Click <strong>Setup</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FsCXWvD9nGwU6RMRg9MmMw.png" /></figure><h3>7. Create a Jenkins Pipeline Item</h3><p><strong>Open Jenkins Dashboard</strong>:</p><ul><li>Log in to your Jenkins instance.</li></ul><p><strong>Create New Item</strong>:</p><ul><li>Click on New Item in the left-hand menu.</li></ul><p><strong>Name the Item</strong>:</p><ul><li>Enter a name for your pipeline (e.g., Uptime-Kuma Pipeline).</li></ul><p><strong>Select Pipeline</strong>:</p><ul><li>Choose Pipeline from the list of item types.</li><li>Click OK.</li></ul><p><strong>Configure the Pipeline</strong>:</p><ul><li>Scroll down to the Pipeline section.</li><li>Under Definition, select Pipeline script from SCM.</li><li>In SCM, select Git.</li><li>In the Repository URL, enter your GitHub repository URL (e.g., <a href="https://github.com/ISIKA2002/uptime-time-project.git).">https://github.com/ISIKA2002/uptime-time-project.git).</a></li><li>In Branch, enter the branch name (e.g., main).</li></ul><p><strong>Save</strong>:</p><ul><li>Click Apply and then Save to create your pipeline item.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6VKuoQ1qAhM0ABie9fURFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJxdxz0Dgv4ln9NoOZaVEA.png" /></figure><h3>8. Create Job for Uptime-Kuma</h3><ul><li><strong>Pipeline Script</strong>:</li></ul><pre>pipeline {<br>  agent any<br>  tools {<br>    jdk &#39;jdk17&#39;<br>    nodejs &#39;node18&#39;<br>  }<br>  environment {<br>    SCANNER_HOME = tool &#39;sonar-scanner&#39;<br>  }<br>  stages {<br>    stage(&#39;Checkout from Git&#39;) {<br>      steps {<br>        git branch: &#39;main&#39;, url: &#39;https://github.com/ISIKA2002/uptime-time-project.git&#39;<br>      }<br>    }<br>    stage(&#39;Install Dependencies&#39;) {<br>      steps {<br>        sh &quot;npm install&quot;<br>      }<br>    }<br>    stage(&#39;SonarQube Analysis&#39;) {<br>      steps {<br>        withSonarQubeEnv(&#39;sonar-server&#39;) {<br>          sh &#39;&#39;&#39; $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=uptime \<br>          -Dsonar.projectKey=uptime &#39;&#39;&#39;<br>        }<br>      }<br>    }<br>    stage(&#39;Quality Gate&#39;) {<br>      steps {<br>        script {<br>          waitForQualityGate abortPipeline: false, credentialsId: &#39;Sonar-token&#39;<br>        }<br>      }<br>    }<br>    stage(&#39;OWASP FS SCAN&#39;) {<br>      steps {<br>        dependencyCheck additionalArguments: &#39; - scan ./ - disableYarnAudit - disableNodeAudit&#39;, odcInstallation: &#39;DP-Check&#39;<br>        dependencyCheckPublisher pattern: &#39;**/dependency-check-report.xml&#39;<br>      }<br>    }<br>    stage(&#39;TRIVY FS SCAN&#39;) {<br>      steps {<br>        sh &quot;trivy fs . &gt; trivyfs.json&quot;<br>      }<br>    }<br>    stage(&#39;Docker Build &amp; Push&#39;) {<br>      steps {<br>        script {<br>          withDockerRegistry(credentialsId: &#39;docker&#39;, toolName: &#39;docker&#39;) {<br>            sh &quot;docker build -t uptime .&quot;<br>            sh &quot;docker tag uptime isika05/uptime:latest&quot;<br>            sh &quot;docker push isika05/uptime:latest&quot;<br>          }<br>        }<br>      }<br>    }<br>    stage(&#39;TRIVY&#39;) {<br>      steps {<br>        sh &quot;trivy image isika05/uptime:latest &gt; trivy.json&quot;<br>      }<br>    }<br>    stage(&#39;Remove container&#39;) {<br>      steps {<br>        sh &quot;docker stop uptime || true&quot;<br>        sh &quot;docker rm uptime || true&quot;<br>      }<br>    }<br>    stage(&#39;Deploy to container&#39;) {<br>      steps {<br>        sh &#39;docker run -d - name chatbot -v /var/run/docker.sock:/var/run/docker.sock -p 3001:3001 isika05/uptime:latest&#39;<br>      }<br>    }<br>  }<br>}</pre><p><em>NOTE:</em> You can mention the names of each tool as per your details given in the Jenkins management console tool (e.g., JDK 17, NodeJS 18, SonarQube Scanner, Dependency-Check, Docker).</p><h3>Push the Code to GitHub</h3><ol><li><strong>Clone the Repository (if not already cloned)</strong>:</li></ol><pre>git clone https://github.com/ISIKA2002/uptime-time-project.git cd uptime-time-project</pre><p><strong>Make Changes to the Code</strong>:</p><ul><li>Edit or add files as needed.</li></ul><p><strong>Stage the Changes</strong>:</p><pre>git add .</pre><p><strong>Commit the Changes</strong>:</p><pre>git commit -m &quot;Your commit message&quot;</pre><p><strong>Push the Changes</strong>:</p><pre>git push origin main</pre><h3>Run the Pipeline</h3><p><strong>Trigger the Pipeline</strong>:</p><ul><li>Go to your Jenkins Dashboard.</li><li>Click on your job (e.g., Uptime-Kuma Pipeline).</li><li>Click <strong>Build Now</strong>.</li></ul><p><strong>Monitor the Pipeline Execution</strong>:</p><ul><li>You can monitor the stages and steps in real-time in the Jenkins job console output.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*k0_UDKiIFERcl69RO_-wTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*uTbJNseeCxK7QIRjvfntUw.png" /></figure><p><strong>Jenkins Pipeline Steps</strong></p><p><strong>Git Checkout</strong>:</p><ul><li>The pipeline starts with checking out the code from the specified Git repository.</li></ul><p><strong>Tool Install</strong>:</p><ul><li>Necessary tools like JDK and NodeJS are installed using Jenkins’ tool management.</li></ul><p><strong>Git Pull</strong>:</p><ul><li>Updates the local repository with any changes from the remote repository.</li></ul><p><strong>NPM Install</strong>:</p><ul><li>Installs dependencies specified in the package.json file using npm.</li></ul><p><strong>SonarQube Analysis</strong>:</p><ul><li>Conducts static code analysis using SonarQube to evaluate code quality and security issues.</li></ul><p><strong>Quality Gate</strong>:</p><ul><li>Checks if the defined quality gate criteria are met before proceeding further.</li></ul><p><strong>OWASP Dependency Check</strong>:</p><ul><li>Scans for known vulnerabilities in project dependencies using OWASP Dependency Check.</li></ul><p><strong>Trivy Filesystem Scan (FS)</strong>:</p><ul><li>Scans the filesystem for vulnerabilities using Trivy.</li></ul><p><strong>Docker Build and Push</strong>:</p><ul><li>Builds the Docker image for the application and pushes it to DockerHub or another registry.</li></ul><p><strong>Trivy Image Scan and Deploy to Docker</strong>:</p><ul><li>Scans the Docker image for vulnerabilities using Trivy and deploys it to Docker, ensuring security compliance.</li></ul><p>This sequence illustrates the workflow of your Jenkins pipeline from code checkout to deployment, ensuring comprehensive testing and security checks throughout the process.</p><h3>9. View SonarQube Results</h3><p>After the pipeline runs, you can view the SonarQube analysis results directly in the SonarQube dashboard. The SonarQube dashboard will display detailed metrics, including code quality, bugs, vulnerabilities, code smells, and coverage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CAZ-BK_3iFMnzg0Nb1eMTA.png" /></figure><h3>10. Create a Twilio Account</h3><p><strong>Visit Twilio Website</strong>:</p><ul><li>Go to the <a href="https://www.twilio.com/">Twilio website</a>.</li></ul><p><strong>Sign Up for a New Account</strong>:</p><ul><li>Click on Sign Up in the top right corner.</li><li>Fill out the required information: your name, email, and password.</li><li>Click Start your free trial.</li></ul><p><strong>Verify Your Email</strong>:</p><ul><li>Check your email inbox for a verification email from Twilio.</li><li>Click on the verification link in the email.</li></ul><p><strong>Complete Your Profile</strong>:</p><ul><li>Log in to Twilio.</li><li>Complete the setup process by providing your phone number for verification.</li></ul><p><strong>Get Your Twilio Credentials</strong>:</p><ul><li>Once logged in, navigate to the Twilio Console.</li><li>Copy your Account SID and Auth Token from the dashboard.</li><li>Note your Twilio phone number, which you’ll use for sending notifications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*I1tbl2OZY9ulxVpFHfp2Rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pO8FOayWoapIC2QBuayegg.png" /></figure><h3>11. Update app.py for Twilio in AWS</h3><p><strong>Connect to AWS Console</strong>:</p><ul><li>Log in to your AWS Management Console.</li><li>Navigate to your EC2 instance where your Uptime-Kuma project is running.</li></ul><p><strong>Access Project Directory</strong>:</p><ul><li>Go to the directory of your project:</li></ul><pre>cd /path/to/uptime-kuma-project/Webhook</pre><p><strong>Edit </strong><strong>app.py</strong>:</p><ul><li>Open the app.py file for editing:</li></ul><pre>nano app.py</pre><p>Update the account_sid, auth_token, numbers_to_call, and from_ values with your Twilio details:</p><pre>from flask import Flask<br>from twilio.rest import Client<br><br>app = Flask(__name__)<br><br>@app.route(&#39;/trigger-call&#39;, methods=[&#39;GET&#39;, &#39;POST&#39;])<br>def trigger_call():<br>    account_sid = &#39;&lt;acc-sid&gt;&#39;<br>    auth_token = &#39;&lt;acc-auth&gt;&#39;<br>    client = Client(account_sid, auth_token)<br>    <br>    # List of numbers to call<br>    numbers_to_call = [&#39;&lt;country-code-number&gt;&#39;, &#39;&lt;country-code-number&gt;&#39;]<br>    call_sids = [] # To store Call SIDs<br>    <br>    for number in numbers_to_call:<br>        call = client.calls.create(<br>            twiml=&#39;&lt;Response&gt;&lt;Say&gt;&quot;Change alert message here&quot;&lt;/Say&gt;&lt;/Response&gt;&#39;,<br>            to=number,<br>            from_=&#39;&lt;twilio-number&gt;&#39;<br>        )<br>        call_sids.append(call.sid)<br>    <br>    # Joining all the Call SIDs to return in response<br>    call_sids_str = &#39;, &#39;.join(call_sids)<br>    return f&quot;Call initiated with SIDs: {call_sids_str}&quot;, 200<br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;0.0.0.0&#39;, port=5000)</pre><p><strong>Save and Exit</strong>:</p><ul><li>Save the file and exit the editor (Ctrl + X, then Y, and Enter).</li></ul><p><strong>Install Dependencies on Server</strong>:</p><ul><li>Install necessary packages:</li></ul><pre>sudo apt install python3-pip <br>sudo apt install python3.12-venv</pre><ul><li>Create and activate a virtual environment:</li></ul><pre>python3 -m venv venv <br>source venv/bin/activate</pre><ul><li>Install the required Python packages:</li></ul><pre>pip install -r requirements.txt</pre><p><strong>Create and Run Docker Webhook</strong>:</p><ul><li>Build the Docker image:</li></ul><pre>cd /path/to/uptime-kuma-project/Webhook <br>docker build -t webhook .</pre><ul><li>Run the Docker container:</li></ul><pre>docker run -d --name webhook -p 5000:5000 webhook:latest</pre><ul><li>The webhook will now be running on port 5000.</li></ul><h3>12. Setup Uptime-Kuma Notifications</h3><p><strong>Copy Public IP and Login to Uptime-Kuma</strong>:</p><ul><li>Obtain the public IP address of your server and ensure port 3001 is accessible.</li><li>Open a web browser and go to http://&lt;public_ip&gt;:3001.</li><li>Log in to Uptime-Kuma.</li></ul><p><strong>Configure Notifications</strong>:</p><ul><li>Go to your profile by selecting <strong>Profile</strong> → <strong>Settings</strong>.</li><li>Under <strong>Notifications</strong>, select <strong>Setup Notification</strong>.</li><li>Choose <strong>Notification Type</strong> as <strong>Webhook</strong>.</li><li>Provide a friendly name and enter the URL of the webhook (e.g., http://&lt;public_ip&gt;:5000/trigger-call).</li><li>Click <strong>Save</strong>.</li></ul><p><strong>Enable Notifications for a Service</strong>:</p><ul><li>From the Uptime-Kuma dashboard, select a service to monitor.</li><li>Click <strong>Edit</strong> on the selected service.</li><li>Turn on <strong>Notification</strong> to enable alerts.</li><li>Save the changes.</li></ul><p><strong>Receive Notifications</strong>:</p><ul><li>You will receive a call when the server or service goes down.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*VymZ1ErVuzgZfHcws_DX5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*uX2H5RFp-E_iAD4-9Heftg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*3F0juOK3x5zOaLQqj0DXBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*iym6N2YMKwL389elmFouYw.png" /></figure><p><strong>Remove Server</strong>:</p><ul><li>When you’re done testing, you can remove the server by stopping and removing the Docker container:</li></ul><pre>docker stop webhook <br>docker rm webhook</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0735c18ad87" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>