CodeInterpreterNetworkConfiguration Class
Network configuration for the Code Interpreter tool.
| Source | aws-bedrockagentcore/lib/network/network-configuration.ts |
|---|---|
| Type last changed |
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,
});
python
# Create a custom execution role
execution_role = iam.Role(self, "CodeInterpreterExecutionRole",
assumed_by=iam.ServicePrincipal("bedrock-agentcore.amazonaws.com")
)
# Create code interpreter with custom execution role
code_interpreter = agentcore.CodeInterpreterCustom(self, "MyCodeInterpreter",
code_interpreter_custom_name="my_code_interpreter",
description="Code interpreter with custom execution role",
network_configuration=agentcore.CodeInterpreterNetworkConfiguration.using_public_network(),
execution_role=execution_role
)
java
// Create a custom execution role
Role executionRole = Role.Builder.create(this, "CodeInterpreterExecutionRole")
.assumedBy(new ServicePrincipal("bedrock-agentcore.amazonaws.com"))
.build();
// Create code interpreter with custom execution role
CodeInterpreterCustom codeInterpreter = CodeInterpreterCustom.Builder.create(this, "MyCodeInterpreter")
.codeInterpreterCustomName("my_code_interpreter")
.description("Code interpreter with custom execution role")
.networkConfiguration(CodeInterpreterNetworkConfiguration.usingPublicNetwork())
.executionRole(executionRole)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a custom execution role
var executionRole = new Role(this, "CodeInterpreterExecutionRole", new RoleProps {
AssumedBy = new ServicePrincipal("bedrock-agentcore.amazonaws.com")
});
// Create code interpreter with custom execution role
var codeInterpreter = new CodeInterpreterCustom(this, "MyCodeInterpreter", new CodeInterpreterCustomProps {
CodeInterpreterCustomName = "my_code_interpreter",
Description = "Code interpreter with custom execution role",
NetworkConfiguration = CodeInterpreterNetworkConfiguration.UsingPublicNetwork(),
ExecutionRole = executionRole
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a custom execution role
executionRole := iam.NewRole(this, jsii.String("CodeInterpreterExecutionRole"), &RoleProps{
AssumedBy: iam.NewServicePrincipal(jsii.String("bedrock-agentcore.amazonaws.com")),
})
// Create code interpreter with custom execution role
codeInterpreter := agentcore.NewCodeInterpreterCustom(this, jsii.String("MyCodeInterpreter"), &CodeInterpreterCustomProps{
CodeInterpreterCustomName: jsii.String("my_code_interpreter"),
Description: jsii.String("Code interpreter with custom execution role"),
NetworkConfiguration: agentcore.CodeInterpreterNetworkConfiguration_UsingPublicNetwork(),
ExecutionRole: executionRole,
})
Properties
connectionsmay be undefinedConnectionsconnectionsmay be undefinedConnectionsconnectionsmay be undefinedConnectionsConnectionsmay be undefinedConnectionsConnectionsmay be undefinedConnections #The connections object to the network.
The network mode to use.
Configure the security level for agent execution to control access, isolate resources, and protect sensitive data.
scopemay be undefinedConstructscopemay be undefinedConstructscopemay be undefinedConstructScopemay be undefinedConstructScopemay be undefinedConstruct #The scope to create the resource in.
vpcSubnetsmay be undefinedSubnetSelectionvpc_subnetsmay be undefinedSubnetSelectionvpcSubnetsmay be undefinedSubnetSelectionVpcSubnetsmay be undefinedSubnetSelectionVpcSubnetsmay be undefinedSubnetSelection #The VPC subnets to use.
Methods
usingPublicNetwork(): CodeInterpreterNetworkConfiguration // chainable@staticmethod def using_public_network() -> CodeInterpreterNetworkConfigurationpublic static CodeInterpreterNetworkConfiguration usingPublicNetwork()public static CodeInterpreterNetworkConfiguration UsingPublicNetwork()func UsingPublicNetwork() CodeInterpreterNetworkConfiguration static #Creates a public network configuration.
returns
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@staticmethod def using_sandbox_network() -> CodeInterpreterNetworkConfigurationpublic static CodeInterpreterNetworkConfiguration usingSandboxNetwork()public static CodeInterpreterNetworkConfiguration UsingSandboxNetwork()func UsingSandboxNetwork() CodeInterpreterNetworkConfiguration static #Creates a sandbox network configuration.
returns
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@staticmethod def using_vpc(scope: Construct, vpc_config: VpcConfigProps) -> CodeInterpreterNetworkConfigurationpublic static CodeInterpreterNetworkConfiguration usingVpc(Construct scope, VpcConfigProps vpcConfig)public static CodeInterpreterNetworkConfiguration UsingVpc(Construct scope, VpcConfigProps vpcConfig)func UsingVpc(Scope Construct, VpcConfig VpcConfigProps) CodeInterpreterNetworkConfiguration static #Creates a network configuration from a VPC configuration.
1 parameter · returns
Parameters
vpcConfigvpc_configvpcConfigvpcConfigVpcConfig— - The VPC configuration.
Returns: A CodeInterpreterNetworkConfiguration.