Skip to content
v2.278.0

AgentRuntimeArtifact Class ​

Abstract base class for agent runtime artifacts.

Provides methods to reference container images from ECR repositories or local assets.

Example ​

ts
// S3 bucket containing the agent core
const codeBucket = new s3.Bucket(this, "AgentCode", {
  bucketName: "my-code-bucket",
  removalPolicy: RemovalPolicy.DESTROY, // For demo purposes
});

// the bucket above needs to contain the agent code

const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromS3(
  {
    bucketName: codeBucket.bucketName,
    objectKey: 'deployment_package.zip',
  },
  agentcore.AgentCoreRuntime.PYTHON_3_12,
  ['opentelemetry-instrument', 'main.py']
);

const runtimeInstance = new agentcore.Runtime(this, "MyAgentRuntime", {
  runtimeName: "myAgent",
  agentRuntimeArtifact: agentRuntimeArtifact,
});
python
# S3 bucket containing the agent core
code_bucket = s3.Bucket(self, "AgentCode",
    bucket_name="my-code-bucket",
    removal_policy=RemovalPolicy.DESTROY
)

# the bucket above needs to contain the agent code

agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_s3(s3.Location(
    bucket_name=code_bucket.bucket_name,
    object_key="deployment_package.zip"
), agentcore.AgentCoreRuntime.PYTHON_3_12, ["opentelemetry-instrument", "main.py"])

runtime_instance = agentcore.Runtime(self, "MyAgentRuntime",
    runtime_name="myAgent",
    agent_runtime_artifact=agent_runtime_artifact
)
java
// S3 bucket containing the agent core
Bucket codeBucket = Bucket.Builder.create(this, "AgentCode")
        .bucketName("my-code-bucket")
        .removalPolicy(RemovalPolicy.DESTROY)
        .build();

// the bucket above needs to contain the agent code

AgentRuntimeArtifact agentRuntimeArtifact = AgentRuntimeArtifact.fromS3(Location.builder()
        .bucketName(codeBucket.getBucketName())
        .objectKey("deployment_package.zip")
        .build(), AgentCoreRuntime.PYTHON_3_12, List.of("opentelemetry-instrument", "main.py"));

Runtime runtimeInstance = Runtime.Builder.create(this, "MyAgentRuntime")
        .runtimeName("myAgent")
        .agentRuntimeArtifact(agentRuntimeArtifact)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// S3 bucket containing the agent core
var codeBucket = new Bucket(this, "AgentCode", new BucketProps {
    BucketName = "my-code-bucket",
    RemovalPolicy = RemovalPolicy.DESTROY
});

// the bucket above needs to contain the agent code

var agentRuntimeArtifact = AgentRuntimeArtifact.FromS3(new Location {
    BucketName = codeBucket.BucketName,
    ObjectKey = "deployment_package.zip"
}, AgentCoreRuntime.PYTHON_3_12, new [] { "opentelemetry-instrument", "main.py" });

var runtimeInstance = new Runtime(this, "MyAgentRuntime", new RuntimeProps {
    RuntimeName = "myAgent",
    AgentRuntimeArtifact = agentRuntimeArtifact
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// S3 bucket containing the agent core
codeBucket := s3.NewBucket(this, jsii.String("AgentCode"), &BucketProps{
	BucketName: jsii.String("my-code-bucket"),
	RemovalPolicy: awscdk.RemovalPolicy_DESTROY,
})

// the bucket above needs to contain the agent code

agentRuntimeArtifact := agentcore.AgentRuntimeArtifact_FromS3(&Location{
	BucketName: codeBucket.bucketName,
	ObjectKey: jsii.String("deployment_package.zip"),
}, agentcore.AgentCoreRuntime_PYTHON_3_12(), []*string{
	jsii.String("opentelemetry-instrument"),
	jsii.String("main.py"),
})

runtimeInstance := agentcore.NewRuntime(this, jsii.String("MyAgentRuntime"), &RuntimeProps{
	RuntimeName: jsii.String("myAgent"),
	AgentRuntimeArtifact: agentRuntimeArtifact,
})

Initializer ​

ts
new AgentRuntimeArtifact()
python
AgentRuntimeArtifact()
java
new AgentRuntimeArtifact()
csharp
new AgentRuntimeArtifact()
go
NewAgentRuntimeArtifact()

Methods ​

bind(scope: Construct, runtime: Runtime): voiddef bind(self, scope: Construct, runtime: Runtime) -> Nonepublic void bind(Construct scope, Runtime runtime)public void Bind(Construct scope, Runtime runtime)func Bind(Scope Construct, Runtime Runtime) #
Called when the image is used by a Runtime to handle side effects like permissions.
fromAsset(directory: string, options?: DockerImageAssetOptions): AgentRuntimeArtifact // chainable@staticmethod def from_asset(directory: str, options: typing.Optional[DockerImageAssetOptions] = None) -> AgentRuntimeArtifactpublic static AgentRuntimeArtifact fromAsset(String directory, DockerImageAssetOptions options)public static AgentRuntimeArtifact FromAsset(string directory, DockerImageAssetOptions? options = null)func FromAsset(Directory *string, Options DockerImageAssetOptions) AgentRuntimeArtifact static #
Reference an agent runtime artifact that's constructed directly from sources on disk.
2 parameters

Parameters

  • directorydirectorydirectorydirectoryDirectory — The directory where the Dockerfile is stored.
  • optionsoptionsoptionsoptionsOptions — The options to further configure the selected image.
fromCodeAsset(options: CodeAssetOptions): AgentRuntimeArtifact // chainable@staticmethod def from_code_asset(options: CodeAssetOptions) -> AgentRuntimeArtifactpublic static AgentRuntimeArtifact fromCodeAsset(CodeAssetOptions options)public static AgentRuntimeArtifact FromCodeAsset(CodeAssetOptions options)func FromCodeAsset(Options CodeAssetOptions) AgentRuntimeArtifact static #
Reference an agent runtime artifact that's constructed from local code assets uploaded to a CDK-managed S3 bucket.

The folder is zipped as is. Include all dependencies, built for Linux arm64, in the folder.

1 parameter

Parameters

  • optionsoptionsoptionsoptionsOptions — The options for configuring the code asset.
fromEcrRepository(repository: IRepository, tag?: string): AgentRuntimeArtifact // chainable@staticmethod def from_ecr_repository(repository: IRepository, tag: typing.Optional[str] = None) -> AgentRuntimeArtifactpublic static AgentRuntimeArtifact fromEcrRepository(IRepository repository, String tag)public static AgentRuntimeArtifact FromEcrRepository(IRepository repository, string? tag = null)func FromEcrRepository(Repository IRepository, Tag *string) AgentRuntimeArtifact static #
Reference an image in an ECR repository.
fromImageUri(containerUri: string): AgentRuntimeArtifact // chainable@staticmethod def from_image_uri(container_uri: str) -> AgentRuntimeArtifactpublic static AgentRuntimeArtifact fromImageUri(String containerUri)public static AgentRuntimeArtifact FromImageUri(string containerUri)func FromImageUri(ContainerUri *string) AgentRuntimeArtifact static #
Reference an image using an ECR container URI.

Use this when referencing ECR images from CloudFormation parameters or cross-stack references.

Note: No IAM permissions are automatically granted. You must ensure the runtime has ECR pull permissions for the repository.

1 parameter

Parameters

  • containerUricontainer_uricontainerUricontainerUriContainerUri — The ECR container image URI (format: {account}.dkr.ecr.{region}.amazonaws.com/{repository}:{tag}, or {account}.dkr.ecr.{region}.amazonaws.com.cn/{repository}:{tag} in the aws-cn partition).
fromS3(s3Location: Location, runtime: AgentCoreRuntime, entrypoint: string[]): AgentRuntimeArtifact // chainable@staticmethod def from_s3(s3_location: Location, runtime: AgentCoreRuntime, entrypoint: typing.List[str]) -> AgentRuntimeArtifactpublic static AgentRuntimeArtifact fromS3(Location s3Location, AgentCoreRuntime runtime, List<String> entrypoint)public static AgentRuntimeArtifact FromS3(Location s3Location, AgentCoreRuntime runtime, string[] entrypoint)func FromS3(S3Location Location, Runtime AgentCoreRuntime, Entrypoint *[]*string) AgentRuntimeArtifact static #
Reference an agent runtime artifact that's constructed directly from an S3 object.
3 parameters

Parameters

  • s3Locations3_locations3Locations3LocationS3Location — The source code location and configuration details.
  • runtimeruntimeruntimeruntimeRuntime — The runtime environment for executing the code.
  • entrypointentrypointentrypointentrypointEntrypoint — The entry point for the code execution, specifying the function or method that should be invoked when the code runs.