# CodeInterpreterNetworkConfiguration

Network configuration for the Code Interpreter tool.

Extends: NetworkConfiguration › CodeInterpreterNetworkConfiguration

- Source: [`aws-bedrockagentcore/lib/network/network-configuration.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/network/network-configuration.ts#L182)
- Type last changed: v2.255.0 · 19 May 2026

## Example

```ts
// Create a custom execution role
const executionRole = new iam.Role(this, "CodeInterpreterExecutionRole", {
  assumedBy: new iam.ServicePrincipal("bedrock-agentcore.amazonaws.com"),
});

// Create code interpreter with custom execution role
const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
  codeInterpreterCustomName: "my_code_interpreter",
  description: "Code interpreter with custom execution role",
  networkConfiguration: agentcore.CodeInterpreterNetworkConfiguration.usingPublicNetwork(),
  executionRole: executionRole,
});
```

## Properties

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — The connections object to the network.

- `networkMode`: string — The network mode to use.

  Configure the security level for agent
  execution to control access, isolate resources, and protect sensitive data.

- `scope`: [Construct](/cdk/api/v2/docs/constructs.Construct.html) — The scope to create the resource in.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — The VPC subnets to use.

## Methods

- `usingPublicNetwork(): CodeInterpreterNetworkConfiguration // chainable` (static) — Creates a public network configuration.

  **Returns:** A CodeInterpreterNetworkConfiguration. Run this tool to operate in a public environment with internet access, suitable for less sensitive or open-use scenarios.

- `usingSandboxNetwork(): CodeInterpreterNetworkConfiguration // chainable` (static) — Creates a sandbox network configuration.

  **Returns:** A CodeInterpreterNetworkConfiguration. Run this tool in a restricted environment with limited Permissions and Encryption to enhance safety and reduce potential risks.

- `usingVpc(scope: Construct, vpcConfig: VpcConfigProps): CodeInterpreterNetworkConfiguration // chainable` (static) — Creates a network configuration from a VPC configuration.

  **Parameters**

  - `vpcConfig` — - The VPC configuration.

  **Returns:** A CodeInterpreterNetworkConfiguration.
