AgentcoreCodeInterpreter class
Manages an AWS Bedrock AgentCore Code Interpreter. Code Interpreter provides a secure environment for AI agents to execute Python code, enabling data analysis, calculations, and file processing capabilities.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.bedrock.AgentcoreCodeInterpreter("example", {
networkConfiguration: {
networkMode: "PUBLIC",
},
name: "example-code-interpreter",
description: "Code interpreter for data analysis",
});
import pulumi
import pulumi_aws as aws
example = aws.bedrock.AgentcoreCodeInterpreter("example",
network_configuration={
"network_mode": "PUBLIC",
},
name="example-code-interpreter",
description="Code interpreter for data analysis")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Bedrock.AgentcoreCodeInterpreter("example", new()
{
NetworkConfiguration = new Aws.Bedrock.Inputs.AgentcoreCodeInterpreterNetworkConfigurationArgs
{
NetworkMode = "PUBLIC",
},
Name = "example-code-interpreter",
Description = "Code interpreter for data analysis",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/bedrock"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := bedrock.NewAgentcoreCodeInterpreter(ctx, "example", &bedrock.AgentcoreCodeInterpreterArgs{
NetworkConfiguration: &bedrock.AgentcoreCodeInterpreterNetworkConfigurationArgs{
NetworkMode: pulumi.String("PUBLIC"),
},
Name: pulumi.String("example-code-interpreter"),
Description: pulumi.String("Code interpreter for data analysis"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_bedrock_agentcorecodeinterpreter" "example" {
network_configuration = {
network_mode = "PUBLIC"
}
name = "example-code-interpreter"
description = "Code interpreter for data analysis"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.bedrock.AgentcoreCodeInterpreter;
import com.pulumi.aws.bedrock.AgentcoreCodeInterpreterArgs;
import com.pulumi.aws.bedrock.inputs.AgentcoreCodeInterpreterNetworkConfigurationArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new AgentcoreCodeInterpreter("example", AgentcoreCodeInterpreterArgs.builder()
.networkConfiguration(AgentcoreCodeInterpreterNetworkConfigurationArgs.builder()
.networkMode("PUBLIC")
.build())
.name("example-code-interpreter")
.description("Code interpreter for data analysis")
.build());
}
}
resources:
example:
type: aws:bedrock:AgentcoreCodeInterpreter
properties:
networkConfiguration:
networkMode: PUBLIC
name: example-code-interpreter
description: Code interpreter for data analysis
Code Interpreter with Execution Role
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const assumeRole = aws.iam.getPolicyDocument({
statements: [{
principals: [{
type: "Service",
identifiers: ["bedrock-agentcore.amazonaws.com"],
}],
effect: "Allow",
actions: ["sts:AssumeRole"],
}],
});
const example = new aws.iam.Role("example", {
name: "bedrock-agentcore-code-interpreter-role",
assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
});
const exampleAgentcoreCodeInterpreter = new aws.bedrock.AgentcoreCodeInterpreter("example", {
networkConfiguration: {
networkMode: "SANDBOX",
},
name: "example-code-interpreter",
description: "Code interpreter with custom execution role",
executionRoleArn: example.arn,
});
import pulumi
import pulumi_aws as aws
assume_role = aws.iam.get_policy_document(statements=[{
"principals": [{
"type": "Service",
"identifiers": ["bedrock-agentcore.amazonaws.com"],
}],
"effect": "Allow",
"actions": ["sts:AssumeRole"],
}])
example = aws.iam.Role("example",
name="bedrock-agentcore-code-interpreter-role",
assume_role_policy=assume_role.json)
example_agentcore_code_interpreter = aws.bedrock.AgentcoreCodeInterpreter("example",
network_configuration={
"network_mode": "SANDBOX",
},
name="example-code-interpreter",
description="Code interpreter with custom execution role",
execution_role_arn=example.arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var assumeRole = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "Service",
Identifiers = new[]
{
"bedrock-agentcore.amazonaws.com",
},
},
},
Effect = "Allow",
Actions = new[]
{
"sts:AssumeRole",
},
},
},
});
var example = new Aws.Iam.Role("example", new()
{
Name = "bedrock-agentcore-code-interpreter-role",
AssumeRolePolicy = assumeRole.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var exampleAgentcoreCodeInterpreter = new Aws.Bedrock.AgentcoreCodeInterpreter("example", new()
{
NetworkConfiguration = new Aws.Bedrock.Inputs.AgentcoreCodeInterpreterNetworkConfigurationArgs
{
NetworkMode = "SANDBOX",
},
Name = "example-code-interpreter",
Description = "Code interpreter with custom execution role",
ExecutionRoleArn = example.Arn,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/bedrock"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
{
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Type: "Service",
Identifiers: []string{
"bedrock-agentcore.amazonaws.com",
},
},
},
Effect: pulumi.StringRef("Allow"),
Actions: []string{
"sts:AssumeRole",
},
},
},
}, nil)
if err != nil {
return err
}
example, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
Name: pulumi.String("bedrock-agentcore-code-interpreter-role"),
AssumeRolePolicy: pulumi.String(assumeRole.Json),
})
if err != nil {
return err
}
_, err = bedrock.NewAgentcoreCodeInterpreter(ctx, "example", &bedrock.AgentcoreCodeInterpreterArgs{
NetworkConfiguration: &bedrock.AgentcoreCodeInterpreterNetworkConfigurationArgs{
NetworkMode: pulumi.String("SANDBOX"),
},
Name: pulumi.String("example-code-interpreter"),
Description: pulumi.String("Code interpreter with custom execution role"),
ExecutionRoleArn: example.Arn,
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_iam_getpolicydocument" "assumeRole" {
statements {
principals {
type = "Service"
identifiers = ["bedrock-agentcore.amazonaws.com"]
}
effect = "Allow"
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role" "example" {
name = "bedrock-agentcore-code-interpreter-role"
assume_role_policy = data.aws_iam_getpolicydocument.assumeRole.json
}
resource "aws_bedrock_agentcorecodeinterpreter" "example" {
network_configuration = {
network_mode = "SANDBOX"
}
name = "example-code-interpreter"
description = "Code interpreter with custom execution role"
execution_role_arn = aws_iam_role.example.arn
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.bedrock.AgentcoreCodeInterpreter;
import com.pulumi.aws.bedrock.AgentcoreCodeInterpreterArgs;
import com.pulumi.aws.bedrock.inputs.AgentcoreCodeInterpreterNetworkConfigurationArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("bedrock-agentcore.amazonaws.com")
.build())
.effect("Allow")
.actions("sts:AssumeRole")
.build())
.build());
var example = new Role("example", RoleArgs.builder()
.name("bedrock-agentcore-code-interpreter-role")
.assumeRolePolicy(assumeRole.json())
.build());
var exampleAgentcoreCodeInterpreter = new AgentcoreCodeInterpreter("exampleAgentcoreCodeInterpreter", AgentcoreCodeInterpreterArgs.builder()
.networkConfiguration(AgentcoreCodeInterpreterNetworkConfigurationArgs.builder()
.networkMode("SANDBOX")
.build())
.name("example-code-interpreter")
.description("Code interpreter with custom execution role")
.executionRoleArn(example.arn())
.build());
}
}
resources:
example:
type: aws:iam:Role
properties:
name: bedrock-agentcore-code-interpreter-role
assumeRolePolicy: ${assumeRole.json}
exampleAgentcoreCodeInterpreter:
type: aws:bedrock:AgentcoreCodeInterpreter
name: example
properties:
networkConfiguration:
networkMode: SANDBOX
name: example-code-interpreter
description: Code interpreter with custom execution role
executionRoleArn: ${example.arn}
variables:
assumeRole:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- type: Service
identifiers:
- bedrock-agentcore.amazonaws.com
effect: Allow
actions:
- sts:AssumeRole
Import
Using pulumi import, import Bedrock AgentCore Code Interpreter using the code interpreter ID. For example:
$ pulumi import aws:bedrock/agentcoreCodeInterpreter:AgentcoreCodeInterpreter example CODEINTERPRETER1234567890
Constructors
- AgentcoreCodeInterpreter(String name, {AgentcoreCodeInterpreterArgs? args, CustomResourceOptions? options})
-
Creates a new AgentcoreCodeInterpreter.
nameThe Pulumi resource name.argsArguments used to configure this AgentcoreCodeInterpreter. The set of arguments for AgentcoreCodeInterpreter.optionsResource options controlling this resource's behavior. - AgentcoreCodeInterpreter.reference(String urn)
- Creates a typed reference to an existing AgentcoreCodeInterpreter resource.
Properties
-
certificates
↔ Output<
List< AgentcoreCodeInterpreterCertificate> ?> -
Certificates to install in the code interpreter. Between 1 and 200 blocks are supported. See
certificatebelow.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
codeInterpreterArn
↔ Output<
String> -
ARN of the Code Interpreter.
latefinal
-
codeInterpreterId
↔ Output<
String> -
Unique identifier of the Code Interpreter.
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
description
↔ Output<
String?> -
Description of the code interpreter.
latefinal
-
executionRoleArn
↔ Output<
String?> -
ARN of the IAM role that the code interpreter assumes for execution. Required when using
SANDBOXnetwork mode.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
Name of the code interpreter.
latefinal
-
networkConfiguration
↔ Output<
AgentcoreCodeInterpreterNetworkConfiguration> -
Network configuration for the code interpreter. See
networkConfigurationbelow.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
Key-value map of resource tags. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
A map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
timeouts
↔ Output<
AgentcoreCodeInterpreterTimeouts?> -
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {AgentcoreCodeInterpreterState? state, CustomResourceOptions? options}) → AgentcoreCodeInterpreter -
Gets an existing AgentcoreCodeInterpreter resource's state with the given
nameandid.