CLI tool imports a raw disk image as an EBS snapshot and registers it as an EC2 AMI. Uses EBS Direct API.
I built this prototype because local OS image creation had stopped being the slow part. mkosi can build a tailored Linux disk image in a matter of seconds, but pushing those into AWS as AMIs still took several minutes per attempt:
- import-snapshot is reliable and requires very little setup, but was too slow for a tight build-run-debug cycle, sometimes up to 12 minutes even for small images.
- the faster
S3 -> tiny EC2 -> EBS -> snapshot1 path still meant waiting a few minutes after every kernel option or boot script change
The EBS Direct API provides a faster path: stream the disk blocks straight into a snapshot, then register the AMI, typically in tens of seconds.
The tradeoff is cost: PutSnapshotBlock pricing is $0.006 per 1,000 requests, or about 1.2 cents per GiB written.
Usage: ami-direct [flags] <input-file>
<input-file> must be a raw disk image
Flags:
-arch string
AMI architecture (default "x86_64")
-description string
description for the snapshot and AMI
-name string
AMI name; also used as the default Name tag
-no-ami
only create the snapshot; do not register an AMI
-no-overwrite
fail if an AMI with the same name already exists
-tag value
tag in Key=Value form; applied to the snapshot and AMI; repeatable
-workers int
number of concurrent upload workers (1-20) (default 20)
Footnotes
-
EBS Surrogate as Packer calls it ↩