Free — no signup required

Resource Allocation: Stealing from the Parent

2 min read

How Enclaves Get Their Resources

Enclaves do not get resources from thin air. Every vCPU and every megabyte of RAM assigned to an enclave is permanently removed from the parent EC2 instance for the duration of the enclave's life. This has important operational implications.

The Nitro Enclaves allocator service on the parent instance manages this reservation. You configure it by editing /etc/nitro_enclaves/allocator.yaml:

# /etc/nitro_enclaves/allocator.yaml
version: 1
memory_mib: 2048      # Reserve 2 GB for enclaves on this instance
cpu_count: 2          # Reserve 2 vCPUs for enclaves on this instance

After editing, restart the allocator service to apply the new reservation.

Key constraints:
- You must reserve at least 2 vCPUs and 64 MiB of RAM for an enclave.
- The parent instance must have at least 4 vCPUs total (2 for itself, 2 for the enclave minimum).
- Not all instance types support Nitro Enclaves. You must use a Nitro-based instance (most modern instance families: M5, C5, R5, M6i, C6i, etc.) and enable enclave support at launch time via the --enclave-options 'Enabled=true' flag in the AWS CLI or the console.
- Memory reserved for the enclave is not available to the parent OS — it does not appear in free -m on the parent.

The Enclave Image File (EIF)

Your enclave application is packaged as an Enclave Image File (EIF) — a signed, self-contained binary that includes a minimal Linux kernel, an init ramdisk, and your application. You build it from a standard Docker image with a single nitro-cli build-enclave call naming the Docker image and the output file path.

The build output includes the PCR values for the image, which you will use in your KMS key policy:

Start building the Enclave Image...
Enclave Image successfully created.
{
  "Measurements": {
    "HashAlgorithm": "Sha384 { ... }",
    "PCR0": "a1b2c3d4e5f6...",
    "PCR1": "7890abcdef12...",
    "PCR2": "3456789012ab..."
  }
}
Interview Tip

A common interview question: "If you update your enclave application, what breaks?" The answer is: your KMS key policy. Updating the application changes PCR0 (and possibly PCR2). You must rebuild the EIF, capture the new PCR values, and update the KMS key policy condition before the new enclave can decrypt anything. This is a deliberate security property — it forces you to explicitly authorize new code versions — but it also means you need a deployment process that updates the KMS policy atomically with the enclave rollout.

This is one of 18 chapters

Get every chapter — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

See pricing