Giter Club home page Giter Club logo

ami-bakery's Introduction

GumGum AMI Bakery (Public Edition)

By Corey Gale ([email protected])

Project Goals

  1. Automated, idempotent AMI builds with Packer AMIs are only re-built when their definition changes
  2. CI-friendly solution

Project Overview

To learn more about the GumGum AMI Bakery, checkout our slideshow!

Usage

Docker image: docker pull docker.io/mechtron/ami-bakery

To use the GumGum AMI Bakery in your CI environment, see the following configuration options:

Environment variables

To specify where the ephemeral Packer instance is launched:

  • AWS_DEFAULT_REGION
  • AWS_SUBNET_ID

To specify the AMI configuration files:

  • PACKER_JSON_PATH: path to the Packer JSON file
  • AMI_DEFINITION_DIRS: comma-separated list of directories containing the AMI's configuration code

Example

docker run --rm -t \
    -e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION \
    -e AWS_SUBNET_ID=$AWS_SUBNET_ID \
    -e PACKER_JSON_PATH=`pwd`/example-app/ami/packer/ami.json \
    -e AMI_DEFINITION_DIRS=`pwd`/example-app/ami/ \
    --mount type=bind,source=`pwd`,target=`pwd` \
    --mount type=bind,source=$HOME/.aws/,target=/root/.aws \
    docker.io/mechtron/ami-bakery:latest

Getting the AMI ID

In addition to the build's stdout, the new AMI ID is also outputted to the file .ami_id.json. Here's an example of the contents of that file:

{"ami_id": "ami-0d8ebf1e938f7f16e"}
Grab the AMI ID from Bash
cat .ami_id.json | jq .ami_id

Implementation Details

AMI Config Checksum Algorithm

To compute the desired "AMI Config Checksum" within the "Build AMI" container:

  1. Within the service's repository, get a list of all files contained in the AMI's passed configuration directories
  2. Sort the list of files alphabetically
  3. Calculate the SHA1 checksums of every file
  4. Concatenate the list of file checksums
  5. Calculate the SHA1 checksum of the concatenated list of checksums - this is the AMI Config Checksum

To look-up an AMI ID by AMI Config Checksum:

  1. List all AMIs tagged with the desired AMI Config Checksum (tag name is ami_config_checksum)
  2. If no AMIs exist with that AMI Config Checksum, build and tag a new AMI and return it's AMI ID
  3. If an AMI has already been built, return it's AMI ID. Should multiple AMIs exist with the same AMI Config Checksum, return the AMI ID of the newest image.

ami-bakery's People

Contributors

mechtron avatar

Watchers

James Cloos avatar Niz avatar  avatar

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.