Code Monkey home page Code Monkey logo

erankitcs / aws_asg_serverless_instancerefresh Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 484 KB

This project is created to build a serverless CICD pipeline to create AMI using Packer and ASG Instance refresh. We would be using HashiCorp Packer to create AMI and create a notification to kick start serverless ASG Instance refresh.

License: MIT License

Python 17.95% HCL 79.57% Shell 2.48%
packer hashicorp-packer ami aws awslambda cicd autoscaling-groups automation

aws_asg_serverless_instancerefresh's Introduction

Packer Image Build and AWS ASG Instance Refresh(Serverless Way)

This project is created to build a serverless CICD pipeline for ASG Instance refresh. We would be using HashiCorp Packer to create AMI and create notification to kick start serverless ASG Instance refresh.

Pre Setup

Update terraform_iac/inputs.tfvars file with below details

  1. Your Repository Name
  2. Owner of the Repository
  3. AWS Profile which has access to deploy resources.
  4. Git Hub token. It can any secret string.
  5. Region
  6. Email Ids for notification (Inform of string seperated by ,)
  7. OauthToken generated from your Github account.
  8. VPC Id
  9. A base AMI for intial deployment of ASG. It will be used in Packer as base ami.
  10. Key Pair for EC2 instances.

Run Terraform to deploy Web ASG and serverless setup to automation for ASG instance refresh.

  • cd terraform_iac
  • terraform init
  • terraform plan -var-file="inputs.tfvars"
  • terraform apply -var-file="inputs.tfvars"
  • note down Web Server URL from Terraform Output

Initiate Image Build CI/CD to new Image build and automated ASG Instance Refresh

  • update ami_build_packer/scripts/web_ami_setup.sh script with new version.
  • push code into github

Once code is pushed into GitHub. GitHub Webhook will kick start AWS CodePipeline and AWS CodeBuild will start EC2 AMI creation with Packer. Once AMI Creation is complete, Serverless Lambda will start Autoscaling Group instance refresh without any downtime.

  • Note: If your Codepipeline is failing connect with GitHub then login into AWS and Authenticate Github from Codepipeline source setup screen.

Architecture Design

Screenshot

Install Packer(Locally for test)

  • Learn more: https://learn.hashicorp.com/tutorials/packer/getting-started-install
  • install choco install packer
  • Verify: packer

Run packer to build image(Locally for test)

  • cd ami_build_packer
  • packer build -var "base_ami=<BASE_AMI_HERE>" images/web_ami_image.json

aws_asg_serverless_instancerefresh's People

Contributors

erankitcs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

thulasya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.