Isolate workloads with AWS Nitro Sandboxes
AWS Nitro Sandboxes is an Amazon EC2 feature that runs a workload in its own lightweight virtual machine, called a Nitro Sandbox. A Nitro Sandbox runs alongside an Amazon EC2 instance, called the parent instance, on vCPUs and memory that the parent instance contributes. A virtual machine monitor (VMM) on the parent instance manages it, and the AWS Nitro System enforces the boundary around it. To use Nitro Sandboxes, you must enable AWS Nitro Enclaves when you launch the parent instance.
You can use Nitro Sandboxes in the following ways:
-
For containers on Amazon Elastic Kubernetes Service (Amazon EKS), the service runs each pod in its own Nitro Sandbox. For more information, see Sandboxing on Amazon EKS with isolated and confidential pods in the Amazon EKS User Guide.
-
For containers on Amazon Elastic Container Service (Amazon ECS), the service runs each task in its own Nitro Sandbox. For more information, see Isolated and confidential tasks in the Amazon Elastic Container Service Developer Guide.
-
With your own orchestrator on an Amazon EC2 instance, you launch Nitro Sandboxes with Firecracker. For more information, see Run Nitro Sandboxes with Firecracker.
For confidential workloads, you verify the attestation of each Nitro Sandbox with an AWS Key Management Service (AWS KMS) key policy, whichever way you launch it.
There are no additional charges for using Nitro Sandboxes. Nitro Sandboxes run on the vCPUs and memory of the parent instance, so you pay the standard charges for the Amazon EC2 instance and for the other AWS services that you use.
Contents
How it works
A Nitro Sandbox runs on the Nitro Hypervisor alongside its parent instance, the same way that an Amazon EC2 instance does, so its vCPUs run at Amazon EC2 instance level performance. The Nitro System isolates Nitro Sandboxes from each other, and code in a Nitro Sandbox can't access the memory of the parent instance. A Nitro Sandbox reaches the parent instance only through its virtual devices.
The VMM creates Nitro Sandboxes through the Nitro Enclaves driver on the parent instance and implements their virtual devices. Currently, Firecracker is the only VMM that supports Nitro Sandboxes, and the driver is available for Linux. For the supported versions, see Prerequisites.
Confidential and direct modes
For each Nitro Sandbox, you choose how much the parent instance can observe. You choose the mode at launch, and you can't change it later.
- Confidential mode (default)
-
The Nitro System removes the memory of the Nitro Sandbox from the parent instance, so neither the parent instance nor its administrators can read or change that memory. Each virtual device exchanges data through its own dedicated buffer. A Nitro Security Module (NSM) in the Nitro Sandbox provides cryptographic attestation.
The parent instance still carries the device traffic, chooses the image, and controls when the Nitro Sandbox runs. Encrypt data that leaves the Nitro Sandbox, and use attestation to check its image before you give it secrets.
Use confidential mode for workloads that you keep private from the administrators of the parent instance.
- Direct mode
-
The parent instance shares the memory of the Nitro Sandbox and can read and write it. There is no NSM and no attestation. The virtual devices exchange data directly through the memory of the Nitro Sandbox, without dedicated buffers, and the trust model is equivalent to that of a nested virtual machine.
Use direct mode when the same trusted party operates both the Nitro Sandbox and the parent instance.
When to use Nitro Sandboxes
Choose by how much of the machinery you want to run yourself:
-
None of it: use AWS Lambda MicroVMs, with no instances or networking to manage.
-
Your instance, with AWS enforcing the boundary between workloads: use Nitro Sandboxes. This is the general case for sharing an instance between independent workloads, such as AI agents that run code from their users, workloads of different tenants, and build jobs.
-
A small, tightly scoped job on highly sensitive data: use Nitro Enclaves. An enclave has no persistent storage, interactive access, or external networking, only a local socket to its parent instance. Choose it when that minimal interface is what your job needs.
-
Your own hypervisor or operating system: use nested virtualization.
Nitro Sandboxes run on instances with Intel, AMD, and AWS Graviton processors. Nested virtualization is available only on instances with Intel processors.
Supported features
Your applications run unmodified in a Nitro Sandbox, which can use the following:
- Storage
-
A Nitro Sandbox can use block devices on storage of the parent instance and resize them while it runs. Over the network, a workload can use Amazon Simple Storage Service (Amazon S3), Amazon Elastic File System (Amazon EFS), and other network storage through a client in your image.
- Networking
-
Each Nitro Sandbox runs its own network stack. The network backend of the VMM on the parent instance decides how that stack connects to the network of the parent instance. A local socket (vsock) connects the Nitro Sandbox to the parent instance.
Cryptographic attestation
In confidential mode, the Nitro System measures the boot image, the launch settings, the virtual devices at boot (unless you enable hot plug), and the identity of the parent instance. The NSM signs these measurements in an attestation document that the parent instance can't forge.
AWS KMS releases a secret only when the document matches the conditions in your key policy. Always check the measurement of the image in the key policy. The measurements of the parent instance alone also match a Nitro Sandbox in debug mode, a development setting that shows the guest console and records no image measurements. For more information, see Attest a Nitro Sandbox.
Considerations and limitations
The following considerations apply when you use Nitro Sandboxes:
- Supported instance types
-
Nitro Sandboxes are not available on flex instances, such as C7i-flex, M7i-flex, C8i-flex, M8i-flex, and R8i-flex. The following instance types support Nitro Sandboxes.
- Number of Nitro Sandboxes and vCPUs
-
Each vCPU of a Nitro Sandbox either has a dedicated hardware thread of the parent instance or, with CPU overcommit, shares the vCPUs of the parent instance. You choose this for each Nitro Sandbox at launch.
You can run up to 5 Nitro Sandboxes for each vCPU of the parent instance, and at most 896 Nitro Sandboxes on one parent instance. Each Nitro Sandbox can have at most as many vCPUs as the parent instance. With CPU overcommit, all Nitro Sandboxes together can have up to 5 times as many vCPUs as the parent instance. The following table shows an example.
Nitro Sandboxes with CPU overcommit on a parent instance with 4 vCPUs vCPUs for each Nitro Sandbox Maximum Nitro Sandboxes 1 20 2 10 4 5 Without CPU overcommit, the vCPUs of all Nitro Sandboxes together can't exceed the vCPUs of the parent instance, minus the vCPUs of its first core. For more information, see Set the size of a Nitro Sandbox.
- CPU on instances with two threads per core
-
On instances with two threads per core, a core runs only one Nitro Sandbox, or only the parent instance, at a time. The compute available to Nitro Sandboxes is therefore bounded by the physical cores, about half the vCPUs. AWS Graviton instances have one thread per core.
- Memory
-
Nitro Sandbox memory comes from a memory pool that the parent instance reserves at boot. Each Nitro Sandbox uses its own memory plus 2 MiB of the pool, and in confidential mode another 16 MiB for each virtual device.
Each running Nitro Sandbox also uses one of the Nitro Sandbox slots of the parent instance. The parent instance starts with 4 slots, and you can add more in steps of 8. Each step uses another 128 MiB of the pool. For more information, see Prepare the parent instance.
Give each Nitro Sandbox at least 256 MiB of memory.
- Devices
-
Each Nitro Sandbox supports up to 32 virtual devices, including devices that you hot plug. You can't remove a device from a running Nitro Sandbox.
- GPU passthrough
-
GPU passthrough into a Nitro Sandbox is currently unavailable.
- Lifecycle
-
When you stop, reboot, or terminate the parent instance, its Nitro Sandboxes stop too. You can't enable hibernation on a parent instance.
You can't change the vCPUs or memory of a running Nitro Sandbox. Nitro Sandboxes do not support snapshot and restore, pause and resume, or live migration.
- Storage
-
The parent instance can read every block device that it presents to a Nitro Sandbox, including encrypted Amazon Elastic Block Store (Amazon EBS) volumes. Amazon EBS encryption and server-side encryption with AWS KMS keys (SSE-KMS) do not protect data from the parent instance. To keep data confidential, encrypt it inside the Nitro Sandbox with a key that AWS KMS releases only to an attested Nitro Sandbox.
- Networking and instance metadata
-
A Nitro Sandbox has no instance metadata service (IMDS) of its own. If the parent instance routes traffic from a Nitro Sandbox, for example with NAT, the Nitro Sandbox can reach the IMDS of the parent instance and read its AWS Identity and Access Management (IAM) role credentials. IMDSv2 and the hop limit of 2 that Amazon Linux 2023 AMIs use do not prevent this. To block this access, reject traffic from Nitro Sandboxes to
169.254.169.254on the parent instance.One Nitro Sandbox can exhaust network resources that all Nitro Sandboxes share on the parent instance, such as the connection tracking table, so limit these resources for each Nitro Sandbox.
- Nested virtualization
-
You can't use Nitro Sandboxes or Nitro Enclaves on an instance that has nested virtualization enabled.
- Credential Guard
-
You can't use Nitro Sandboxes and Credential Guard on the same instance during the same boot. If Credential Guard starts first, creating a Nitro Sandbox fails. If a Nitro Sandbox starts first, Windows stops with an error when Credential Guard starts. Nitro Enclaves on its own is not affected.