mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* feat(ec2): support CreateImage from an instance Validates the source instance exists, then registers an image the same way RegisterImage does. Unblocks AMI-baking flows (e.g. CDK AwsCustomResource calling ec2:CreateImage on a stack-created instance). Fixes #1978 * fix(ec2): CreateImage reboots the source and produces a launchable AMI Two review findings. CreateImage ignored the default reboot. AWS reboots the source instance unless NoReboot=true so the image is captured from a quiesced file system; the action only checked that the instance existed. NoReboot is now parsed and the reboot runs by default. The resulting AMI kept nothing of what it was captured from. registerImage was called with null architecture, root device and block device mappings, so DescribeImages reported a generic x86_64 /dev/sda1 image with no devices, and RunInstances on the new id fell through to the catalog default guest because a generated ami-* is not in the catalog. The image now inherits architecture, root device name and block device mappings from the source instance's image, and records the launchable ancestor so RunInstances starts the same guest. CreateImage on an instance launched from a created AMI follows the chain back. Tests: unit coverage for the reboot default and its NoReboot opt-out, and for chained images resolving to the catalog ancestor rather than the generated id; integration coverage that an arm64 source yields an arm64 AMI that launches. * fix(ec2): a capture of a catalog AMI reports its root device CreateImage inherits the source image's block device mappings, but a catalog entry describes only its root device name and carries no mappings, so an AMI captured from a catalog-launched instance was registered with no devices and DescribeImages reported none. The root device is now rebuilt from the catalog entry, with a snapshot registered through the existing RegisterImage path. * fix(ec2): a capture takes its own snapshot of each device CreateImage handed the source AMI's mappings straight to RegisterImage, so the captured image reported the source's snapshot ids and the two images shared one snapshot. The mappings are now copied with fresh snapshot ids, keeping the device name, size, type and encryption. * fix(ec2): a capture includes the volumes attached after launch CreateImage read only the mappings of the AMI the instance was launched from, so a data volume attached afterwards was missing from the captured image. AWS records block device mapping information for those volumes as well. The instance's attached volumes are now added to the capture, each with its device name, size, type and a fresh snapshot. The root volume is skipped because the source AMI already describes that device. Also lists CreateImage and RegisterImage in the AMIs action table. That table is hand-maintained because Ec2QueryHandler is a deferred handler. * fix(ec2): a capture reports the root volume type the source actually has The catalog-source fallback in sourceImageMappings recorded the rebuilt root device as gp2, while RunInstances creates the source instance's root volume as gp3. DescribeImages therefore reported a type the instance never had. Both sites now read one DEFAULT_ROOT_VOLUME_TYPE constant, alongside the existing DEFAULT_ROOT_VOLUME_SIZE_GIB, so the two cannot drift apart again.