Skip to content
v2.274.0

Experimental

@aws-cdk/aws-bedrock-agentcore-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

CodeInterpreterCustom L2 construct ​

Custom code interpreter resource for AWS Bedrock Agent Core.

Provides a sandboxed environment for code execution with configurable network access.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as bedrock_agentcore_alpha from '@aws-cdk/aws-bedrock-agentcore-alpha';
import { aws_iam as iam } from 'aws-cdk-lib';

declare const codeInterpreterNetworkConfiguration: bedrock_agentcore_alpha.CodeInterpreterNetworkConfiguration;
declare const role: iam.Role;
const codeInterpreterCustom = new bedrock_agentcore_alpha.CodeInterpreterCustom(this, 'MyCodeInterpreterCustom', /* all optional props */ {
  codeInterpreterCustomName: 'codeInterpreterCustomName',
  description: 'description',
  executionRole: role,
  networkConfiguration: codeInterpreterNetworkConfiguration,
  tags: {
    tagsKey: 'tags',
  },
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_bedrock_agentcore_alpha as bedrock_agentcore_alpha
from aws_cdk import aws_iam as iam

# code_interpreter_network_configuration: bedrock_agentcore_alpha.CodeInterpreterNetworkConfiguration
# role: iam.Role

code_interpreter_custom = bedrock_agentcore_alpha.CodeInterpreterCustom(self, "MyCodeInterpreterCustom",
    code_interpreter_custom_name="codeInterpreterCustomName",
    description="description",
    execution_role=role,
    network_configuration=code_interpreter_network_configuration,
    tags={
        "tags_key": "tags"
    }
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.bedrock.agentcore.alpha.*;
import software.amazon.awscdk.services.iam.*;

CodeInterpreterNetworkConfiguration codeInterpreterNetworkConfiguration;
Role role;

CodeInterpreterCustom codeInterpreterCustom = CodeInterpreterCustom.Builder.create(this, "MyCodeInterpreterCustom")
        .codeInterpreterCustomName("codeInterpreterCustomName")
        .description("description")
        .executionRole(role)
        .networkConfiguration(codeInterpreterNetworkConfiguration)
        .tags(Map.of(
                "tagsKey", "tags"))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Bedrock.Agentcore.Alpha;
using Amazon.CDK.AWS.IAM;

CodeInterpreterNetworkConfiguration codeInterpreterNetworkConfiguration;
Role role;

var codeInterpreterCustom = new CodeInterpreterCustom(this, "MyCodeInterpreterCustom", new CodeInterpreterCustomProps {
    CodeInterpreterCustomName = "codeInterpreterCustomName",
    Description = "description",
    ExecutionRole = role,
    NetworkConfiguration = codeInterpreterNetworkConfiguration,
    Tags = new Dictionary<string, string> {
        { "tagsKey", "tags" }
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import bedrock_agentcore_alpha "github.com/aws/aws-cdk-go/awsbedrockagentcorealpha"
import "github.com/aws/aws-cdk-go/awscdk"

var codeInterpreterNetworkConfiguration CodeInterpreterNetworkConfiguration
var role Role

codeInterpreterCustom := bedrock_agentcore_alpha.NewCodeInterpreterCustom(this, jsii.String("MyCodeInterpreterCustom"), &CodeInterpreterCustomProps{
	CodeInterpreterCustomName: jsii.String("codeInterpreterCustomName"),
	Description: jsii.String("description"),
	ExecutionRole: role,
	NetworkConfiguration: codeInterpreterNetworkConfiguration,
	Tags: map[string]*string{
		"tagsKey": jsii.String("tags"),
	},
})

Initializer ​

ts
new CodeInterpreterCustom(scope: Construct, id: string, props?: CodeInterpreterCustomProps)
python
CodeInterpreterCustom(scope: Construct, id: str, props: typing.Optional[CodeInterpreterCustomProps] = None)
java
new CodeInterpreterCustom(Construct scope, String id, CodeInterpreterCustomProps props)
csharp
new CodeInterpreterCustom(Construct scope, string id, CodeInterpreterCustomProps? props = null)
go
NewCodeInterpreterCustom(Scope Construct, Id *string, Props CodeInterpreterCustomProps)

Construct Props ​

codeInterpreterCustomNamestringcode_interpreter_custom_namestrcodeInterpreterCustomNameStringCodeInterpreterCustomNamestringCodeInterpreterCustomName*string#
The name of the code interpreter Valid characters are a-z, A-Z, 0-9, _ (underscore) The name must start with a letter and can be up to 48 characters long Pattern: [a-zA-Z][a-zA-Z0-9_]{0,47}.

Default: auto generate

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string#
Optional description for the code interpreter Valid characters are a-z, A-Z, 0-9, _ (underscore), - (hyphen) and spaces The description can have up to 200 characters.

Default: No description

executionRoleIRoleexecution_roleIRoleexecutionRoleIRoleExecutionRoleIRoleExecutionRoleIRole#
The IAM role that provides permissions for the code interpreter to access AWS services.

Default: A new role will be created.

Network configuration for code interpreter.

Default: PUBLIC network mode

tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string#
Tags (optional) A list of key:value pairs of tags to apply to this Code Interpreter resource.

Default: {} - no tags

Properties ​

codeInterpreterArnstringcode_interpreter_arnstrcodeInterpreterArnStringCodeInterpreterArnstringCodeInterpreterArn*stringrequired#
The ARN of the code interpreter resource.
codeInterpreterCustomRefCodeInterpreterCustomReferencecode_interpreter_custom_refCodeInterpreterCustomReferencecodeInterpreterCustomRefCodeInterpreterCustomReferenceCodeInterpreterCustomRefCodeInterpreterCustomReferenceCodeInterpreterCustomRefCodeInterpreterCustomReferencerequired#
A reference to a CodeInterpreterCustom resource.
codeInterpreterIdstringcode_interpreter_idstrcodeInterpreterIdStringCodeInterpreterIdstringCodeInterpreterId*stringrequired#
The id of the code interpreter.
connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnectionsrequired#
An accessor for the Connections object that will fail if this Browser does not have a VPC configured.
createdAtstringcreated_atstrcreatedAtStringCreatedAtstringCreatedAt*string#
The created timestamp of the code interpreter.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string#
The description of the code interpreter.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

executionRoleIRoleexecution_roleIRoleexecutionRoleIRoleExecutionRoleIRoleExecutionRoleIRolerequired#
The IAM role that provides permissions for the code interpreter to access AWS services.
failureReasonstringfailure_reasonstrfailureReasonStringFailureReasonstringFailureReason*string#
The failure reason of the code interpreter.
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#
The principal to grant permissions to.
lastUpdatedAtstringlast_updated_atstrlastUpdatedAtStringLastUpdatedAtstringLastUpdatedAt*string#
The last updated timestamp of the code interpreter.
namestringnamestrnameStringNamestringName*stringrequired#
The name of the code interpreter.
The network configuration of the code interpreter.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
statusstringstatusstrstatusStringStatusstringStatus*string#
The status of the code interpreter.
tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string#
Tags applied to this code interpreter resource A map of key-value pairs for resource tagging.

Default: No tags applied

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

fromCodeInterpreterCustomAttributes(scope: Construct, id: string, attrs: CodeInterpreterCustomAttributes): ICodeInterpreterCustom@staticmethod def from_code_interpreter_custom_attributes(scope: Construct, id: str, attrs: CodeInterpreterCustomAttributes) -> ICodeInterpreterCustompublic static ICodeInterpreterCustom fromCodeInterpreterCustomAttributes(Construct scope, String id, CodeInterpreterCustomAttributes attrs)public static ICodeInterpreterCustom FromCodeInterpreterCustomAttributes(Construct scope, string id, CodeInterpreterCustomAttributes attrs)func FromCodeInterpreterCustomAttributes(Scope Construct, Id *string, Attrs CodeInterpreterCustomAttributes) ICodeInterpreterCustomstatic#
Creates an Code Interpreter Custom reference from an existing code interpreter's attributes.
3 parameters · returns

Parameters

  • scopescopescopescopeScope — - The construct scope.
  • ididididId — - Identifier of the construct.
  • attrsattrsattrsattrsAttrs — - Attributes of the existing code interpreter custom.

Returns: An ICodeInterpreterCustom reference to the existing code interpreter

grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#
Grants IAM actions to the IAM Principal.

[disable-awslint:no-grants]

2 parameters · returns

Parameters

  • granteegranteegranteegranteeGrantee — - The IAM principal to grant permissions to.
  • actionsactionsactionsactionsActions — - The actions to grant.

Returns: An IAM Grant object representing the granted permissions

grantInvoke(grantee: IGrantable): Grantdef grant_invoke(self, grantee: IGrantable) -> Grantpublic Grant grantInvoke(IGrantable grantee)public Grant GrantInvoke(IGrantable grantee)func GrantInvoke(Grantee IGrantable) Grant#
Grant invoke permissions on this code interpreter to an IAM principal.

[disable-awslint:no-grants]

1 parameter · returns

Parameters

  • granteegranteegranteegranteeGrantee — - The IAM principal to grant invoke permissions to.

Returns: An IAM Grant object representing the granted permissions

grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#
Grant read permissions on this code interpreter to an IAM principal.

This includes both read permissions on the specific code interpreter and list permissions on all code interpreters.

[disable-awslint:no-grants]

1 parameter · returns

Parameters

  • granteegranteegranteegranteeGrantee — - The IAM principal to grant read permissions to.

Returns: An IAM Grant object representing the granted permissions

grantUse(grantee: IGrantable): Grantdef grant_use(self, grantee: IGrantable) -> Grantpublic Grant grantUse(IGrantable grantee)public Grant GrantUse(IGrantable grantee)func GrantUse(Grantee IGrantable) Grant#
Grant invoke permissions on this code interpreter to an IAM principal.

[disable-awslint:no-grants]

1 parameter · returns

Parameters

  • granteegranteegranteegranteeGrantee — - The IAM principal to grant invoke permissions to.

Returns: An IAM Grant object representing the granted permissions

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
metric(metricName: string, dimensions: { [key: string]: string }, props?: MetricOptions): Metricdef metric(self, metric_name: str, dimensions: typing.Mapping[str, str], props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, Map<String, String> dimensions, MetricOptions props)public Metric Metric(string metricName, IDictionary<string, string> dimensions, MetricOptions? props = null)func Metric(MetricName *string, Dimensions *map[string]*string, Props MetricOptions) Metric#
Return the given named metric for this code interpreter.

By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricErrorsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_errors_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricErrorsForApiOperation(String operation, MetricOptions props)public Metric MetricErrorsForApiOperation(string operation, MetricOptions? props = null)func MetricErrorsForApiOperation(Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter errors.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter errors

metricForApiOperation(metricName: string, operation: string, props?: MetricOptions): Metricdef metric_for_api_operation(self, metric_name: str, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricForApiOperation(String metricName, String operation, MetricOptions props)public Metric MetricForApiOperation(string metricName, string operation, MetricOptions? props = null)func MetricForApiOperation(MetricName *string, Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter api operations..
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter api operations

metricInvocationsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_invocations_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricInvocationsForApiOperation(String operation, MetricOptions props)public Metric MetricInvocationsForApiOperation(string operation, MetricOptions? props = null)func MetricInvocationsForApiOperation(Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter invocations.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter invocations

metricLatencyForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_latency_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricLatencyForApiOperation(String operation, MetricOptions props)public Metric MetricLatencyForApiOperation(string operation, MetricOptions? props = null)func MetricLatencyForApiOperation(Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter latencies.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter latencies

metricSessionDuration(props?: MetricOptions): Metricdef metric_session_duration(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSessionDuration(MetricOptions props)public Metric MetricSessionDuration(MetricOptions? props = null)func MetricSessionDuration(Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter session duration.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter session duration

metricSystemErrorsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_system_errors_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSystemErrorsForApiOperation(String operation, MetricOptions props)public Metric MetricSystemErrorsForApiOperation(string operation, MetricOptions? props = null)func MetricSystemErrorsForApiOperation(Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter system errors.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter system errors

metricThrottlesForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_throttles_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricThrottlesForApiOperation(String operation, MetricOptions props)public Metric MetricThrottlesForApiOperation(string operation, MetricOptions? props = null)func MetricThrottlesForApiOperation(Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter throttles.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter throttles

metricUserErrorsForApiOperation(operation: string, props?: MetricOptions): Metricdef metric_user_errors_for_api_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricUserErrorsForApiOperation(String operation, MetricOptions props)public Metric MetricUserErrorsForApiOperation(string operation, MetricOptions? props = null)func MetricUserErrorsForApiOperation(Operation *string, Props MetricOptions) Metric#
Creates a CloudWatch metric for tracking code interpreter user errors.
1 parameter · returns

Parameters

  • propspropspropspropsProps — - Configuration options for the metric.

Returns: A CloudWatch Metric configured for code interpreter user errors

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.