Coder Social home page Coder Social logo

packer-docker-ami-spike's Introduction

Packer

A quick spike of using Packer to build an image which runs a Docker container on boot.

Virtualbox

Commands

After copying and modifying the example env file:

cp .env.json.example .env.json
vim .env.json

Validation:

packer validate packer/template-virtualbox.json

Building with variables:

packer build packer/template-virtualbox.json

Once finished the created ova can be found in output-virtualbox-iso. You can log in with the username vagrant and password password

AMI

Commands

After copying and modifying the example env file:

cp .env.json.example .env.json
vim .env.json

Validation:

packer validate packer/template-ami.json

Building with variables:

packer build -var-file=.env.json packer/template-ami.json

Once finished the name of the AMI will be logged:

==> Wait completed after 7 minutes 55 seconds

==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
us-east-1: ami-0a6f11683b647ffe7

You can use this AMI to create a new ec2 instance and SSH in with the ubuntu username.

Exporting AMI as VMDK

Following the steps from https://docs.aws.amazon.com/vm-import/latest/userguide/vmexport_image.html to create the required IAM role.

Create the AMI role:

aws iam create-role --role-name vmimport --assume-role-policy-document "file://$(pwd)/packer/aws/trust-policy.json"

Create the AMI policy:

aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document "file://$(pwd)/packer/aws/role-policy.json"

Create a bucket:

aws s3api create-bucket --bucket packer-example-export-bucket --region us-east-1

Exporting VMDK:

aws ec2 export-image --image-id ami-0a6f11683b647ffe7 --disk-image-format VMDK --s3-export-location S3Bucket=packer-example-export-bucket,S3Prefix=exports/

Once finished the export will appear in the created exports bucket.

packer-docker-ami-spike's People

Contributors

alanfoster avatar

Watchers

James Cloos avatar  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.