Repository navigation
Description
Filed as the spawn-side primitive that nf-spawn#45 depends on (consumer-facing ext.volumes). nf-spawn can't implement per-process data volumes until spawn launch can attach one, so this lands first.
Request
Let spawn launch attach an additional EBS volume created from a snapshot, mounted at a given path (optionally read-only), on a stock AMI — so large reference data (the motivating case: a ~16 GB Kraken2 k2_pluspf DB for nf-core/taxprofiler) doesn't have to be baked into a custom AMI.
Proposed surface (repeatable):
spawn launch ... --attach-volume snap-0abc123:/opt/databases/kraken2:ro
Format snapshot:mountpoint[:ro]. Allow multiple. (Could also accept a bare size for a fresh blank volume later, but snapshot-backed is the use case here.)
Why not the existing storage flags
--volume-size is root-only. --efs-id / --fsx-id / --fsx-create exist but are a different access model (shared network filesystem, separate lifecycle). For a read-only reference blob that wants to be local block storage and created-once-from-snapshot, an attached EBS volume is the right primitive — and it's the one piece spawn is missing.
Where it plugs in (confirmed in the code)
- Flag + config —
cmd/launch.go(~line 216, by--volume-size); add toLaunchConfiginpkg/aws/client.go:102(e.g.AttachVolumes []AttachVolumeSpec{SnapshotID, MountPoint, ReadOnly}). - Block-device mapping —
pkg/aws/client.go:buildBlockDevices(~line 658) currently emits only the root/dev/xvda. Append one BDM per attach spec:DeviceName(e.g./dev/sdf,/dev/sdg, …),Ebs{SnapshotId, DeleteOnTermination:true, VolumeType:gp3}. Note the Nitro wrinkle: on Nitro instances the requested/dev/sdfshows up as an NVMe device (/dev/nvme1n1…) with a non-deterministic order — the mount step must resolve the real device (by volume-id vianvme id-ctrl/lsblk, or by the EBS volume tag), not assume/dev/sdf. - Mount in user-data —
pkg/userdata/storage.goalready has FSx/EFS mount templates and aStorageConfig; add an attached-EBS branch: resolve the NVMe device for each snapshot's volume,mkdir -p <mount>,mount -o ro,noatime(or rw)<dev> <mount>, append to/etc/fstabwith_netdev-equivalent ordering, and (if rw blank)mkfs— but for snapshot-backed RO, never mkfs. - Tags — write
spawn:attached-volume-*tags viabuildTagsso the reaper/inventory see them (and so the auto-created volumes are cleaned with the instance —DeleteOnTermination:truealready covers the EBS lifecycle).
Cost / lifecycle notes
- The attached volume is created from the snapshot at launch and should set
DeleteOnTermination: trueso it dies with the ephemeral instance (the lifecycle invariant — "everything dies eventually"). The snapshot persists and is reused; each task gets a fresh cheap copy. - A read-only reference volume mounted by many concurrent task instances = many EBS volumes from one snapshot; that's expected and is the cost the user is explicitly trading against per-task S3 download / oversized root volumes.
Validation
- Unit: flag parsing (
snap:mount:ro→ spec; multiple; bad forms rejected),buildBlockDevicesappends the snapshot BDMs with distinct device names, storage user-data emits the RO mount + NVMe device resolution + no mkfs for snapshot-backed. - Live (paid, TTL + terminate + leak-check per the cost rule): launch a stock AL2023 arm64 instance with
--attach-volume <kraken2-snap>:/opt/databases/kraken2:ro, confirm the DB is present and read-only at the mount, terminate, and verify the auto-created data volume is gone (DeleteOnTermination) — no leaked volumes or snapshots.
Cross-refs
- Consumer/feature request: nf-spawn#45 (
ext.volumesper process → forwards to this flag). - Tradeoff analysis the filer wrote lives in the aws-microbiome-demo repo at
docs/ami-vs-data-volume.md.
Activity
feat: attach EBS data volume from a snapshot at launch (#144) (#145)
feat: spawn snapshot create — build EBS snapshot via EBS direct APIs (#…