# CodeAssetOptions

Options for configuring an S3 code asset from local files for agent runtime artifact.

Extends: [AssetOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.AssetOptions.html)
Used as argument in: [AgentRuntimeArtifact.fromCodeAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.AgentRuntimeArtifact.html#fromcodeasset)

- Source: [`aws-bedrockagentcore/lib/runtime/runtime-artifact.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/runtime/runtime-artifact.ts#L84)
- Type last changed: v2.255.0 · 19 May 2026

## Example

TypeScript:

```ts
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromCodeAsset({
  path: path.join(__dirname, 'path/to/agent/code'),
  runtime: agentcore.AgentCoreRuntime.PYTHON_3_12,
  entrypoint: ['opentelemetry-instrument', 'main.py'],
});

const runtimeInstance = new agentcore.Runtime(this, "MyAgentRuntime", {
  runtimeName: "myAgent",
  agentRuntimeArtifact: agentRuntimeArtifact,
});
```

Python:

```python
agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_code_asset(
    path=path.join(__dirname, "path/to/agent/code"),
    runtime=agentcore.AgentCoreRuntime.PYTHON_3_12,
    entrypoint=["opentelemetry-instrument", "main.py"]
)

runtime_instance = agentcore.Runtime(self, "MyAgentRuntime",
    runtime_name="myAgent",
    agent_runtime_artifact=agent_runtime_artifact
)
```

Java:

```java
AgentRuntimeArtifact agentRuntimeArtifact = AgentRuntimeArtifact.fromCodeAsset(CodeAssetOptions.builder()
        .path(path.join(__dirname, "path/to/agent/code"))
        .runtime(AgentCoreRuntime.PYTHON_3_12)
        .entrypoint(List.of("opentelemetry-instrument", "main.py"))
        .build());

Runtime runtimeInstance = Runtime.Builder.create(this, "MyAgentRuntime")
        .runtimeName("myAgent")
        .agentRuntimeArtifact(agentRuntimeArtifact)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var agentRuntimeArtifact = AgentRuntimeArtifact.FromCodeAsset(new CodeAssetOptions {
    Path = path.Join(__dirname, "path/to/agent/code"),
    Runtime = AgentCoreRuntime.PYTHON_3_12,
    Entrypoint = new [] { "opentelemetry-instrument", "main.py" }
});

var runtimeInstance = new Runtime(this, "MyAgentRuntime", new RuntimeProps {
    RuntimeName = "myAgent",
    AgentRuntimeArtifact = agentRuntimeArtifact
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
agentRuntimeArtifact := agentcore.AgentRuntimeArtifact_FromCodeAsset(&CodeAssetOptions{
	Path: path.join(__dirname, jsii.String("path/to/agent/code")),
	Runtime: agentcore.AgentCoreRuntime_PYTHON_3_12(),
	Entrypoint: []*string{
		jsii.String("opentelemetry-instrument"),
		jsii.String("main.py"),
	},
})

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

## Properties

- `assetHash`: string — Specify a custom hash for this asset.

  **Default:** based on `assetHashType`

  If `assetHashType` is set it must
  be set to `AssetHashType.CUSTOM`. For consistency, this custom hash will
  be SHA256 hashed and encoded as hex. The resulting hash will be the asset
  hash.

  NOTE: the hash is used in order to identify a specific revision of the asset, and
  used for optimizing and caching deployment activities related to this asset such as
  packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will
  need to make sure it is updated every time the asset changes, or otherwise it is
  possible that some deployments will not be invalidated.

- `assetHashType`: [AssetHashType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetHashType.html) — Specifies the type of hash to calculate for this asset.

  **Default:** the default is `AssetHashType.SOURCE`, but if `assetHash` is explicitly specified this value defaults to `AssetHashType.CUSTOM`.

  If `assetHash` is configured, this option must be `undefined` or
  `AssetHashType.CUSTOM`.

- `bundling`: [BundlingOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html) — Bundle the asset by executing a command in a Docker container or a custom bundling provider.

  **Default:** uploaded as-is to S3 if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to S3 otherwise

  The asset path will be mounted at `/asset-input`. The Docker
  container is responsible for putting content at `/asset-output`.
  The content at `/asset-output` will be zipped and used as the
  final asset.

- `deployTime`: boolean = false — Whether or not the asset needs to exist beyond deployment time;

  i.e.
  are copied over to a different location and not needed afterwards.
  Setting this property to true has an impact on the lifecycle of the asset,
  because we will assume that it is safe to delete after the CloudFormation
  deployment succeeds.

  For example, Lambda Function assets are copied over to Lambda during
  deployment. Therefore, it is not necessary to store the asset in S3, so
  we consider those deployTime assets.

- `displayName`: string — A display name for this asset.

  **Default:** Stack-relative construct path

  If supplied, the display name will be used in locations where the asset
  identifier is printed, like in the CLI progress information. If the same
  asset is added multiple times, the display name of the first occurrence is
  used.

  The default is the construct path of the Asset construct, with respect to
  the enclosing stack. If the asset is produced by a construct helper
  function (such as `lambda.Code.fromAsset()`), this will look like
  `MyFunction/Code`.

  We use the stack-relative construct path so that in the common case where
  you have multiple stacks with the same asset, we won't show something like
  `/MyBetaStack/MyFunction/Code` when you are actually deploying to
  production.

- `entrypoint`: string[] (required) — The entry point for the code execution, specifying the function or method that should be invoked when the code runs.

- `exclude`: string[] — File paths matching the patterns will be excluded. See `ignoreMode` to set the matching behavior.

  **Default:** nothing is excluded

  ## Without bundling

  When used without the `bundling` property, the asset is just a regular file
  copy operation. In that case, this controls the files that will be included
  in the copy. Files matching the `exclude` patterns will not be included in
  the copy.

  ## With bundling

  When used with the `bundling` property, the asset is produced by a
  bundling operation. In that case, the value of `exclude` is only meaningful
  if the `assetHashType` is set to `AssetHashType.SOURCE`, and ignored for
  other asset hash types. The `exclude` patterns will be used to determine
  which files contribute to the asset, and the bundling command is skipped
  if the source files have not changed since the last bundling operation.

  **NOTE:** The bundling operation still has access to all files in the source path,
  regardless of the `exclude` patterns. It is your responsibility to ensure
  the `exclude` pattern accurately matches the files the bundling operation
  will *actually* access and base its final output on.

  For `OUTPUT` or `CUSTOM` asset hash types, the `exclude` pattern is ignored.

- `followSymlinks`: [SymlinkFollowMode](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.SymlinkFollowMode.html) = SymlinkFollowMode.EXTERNAL — A strategy for how to handle symlinks.

  Symlinks may be copied, materialized or rejected. Note that if symlinks are
  copied they should be relative; absolute symlinks will lose their
  meaning if the cloud assembly is moved to another machine.

  ## Without bundling

  When used without the `bundling` property, the asset is just a regular file
  copy operation. In that case, symlinks are materialized or blocked with respect
  to the `sourcePath` directory as they are being copied.

  ## With bundling

  When used with the `bundling` property, the asset is produced by a
  bundling operation. In that case, the bundling command is fully
  in charge of producing a set of files in an output directory, and
  the `AssetStaging` construct will never affect symlink materialization.

  If the `assetHashType` is `AssetHashType.SOURCE`, this flag affects what
  the source hash is based on, and the recommended value is one of
  `SymlinkFollowMode.EXTERNAL` or `SymlinkFollowMode.BLOCK_EXTERNAL`.

  If the `SymlinkFollowMode.BLOCK_EXTERNAL` mode is used:
  - symlinks pointing outside the source tree will be blocked if using `AssetHashType.SOURCE`.
  - symlinks pointing outside the bundle output will be blocked.

- `ignoreMode`: [IgnoreMode](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IgnoreMode.html) — What syntax the `exclude` patterns are written in.

  **Default:** IgnoreMode.GLOB for file assets, `IgnoreMode.DOCKER` for image assets (requires that the `@aws-cdk/aws-ecr-assets:dockerIgnoreSupport` feature flag is set, which is recommended)

- `path`: string (required) — The file path to the code asset.

- `readers`: [IGrantable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IGrantable.html)[] — A list of principals that should be able to read this asset from S3.

  **Default:** No principals that can read file asset.

  You can use `asset.grantRead(principal)` to grant read permissions later.

- `runtime`: [AgentCoreRuntime](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.AgentCoreRuntime.html) (required) — The runtime environment for executing the code.

- `sourceKMSKey`: [IKeyRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) — The ARN of the KMS key used to encrypt the handler code.

  **Default:** the default server-side encryption with Amazon S3 managed keys(SSE-S3) key will be used.
