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 cron monitoring tool written in Python & Django

Healthchecks Healthchecks is a cron job monitoring service. It listens for HTTP requests and email messages ("pings") from your cron jobs and schedule

Healthchecks 5.8k Jan 02, 2023
NixOps is a tool for deploying to NixOS machines in a network or cloud.

NixOps NixOps is a tool for deploying to NixOS machines in a network or the cloud. Key features include: Declarative: NixOps determines and carries ou

Nix/Nixpkgs/NixOS 1.2k Jan 02, 2023
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
Travis CI testing a Dockerfile based on Palantir's remix of Apache Cassandra, testing IaC, and testing integration health of Debian

Testing Palantir's remix of Apache Cassandra with Snyk & Travis CI This repository is to show Travis CI testing a Dockerfile based on Palantir's remix

Montana Mendy 1 Dec 20, 2021
CDK Template of Table Definition AWS Lambda for RDB

CDK Template of Table Definition AWS Lambda for RDB Overview This sample deploys Amazon Aurora of PostgreSQL or MySQL with AWS Lambda that can define

AWS Samples 5 May 16, 2022
Wiremind Kubernetes helper

Wiremind Kubernetes helper This Python library is a high-level set of Kubernetes Helpers allowing either to manage individual standard Kubernetes cont

Wiremind 3 Oct 09, 2021
IP address management (IPAM) and data center infrastructure management (DCIM) tool.

NetBox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. Initially conceived by the network engineering team a

NetBox Community 11.8k Jan 07, 2023
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
Jenkins-AWS-CICD - Implement Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy, build a python flask web application.

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

Ning 1 Jan 01, 2022
Kube kombu - Running kombu consumers with support of liveness probe for kubernetes

Setup and Running Kombu consumers Steps: Install python 3.9 or greater on your s

Anmol Porwal 5 Dec 10, 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
Tools for writing awesome Fabric files

About fabtools includes useful functions to help you write your Fabric files. fabtools makes it easier to manage system users, packages, databases, et

1.3k Dec 30, 2022
Ajenti Core and stock plugins

Ajenti is a Linux & BSD modular server admin panel. Ajenti 2 provides a new interface and a better architecture, developed with Python3 and AngularJS.

Ajenti Project 7k Jan 03, 2023
This is a tool to develop, build and test PHP extensions in Docker containers.

Develop, Build and Test PHP Extensions This is a tool to develop, build and test PHP extensions in Docker containers. Installation Clone this reposito

Suora GmbH 10 Oct 22, 2022
Remote Desktop Protocol in Twisted Python

RDPY Remote Desktop Protocol in twisted python. RDPY is a pure Python implementation of the Microsoft RDP (Remote Desktop Protocol) protocol (client a

Sylvain Peyrefitte 1.6k Dec 30, 2022
Hatch plugin for Docker containers

hatch-containers CI/CD Package Meta This provides a plugin for Hatch that allows

Ofek Lev 11 Dec 30, 2022
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Arie Bregman 35.1k Jan 02, 2023
🐳 Docker templates for various languages.

Docker Deployment Templates One Stop repository for Docker Compose and Docker Templates for Deployment. Features Python (FastAPI, Flask) Screenshots D

CodeChef-VIT 6 Aug 28, 2022
A tool to convert AWS EC2 instances back and forth between On-Demand and Spot billing models.

ec2-spot-converter This tool converts existing AWS EC2 instances back and forth between On-Demand and 'persistent' Spot billing models while preservin

jcjorel 152 Dec 29, 2022