You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use SDK-native certificates parameter for Code Interpreter (#1416)
The CodeInterpreter SDK wrapper supports the certificates parameter
on create_code_interpreter(). Replace the boto3 control plane workaround
with Certificate.from_secret_arn(), matching the pattern used for
BrowserClient.create_browser().
Co-authored-by: Sundar Raghavan <sdraghav@amazon.com>
Copy file name to clipboardExpand all lines: 01-tutorials/05-AgentCore-tools/02-Agent-Core-browser-tool/13-browser-chrome-policies/browser-chrome-policies.ipynb
+32-46Lines changed: 32 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
"\n",
15
15
"**Part 1** creates a Chrome policy that locks the browser to AWS documentation, uses Playwright to demonstrate the restrictions (allowed URL succeeds, blocked URL is rejected by Chrome), and uses session recording to review the enforcement.\n",
16
16
"\n",
17
-
"**Part 2** demonstrates custom root CA certificates using [badssl.com](https://badssl.com) \u2014 a public site with an intentionally untrusted certificate \u2014 to show how Code Interpreter sessions can trust non-public CAs."
17
+
"**Part 2** demonstrates custom root CA certificates using [badssl.com](https://badssl.com) — a public site with an intentionally untrusted certificate — to show how Code Interpreter sessions can trust non-public CAs."
"# Trust policy \u2014 bedrock-agentcore.amazonaws.com is the service principal\n",
155
+
"# Trust policy — bedrock-agentcore.amazonaws.com is the service principal\n",
156
156
"trust_policy = {\n",
157
157
"\"Version\": \"2012-10-17\",\n",
158
158
"\"Statement\": [{\n",
@@ -263,7 +263,7 @@
263
263
"id": "ba7a07117329",
264
264
"metadata": {},
265
265
"source": [
266
-
"> **Important \u2014 CDP compatibility:** Do not set `DeveloperToolsAvailability` to `2` (disabled). All AgentCore Browser automation uses the Chrome DevTools Protocol (CDP) via Playwright's `connect_over_cdp`. Setting this policy to `2` disables CDP at the Chrome level, which silently breaks all automation \u2014 the WebSocket connection succeeds at the proxy layer but Chrome refuses CDP commands, causing timeouts. Use `0` (allowed) or `1` (allowed only for extensions) instead.\n"
266
+
"> **Important — CDP compatibility:** Do not set `DeveloperToolsAvailability` to `2` (disabled). All AgentCore Browser automation uses the Chrome DevTools Protocol (CDP) via Playwright's `connect_over_cdp`. Setting this policy to `2` disables CDP at the Chrome level, which silently breaks all automation — the WebSocket connection succeeds at the proxy layer but Chrome refuses CDP commands, causing timeouts. Use `0` (allowed) or `1` (allowed only for extensions) instead.\n"
267
267
]
268
268
},
269
269
{
@@ -309,8 +309,8 @@
309
309
"\n",
310
310
"Create a custom browser that enforces the Chrome policy on every session. The `enterprise_policies` parameter takes a list of policy objects, each with a `location` (S3 path to the JSON file) and a `type`:\n",
311
311
"\n",
312
-
"- **`MANAGED`** \u2014 enforced at the browser level, cannot be overridden (maps to Chrome's `/etc/chromium/policies/managed/`)\n",
313
-
"- **`RECOMMENDED`** \u2014 applied at the session level as preferences (maps to Chrome's `/etc/chromium/policies/recommended/`)\n",
312
+
"- **`MANAGED`** — enforced at the browser level, cannot be overridden (maps to Chrome's `/etc/chromium/policies/managed/`)\n",
313
+
"- **`RECOMMENDED`** — applied at the session level as preferences (maps to Chrome's `/etc/chromium/policies/recommended/`)\n",
314
314
"\n",
315
315
"Session recording is enabled so you can replay the session afterward in the AgentCore console."
"Start a browser session and use [Playwright](https://playwright.dev/docs/intro) to navigate to two URLs:\n",
418
418
"\n",
419
-
"1. **`docs.aws.amazon.com`** \u2014 allowed by the policy \u2192 page loads successfully\n",
420
-
"2. **`www.wikipedia.org`** \u2014 blocked by the policy \u2192 Chrome displays an error page\n",
419
+
"1. **`docs.aws.amazon.com`** — allowed by the policy → page loads successfully\n",
420
+
"2. **`www.wikipedia.org`** — blocked by the policy → Chrome displays an error page\n",
421
421
"\n",
422
422
"This demonstrates that the restriction happens at the browser level, independent of any agent prompt or reasoning logic.\n",
423
423
"\n",
424
-
"> **Tip:** While this cell runs, you can watch the browser live in the AgentCore console. Navigate to **Built-in tools** \u2192 **docs_research_browser** \u2192 **View live session**."
424
+
"> **Tip:** While this cell runs, you can watch the browser live in the AgentCore console. Navigate to **Built-in tools** → **docs_research_browser** → **View live session**."
425
425
]
426
426
},
427
427
{
@@ -457,7 +457,7 @@
457
457
" context = browser.contexts[0]\n",
458
458
" page = context.pages[0] if context.pages else await context.new_page()\n",
459
459
"\n",
460
-
" # \u2500\u2500 Test 1: Navigate to ALLOWED URL \u2500\u2500\n",
460
+
" # ── Test 1: Navigate to ALLOWED URL ──\n",
461
461
" print(\"\\n\" + \"=\" * 60)\n",
462
462
" print(\"TEST 1: Navigate to docs.aws.amazon.com (ALLOWED)\")\n",
463
463
" print(\"=\" * 60)\n",
@@ -480,7 +480,7 @@
480
480
" print(f\"Extracted {len(text)} chars\")\n",
481
481
" print(f\"First 500 chars:\\n{text[:500]}\")\n",
482
482
"\n",
483
-
" # \u2500\u2500 Test 2: Navigate to BLOCKED URL \u2500\u2500\n",
483
+
" # ── Test 2: Navigate to BLOCKED URL ──\n",
484
484
" print(\"\\n\" + \"=\" * 60)\n",
485
485
" print(\"TEST 2: Navigate to www.wikipedia.org (BLOCKED)\")\n",
" print(\"Result: CHROME POLICY BLOCKED THIS URL \u2705\")\n",
497
+
" print(\"Result: CHROME POLICY BLOCKED THIS URL ✅\")\n",
498
498
"\n",
499
499
" await browser.close()\n",
500
500
" return text\n",
@@ -522,9 +522,9 @@
522
522
"5. Choose **View Recording**\n",
523
523
"\n",
524
524
"The replay interface shows:\n",
525
-
"- **Video player** \u2014 interactive playback with timeline scrubber\n",
526
-
"- **User actions** \u2014 timestamped navigation events, including the blocked URL attempt\n",
527
-
"- **Network events** \u2014 confirming only `docs.aws.amazon.com` traffic succeeded"
525
+
"- **Video player** — interactive playback with timeline scrubber\n",
526
+
"- **User actions** — timestamped navigation events, including the blocked URL attempt\n",
527
+
"- **Network events** — confirming only `docs.aws.amazon.com` traffic succeeded"
528
528
]
529
529
},
530
530
{
@@ -536,7 +536,7 @@
536
536
"\n",
537
537
"You can also use the policy-restricted browser with an AI agent framework. The cell below creates a [Strands](https://strandsagents.com/) agent that researches AgentCore documentation. The agent will succeed on `docs.aws.amazon.com` and observe that `wikipedia.org` is blocked.\n",
538
538
"\n",
539
-
"This sample uses Anthropic Claude through Amazon Bedrock. AgentCore is model-agnostic \u2014 you can substitute any model provider. For model configuration, refer to [Model Providers](https://strandsagents.com/latest/user-guide/concepts/model-providers/).\n",
539
+
"This sample uses Anthropic Claude through Amazon Bedrock. AgentCore is model-agnostic — you can substitute any model provider. For model configuration, refer to [Model Providers](https://strandsagents.com/latest/user-guide/concepts/model-providers/).\n",
540
540
"\n",
541
541
"> **Note:** The `AgentCoreBrowser` tool in `strands-agents-tools` creates browser sessions on demand. If you experience connection timeouts on the first attempt, the tool will retry. The first session creation for a newly created browser may take longer."
542
542
]
@@ -596,7 +596,7 @@
596
596
"\n",
597
597
"Organizations that run internal services with private certificate authorities, or route traffic through SSL-intercepting corporate proxies, need their agents to trust those non-public certificates.\n",
598
598
"\n",
599
-
"To demonstrate this capability without requiring internal infrastructure, this section uses [https://untrusted-root.badssl.com](https://untrusted-root.badssl.com) \u2014 a public website that intentionally uses a certificate signed by an untrusted root CA. Normally, HTTPS connections to this site fail with SSL certificate errors, just like connections to your internal services would fail without the correct root CA."
599
+
"To demonstrate this capability without requiring internal infrastructure, this section uses [https://untrusted-root.badssl.com](https://untrusted-root.badssl.com) — a public website that intentionally uses a certificate signed by an untrusted root CA. Normally, HTTPS connections to this site fail with SSL certificate errors, just like connections to your internal services would fail without the correct root CA."
600
600
]
601
601
},
602
602
{
@@ -677,7 +677,7 @@
677
677
"id": "04d58e025d2e",
678
678
"metadata": {},
679
679
"source": [
680
-
"### Step 6: Code Interpreter WITHOUT root CA \u2014 expect SSL error\n",
680
+
"### Step 6: Code Interpreter WITHOUT root CA — expect SSL error\n",
681
681
"\n",
682
682
"Create a default Code Interpreter session and attempt to connect to `https://untrusted-root.badssl.com`. The connection will fail because the root CA is not trusted."
683
683
]
@@ -727,11 +727,9 @@
727
727
"id": "43c58bb1e8f7",
728
728
"metadata": {},
729
729
"source": [
730
-
"### Step 7: Code Interpreter WITH root CA \u2014 expect HTTP 200\n",
730
+
"### Step 7: Code Interpreter WITH root CA — expect HTTP 200\n",
731
731
"\n",
732
-
"Create a custom Code Interpreter that trusts the BadSSL root CA certificate using the `certificates` parameter.\n",
733
-
"\n",
734
-
"> **Note:** The `CodeInterpreter` SDK wrapper does not yet support the `certificates` parameter in `create_code_interpreter()`. The cell below uses the boto3 control plane client directly for creation, then switches back to the SDK for session operations. Once the SDK is updated, you can use `Certificate.from_secret_arn(secret_arn)` directly \u2014 the same pattern shown in the Browser\u2019s `create_browser()` call.\n"
732
+
"Create a custom Code Interpreter that trusts the BadSSL root CA certificate using the `certificates` parameter. This uses the same `Certificate.from_secret_arn(...)` pattern shown in the Browser's `create_browser()` call.\n"
" print(\" The connection succeeded because the root CA is now trusted.\")\n",
820
806
" print(f\" Output: {stdout[:200]}\")\n",
821
807
" else:\n",
@@ -839,7 +825,7 @@
839
825
"| Internal corporate services | Your organization's root CA certificate (HR portal, Jira, Artifactory) | Reference the secret ARN in `certificates` when creating a browser or code interpreter |\n",
840
826
"| SSL-intercepting corporate proxies | Your proxy's root CA certificate (Zscaler, Palo Alto Networks) | Reference the secret ARN in `certificates` and configure proxy settings |\n",
841
827
"\n",
842
-
"You can combine root CA certificates with Chrome policies in a single `create_browser` call \u2014 see the accompanying blog post for a combined example."
828
+
"You can combine root CA certificates with Chrome policies in a single `create_browser` call — see the accompanying blog post for a combined example."
0 commit comments