Coder Social home page Coder Social logo

thresheek / alpine-ec2-ami Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exordian/alpine-ec2-ami

0.0 2.0 0.0 125 KB

Packer builder and scripts to create an EC2 optimized Alpine Linux AMI

License: MIT License

Makefile 11.68% Shell 86.07% Roff 2.25%

alpine-ec2-ami's Introduction

Alpine Linux EC2 AMI Builder

NOTE: This is not an official AWS or Alpine project. This is community built and supported.

Pre-Built AMIs

To get started with one of our pre-built minimalist AMIs, please refer to the README in the releases subdirectory.

Alternately, with the right filters, you can query the EC2 API to programmatically find our most recent AMIs. For example, using the aws command line tool...

aws ec2 describe-images \
  --output text \
  --filters \
    Name=owner-id,Values=538276064493 \
    Name=name,Values='alpine-ami-*' \
    Name=state,Values=available \
    Name=tag:profile_build,Values=v3_10-x86_64 \
  --query 'max_by(Images[], &CreationDate).ImageId'

...will list the latest AMI id from our collection of 'v3_10-x86_64' builds. Refer to the AWS CLI Command Reference for describe-images for more details.

Custom AMIs

Using the scripts and configuration in this project, you can build your own custom Alpine Linux AMIs. If you experience any problems building custom AMIs, please open an issue and include as much detailed information as possible.

Build Requirements

  • Packer >= 1.4.1
  • Python 3.x (3.7 is known to work)
  • make (GNU Make is known to work)
  • an AWS account with an existing subnet in an AWS Virtual Private Cloud

Profile Configuration

Target profile config files reside in the profiles subdirectory, where you will also find the config we use for our pre-built AMIs. Refer to the README in that subdirectory for more details and information about how AMI profile configs work.

AWS Credentials

These scripts use the boto3 library to interact with AWS, enabling you to provide your AWS account credentials in a number of different ways. see the offical boto3 documentation's section on configuring credentials for more details. Please note that these scripts do not implement the first two methods on the list.

Building AMIs

To build all build targets in a target profile, simply...

make PROFILE=<profile>

You can also build specfic build targets within a profile:

make PROFILE=<profile> BUILDS="<build1> <build2>"

If the packer binary is not in your PATH, or you would like to specify a different one, use...

make PACKER=<packer-path> PROFILE=<profile>

Before each build, new Alpine Linux releases are detected and the version's core profile is updated.

If there's already an AMI with the same name as the profile build's, that build will be skipped and the process moves on to build the other profile's build targets (if any).

After each successful build, releases/<profile>.yaml is updated with the build's details, including (most importantly) the ids of the AMI artifacts that were built.

Additional information about using your custom AMIs can be found in the README in the releases subdirectory.

Pruning AMIs

Every now and then, you may want to clean up old AMIs from your EC2 account and your profile's releases/<profile>.yaml. There are three different levels of pruning:

  • revision - keep only the latest revision for each release
  • release - keep only the latest release for each version
  • version - remove any end-of-life versions

To prune a profile (or optionally one build target of a profile)...

make prune LEVEL=<level> PROFILE=<profile> [BUILD=<build>]

Any AMIs in the account which are "unknown" (to the profile/build target, at least) will be called out as such, but will not be pruned.

Updating the Release README

This make target updates the releases README, primarily for updating the list of our pre-built AMIs. This may-or-may-not be useful for other target profiles.

make release-readme PROFILE=<profile>

Cleaning up the Build Environment

make clean will remove the temporary build subdirectory, which contains the resolved profile and Packer configs, the Python virtual environment, and other temporary build-related artifacts.

Caveats

  • New Alpine Linux versions are currently not auto-detected and added as a core version profile; this process is, at the moment, still a manual task.

  • Although it's possible to build "aarch64" (arm64) AMIs, they don't quite work yet.

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.