konokenj.cdk-api-mcp-server 0.49.0__py3-none-any.whl → 0.51.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. cdk_api_mcp_server/__about__.py +1 -1
  2. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-agentcore-alpha/README.md +796 -0
  3. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-eks-v2-alpha/README.md +116 -29
  4. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-msk-alpha/README.md +38 -8
  5. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/mixins-preview/README.md +16 -0
  6. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.api-with-authorizer-and-proxy.ts +1 -1
  7. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.lambda-api.ts +1 -1
  8. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.iam.ts +1 -1
  9. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.lambda.ts +2 -2
  10. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.user-pool.ts +1 -1
  11. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.add-subroute-integration.ts +7 -4
  12. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.http-proxy.ts +1 -1
  13. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.lambda-proxy.ts +1 -1
  14. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.lambda.ts +4 -4
  15. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-appsync/integ.graphql-lambda-permission.ts +1 -1
  16. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-appsync/integ.js-resolver.ts +1 -1
  17. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudformation/integ.core-custom-resources-node-18.ts +1 -1
  18. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudformation/integ.core-custom-resources-service-timeout.ts +1 -1
  19. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.origin-response-completion-timeout.ts +1 -1
  20. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudtrail/integ.cloudtrail-data-events-only.ts +1 -1
  21. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-elastic-beanstalk-deploy.ts +4 -1
  22. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/README.md +53 -0
  23. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.add-to-resource-policy.ts +80 -0
  24. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.policy.ts +21 -1
  25. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.vpc-flow-logs.ts +4 -0
  26. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecr/README.md +40 -1
  27. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecr/integ.tag-mutability-exclusion.ts +30 -0
  28. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +3 -0
  29. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.managedinstances-capacity-provider.ts +5 -3
  30. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.managedinstances-no-default-capacity-provider.ts +107 -0
  31. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs-patterns/integ.alb-fargate-service-public-private-switch.ts +45 -0
  32. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/README.md +34 -4
  33. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.alb-lambda-multi-value-headers.ts +1 -1
  34. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.alb.oidc.ts +1 -1
  35. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.nlb.security-group.ts +70 -0
  36. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2-actions/integ.cognito.ts +1 -1
  37. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events-targets/README.md +22 -0
  38. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events-targets/integ.firehose-delivery-stream.ts +51 -0
  39. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/README.md +96 -0
  40. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.record-format-conversion-schema.ts +154 -0
  41. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.record-format-conversion.ts +178 -0
  42. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.binary-payload.ts +1 -1
  43. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.logging-config.ts +8 -8
  44. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.params-and-secrets.ts +1 -1
  45. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime-management.ts +1 -1
  46. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime.inlinecode.ts +0 -7
  47. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.dependencies-pnpm.ts +1 -1
  48. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.function-exclude-smithy-models.ts +2 -2
  49. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.nodejs.build.images.ts +1 -1
  50. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.subscriptionfilter.ts +1 -1
  51. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-data-api-to-imported-cluster.ts +1 -1
  52. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-data-api.ts +1 -1
  53. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-data.ts +4 -0
  54. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/README.md +1 -1
  55. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.call-aws-service-cross-region-lambda.ts +1 -1
  56. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-json-path.ts +102 -0
  57. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary.ts +2 -0
  58. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.aws-custom-resource.ts +1 -1
  59. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.custom-resource-config-lambda-node-runtime.ts +1 -1
  60. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.invoke-function-payload.ts +1 -1
  61. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +62 -1
  62. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/README.md +32 -1
  63. {konokenj_cdk_api_mcp_server-0.49.0.dist-info → konokenj_cdk_api_mcp_server-0.51.0.dist-info}/METADATA +2 -2
  64. {konokenj_cdk_api_mcp_server-0.49.0.dist-info → konokenj_cdk_api_mcp_server-0.51.0.dist-info}/RECORD +67 -57
  65. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events-targets/integ.kinesis-firehose-stream.ts +0 -33
  66. {konokenj_cdk_api_mcp_server-0.49.0.dist-info → konokenj_cdk_api_mcp_server-0.51.0.dist-info}/WHEEL +0 -0
  67. {konokenj_cdk_api_mcp_server-0.49.0.dist-info → konokenj_cdk_api_mcp_server-0.51.0.dist-info}/entry_points.txt +0 -0
  68. {konokenj_cdk_api_mcp_server-0.49.0.dist-info → konokenj_cdk_api_mcp_server-0.51.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,796 @@
1
+ # Amazon Bedrock AgentCore Construct Library
2
+
3
+ <!--BEGIN STABILITY BANNER-->
4
+
5
+ ---
6
+
7
+ ![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
8
+
9
+ > The APIs of higher level constructs in this module are experimental and under active development.
10
+ > They are subject to non-backward compatible changes or removal in any future version. These are
11
+ > not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
12
+ > announced in the release notes. This means that while you may use them, you may need to update
13
+ > your source code when upgrading to a newer version of this package.
14
+
15
+ ---
16
+
17
+ <!--END STABILITY BANNER-->
18
+
19
+ | **Language** | **Package** |
20
+ | :--------------------------------------------------------------------------------------------- | --------------------------------------- |
21
+ | ![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript | `@aws-cdk/aws-bedrock-agentcore-alpha` |
22
+
23
+ [Amazon Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/) enables you to deploy and operate highly capable AI agents securely, at scale. It offers infrastructure purpose-built for dynamic agent workloads, powerful tools to enhance agents, and essential controls for real-world deployment. AgentCore services can be used together or independently and work with any framework including CrewAI, LangGraph, LlamaIndex, and Strands Agents, as well as any foundation model in or outside of Amazon Bedrock, giving you ultimate flexibility. AgentCore eliminates the undifferentiated heavy lifting of building specialized agent infrastructure, so you can accelerate agents to production.
24
+
25
+ This construct library facilitates the deployment of Bedrock AgentCore primitives, enabling you to create sophisticated AI applications that can interact with your systems and data sources.
26
+
27
+ ## Table of contents
28
+
29
+ - [AgentCore Runtime](#agentcore-runtime)
30
+ - [Runtime Versioning](#runtime-versioning)
31
+ - [Runtime Endpoints](#runtime-endpoints)
32
+ - [AgentCore Runtime Properties](#agentcore-runtime-properties)
33
+ - [Runtime Endpoint Properties](#runtime-endpoint-properties)
34
+ - [Creating a Runtime](#creating-a-runtime)
35
+ - [Option 1: Use an existing image in ECR](#option-1-use-an-existing-image-in-ecr)
36
+ - [Managing Endpoints and Versions](#managing-endpoints-and-versions)
37
+ - [Option 2: Use a local asset](#option-2-use-a-local-asset)
38
+ - [Browser Custom tool](#browser)
39
+ - [Browser properties](#browser-properties)
40
+ - [Browser Network modes](#browser-network-modes)
41
+ - [Basic Browser Creation](#basic-browser-creation)
42
+ - [Browser IAM permissions](#browser-iam-permissions)
43
+ - [Code Interpreter Custom tool](#code-interpreter)
44
+ - [Code Interpreter properties](#code-interpreter-properties)
45
+ - [Code Interpreter Network Modes](#code-interpreter-network-modes)
46
+ - [Basic Code Interpreter Creation](#basic-code-interpreter-creation)
47
+ - [Code Interpreter IAM permissions](#code-interpreter-iam-permissions)
48
+
49
+
50
+ ## AgentCore Runtime
51
+
52
+ The AgentCore Runtime construct enables you to deploy containerized agents on Amazon Bedrock AgentCore.
53
+ This L2 construct simplifies runtime creation just pass your ECR repository name
54
+ and the construct handles all the configuration with sensible defaults.
55
+
56
+ ### Runtime Endpoints
57
+
58
+ Endpoints provide a stable way to invoke specific versions of your agent runtime, enabling controlled deployments across different environments.
59
+ When you create an agent runtime, Amazon Bedrock AgentCore automatically creates a "DEFAULT" endpoint which always points to the latest version
60
+ of runtime.
61
+
62
+ You can create additional endpoints in two ways:
63
+
64
+ 1. **Using Runtime.addEndpoint()** - Convenient method when creating endpoints alongside the runtime.
65
+ 2. **Using RuntimeEndpoint** - Flexible approach for existing runtimes.
66
+
67
+ For example, you might keep a "production" endpoint on a stable version while testing newer versions
68
+ through a "staging" endpoint. This separation allows you to test changes thoroughly before promoting them
69
+ to production by simply updating the endpoint to point to the newer version.
70
+
71
+ ### AgentCore Runtime Properties
72
+
73
+ | Name | Type | Required | Description |
74
+ |------|------|----------|-------------|
75
+ | `runtimeName` | `string` | Yes | The name of the agent runtime. Valid characters are a-z, A-Z, 0-9, _ (underscore). Must start with a letter and can be up to 48 characters long |
76
+ | `agentRuntimeArtifact` | `AgentRuntimeArtifact` | Yes | The artifact configuration for the agent runtime containing the container configuration with ECR URI |
77
+ | `executionRole` | `iam.IRole` | No | The IAM role that provides permissions for the agent runtime. If not provided, a role will be created automatically |
78
+ | `networkConfiguration` | `NetworkConfiguration` | No | Network configuration for the agent runtime. Defaults to `RuntimeNetworkConfiguration.usingPublicNetwork()` |
79
+ | `description` | `string` | No | Optional description for the agent runtime |
80
+ | `protocolConfiguration` | `ProtocolType` | No | Protocol configuration for the agent runtime. Defaults to `ProtocolType.HTTP` |
81
+ | `authorizerConfiguration` | `RuntimeAuthorizerConfiguration` | No | Authorizer configuration for the agent runtime. Use `RuntimeAuthorizerConfiguration` static methods to create configurations for IAM, Cognito, JWT, or OAuth authentication |
82
+ | `environmentVariables` | `{ [key: string]: string }` | No | Environment variables for the agent runtime. Maximum 50 environment variables |
83
+ | `tags` | `{ [key: string]: string }` | No | Tags for the agent runtime. A list of key:value pairs of tags to apply to this Runtime resource |
84
+
85
+ ### Runtime Endpoint Properties
86
+
87
+ | Name | Type | Required | Description |
88
+ |------|------|----------|-------------|
89
+ | `endpointName` | `string` | Yes | The name of the runtime endpoint. Valid characters are a-z, A-Z, 0-9, _ (underscore). Must start with a letter and can be up to 48 characters long |
90
+ | `agentRuntimeId` | `string` | Yes | The Agent Runtime ID for this endpoint |
91
+ | `agentRuntimeVersion` | `string` | Yes | The Agent Runtime version for this endpoint. Must be between 1 and 5 characters long.|
92
+ | `description` | `string` | No | Optional description for the runtime endpoint |
93
+ | `tags` | `{ [key: string]: string }` | No | Tags for the runtime endpoint |
94
+
95
+ ### Creating a Runtime
96
+
97
+ #### Option 1: Use an existing image in ECR
98
+
99
+ Reference an image available within ECR.
100
+
101
+ ```typescript
102
+ const repository = new ecr.Repository(this, "TestRepository", {
103
+ repositoryName: "test-agent-runtime",
104
+ });
105
+
106
+ // The runtime by default create ECR permission only for the repository available in the account the stack is being deployed
107
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
108
+
109
+ // Create runtime using the built image
110
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
111
+ runtimeName: "myAgent",
112
+ agentRuntimeArtifact: agentRuntimeArtifact
113
+ });
114
+ ```
115
+
116
+ To grant the runtime permission to invoke a Bedrock model or inference profile:
117
+
118
+ ```typescript fixture=default
119
+ // Note: This example uses @aws-cdk/aws-bedrock-alpha which must be installed separately
120
+ declare const runtime: agentcore.Runtime;
121
+
122
+ // Create a cross-region inference profile for Claude 3.7 Sonnet
123
+ const inferenceProfile = bedrock.CrossRegionInferenceProfile.fromConfig({
124
+ geoRegion: bedrock.CrossRegionInferenceProfileRegion.US,
125
+ model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_7_SONNET_V1_0
126
+ });
127
+
128
+ // Grant the runtime permission to invoke the inference profile
129
+ inferenceProfile.grantInvoke(runtime);
130
+ ```
131
+
132
+ #### Option 2: Use a local asset
133
+
134
+ Reference a local directory containing a Dockerfile.
135
+ Images are built from a local Docker context directory (with a Dockerfile), uploaded to Amazon Elastic Container Registry (ECR)
136
+ by the CDK toolkit,and can be naturally referenced in your CDK app .
137
+
138
+ ```typescript
139
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromAsset(
140
+ path.join(__dirname, "path to agent dockerfile directory")
141
+ );
142
+
143
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
144
+ runtimeName: "myAgent",
145
+ agentRuntimeArtifact: agentRuntimeArtifact,
146
+ });
147
+ ```
148
+
149
+ ### Runtime Versioning
150
+
151
+ Amazon Bedrock AgentCore automatically manages runtime versioning to ensure safe deployments and rollback capabilities.
152
+ When you create an agent runtime, AgentCore automatically creates version 1 (V1). Each subsequent update to the
153
+ runtime configuration (such as updating the container image, modifying network settings, or changing protocol configurations)
154
+ creates a new immutable version. These versions contain complete, self-contained configurations that can be referenced by endpoints,
155
+ allowing you to maintain different versions for different environments or gradually roll out updates.
156
+
157
+ #### Managing Endpoints and Versions
158
+
159
+ Amazon Bedrock AgentCore automatically manages runtime versioning to provide safe deployments and rollback capabilities. You can follow
160
+ the steps below to understand how to use versioning with runtime for controlled deployments across different environments.
161
+
162
+ ##### Step 1: Initial Deployment
163
+
164
+ When you first create an agent runtime, AgentCore automatically creates Version 1 of your runtime. At this point, a DEFAULT endpoint is
165
+ automatically created that points to Version 1. This DEFAULT endpoint serves as the main access point for your runtime.
166
+
167
+ ```ts
168
+ const repository = new ecr.Repository(this, "TestRepository", {
169
+ repositoryName: "test-agent-runtime",
170
+ });
171
+
172
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
173
+ runtimeName: "myAgent",
174
+ agentRuntimeArtifact: agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0"),
175
+ });
176
+ ```
177
+
178
+ ##### Step 2: Creating Custom Endpoints
179
+
180
+ After the initial deployment, you can create additional endpoints for different environments. For example, you might create a "production"
181
+ endpoint that explicitly points to Version 1. This allows you to maintain stable access points for specific environments while keeping the
182
+ flexibility to test newer versions elsewhere.
183
+
184
+ ```ts
185
+ const repository = new ecr.Repository(this, "TestRepository", {
186
+ repositoryName: "test-agent-runtime",
187
+ });
188
+
189
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
190
+ runtimeName: "myAgent",
191
+ agentRuntimeArtifact: agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0"),
192
+ });
193
+
194
+ const prodEndpoint = runtime.addEndpoint("production", {
195
+ version: "1",
196
+ description: "Stable production endpoint - pinned to v1"
197
+ });
198
+ ```
199
+
200
+ ##### Step 3: Runtime Update Deployment
201
+
202
+ When you update the runtime configuration (such as updating the container image, modifying network settings, or changing protocol
203
+ configurations), AgentCore automatically creates a new version (Version 2). Upon this update:
204
+
205
+ - Version 2 is created automatically with the new configuration
206
+ - The DEFAULT endpoint automatically updates to point to Version 2
207
+ - Any explicitly pinned endpoints (like the production endpoint) remain on their specified versions
208
+
209
+ ```ts
210
+ const repository = new ecr.Repository(this, "TestRepository", {
211
+ repositoryName: "test-agent-runtime",
212
+ });
213
+
214
+ const agentRuntimeArtifactNew = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v2.0.0");
215
+
216
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
217
+ runtimeName: "myAgent",
218
+ agentRuntimeArtifact: agentRuntimeArtifactNew,
219
+ });
220
+ ```
221
+
222
+ ##### Step 4: Testing with Staging Endpoints
223
+
224
+ Once Version 2 exists, you can create a staging endpoint that points to the new version. This staging endpoint allows you to test the
225
+ new version in a controlled environment before promoting it to production. This separation ensures that production traffic continues
226
+ to use the stable version while you validate the new version.
227
+
228
+ ```ts
229
+ const repository = new ecr.Repository(this, "TestRepository", {
230
+ repositoryName: "test-agent-runtime",
231
+ });
232
+
233
+ const agentRuntimeArtifactNew = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v2.0.0");
234
+
235
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
236
+ runtimeName: "myAgent",
237
+ agentRuntimeArtifact: agentRuntimeArtifactNew,
238
+ });
239
+
240
+ const stagingEndpoint = runtime.addEndpoint("staging", {
241
+ version: "2",
242
+ description: "Staging environment for testing new version"
243
+ });
244
+ ```
245
+
246
+ ##### Step 5: Promoting to Production
247
+
248
+ After thoroughly testing the new version through the staging endpoint, you can update the production endpoint to point to Version 2.
249
+ This controlled promotion process ensures that you can validate changes before they affect production traffic.
250
+
251
+ ```ts
252
+ const repository = new ecr.Repository(this, "TestRepository", {
253
+ repositoryName: "test-agent-runtime",
254
+ });
255
+
256
+ const agentRuntimeArtifactNew = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v2.0.0");
257
+
258
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
259
+ runtimeName: "myAgent",
260
+ agentRuntimeArtifact: agentRuntimeArtifactNew,
261
+ });
262
+
263
+ const prodEndpoint = runtime.addEndpoint("production", {
264
+ version: "2", // New version added here
265
+ description: "Stable production endpoint"
266
+ });
267
+ ```
268
+
269
+ ### Creating Standalone Runtime Endpoints
270
+
271
+ RuntimeEndpoint can also be created as a standalone resource.
272
+
273
+ #### Example: Creating an endpoint for an existing runtime
274
+
275
+ ```typescript
276
+ // Reference an existing runtime by its ID
277
+ const existingRuntimeId = "abc123-runtime-id"; // The ID of an existing runtime
278
+
279
+ // Create a standalone endpoint
280
+ const endpoint = new agentcore.RuntimeEndpoint(this, "MyEndpoint", {
281
+ endpointName: "production",
282
+ agentRuntimeId: existingRuntimeId,
283
+ agentRuntimeVersion: "1", // Specify which version to use
284
+ description: "Production endpoint for existing runtime"
285
+ });
286
+ ```
287
+
288
+ ### Runtime Authentication Configuration
289
+
290
+ The AgentCore Runtime supports multiple authentication modes to secure access to your agent endpoints. Authentication is configured during runtime creation using the `RuntimeAuthorizerConfiguration` class's static factory methods.
291
+
292
+ #### IAM Authentication (Default)
293
+
294
+ IAM authentication is the default mode, when no authorizerConfiguration is set then the underlying service use IAM.
295
+
296
+ #### Cognito Authentication
297
+
298
+ To configure AWS Cognito User Pool authentication:
299
+
300
+ ```typescript
301
+ const repository = new ecr.Repository(this, "TestRepository", {
302
+ repositoryName: "test-agent-runtime",
303
+ });
304
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
305
+
306
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
307
+ runtimeName: "myAgent",
308
+ agentRuntimeArtifact: agentRuntimeArtifact,
309
+ authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingCognito(
310
+ "us-west-2_ABC123", // User Pool ID (required)
311
+ "client123", // Client ID (required)
312
+ "us-west-2" // Region (optional, defaults to stack region)
313
+ ),
314
+ });
315
+ ```
316
+
317
+ #### JWT Authentication
318
+
319
+ To configure custom JWT authentication with your own OpenID Connect (OIDC) provider:
320
+
321
+ ```typescript
322
+ const repository = new ecr.Repository(this, "TestRepository", {
323
+ repositoryName: "test-agent-runtime",
324
+ });
325
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
326
+
327
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
328
+ runtimeName: "myAgent",
329
+ agentRuntimeArtifact: agentRuntimeArtifact,
330
+ authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingJWT(
331
+ "https://example.com/.well-known/openid-configuration", // Discovery URL (required)
332
+ ["client1", "client2"], // Allowed Client IDs (optional)
333
+ ["audience1"] // Allowed Audiences (optional)
334
+ ),
335
+ });
336
+ ```
337
+
338
+ **Note**: The discovery URL must end with `/.well-known/openid-configuration`.
339
+
340
+ #### OAuth Authentication
341
+
342
+ To configure OAuth 2.0 authentication:
343
+
344
+ ```typescript
345
+ const repository = new ecr.Repository(this, "TestRepository", {
346
+ repositoryName: "test-agent-runtime",
347
+ });
348
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
349
+
350
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
351
+ runtimeName: "myAgent",
352
+ agentRuntimeArtifact: agentRuntimeArtifact,
353
+ authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingOAuth(
354
+ "https://github.com/.well-known/openid-configuration",
355
+ "oauth_client_123",
356
+ ),
357
+ });
358
+ ```
359
+
360
+ #### Using a Custom IAM Role
361
+
362
+ Instead of using the auto-created execution role, you can provide your own IAM role with specific permissions:
363
+ The auto-created role includes all necessary baseline permissions for ECR access, CloudWatch logging, and X-Ray tracing. When providing a custom role, ensure these permissions are included.
364
+
365
+ ### Runtime Network Configuration
366
+
367
+ The AgentCore Runtime supports two network modes for deployment:
368
+
369
+ #### Public Network Mode (Default)
370
+
371
+ By default, runtimes are deployed in PUBLIC network mode, which provides internet access suitable for less sensitive or open-use scenarios:
372
+
373
+ ```typescript
374
+ const repository = new ecr.Repository(this, "TestRepository", {
375
+ repositoryName: "test-agent-runtime",
376
+ });
377
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
378
+
379
+ // Explicitly using public network (this is the default)
380
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
381
+ runtimeName: "myAgent",
382
+ agentRuntimeArtifact: agentRuntimeArtifact,
383
+ networkConfiguration: agentcore.RuntimeNetworkConfiguration.usingPublicNetwork(),
384
+ });
385
+ ```
386
+
387
+ #### VPC Network Mode
388
+
389
+ For enhanced security and network isolation, you can deploy your runtime within a VPC:
390
+
391
+ ```typescript
392
+ const repository = new ecr.Repository(this, "TestRepository", {
393
+ repositoryName: "test-agent-runtime",
394
+ });
395
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
396
+
397
+ // Create or use an existing VPC
398
+ const vpc = new ec2.Vpc(this, 'MyVpc', {
399
+ maxAzs: 2,
400
+ });
401
+
402
+ // Configure runtime with VPC
403
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
404
+ runtimeName: "myAgent",
405
+ agentRuntimeArtifact: agentRuntimeArtifact,
406
+ networkConfiguration: agentcore.RuntimeNetworkConfiguration.usingVpc(this, {
407
+ vpc: vpc,
408
+ vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
409
+ // Optionally specify security groups, or one will be created automatically
410
+ // securityGroups: [mySecurityGroup],
411
+ }),
412
+ });
413
+ ```
414
+
415
+ #### Managing Security Groups with VPC Configuration
416
+
417
+ When using VPC mode, the Runtime implements `ec2.IConnectable`, allowing you to manage network access using the `connections` property:
418
+
419
+ ```typescript
420
+
421
+ const vpc = new ec2.Vpc(this, 'MyVpc', {
422
+ maxAzs: 2,
423
+ });
424
+
425
+ const repository = new ecr.Repository(this, "TestRepository", {
426
+ repositoryName: "test-agent-runtime",
427
+ });
428
+ const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
429
+
430
+ // Create runtime with VPC configuration
431
+ const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
432
+ runtimeName: "myAgent",
433
+ agentRuntimeArtifact: agentRuntimeArtifact,
434
+ networkConfiguration: agentcore.RuntimeNetworkConfiguration.usingVpc(this, {
435
+ vpc: vpc,
436
+ vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
437
+ }),
438
+ });
439
+
440
+ // Now you can manage network access using the connections property
441
+ // Allow inbound HTTPS traffic from a specific security group
442
+ const webServerSecurityGroup = new ec2.SecurityGroup(this, 'WebServerSG', { vpc });
443
+ runtime.connections.allowFrom(webServerSecurityGroup, ec2.Port.tcp(443), 'Allow HTTPS from web servers');
444
+
445
+ // Allow outbound connections to a database
446
+ const databaseSecurityGroup = new ec2.SecurityGroup(this, 'DatabaseSG', { vpc });
447
+ runtime.connections.allowTo(databaseSecurityGroup, ec2.Port.tcp(5432), 'Allow PostgreSQL connection');
448
+
449
+ // Allow outbound HTTPS to anywhere (for external API calls)
450
+ runtime.connections.allowToAnyIpv4(ec2.Port.tcp(443), 'Allow HTTPS outbound');
451
+ ```
452
+
453
+ ## Browser
454
+
455
+ The Amazon Bedrock AgentCore Browser provides a secure, cloud-based browser that enables AI agents to interact with websites. It includes security features such as session isolation, built-in observability through live viewing, CloudTrail logging, and session replay capabilities.
456
+
457
+ Additional information about the browser tool can be found in the [official documentation](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/browser-tool.html)
458
+
459
+ ### Browser Network modes
460
+
461
+ The Browser construct supports the following network modes:
462
+
463
+ 1. **Public Network Mode** (`BrowserNetworkMode.usingPublicNetwork()`) - Default
464
+
465
+ - Allows internet access for web browsing and external API calls
466
+ - Suitable for scenarios where agents need to interact with publicly available websites
467
+ - Enables full web browsing capabilities
468
+ - VPC mode is not supported with this option
469
+
470
+ 2. **VPC (Virtual Private Cloud)** (`BrowserNetworkMode.usingVpc()`)
471
+
472
+ - Select whether to run the browser in a virtual private cloud (VPC).
473
+ - By configuring VPC connectivity, you enable secure access to private resources such as databases, internal APIs, and services within your VPC.
474
+
475
+ While the VPC itself is mandatory, these are optional:
476
+ - Subnets - if not provided, CDK will select appropriate subnets from the VPC
477
+ - Security Groups - if not provided, CDK will create a default security group
478
+ - Specific subnet selection criteria - you can let CDK choose automatically
479
+
480
+ For more information on VPC connectivity for Amazon Bedrock AgentCore Browser, please refer to the [official documentation](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-vpc.html).
481
+
482
+ ### Browser Properties
483
+
484
+ | Name | Type | Required | Description |
485
+ |------|------|----------|-------------|
486
+ | `browserCustomName` | `string` | Yes | The name of the browser. Must start with a letter and can be up to 48 characters long. Pattern: `[a-zA-Z][a-zA-Z0-9_]{0,47}` |
487
+ | `description` | `string` | No | Optional description for the browser. Can have up to 200 characters |
488
+ | `networkConfiguration` | `BrowserNetworkConfiguration` | No | Network configuration for browser. Defaults to PUBLIC network mode |
489
+ | `recordingConfig` | `RecordingConfig` | No | Recording configuration for browser. Defaults to no recording |
490
+ | `executionRole` | `iam.IRole` | No | The IAM role that provides permissions for the browser to access AWS services. A new role will be created if not provided |
491
+ | `tags` | `{ [key: string]: string }` | No | Tags to apply to the browser resource |
492
+
493
+ ### Basic Browser Creation
494
+
495
+ ```typescript fixture=default
496
+ // Create a basic browser with public network access
497
+ const browser = new agentcore.BrowserCustom(this, "MyBrowser", {
498
+ browserCustomName: "my_browser",
499
+ description: "A browser for web automation",
500
+ });
501
+ ```
502
+
503
+ ### Browser with Tags
504
+
505
+ ```typescript fixture=default
506
+ // Create a browser with custom tags
507
+ const browser = new agentcore.BrowserCustom(this, "MyBrowser", {
508
+ browserCustomName: "my_browser",
509
+ description: "A browser for web automation with tags",
510
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingPublicNetwork(),
511
+ tags: {
512
+ Environment: "Production",
513
+ Team: "AI/ML",
514
+ Project: "AgentCore",
515
+ },
516
+ });
517
+ ```
518
+
519
+ ### Browser with VPC
520
+
521
+ ```typescript fixture=default
522
+ const browser = new agentcore.BrowserCustom(this, 'BrowserVpcWithRecording', {
523
+ browserCustomName: 'browser_recording',
524
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingVpc(this, {
525
+ vpc: new ec2.Vpc(this, 'VPC', { restrictDefaultSecurityGroup: false }),
526
+ }),
527
+ });
528
+ ```
529
+
530
+ Browser exposes a [connections](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) property. This property returns a connections object, which simplifies the process of defining and managing ingress and egress rules for security groups in your AWS CDK applications. Instead of directly manipulating security group rules, you interact with the Connections object of a construct, which then translates your connectivity requirements into the appropriate security group rules. For instance:
531
+
532
+ ```typescript fixture=default
533
+ const vpc = new ec2.Vpc(this, 'testVPC');
534
+
535
+ const browser = new agentcore.BrowserCustom(this, 'test-browser', {
536
+ browserCustomName: 'test_browser',
537
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingVpc(this, {
538
+ vpc: vpc,
539
+ }),
540
+ });
541
+
542
+ browser.connections.addSecurityGroup(new ec2.SecurityGroup(this, 'AdditionalGroup', { vpc }));
543
+ ```
544
+
545
+ So security groups can be added after the browser construct creation. You can use methods like allowFrom() and allowTo() to grant ingress access to/egress access from a specified peer over a given portRange. The Connections object automatically adds the necessary ingress or egress rules to the security group(s) associated with the calling construct.
546
+
547
+ ### Browser with Recording Configuration
548
+
549
+ ```typescript fixture=default
550
+ // Create an S3 bucket for recordings
551
+ const recordingBucket = new s3.Bucket(this, "RecordingBucket", {
552
+ bucketName: "my-browser-recordings",
553
+ removalPolicy: RemovalPolicy.DESTROY, // For demo purposes
554
+ });
555
+
556
+ // Create browser with recording enabled
557
+ const browser = new agentcore.BrowserCustom(this, "MyBrowser", {
558
+ browserCustomName: "my_browser",
559
+ description: "Browser with recording enabled",
560
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingPublicNetwork(),
561
+ recordingConfig: {
562
+ enabled: true,
563
+ s3Location: {
564
+ bucketName: recordingBucket.bucketName,
565
+ objectKey: "browser-recordings/",
566
+ },
567
+ },
568
+ });
569
+ ```
570
+
571
+ ### Browser with Custom Execution Role
572
+
573
+ ```typescript fixture=default
574
+ // Create a custom execution role
575
+ const executionRole = new iam.Role(this, "BrowserExecutionRole", {
576
+ assumedBy: new iam.ServicePrincipal("bedrock-agentcore.amazonaws.com"),
577
+ managedPolicies: [
578
+ iam.ManagedPolicy.fromAwsManagedPolicyName("AmazonBedrockAgentCoreBrowserExecutionRolePolicy"),
579
+ ],
580
+ });
581
+
582
+ // Create browser with custom execution role
583
+ const browser = new agentcore.BrowserCustom(this, "MyBrowser", {
584
+ browserCustomName: "my_browser",
585
+ description: "Browser with custom execution role",
586
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingPublicNetwork(),
587
+ executionRole: executionRole,
588
+ });
589
+ ```
590
+
591
+ ### Browser with S3 Recording and Permissions
592
+
593
+ ```typescript fixture=default
594
+ // Create an S3 bucket for recordings
595
+ const recordingBucket = new s3.Bucket(this, "RecordingBucket", {
596
+ bucketName: "my-browser-recordings",
597
+ removalPolicy: RemovalPolicy.DESTROY, // For demo purposes
598
+ });
599
+
600
+ // Create browser with recording enabled
601
+ const browser = new agentcore.BrowserCustom(this, "MyBrowser", {
602
+ browserCustomName: "my_browser",
603
+ description: "Browser with recording enabled",
604
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingPublicNetwork(),
605
+ recordingConfig: {
606
+ enabled: true,
607
+ s3Location: {
608
+ bucketName: recordingBucket.bucketName,
609
+ objectKey: "browser-recordings/",
610
+ },
611
+ },
612
+ });
613
+
614
+ // The browser construct automatically grants S3 permissions to the execution role
615
+ // when recording is enabled, so no additional IAM configuration is needed
616
+ ```
617
+
618
+ ### Browser IAM Permissions
619
+
620
+ The Browser construct provides convenient methods for granting IAM permissions:
621
+
622
+ ```typescript fixture=default
623
+ // Create a browser
624
+ const browser = new agentcore.BrowserCustom(this, "MyBrowser", {
625
+ browserCustomName: "my_browser",
626
+ description: "Browser for web automation",
627
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingPublicNetwork(),
628
+ });
629
+
630
+ // Create a role that needs access to the browser
631
+ const userRole = new iam.Role(this, "UserRole", {
632
+ assumedBy: new iam.ServicePrincipal("lambda.amazonaws.com"),
633
+ });
634
+
635
+ // Grant read permissions (Get and List actions)
636
+ browser.grantRead(userRole);
637
+
638
+ // Grant use permissions (Start, Update, Stop actions)
639
+ browser.grantUse(userRole);
640
+
641
+ // Grant specific custom permissions
642
+ browser.grant(userRole, "bedrock-agentcore:GetBrowserSession");
643
+ ```
644
+
645
+ ## Code Interpreter
646
+
647
+ The Amazon Bedrock AgentCore Code Interpreter enables AI agents to write and execute code securely in sandbox environments, enhancing their accuracy and expanding their ability to solve complex end-to-end tasks. This is critical in Agentic AI applications where the agents may execute arbitrary code that can lead to data compromise or security risks. The AgentCore Code Interpreter tool provides secure code execution, which helps you avoid running into these issues.
648
+
649
+ For more information about code interpreter, please refer to the [official documentation](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/code-interpreter-tool.html)
650
+
651
+ ### Code Interpreter Network Modes
652
+
653
+ The Code Interpreter construct supports the following network modes:
654
+
655
+ 1. **Public Network Mode** (`CodeInterpreterNetworkMode.usingPublicNetwork()`) - Default
656
+
657
+ - Allows internet access for package installation and external API calls
658
+ - Suitable for development and testing environments
659
+ - Enables downloading Python packages from PyPI
660
+
661
+ 2. **Sandbox Network Mode** (`CodeInterpreterNetworkMode.usingSandboxNetwork()`)
662
+ - Isolated network environment with no internet access
663
+ - Suitable for production environments with strict security requirements
664
+ - Only allows access to pre-installed packages and local resources
665
+
666
+ 3. **VPC (Virtual Private Cloud)** (`CodeInterpreterNetworkMode.usingVpc()`)
667
+ - Select whether to run the browser in a virtual private cloud (VPC).
668
+ - By configuring VPC connectivity, you enable secure access to private resources such as databases, internal APIs, and services within your VPC.
669
+
670
+ While the VPC itself is mandatory, these are optional:
671
+ - Subnets - if not provided, CDK will select appropriate subnets from the VPC
672
+ - Security Groups - if not provided, CDK will create a default security group
673
+ - Specific subnet selection criteria - you can let CDK choose automatically
674
+
675
+ For more information on VPC connectivity for Amazon Bedrock AgentCore Browser, please refer to the [official documentation](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-vpc.html).
676
+
677
+ ### Code Interpreter Properties
678
+
679
+ | Name | Type | Required | Description |
680
+ |------|------|----------|-------------|
681
+ | `codeInterpreterCustomName` | `string` | Yes | The name of the code interpreter. Must start with a letter and can be up to 48 characters long. Pattern: `[a-zA-Z][a-zA-Z0-9_]{0,47}` |
682
+ | `description` | `string` | No | Optional description for the code interpreter. Can have up to 200 characters |
683
+ | `executionRole` | `iam.IRole` | No | The IAM role that provides permissions for the code interpreter to access AWS services. A new role will be created if not provided |
684
+ | `networkConfiguration` | `CodeInterpreterNetworkConfiguration` | No | Network configuration for code interpreter. Defaults to PUBLIC network mode |
685
+ | `tags` | `{ [key: string]: string }` | No | Tags to apply to the code interpreter resource |
686
+
687
+ ### Basic Code Interpreter Creation
688
+
689
+ ```typescript fixture=default
690
+ // Create a basic code interpreter with public network access
691
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
692
+ codeInterpreterCustomName: "my_code_interpreter",
693
+ description: "A code interpreter for Python execution",
694
+ });
695
+ ```
696
+
697
+ ### Code Interpreter with VPC
698
+
699
+ ```typescript fixture=default
700
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
701
+ codeInterpreterCustomName: "my_sandbox_interpreter",
702
+ description: "Code interpreter with isolated network access",
703
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingVpc(this, {
704
+ vpc: new ec2.Vpc(this, 'VPC', { restrictDefaultSecurityGroup: false }),
705
+ }),
706
+ });
707
+ ```
708
+
709
+ Code Interpreter exposes a [connections](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) property. This property returns a connections object, which simplifies the process of defining and managing ingress and egress rules for security groups in your AWS CDK applications. Instead of directly manipulating security group rules, you interact with the Connections object of a construct, which then translates your connectivity requirements into the appropriate security group rules. For instance:
710
+
711
+ ```typescript fixture=default
712
+ const vpc = new ec2.Vpc(this, 'testVPC');
713
+
714
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
715
+ codeInterpreterCustomName: "my_sandbox_interpreter",
716
+ description: "Code interpreter with isolated network access",
717
+ networkConfiguration: agentcore.BrowserNetworkConfiguration.usingVpc(this, {
718
+ vpc: vpc,
719
+ }),
720
+ });
721
+
722
+ codeInterpreter.connections.addSecurityGroup(new ec2.SecurityGroup(this, 'AdditionalGroup', { vpc }));
723
+ ```
724
+
725
+ So security groups can be added after the browser construct creation. You can use methods like allowFrom() and allowTo() to grant ingress access to/egress access from a specified peer over a given portRange. The Connections object automatically adds the necessary ingress or egress rules to the security group(s) associated with the calling construct.
726
+
727
+ ### Code Interpreter with Sandbox Network Mode
728
+
729
+ ```typescript fixture=default
730
+ // Create code interpreter with sandbox network mode (isolated)
731
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
732
+ codeInterpreterCustomName: "my_sandbox_interpreter",
733
+ description: "Code interpreter with isolated network access",
734
+ networkConfiguration: agentcore.CodeInterpreterNetworkConfiguration.usingSandboxNetwork(),
735
+ });
736
+ ```
737
+
738
+ ### Code Interpreter with Custom Execution Role
739
+
740
+ ```typescript fixture=default
741
+ // Create a custom execution role
742
+ const executionRole = new iam.Role(this, "CodeInterpreterExecutionRole", {
743
+ assumedBy: new iam.ServicePrincipal("bedrock-agentcore.amazonaws.com"),
744
+ });
745
+
746
+ // Create code interpreter with custom execution role
747
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
748
+ codeInterpreterCustomName: "my_code_interpreter",
749
+ description: "Code interpreter with custom execution role",
750
+ networkConfiguration: agentcore.CodeInterpreterNetworkConfiguration.usingPublicNetwork(),
751
+ executionRole: executionRole,
752
+ });
753
+ ```
754
+
755
+ ### Code Interpreter IAM Permissions
756
+
757
+ The Code Interpreter construct provides convenient methods for granting IAM permissions:
758
+
759
+ ```typescript fixture=default
760
+ // Create a code interpreter
761
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
762
+ codeInterpreterCustomName: "my_code_interpreter",
763
+ description: "Code interpreter for Python execution",
764
+ networkConfiguration: agentcore.CodeInterpreterNetworkConfiguration.usingPublicNetwork(),
765
+ });
766
+
767
+ // Create a role that needs access to the code interpreter
768
+ const userRole = new iam.Role(this, "UserRole", {
769
+ assumedBy: new iam.ServicePrincipal("lambda.amazonaws.com"),
770
+ });
771
+
772
+ // Grant read permissions (Get and List actions)
773
+ codeInterpreter.grantRead(userRole);
774
+
775
+ // Grant use permissions (Start, Invoke, Stop actions)
776
+ codeInterpreter.grantUse(userRole);
777
+
778
+ // Grant specific custom permissions
779
+ codeInterpreter.grant(userRole, "bedrock-agentcore:GetCodeInterpreterSession");
780
+ ```
781
+
782
+ ### Code interpreter with tags
783
+
784
+ ```typescript fixture=default
785
+ // Create code interpreter with sandbox network mode (isolated)
786
+ const codeInterpreter = new agentcore.CodeInterpreterCustom(this, "MyCodeInterpreter", {
787
+ codeInterpreterCustomName: "my_sandbox_interpreter",
788
+ description: "Code interpreter with isolated network access",
789
+ networkConfiguration: agentcore.CodeInterpreterNetworkConfiguration.usingPublicNetwork(),
790
+ tags: {
791
+ Environment: "Production",
792
+ Team: "AI/ML",
793
+ Project: "AgentCore",
794
+ },
795
+ });
796
+ ```