Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Creating your own EC2 AMIs Build with Packer, t...

Creating your own EC2 AMIs Build with Packer, test with Docker

Avatar for Andreas Rütten

Andreas Rütten

July 06, 2017
Tweet

More Decks by Andreas Rütten

Other Decks in Technology

Transcript

  1. Creating your own EC2 AMIs Build with Packer, test with

    Docker Andreas Rütten Smaato Team Review 2016-07-06
  2. What are AWS EC2 AMIs • Amazon Machine Image •

    Used to create new EC2 instances • A template for the root volume of an instance • Contains the OS and Software which should run on the EC2 instance 2
  3. Types of AMIs • Public AMIs ◦ AWS Marketplace ◦

    Community AMIs ◦ Paid or free • Private AMIs ◦ Grants launch permissions to a specific AWS account ◦ Copy of a public AMI ◦ Created by yourself 3
  4. Why creating your own AMI • Predefined collection of software

    and configuration • Just start an instance and everything is ready to run • No need for having a ConfigMgmt (Puppet, Chef, …) run at first boot 4
  5. Packer • Tool created by HashiCorp ◦ Like Vagrant, Terraform,

    Consul, … Packer is a tool for creating machine and container images for multiple platforms from a single source configuration. 5
  6. Packer Concepts • Builders ◦ Amazon EC2 AMI ◦ Azure

    ◦ DigitalOcean ◦ Docker ◦ Google Compute Engine ◦ VirtualBox ◦ … • Provisioners ◦ Ansible ◦ Chef ◦ Puppet ◦ Salt ◦ Shell ◦ File Upload ◦ … 6
  7. Packer Templates • Configuration file which defines what and how

    we want to build • Optional parts ◦ description ◦ post-processors ◦ variables 7
  8. Example Build Process Packer and Docker • Easy and fast

    for local tests • Uses the local Docker daemon 1. Starts local container 2. Runs provisioners inside 3. Commits and tags the image 4. Push to a registry (optional) 8
  9. Example Build Process Packer and Docker • Easy and fast

    for local tests • Uses the local Docker daemon 1. Starts local container 2. Runs provisioners inside 3. Commits and tags the image 4. Push to a registry (optional) Packer and AWS (amazon-ebs) • Creates AMIs in your AWS environment • Uses temp key pairs and sec groups 1. Starts an EC2 instance 2. Runs provisioners inside 3. Stops the instance 4. Creates the AMI based on that instance 5. Terminates the instance 9
  10. Things to be aware of • Different environments for build

    and run time ◦ Simple things like hostnames ◦ Instance type specific configuration ◦ … • Can be handled via a script or any config management system at first boot 11