Isolate workloads with AWS Nitro Sandboxes - Amazon Elastic Compute Cloud
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

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 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.

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.

General purpose
General purpose instances that support Nitro Sandboxes
Instance family Instance types
M5 All instance types, except: m5.large | m5.metal
M5a All instance types, except: m5a.large
M5ad All instance types, except: m5ad.large
M5d All instance types, except: m5d.large | m5d.metal
M5dn All instance types, except: m5dn.large | m5dn.metal
M5n All instance types, except: m5n.large | m5n.metal
M5zn All instance types, except: m5zn.large | m5zn.metal
M6a All instance types, except: m6a.large | m6a.metal
M6g All instance types, except: m6g.medium | m6g.metal
M6gd All instance types, except: m6gd.medium | m6gd.metal
M6i All instance types, except: m6i.large | m6i.metal
M6id All instance types, except: m6id.large | m6id.metal
M6idn All instance types, except: m6idn.large | m6idn.metal
M6in All instance types, except: m6in.large | m6in.metal
M7a All instance types, except: m7a.medium | m7a.large | m7a.metal-48xl
M7g All instance types, except: m7g.medium | m7g.metal
M7gd All instance types, except: m7gd.medium | m7gd.metal
M7i All instance types, except: m7i.large | m7i.metal-24xl | m7i.metal-48xl
M8a All instance types, except: m8a.medium | m8a.metal-24xl | m8a.metal-48xl
M8azn All instance types, except: m8azn.medium | m8azn.metal-12xl | m8azn.metal-24xl
M8g All instance types, except: m8g.medium | m8g.metal-24xl | m8g.metal-48xl
M8gb All instance types, except: m8gb.medium | m8gb.metal-24xl | m8gb.metal-48xl
M8gd All instance types, except: m8gd.medium | m8gd.metal-24xl | m8gd.metal-48xl
M8gn All instance types, except: m8gn.medium | m8gn.metal-24xl | m8gn.metal-48xl
M8i All instance types, except: m8i.large | m8i.metal-48xl | m8i.metal-96xl
M8id All instance types, except: m8id.large | m8id.metal-48xl | m8id.metal-96xl
M8in All instance types, except: m8in.large | m8in.metal-48xl | m8in.metal-96xl
M8idn All instance types, except: m8idn.large | m8idn.metal-48xl | m8idn.metal-96xl
M8ine All instance types, except: m8ine.large
M8ib All instance types, except: m8ib.large | m8ib.metal-48xl | m8ib.metal-96xl
M8idb All instance types, except: m8idb.large | m8idb.metal-48xl | m8idb.metal-96xl
M9g All instance types, except: m9g.medium | m9g.metal-48xl
M9gd All instance types, except: m9gd.medium | m9gd.metal-48xl
Compute optimized
Compute optimized instances that support Nitro Sandboxes
Instance family Instance types
C5 All instance types, except: c5.large | c5.metal
C5a All instance types, except: c5a.large
C5ad All instance types, except: c5ad.large
C5d All instance types, except: c5d.large | c5d.metal
C5n All instance types, except: c5n.large | c5n.metal
C6a All instance types, except: c6a.large | c6a.metal
C6g All instance types, except: c6g.medium | c6g.metal
C6gd All instance types, except: c6gd.medium | c6gd.metal
C6gn All instance types, except: c6gn.medium
C6i All instance types, except: c6i.large | c6i.metal
C6id All instance types, except: c6id.large | c6id.metal
C6in All instance types, except: c6in.large | c6in.metal
C7a All instance types, except: c7a.medium | c7a.large | c7a.metal-48xl
C7g All instance types, except: c7g.medium | c7g.metal
C7gd All instance types, except: c7gd.medium | c7gd.metal
C7i All instance types, except: c7i.large | c7i.metal-24xl | c7i.metal-48xl
C8a All instance types, except: c8a.medium | c8a.metal-24xl | c8a.metal-48xl
C8g All instance types, except: c8g.medium | c8g.metal-24xl | c8g.metal-48xl
C8gb All instance types, except: c8gb.medium | c8gb.metal-24xl | c8gb.metal-48xl
C8gd All instance types, except: c8gd.medium | c8gd.metal-24xl | c8gd.metal-48xl
C8gn All instance types, except: c8gn.medium | c8gn.metal-24xl | c8gn.metal-48xl
C8i All instance types, except: c8i.large | c8i.metal-48xl | c8i.metal-96xl
C8id All instance types, except: c8id.large | c8id.metal-48xl | c8id.metal-96xl
C8in All instance types, except: c8in.large | c8in.metal-48xl | c8in.metal-96xl
C8ine All instance types, except: c8ine.large
C8ib All instance types, except: c8ib.large | c8ib.metal-48xl | c8ib.metal-96xl
C9g All instance types, except: c9g.medium | c9g.metal-48xl
C9gd All instance types, except: c9gd.medium | c9gd.metal-48xl
Memory optimized
Memory optimized instances that support Nitro Sandboxes
Instance family Instance types
R5 All instance types, except: r5.large | r5.metal
R5a All instance types, except: r5a.large
R5ad All instance types, except: r5ad.large
R5b All instance types, except: r5b.large | r5b.metal
R5d All instance types, except: r5d.large | r5d.metal
R5dn All instance types, except: r5dn.large | r5dn.metal
R5n All instance types, except: r5n.large | r5n.metal
R6a All instance types, except: r6a.large | r6a.metal
R6g All instance types, except: r6g.medium | r6g.metal
R6gd All instance types, except: r6gd.medium | r6gd.metal
R6i All instance types, except: r6i.large | r6i.metal
R6id All instance types, except: r6id.large | r6id.metal
R6idn All instance types, except: r6idn.large | r6idn.metal
R6in All instance types, except: r6in.large | r6in.metal
R7a All instance types, except: r7a.medium | r7a.large | r7a.metal-48xl
R7g All instance types, except: r7g.medium | r7g.metal
R7gd All instance types, except: r7gd.medium | r7gd.metal
R7i All instance types, except: r7i.large | r7i.metal-24xl | r7i.metal-48xl
R7iz All instance types, except: r7iz.large | r7iz.metal-16xl | r7iz.metal-32xl
R8a All instance types, except: r8a.medium | r8a.metal-24xl | r8a.metal-48xl
R8g All instance types, except: r8g.medium | r8g.metal-24xl | r8g.metal-48xl
R8gb All instance types, except: r8gb.medium | r8gb.metal-24xl | r8gb.metal-48xl
R8gd All instance types, except: r8gd.medium | r8gd.metal-24xl | r8gd.metal-48xl
R8gn All instance types, except: r8gn.medium | r8gn.metal-24xl | r8gn.metal-48xl
R8i All instance types, except: r8i.large | r8i.metal-48xl | r8i.metal-96xl
R8id All instance types, except: r8id.large | r8id.metal-48xl | r8id.metal-96xl
R8in All instance types, except: r8in.large | r8in.metal-48xl | r8in.metal-96xl
R8idn All instance types, except: r8idn.large | r8idn.metal-48xl | r8idn.metal-96xl
R8ib All instance types, except: r8ib.large | r8ib.metal-48xl | r8ib.metal-96xl
R8idb All instance types, except: r8idb.large | r8idb.metal-48xl | r8idb.metal-96xl
R9g All instance types, except: r9g.medium | r9g.metal-48xl
R9gd All instance types, except: r9gd.medium | r9gd.metal-48xl
X2gd All instance types, except: x2gd.medium | x2gd.metal
X2idn All instance types, except: x2idn.metal
X2iedn All instance types, except: x2iedn.metal
X2iezn All instance types, except: x2iezn.metal
X8g All instance types, except: x8g.medium | x8g.metal-24xl | x8g.metal-48xl
X8aedz All instance types, except: x8aedz.metal-12xl | x8aedz.metal-24xl
X8i All instance types, except: x8i.large | x8i.metal-48xl | x8i.metal-96xl
z1d All instance types, except: z1d.large | z1d.metal
Storage optimized
Storage optimized instances that support Nitro Sandboxes
Instance family Instance types
D3 All instance types.
D3en All instance types.
I3en All instance types, except: i3en.large | i3en.metal
I4g All instance types.
I4i All instance types, except: i4i.large | i4i.metal
I7i All instance types, except: i7i.large | i7i.metal-24xl | i7i.metal-48xl
I7ie All instance types, except: i7ie.large | i7ie.metal-24xl | i7ie.metal-48xl
I8g All instance types, except: i8g.metal-24xl | i8g.metal-48xl
I8ge All instance types, except: i8ge.metal-24xl | i8ge.metal-48xl
Accelerated computing

On accelerated computing instances, a Nitro Sandbox runs CPU workloads only.

Accelerated computing instances that support Nitro Sandboxes
Instance family Instance types
G5 g5.xlarge | g5.2xlarge | g5.4xlarge | g5.8xlarge | g5.12xlarge | g5.16xlarge | g5.24xlarge | g5.48xlarge
G5g g5g.xlarge | g5g.2xlarge | g5g.4xlarge | g5g.8xlarge | g5g.16xlarge
G6 g6.xlarge | g6.2xlarge | g6.4xlarge | g6.8xlarge | g6.12xlarge | g6.16xlarge | g6.24xlarge | g6.48xlarge
G6e g6e.xlarge | g6e.2xlarge | g6e.4xlarge | g6e.8xlarge | g6e.12xlarge | g6e.16xlarge | g6e.24xlarge | g6e.48xlarge
Gr6 gr6.4xlarge | gr6.8xlarge
G7 g7.2xlarge | g7.4xlarge | g7.8xlarge | g7.12xlarge | g7.24xlarge | g7.48xlarge
G7e g7e.2xlarge | g7e.4xlarge | g7e.8xlarge | g7e.12xlarge | g7e.24xlarge | g7e.48xlarge
P3dn p3dn.24xlarge
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.254 on 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.