A sealed image mode system gives you something unusual: Cryptographic verification of every file on the root filesystem, anchored all the way back to UEFI firmware. If you've followed the bootc sealed images blog series, then you've seen how the chain of trust works and how to build and test a sealed image locally with bcvk. This article takes the next step: Deploying that same sealed image to AWS EC2 with your own custom UEFI secure boot keys.
The challenge is that AWS handles UEFI firmware differently than a local VM. You can't just hand EC2 an OVMF variables file the way bcvk uses virt-fw-vars. Instead, you need to build a UEFI variable store blob offline and pass it to AWS when registering your AMI. This article walks through that workflow end to end, from building an AWS-specific image to verifying that composefs is enforcing verity=require on a running EC2 instance.
What's different about AWS
If you've been testing sealed images locally with bcvk, 3 things change when you move to AWS EC2:
- Console device: EC2 x86_64 instances use
ttyS0for their serial console, not the virtiohvc0that QEMU andbcvkuse. Since the console kernel argument is baked into the signed UKI at build time, this means building a separate image for AWS. The example Containerfile is parameterized with build ARGs so you can produce both variants from a single file. - SSH access:
bcvkinjects SSH keys as systemd credentials with SMBIOS. EC2 uses instance metadata instead, which means the image needs cloud-init to pick up SSH keys at boot. This is another build ARG that addscloud-initto the sealed rootfs for the AWS variant. - UEFI Secure Boot key enrollment: This is the big one. When
bcvkcreates a local VM, it usesvirt-fw-varsto inject your PK, KEK, and db certificates directly into the OVMF firmware variables. EC2 doesn't expose its firmware that way. Instead, AWS supports passing a pre-built UEFI variable store blob when you register an AMI usingaws ec2 register-image. You build this blob offline using python-uefivars from AWS Labs. The key management post covers the UEFI key hierarchy in detail if you need a refresher on platform key (PK), key exchange key (KEK), and signature database (db).
Prerequisites
You need an AWS account with credentials configured (aws sts get-caller-identity is enough). Your build host also needs a Red Hat subscription visible to Podman, because the image build pulls packages from Red Hat Enterprise Linux (RHEL) repositories inside the container. A no-cost developer subscription is sufficient.
Install the required tools:
- Podman
- OpenSSL
justbcvk(for disk image creation)awsjq- coldsnap (for uploading disk images as EBS snapshots, using
cargo install –locked coldsnap) cert-to-efi-sig-listfromefitoolspython-uefivars
Clone the examples repository at the aws-sealing tag to follow along:
$ git clone --branch aws-sealing \ https://github.com/redhat-cop/rhel-bootc-examples.git$ cd rhel-bootc-examples/sealingThe Justfile includes a _check-aws-deps recipe to validate that all tools and credentials are present before any AWS recipe runs, so you get clear error messages if anything is missing.
The workflow
The AWS test is structured as a chain of idempotent Justfile recipes, each building on the previous:
- Keygen
aws-buildaws-diskaws-snapshotaws-registeraws-launchaws-test
After just keygen, a single command does the rest. You can run just aws-test to execute the entire chain, or run any step individually. Each recipe checks whether its output already exists before doing work, so if a step fails partway through, re-running resumes from the point of failure.
Build the AWS image
Start by generating secure boot keys if you haven't already:
just keygenThen build the AWS-specific image:
just aws-buildThis runs podman build with 2 build ARGs that differentiate it from the local image:
console_kargs="console=ttyS0,115200"targets the EC2 serial consoleextra_packages="cloud-init"enables SSH key injection with instance metadata
The resulting image uses the same multi-stage Containerfile as the local variant. The signed UKI contains a different composefs digest because the filesystem now includes cloud-init, but the security model is identical: Your db key signs both systemd-boot and the UKI, and the composefs digest embedded in the UKI covers every file on the root filesystem. The building a sealed image post covers this build process in detail.
Create the disk image and upload as an EBS snapshot
With the container image built, create a raw disk image:
just aws-diskThis calls bcvk to-disk to install the container image onto a raw disk with an ext4 root filesystem. Ext4 is required here because the default XFS does not support fs-verity. The output is target/aws-disk.raw.
Next, upload the disk directly as an EBS snapshot:
just aws-snapshotThis uses coldsnap, a command from AWS Labs that uploads a disk image directly as an EBS snapshot.
Enroll secure boot keys and register the AMI
This is the AWS-specific piece that has no equivalent in the local bcvk workflow. Register an AMI from the snapshot with your custom secure boot keys enrolled:
just aws-registerAWS documents 2 approaches for creating an AMI with UEFI Secure Boot:
- Enrolling keys from inside a running instance
- Providing a pre-built variable store blob at AMI registration time
This recipe uses a pre-built variable store. Because we sign our boot images at build time, they are already signed before enrollment, satisfying that option's requirement.
The recipe converts your PEM certificates to EFI signature lists using cert-to-efi-sig-list:
cert-to-efi-sig-list -g "$(cat target/keys/GUID.txt)" target/keys/PK.crt PK.esl
cert-to-efi-sig-list -g "$(cat target/keys/GUID.txt)" target/keys/KEK.crt KEK.esl
cert-to-efi-sig-list -g "$(cat target/keys/GUID.txt)" target/keys/db.crt db.eslThen it assembles them into an AWS-format UEFI variable store blob using python-uefivars:
uefivars -i none -o aws -O target/uefi-data.bin -P PK.esl -K KEK.esl --db db.eslFinally, it registers the AMI with the blob:
aws ec2 register-image \
--boot-mode uefi \
--uefi-data "$(cat target/uefi-data.bin)" \
--block-device-mappings "DeviceName=/dev/sda1,Ebs={SnapshotId=snap-xxx,...}" \
...The --uefi-data parameter populates the instance's UEFI firmware variable store with your PK, KEK, and db certificates. When the instance boots, the firmware is in user mode with secure boot enforced, and it only loads boot binaries signed by your db key. Only your db certificate is enrolled. There is no Microsoft UEFI CA and the dbx (revocation list) is empty, so the instance exclusively boots binaries you have signed. Without this step, the firmware would be in setup mode, and secure boot wouldn't be enforced.
Launch and verify
With the AMI registered, launch an instance and verify the seal:
just aws-launchThis creates an ephemeral EC2 key pair and security group, launches the instance, and waits for SSH to become available. All created resource IDs are tracked in target/aws-resources.json for cleanup.
Then run the verification:
just aws-testThe test SSHes into the instance and checks 4 things:
--- kernel ---
6.12.0-211.73.1.el10_2.x86_64
--- secure boot ---
Secure Boot: enabled (user)
OK: Secure Boot is enabled
--- root mount ---
composefs:aee2f550... on / type overlay (ro,verity=require,...)
OK: composefs root with verity=require
--- cmdline ---
composefs=aee2f550... rw console=ttyS0,115200 ...
=== COMPOSEFS BOOT VERIFIED (AWS) ===The secure boot check confirms that the UEFI firmware is in user mode and enforcing signature verification. It only loads boot binaries signed by your db key. The verity=require in the root mount confirms that the kernel is verifying every file read against its fs-verity digest. And the composefs=<digest> in the kernel command line confirms that the UKI delivered the correct digest to the initramfs. The deploying and verifying post covers these same checks for local VMs.
After verification, aws-test automatically tears down all AWS resources with a trap. If you need to clean up manually (for example, after an aws-ssh session), run just aws-clean.
Running the full flow
For a complete end-to-end test, after generating keys with just keygen, a single command does the rest:
just aws-testIf any step fails, re-run the same command. The recipes check for existing outputs (disk image, snapshot, AMI, running instance) and skip completed steps. This makes the workflow resilient to transient failures.
Several environment variables let you customize the behavior:
AWS_REGION
- Default: From
aws configure - Description: AWS region for all operations
AWS_INSTANCE_TYPE
- Default: m5.large
- Description: EC2 instance type (must support UEFI)
AWS_SUBNET_ID
- Default: Default VPC subnet
- Description: Subnet to launch in
AWS_SECURITY_GROUP_ID
- Default: Auto-created
- Description: Security group with SSH access
AWS_SSH_USER
- Default: cloud-user
- Description: SSH username (
cloud-initdefault for RHEL)
Wrapping up
The same chain of trust that works on a local VM now runs on AWS EC2. The UEFI firmware verifies systemd-boot against your enrolled db certificate. systemd-boot loads the signed UKI, which carries the composefs digest in its kernel command-line. The initramfs mounts the root as a composefs overlay with verity=require. Every subsequent file read is verified by the kernel against its fs-verity digest. A tampered file returns an I/O error – corrupted data is never served to userspace.
The examples repository provides the full workflow in a set of composable, resumable Justfile recipes. For the foundational concepts, start with the sealed images blog series. To learn more about how image mode for RHEL delivers container-native OS management, see the RHEL image mode product page.