Set up a Sandbox
AWS Ops Agent Sandbox (Sandbox) is a preview feature that gives AWS Ops Agent a secure, isolated Linux environment where it can write and run code during investigations, chat conversations, and custom agent invocations. Some problems are faster and more reliable to solve with code than through reasoning alone. With Sandbox, the agent complements its reasoning with computation—for example, to analyze a large log file, calculate statistics across a set of metrics, or parse and correlate data from multiple sources.
Each sandbox is ephemeral and scoped to a single investigation, chat conversation, or custom agent invocation, so the code the agent runs stays isolated from your other resources. You control the environment's outbound network access and the registries the agent installs packages from. By default, the sandbox restricts outbound network access: until you add an entry to the networking allowlist, it can reach only AWS service endpoints.
Sandbox is available in preview and is subject to change.
Sandbox is available in all commercial AWS Regions (in the aws partition). For more information, see Feature availability by Region.
How Sandbox works
When you configure Sandbox for an Agent Space, AWS Ops Agent automatically provisions a fresh Linux environment while it works on an investigation, a chat conversation, or a custom agent invocation. In this environment, the agent can run shell commands and read and write files, then read the results back into its analysis. The environment lasts only for as long as the agent using it is running, and no two investigations, chat conversations, or invocations share one.
The environment comes with pre-configured AWS profiles for the AWS accounts connected to your Agent Space. The agent can use these profiles to make AWS CLI and boto3 (AWS SDK for Python) calls to those accounts, scoped to the same permissions the agent already has. This lets the agent query and correlate AWS resources programmatically with code.
The agent can also make HTTP requests from the sandbox—using command line tools or Python and Node.js libraries—to any host and path permitted by your networking policy.
Two settings control what the environment can do:
Networking policy – An explicit allowlist of the hosts, HTTP methods, and paths the environment may reach. An empty allowlist denies all outbound requests except requests to AWS service endpoints and to package registries you configure.
Package registries – The registry that Python (
pipanduv) and Node.js (npm) install packages from. The agent installs the packages it needs at runtime.
Sandbox environment isolation
AWS Ops Agent runs each sandbox in an isolated Lambda MicroVM. Each MicroVM is scoped to a single investigation, chat conversation, or custom agent invocation. AWS Ops Agent discards it when that work ends. When the agent makes AWS CLI or SDK calls from the sandbox, it routes those calls through a proxy. That proxy limits the calls to read-only operations, so sandbox code cannot modify or delete your AWS resources.
Skills in the sandbox
With Sandbox enabled, the agent reads your Skills from the sandbox's filesystem rather than from a virtual filesystem. This changes how the agent works with skills in two ways:
Search and read with command line tools – The agent can use standard command line tools to search across your skills and read their files, instead of loading them through a virtual filesystem. This helps it find and apply the right skill for the task.
Run bundled code – The agent can run and adapt code bundled with a skill. Without Sandbox, a skill can include only non-executable files such as Markdown instructions, references, and data files. With Sandbox, a skill can include executable code that the agent can run in the environment.
Before you begin
Sandbox is not configured by default, so until you opt in, the agent cannot run code. Until then, the Sandbox section displays the message "Sandbox is not configured. To opt in, configure sandbox." and a Configure button. The following image shows the Sandbox section before you configure it.
Before you configure Sandbox, determine the following:
Where the agent installs Python and Node.js packages from: the AWS managed registry (in supported Regions), a registry you provide a URL for, or none.
The hosts, HTTP methods, and paths the agent's code needs to reach, if any.
Configure Sandbox for an Agent Space
Sign in to the AWS Management Console and open the AWS Ops Agent console.
Select your Agent Space and choose the Capabilities tab.
In the Sandbox section, choose Configure.
Configure package registries and a networking policy as described in the following sections. Then choose Next.
On the Review and confirm page, check your configuration. Choose Save.
After you configure Sandbox, the Sandbox section shows the registry for each package manager and your allowlist entries. To change the configuration, choose Edit. To remove it, see Remove Sandbox.
Configure package registries
In the Package registries section, choose a registry for Python packages (pip and uv) and one for Node.js packages (npm). The options for each are:
AWS managed – A mirror of the public PyPI or npm registry that AWS Ops Agent maintains. Available only in some Regions.
Custom – An HTTPS URL for a registry that you trust, such as a private registry that you manage or the public PyPI or npm registry. Don't include a secret in the URL.
None – The agent can't install packages for that language.
The following example sets the AWS managed registry for pip, a custom registry for npm, and an empty networking allowlist. Replace the following values with your own:
<AGENT_SPACE_ID>— The ID of the Agent Space to configure.<REGION>— The AWS Region code for your Agent Space, such asus-east-1.
The update-association command accepts the same configuration.
aws devops-agent associate-service \ --agent-space-id <AGENT_SPACE_ID> \ --service-id sandbox \ --configuration '{ "sandbox": { "name": "default", "config": { "managed": { "packageRegistries": { "pypi": { "awsManaged": {} }, "npm": { "custom": { "uri": "https://registry.example.com/npm/" } } }, "networking": { "restricted": { "allowlist": [] } } } } } }' \ --region <REGION>
Configure the networking policy
The sandbox restricts outbound requests to an explicit allowlist. An empty allowlist denies all outbound requests except requests to AWS service endpoints and to package registries you configure. To let the environment reach any other host, add an allowlist entry for it.
Choose Add entry, then configure the following for the allowlist entry:
Host pattern – The host the entry applies to. Partial label matching isn't supported. Use one of the following forms:
**– All hosts.*.example.com– One subdomain level.**.example.com– Any subdomain depth.example.com– An exact host.
HTTP methods – The HTTP methods permitted for this host. Choose one or more methods, such as
GETandOPTIONS, from the dropdown list.Path patterns – The paths permitted for this host. Choose Add path to add one or more patterns:
*matches one segment, such as/repos/*/pulls.Partial matching is allowed, such as
/users/aws-*/./**permits all sub-paths.Query parameters are ignored.
For example, an entry might allow GET and OPTIONS requests to *.github.com for the paths /aws/** and /awslabs/**.
Choose Add entry for each additional host the agent's code needs to reach. To remove an entry, choose Remove.
Remove Sandbox
To opt out, select your Agent Space, go to the Capabilities tab, and in the Sandbox section, choose Remove. In the Remove sandbox configuration? dialog, choose Remove. Without a Sandbox configuration, the agent doesn't provision sandbox environments for investigations, chat conversations, or custom agent invocations.
Sandbox configuration limits
The following limits apply to each Sandbox configuration during preview.
| Limit | Value |
|---|---|
| Networking allowlist entries | 100 |
| Path patterns per allowlist entry | 1–50 |
| HTTP methods per allowlist entry | 1–7, each listed once |
| Host pattern length | 253 characters |
| Path pattern length | 256 characters |
| Registry URL length | 2,048 characters |
Security considerations
AWS Ops Agent isolates each investigation, chat conversation, and custom agent invocation in its own sandbox environment, so code and data from one are never shared with another. AWS Ops Agent inspects and filters all traffic leaving the sandbox so that only safe, permitted requests reach their destinations. It permits requests to AWS service endpoints and to package registries you configure, and requests that match your networking allowlist. It denies all other requests.
Security best practices
The agent writes and runs code in the sandbox, so keep the following in mind when you configure Sandbox:
Keep the allowlist minimal. Add allowlist entries only for the specific hosts, methods, and paths the agent needs.
Scope allowlist entries narrowly. Use exact host patterns and specific path patterns rather than broad wildcards such as
**and/**, and grant only the HTTP methods that are required.Use package registries you trust. Choose the AWS managed registry or a Custom registry that you manage. A registry that you manage also lets you control which packages and versions the agent can install. Choose None for a language the agent doesn't need.
For more information about the AWS Ops Agent security model, see AWS Ops Agent Security.