For the complete documentation index, see llms.txt.
Skip to main content
Version: 8.11 (unreleased)

Amazon Bedrock Code Interpreter connector

Use the Amazon Bedrock Code Interpreter connector to execute code in a secure Amazon Bedrock AgentCore Code Interpreter sandbox from your BPMN process.

About this connector​

The Amazon Bedrock Code Interpreter connector is an outbound connector. It starts a sandbox session, runs the Python, JavaScript, or TypeScript code you provide, and returns the output and any files generated by the code as Camunda documents. The session is stopped when the code has run.

Prerequisites​

To use the Amazon Bedrock Code Interpreter connector, you need the following:

  • An AWS account with an access key and secret key, a configured default credentials chain (hybrid/Self-Managed only), or a saved AWS credential.
  • IAM permissions to execute the following actions on the bedrock-agentcore service:
    • StartCodeInterpreterSession
    • InvokeCodeInterpreter
    • StopCodeInterpreterSession
  • The AgentCore Code Interpreter service must be available in your selected AWS region.

Learn more about the AgentCore Code Interpreter in the official documentation.

note

Use secrets to store credentials and avoid exposing sensitive information from the process. See managing secrets.

Use this connector​

New to using an outbound connector? Learn how to add and use this type of connector, apply element templates, use connector secrets, handle results and errors, and more.

Configuration​

Authentication​

PropertyTypeRequiredDescriptionExample
AWS credentialConfigurationNoSelect a saved AWS credential with an optional default region, or enter the authentication details and a region in the fields below. Learn more about credentials.
AuthenticationDropdownYes, if no AWS credential is set

The AWS authentication strategy:

  • Credentials (SaaS/Self-Managed): Use this option if you have a valid pair of access and secret keys provided by your AWS account administrator.

  • Default Credentials Chain (hybrid/Self-Managed only): Use this option if your system is configured for implicit authentication, such as role-based authentication, credentials supplied through environment variables, or files on the target host. This approach uses the Default Credential Provider Chain to resolve the required credentials.

Access keyStringYes, if Authentication is CredentialsThe access key of an IAM user with the necessary permissions for this connector.
Secret keyStringYes, if Authentication is CredentialsThe secret key of the IAM user with the access key above.

For more information on authentication and security in Amazon Bedrock, see Amazon Bedrock security and privacy.

Region​

PropertyTypeRequiredDescriptionExample
RegionStringYes, if no AWS credential is setThe AWS region where Amazon Bedrock AgentCore Code Interpreter is available.us-east-1
RegionStringYes, if the credential has no default regionOverrides the default region of the selected AWS credential. Shown when an AWS credential is selected. Required when the credential has no default region.

Operations​

The connector has a single operation, which runs code in the sandbox.

Run code​

Execute code in an Amazon Bedrock AgentCore Code Interpreter sandbox session.

Input parameters​

PropertyTypeRequiredDescriptionExample
LanguageDropdownYesThe programming language of the code: Python, JavaScript, or TypeScript.
CodeStringYesThe code to execute in the Code Interpreter sandbox. Supports FEEL expressions.
Code Interpreter IDStringNoThe identifier of the Code Interpreter to use. The default is aws.codeinterpreter.v1, the AWS managed default.
Session timeoutStringNoThe session timeout as an ISO 8601 duration. The default is PT5M (5 minutes).PT10M
Max files to retrieveNumberNoThe maximum number of generated files to retrieve. The default is 10.
Max total file sizeNumberNoThe maximum total size of the retrieved files in bytes. The default is 10485760 (10 MB).
note

The session timeout controls how long the sandbox environment remains available, not how long the code takes to execute. Code execution typically completes in seconds.

The sandbox environment includes common Python libraries such as matplotlib, pandas, numpy, and csv. Network access is not available in the sandbox.

File handling​

Any files created by the code during execution are automatically detected and returned as Camunda documents in the files field. This includes images (for example, charts saved with plt.savefig()), CSV files, text files, and other output files. Hidden files (names starting with a dot) are not returned.

Retrieval is limited by Max files to retrieve and Max total file size. Files beyond these limits are not returned, and a warning is logged.

Output​

The connector returns the following fields:

FieldDescription
stdoutThe standard output printed by the code.
stderrAny error output produced during execution.
exitCodeThe process exit code. A value of 0 indicates successful execution.
executionTimeMsThe execution duration in milliseconds.
filesA list of Camunda documents for any files generated by the code.

To map specific fields into process variables, use Result expression. For example, to extract the output and generated files:

= {
output: stdout,
files: files
}

Example: Run a calculation​

Code:

total = sum([12000, 8500, 15000, 9200])
print(f"Total claims: ${total:,}")

Response:

{
"stdout": "Total claims: $44,700\n",
"stderr": "",
"exitCode": 0,
"executionTimeMs": 0.05,
"files": []
}

Example: Generate a chart​

Code:

import matplotlib.pyplot as plt
plt.bar(["Q1", "Q2", "Q3", "Q4"], [12000, 8500, 15000, 9200])
plt.title("Claims by Quarter")
plt.ylabel("Amount ($)")
plt.savefig("chart.png")
print("Chart saved")

Response:

{
"stdout": "Chart saved\n",
"stderr": "",
"exitCode": 0,
"executionTimeMs": 1.67,
"files": [
{
"storeId": "in-memory",
"documentId": "851505b2-61bd-4717-9c86-07678b67f033",
"metadata": {
"contentType": "image/png",
"size": 14734,
"fileName": "chart.png"
},
"camunda.document.type": "camunda"
}
]
}

Example: Generate a CSV report​

Code:

import csv
with open("claims.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["ClaimID", "Amount", "Status"])
w.writerows([["C001", 45000, "Rejected"], ["C002", 12000, "Approved"]])
print("Report created")

Response:

{
"stdout": "Report created\n",
"stderr": "",
"exitCode": 0,
"executionTimeMs": 0.05,
"files": [
{
"storeId": "in-memory",
"documentId": "c209e3a4-cefa-4622-adc1-88c92bf06bb2",
"metadata": {
"contentType": "text/csv",
"size": 80,
"fileName": "claims.csv"
},
"camunda.document.type": "camunda"
}
]
}

Troubleshooting​

To learn about general error handling in Camunda, see BPMN errors and failing jobs.

Connector-specific errors​

The connector fails the job with the error code CODE_INTERPRETER_FAILED when Code is empty, when the AWS service returns an error, or when the invocation times out or is interrupted. To handle it in your process, use Error expression.