class Runtime (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Bedrock.Agentcore.Alpha.Runtime |
Go | github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2#Runtime |
Java | software.amazon.awscdk.services.bedrock.agentcore.alpha.Runtime |
Python | aws_cdk.aws_bedrock_agentcore_alpha.Runtime |
TypeScript (source) | @aws-cdk/aws-bedrock-agentcore-alpha ยป Runtime |
Implements
IConstruct, IDependable, IResource, IBedrock, IGrantable, IConnectable
Bedrock Agent Core Runtime Enables running containerized agents with specific network configurations, security settings, and runtime artifacts.
See also: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime.html
Example
const repository = new ecr.Repository(this, "TestRepository", {
repositoryName: "test-agent-runtime",
});
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, "v1.0.0");
const runtime = new agentcore.Runtime(this, "MyAgentRuntime", {
runtimeName: "myAgent",
agentRuntimeArtifact: agentRuntimeArtifact,
authorizerConfiguration: agentcore.RuntimeAuthorizerConfiguration.usingOAuth(
"https://github.com/.well-known/openid-configuration",
"oauth_client_123",
),
});
Initializer
new Runtime(scope: Construct, id: string, props: RuntimeProps)
Parameters
- scope
Construct - id
string - props
RuntimeProps
Construct Props
| Name | Type | Description |
|---|---|---|
| agent | Agent | The artifact configuration for the agent runtime Contains the container configuration with ECR URI. |
| runtime | string | 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 Pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,47}$. |
| authorizer | Runtime | Authorizer configuration for the agent runtime Use RuntimeAuthorizerConfiguration static methods to create the configuration. |
| description? | string | Optional description for the agent runtime. |
| environment | { [string]: string } | Environment variables for the agent runtime - Maximum 50 environment variables - Key: Must be 1-100 characters, start with letter or underscore, contain only letters, numbers, and underscores - Value: Must be 0-2048 characters (per CloudFormation specification). |
| execution | IRole | The IAM role that provides permissions for the agent runtime If not provided, a role will be created automatically. |
| network | Runtime | Network configuration for the agent runtime. |
| protocol | Protocol | Protocol configuration for the agent runtime. |
| tags? | { [string]: string } | Tags for the agent runtime A list of key:value pairs of tags to apply to this Runtime resource. |
agentRuntimeArtifact
Type:
Agent
The artifact configuration for the agent runtime Contains the container configuration with ECR URI.
runtimeName
Type:
string
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 Pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,47}$.
authorizerConfiguration?
Type:
Runtime
(optional, default: RuntimeAuthorizerConfiguration.iam() (IAM authentication))
Authorizer configuration for the agent runtime Use RuntimeAuthorizerConfiguration static methods to create the configuration.
description?
Type:
string
(optional, default: No description
Length Minimum: 1 , Maximum: 1200)
Optional description for the agent runtime.
environmentVariables?
Type:
{ [string]: string }
(optional, default: No environment variables)
Environment variables for the agent runtime - Maximum 50 environment variables - Key: Must be 1-100 characters, start with letter or underscore, contain only letters, numbers, and underscores - Value: Must be 0-2048 characters (per CloudFormation specification).
executionRole?
Type:
IRole
(optional, default: A new role will be created)
The IAM role that provides permissions for the agent runtime If not provided, a role will be created automatically.
networkConfiguration?
Type:
Runtime
(optional, default: RuntimeNetworkConfiguration.usingPublicNetwork())
Network configuration for the agent runtime.
protocolConfiguration?
Type:
Protocol
(optional, default: ProtocolType.HTTP)
Protocol configuration for the agent runtime.
tags?
Type:
{ [string]: string }
(optional, default: {} - no tags)
Tags for the agent runtime A list of key:value pairs of tags to apply to this Runtime resource.
Properties
| Name | Type | Description |
|---|---|---|
| agent | string | The ARN of the agent runtime. |
| agent | Agent | The artifact configuration for the agent runtime. |
| agent | string | The unique identifier of the agent runtime. |
| agent | string | The name of the agent runtime. |
| connections | Connections | An accessor for the Connections object that will fail if this Runtime does not have a VPC configured. |
| env | Resource | The environment this resource belongs to. |
| grant | IPrincipal | The principal to grant permissions to. |
| node | Node | The tree node. |
| role | IRole | The IAM role that provides permissions for the agent runtime. |
| stack | Stack | The stack in which this resource is defined. |
| agent | string | The version of the agent runtime. |
| agent | string | The status of the agent runtime. |
| created | string | The timestamp when the agent runtime was created. |
| description? | string | Optional description for the agent runtime. |
| last | string | The timestamp when the agent runtime was last updated. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
agentRuntimeArn
Type:
string
The ARN of the agent runtime.
agentRuntimeArtifact
Type:
Agent
The artifact configuration for the agent runtime.
agentRuntimeId
Type:
string
The unique identifier of the agent runtime.
agentRuntimeName
Type:
string
The name of the agent runtime.
connections
Type:
Connections
An accessor for the Connections object that will fail if this Runtime does not have a VPC configured.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
grantPrincipal
Type:
IPrincipal
The principal to grant permissions to.
node
Type:
Node
The tree node.
role
Type:
IRole
The IAM role that provides permissions for the agent runtime.
stack
Type:
Stack
The stack in which this resource is defined.
agentRuntimeVersion?
Type:
string
(optional)
The version of the agent runtime.
agentStatus?
Type:
string
(optional)
The status of the agent runtime.
createdAt?
Type:
string
(optional)
The timestamp when the agent runtime was created.
description?
Type:
string
(optional)
Optional description for the agent runtime.
lastUpdatedAt?
Type:
string
(optional)
The timestamp when the agent runtime was last updated.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| add | Add an endpoint to this runtime This is a convenience method that creates a RuntimeEndpoint associated with this runtime. |
| add | Adds a policy statement to the runtime's execution role. |
| apply | Apply the given removal policy to this resource. |
| grant(actions, resources) | Grant the runtime specific actions on AWS resources. |
| grant | Permits an IAM principal to invoke this runtime both directly and on behalf of users Grants both bedrock-agentcore:InvokeAgentRuntime and bedrock-agentcore:InvokeAgentRuntimeForUser permissions. |
| grant | Permits an IAM principal to invoke this runtime Grants the bedrock-agentcore:InvokeAgentRuntime permission. |
| grant | Permits an IAM principal to invoke this runtime on behalf of a user Grants the bedrock-agentcore:InvokeAgentRuntimeForUser permission Required when using the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header. |
| metric(metricName, dimensions, props?) | Return the given named metric for this agent runtime. |
| metric | Return a metric containing the total number of invocations for this agent runtime. |
| metric | Return a metric containing the total number of invocations across all resources. |
| metric | Return a metric measuring the latency of requests for this agent runtime. |
| metric | Return a metric containing the number of agent sessions for this agent runtime. |
| metric | Return a metric containing the total number of sessions across all resources. |
| metric | Return a metric containing the number of system errors for this agent runtime. |
| metric | Return a metric containing the number of throttled requests for this agent runtime. |
| metric | Return a metric containing the total number of errors (system + user) for this agent runtime. |
| metric | Return a metric containing the number of user errors for this agent runtime. |
| to | Returns a string representation of this construct. |
| static from | Import an existing Agent Runtime using attributes This allows you to reference an Agent Runtime that was created outside of CDK. |
addEndpoint(endpointName, options?)
public addEndpoint(endpointName: string, options?: AddEndpointOptions): RuntimeEndpoint
Parameters
- endpointName
stringโ The name of the endpoint. - options
Addโ Optional configuration for the endpoint.Endpoint Options
Returns
Add an endpoint to this runtime This is a convenience method that creates a RuntimeEndpoint associated with this runtime.
addToRolePolicy(statement)
public addToRolePolicy(statement: PolicyStatement): IBedrockAgentRuntime
Parameters
- statement
Policyโ The IAM policy statement to add.Statement
Returns
Adds a policy statement to the runtime's execution role.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
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).
grant(actions, resources)
public grant(actions: string[], resources: string[]): Grant
Parameters
- actions
string[]โ The actions to grant. - resources
string[]โ The resource ARNs to grant access to.
Returns
Grant the runtime specific actions on AWS resources.
grantInvoke(grantee)
public grantInvoke(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal to grant access to.
Returns
Permits an IAM principal to invoke this runtime both directly and on behalf of users Grants both bedrock-agentcore:InvokeAgentRuntime and bedrock-agentcore:InvokeAgentRuntimeForUser permissions.
grantInvokeRuntime(grantee)
public grantInvokeRuntime(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal to grant access to.
Returns
Permits an IAM principal to invoke this runtime Grants the bedrock-agentcore:InvokeAgentRuntime permission.
grantInvokeRuntimeForUser(grantee)
public grantInvokeRuntimeForUser(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal to grant access to.
Returns
Permits an IAM principal to invoke this runtime on behalf of a user Grants the bedrock-agentcore:InvokeAgentRuntimeForUser permission Required when using the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header.
metric(metricName, dimensions, props?)
public metric(metricName: string, dimensions: { [string]: string }, props?: MetricOptions): Metric
Parameters
- metricName
string - dimensions
{ [string]: string } - props
MetricOptions
Returns
Return the given named metric for this agent runtime.
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.
metricInvocations(props?)
public metricInvocations(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the total number of invocations for this agent runtime.
metricInvocationsAggregated(props?)
public metricInvocationsAggregated(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the total number of invocations across all resources.
metricLatency(props?)
public metricLatency(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric measuring the latency of requests for this agent runtime.
The latency metric represents the total time elapsed between receiving the request and sending the final response token, representing complete end-to-end processing time.
metricSessionCount(props?)
public metricSessionCount(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the number of agent sessions for this agent runtime.
metricSessionsAggregated(props?)
public metricSessionsAggregated(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the total number of sessions across all resources.
metricSystemErrors(props?)
public metricSystemErrors(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the number of system errors for this agent runtime.
metricThrottles(props?)
public metricThrottles(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the number of throttled requests for this agent runtime.
metricTotalErrors(props?)
public metricTotalErrors(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the total number of errors (system + user) for this agent runtime.
metricUserErrors(props?)
public metricUserErrors(props?: MetricOptions): Metric
Parameters
- props
MetricOptions
Returns
Return a metric containing the number of user errors for this agent runtime.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromAgentRuntimeAttributes(scope, id, attrs)
public static fromAgentRuntimeAttributes(scope: Construct, id: string, attrs: AgentRuntimeAttributes): IBedrockAgentRuntime
Parameters
- scope
Constructโ The construct scope. - id
stringโ The construct id. - attrs
Agentโ The attributes of the existing Agent Runtime.Runtime Attributes
Returns
Import an existing Agent Runtime using attributes This allows you to reference an Agent Runtime that was created outside of CDK.

.NET
Go
Java
Python
TypeScript (