Jenkins-AWS-CICD - Implement Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy, build a python flask web application.

Overview

Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy

Continuous integration and continuous deployment for a python flask web application.

Architecture

Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy

Installation

1. Launch an EC2 instance as config host, clone repository from Github

    git clone https://github.com/dragonflly/Jenkins-AWS-CICD.git

    Repository folder tree:

  └── Jenkins-AWS-CICD/
      ├── application
      ├── cfn-template
      ├── iam-resource
      ├── images
      └── README.md

2. Create flask web application repository in Github

  • Create a new repository in your Gitbub account (Example: Jenkins-app)
  • Clone Jenkins-app
    git clone https://github.com/
   
    /Jenkins-app.git

   

two repo

  • Copy flask web application to Jenkins-app, then push
    cp -r Jenkins-AWS-CICD/application/* Jenkins-app
    cd Jenkins-app
    git add .
    git commit -m "flask web initial"
    git push

3. Create SSH keyPair

  • Create a KeyPair on AWS console (Example: KeyPair-us-east-1 in us-east-1)

4. Create a CFN templates S3 bucket and upload templates

  • Create a S3 bucket (Example: jenkins-cicd-cfn-templates in us-east-1)
    aws s3api create-bucket --bucket jenkins-cicd-cfn-templates --region us-east-1
  • Copy CFN templates to the S3 bucket
    aws s3 cp Jenkins-AWS-CICD s3://jenkins-cicd-cfn-templates/Jenkins-AWS-CICD --recursive

5. Create whole AWS infrastructure as Code (IaC) with CloudFormation

  • Create stack from AWS CloudFormation console, specify template source by Amazon S3 URL
    https://jenkins-cicd-cfn-templates.s3.amazonaws.com/Jenkins-AWS-CICD/cfn-template/cicd-Jenkins.yaml
  • Specify stack input parameter from console
    Stack name: Jenkins-cicd
    KeyPairName: KeyPair-us-east-1
    TemplateS3Bucket: jenkins-cicd-cfn-templates

      It will takes approximately 6 minutes, and CloudFormation stack Outputs tab:
Jenkins CICD AWS IaC

6. Unlock Jenkins server, and initialize Jenkins

  • SSH into JenkinsServer with IP address and KeyPair-us-east-1
    Jenkins Server

  • Get initialAdminPassword

    cat /var/lib/jenkins/secrets/initialAdminPassword
  • Copy the JenkinsServerAddr value (Example: 34.205.33.197:8080) from the CloudFormation stack Outputs tab, and paste it into browser

  • Paste initialAdminPassword into Administrator password, unlock Jenkins server Unlock Jenkins server

  • Install suggested plugins
    Install suggested plugins

  • Create First Admin User
    Create First Admin User

  • Waiting a few minutes, Jenkins will be ready!

7. Add Jenkins plugin

  • Click on Manage Jenkins, then Manage Plugins
  • Search Available and select the below plugins, then choose Install without restart
    AWS CodeDeploy
    AWS CodeBuild
    Http Request
    File Operations

choose plugin

  • Choose Restart Jenkins when installation is complete
    Restart Jenkins

  • It will take couple of minutes to download the plugins then restart

8. Create a Jenkins CICD project

  • Choose New Item
    Enter an item name (Example: Jenkins-CICD)
    Select Freestyle project
    Create Freestyle project

  • Under Source Code Management
    Choose Git
    Enter HTTPS of Jenkins-app.git into Repository URL
    Change Branch Specifier from master to main
    SCM config

  • Under Build Triggers
    Select Poll SCM
    Enter H/2 * * * * into Schedule, to poll GitHub every two minutes
    build trigger

  • Under Build Environment
    Select Delete workspace before build starts
    build environment

9. Add AWS CodeBuild

  • Under Build
    Select Add build step
    Choose AWS CodeBuild
    Add CodeBuild step

  • Under AWS Configuration
    Choose Manually specify access and secret keys
    Input AWS Access Key
    Input AWS Secret Key
    input AK SK

  • Under Project Configuration
    Enter AWS Region (Example: us-east-1)
    Enter CodeBuild Project Name, copy from CloudFormation Outputs tab
    Select Use Jenkins source
    project configuration

10. Add File Operation

  • Under Build
    Select Add build step
    Choose File Operation

  • Under File Operation
    Select File Delete
    file delete

  • Under File Delete
    Input asterisk, to delete all files which from Github after zip and upload
    Input asterisk

11. Add HTTP Request

12. Add File Operation

  • Under Build
    Select Add build step
    Choose File Operation

  • Under File Operation
    Select Add, then Unzip
    Select Add, then File Delete

  • Under Zip File
    Enter codebuild-artifact.zip into Zip File

  • Under File Delete
    Enter codebuild-artifact.zip into Include File Pattern
    file zip delete

13. Add AWS CodeDeploy

  • Under Post-build Actions
    Select Add post-build action
    Choose Deploy an application to AWS CodeDeploy
    add CodeDeploy

  • Under Deploy an application to AWS CodeDeploy
    Fill AWS CodeDeploy Application Name which copied from Outputs tab
    Fill AWS CodeDeploy Deployment Group which copied from Outputs tab
    Fill AWS CodeDeploy Deployment Config with CodeDeployDefault.OneAtATime
    Fill AWS Region (Example: us-east-1)
    Fill S3 Bucket which copied from Outputs tab
    CodeDeploy config

  • Select Deploy Revision

  • Choose Wait for deployment to finish
    deploy revision

  • Click SAVE to finish configuration

14. Build and check

  • Click Build Now
    Check Jenkins CICD progress
    build and deploy

  • CICD finished, copy ALBURL from Outputs tab, paste into browser
    Python flask web application should be
    falsk application

  • In flask application repository Jenkins-app
    Change background-color from blue to red in application/templates/Jenkins-page.html
    Commit change, trigger CI/CD in two minutes
    falsk application

License Summary

This code is made available under the MIT license. See the LICENSE file.

A lobby boy will create a VPS server when you need one, and destroy it after using it.

Lobbyboy What is a lobby boy? A lobby boy is completely invisible, yet always in sight. A lobby boy remembers what people hate. A lobby boy anticipate

226 Dec 29, 2022
A system for managing CI data for Mozilla projects

Treeherder Description Treeherder is a reporting dashboard for Mozilla checkins. It allows users to see the results of automatic builds and their resp

Mozilla 235 Dec 22, 2022
RMRK spy bot for RMRK hackathon

rmrk_spy_bot RMRK spy bot https://t.me/RMRKspyBot for rmrk hacktoberfest https://rmrk.devpost.com/ Birds and items price and rarity estimation Reports

Victor Ryabinin 2 Sep 06, 2022
A curated list of awesome DataOps tools

Awesome DataOps A curated list of awesome DataOps tools. Awesome DataOps Data Catalog Data Exploration Data Ingestion Data Lake Data Processing Data Q

Kelvin S. do Prado 40 Dec 23, 2022
Asynchronous parallel SSH client library.

parallel-ssh Asynchronous parallel SSH client library. Run SSH commands over many - hundreds/hundreds of thousands - number of servers asynchronously

1.1k Dec 31, 2022
Google Kubernetes Engine (GKE) with a Snyk Kubernetes controller installed/configured for Snyk App

Google Kubernetes Engine (GKE) with a Snyk Kubernetes controller installed/configured for Snyk App This example provisions a Google Kubernetes Engine

Pas Apicella 2 Feb 09, 2022
Simple ssh overlay for easy, remote server management written in Python GTK with paramiko

Simple "ssh" overlay for easy, remote server management written in Python GTK with paramiko

kłapouch 3 May 01, 2022
DAMPP (gui) is a Python based program to run simple webservers using MySQL, Php, Apache and PhpMyAdmin inside of Docker containers.

DAMPP (gui) is a Python based program to run simple webservers using MySQL, Php, Apache and PhpMyAdmin inside of Docker containers.

Sehan Weerasekara 1 Feb 19, 2022
Ansible for DevOps examples.

Ansible for DevOps Examples This repository contains Ansible examples developed to support different sections of Ansible for DevOps, a book on Ansible

Jeff Geerling 6.6k Jan 08, 2023
Deploying a production-ready Django project using Nginx and Gunicorn

django-nginx-gunicorn This project is for deploying a production-ready Django project using Nginx and Gunicorn. Running a local server of Django is no

Arash Sayareh 8 Jul 03, 2022
Blazingly-fast :rocket:, rock-solid, local application development :arrow_right: with Kubernetes.

Gefyra Gefyra gives Kubernetes-("cloud-native")-developers a completely new way of writing and testing their applications. Over are the times of custo

Michael Schilonka 352 Dec 26, 2022
Bash-based Python-venv convenience wrapper

venvrc Bash-based Python-venv convenience wrapper. Demo Install Copy venvrc file to ~/.venvrc, and add the following line to your ~/.bashrc file: # so

1 Dec 29, 2022
Find-Xss - Termux Kurulum Dosyası Eklendi Eğer Hata Alıyorsanız Lütfen Resmini Çekip İnstagramdan Bildiriniz

FindXss Waf Bypass Eklendi !!! PRODUCER: Saep UPDATER: Aser-Vant Download: git c

Aser 2 Apr 17, 2022
Pulumi - Developer-First Infrastructure as Code. Your Cloud, Your Language, Your Way 🚀

Pulumi's Infrastructure as Code SDK is the easiest way to create and deploy cloud software that use containers, serverless functions, hosted services,

Pulumi 14.7k Jan 08, 2023
GitGoat enables DevOps and Engineering teams to test security products intending to integrate with GitHub

GitGoat is an open source tool that was built to enable DevOps and Engineering teams to design and implement a sustainable misconfiguration prevention strategy. It can be used to test with products w

Arnica 149 Dec 22, 2022
Nagios status monitor for your desktop.

Nagstamon Nagstamon is a status monitor for the desktop. It connects to multiple Nagios, Icinga, Opsview, Centreon, Op5 Monitor/Ninja, Checkmk Multisi

Henri Wahl 361 Jan 05, 2023
Tiny Git is a simplified version of Git with only the basic functionalities to gain better understanding of git internals.

Tiny Git is a simplified version of Git with only the basic functionalities to gain better understanding of git internals. Implemented Functi

Ahmed Ayman 2 Oct 15, 2021
Honcho: a python clone of Foreman. For managing Procfile-based applications.

___ ___ ___ ___ ___ ___ /\__\ /\ \ /\__\ /\ \ /\__\ /\

Nick Stenning 1.5k Jan 03, 2023
ZeroMQ bindings for Twisted

Twisted bindings for 0MQ Introduction txZMQ allows to integrate easily ØMQ sockets into Twisted event loop (reactor). txZMQ supports both CPython and

Andrey Smirnov 149 Dec 08, 2022
Dockerized iCloud drive

iCloud-drive-docker is a simple iCloud drive client in Docker environment. It uses pyiCloud python library to interact with iCloud

Mandar Patil 376 Jan 01, 2023