Skip to content
v2.273.0

AssetToolSchema Class ​

Tool Schema from a local asset.

The asset is uploaded to an S3 staging bucket, then moved to its final location by CloudFormation during deployment.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_bedrockagentcore as bedrockagentcore } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_kms as interfaces_kms } from 'aws-cdk-lib/interfaces';

declare const dockerImage: cdk.DockerImage;
declare const grantable: iam.IGrantable;
declare const keyRef: interfaces_kms.IKeyRef;
declare const localBundling: cdk.ILocalBundling;
const assetToolSchema = new bedrockagentcore.AssetToolSchema('path', /* all optional props */ {
  assetHash: 'assetHash',
  assetHashType: cdk.AssetHashType.SOURCE,
  bundling: {
    image: dockerImage,

    // the properties below are optional
    bundlingFileAccess: cdk.BundlingFileAccess.VOLUME_COPY,
    command: ['command'],
    entrypoint: ['entrypoint'],
    environment: {
      environmentKey: 'environment',
    },
    local: localBundling,
    network: 'network',
    outputType: cdk.BundlingOutput.ARCHIVED,
    platform: 'platform',
    securityOpt: 'securityOpt',
    user: 'user',
    volumes: [{
      containerPath: 'containerPath',
      hostPath: 'hostPath',

      // the properties below are optional
      consistency: cdk.DockerVolumeConsistency.CONSISTENT,
    }],
    volumesFrom: ['volumesFrom'],
    workingDirectory: 'workingDirectory',
  },
  deployTime: false,
  displayName: 'displayName',
  exclude: ['exclude'],
  followSymlinks: cdk.SymlinkFollowMode.NEVER,
  ignoreMode: cdk.IgnoreMode.GLOB,
  readers: [grantable],
  sourceKMSKey: keyRef,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_bedrockagentcore as bedrockagentcore
from aws_cdk import aws_iam as iam
from aws_cdk.interfaces import aws_kms as interfaces_kms

# docker_image: cdk.DockerImage
# grantable: iam.IGrantable
# key_ref: interfaces_kms.IKeyRef
# local_bundling: cdk.ILocalBundling

asset_tool_schema = bedrockagentcore.AssetToolSchema("path",
    asset_hash="assetHash",
    asset_hash_type=cdk.AssetHashType.SOURCE,
    bundling=cdk.BundlingOptions(
        image=docker_image,

        # the properties below are optional
        bundling_file_access=cdk.BundlingFileAccess.VOLUME_COPY,
        command=["command"],
        entrypoint=["entrypoint"],
        environment={
            "environment_key": "environment"
        },
        local=local_bundling,
        network="network",
        output_type=cdk.BundlingOutput.ARCHIVED,
        platform="platform",
        security_opt="securityOpt",
        user="user",
        volumes=[cdk.DockerVolume(
            container_path="containerPath",
            host_path="hostPath",

            # the properties below are optional
            consistency=cdk.DockerVolumeConsistency.CONSISTENT
        )],
        volumes_from=["volumesFrom"],
        working_directory="workingDirectory"
    ),
    deploy_time=False,
    display_name="displayName",
    exclude=["exclude"],
    follow_symlinks=cdk.SymlinkFollowMode.NEVER,
    ignore_mode=cdk.IgnoreMode.GLOB,
    readers=[grantable],
    source_kms_key=key_ref
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.bedrockagentcore.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.interfaces.kms.*;

DockerImage dockerImage;
IGrantable grantable;
IKeyRef keyRef;
ILocalBundling localBundling;

AssetToolSchema assetToolSchema = AssetToolSchema.Builder.create("path")
        .assetHash("assetHash")
        .assetHashType(AssetHashType.SOURCE)
        .bundling(BundlingOptions.builder()
                .image(dockerImage)

                // the properties below are optional
                .bundlingFileAccess(BundlingFileAccess.VOLUME_COPY)
                .command(List.of("command"))
                .entrypoint(List.of("entrypoint"))
                .environment(Map.of(
                        "environmentKey", "environment"))
                .local(localBundling)
                .network("network")
                .outputType(BundlingOutput.ARCHIVED)
                .platform("platform")
                .securityOpt("securityOpt")
                .user("user")
                .volumes(List.of(DockerVolume.builder()
                        .containerPath("containerPath")
                        .hostPath("hostPath")

                        // the properties below are optional
                        .consistency(DockerVolumeConsistency.CONSISTENT)
                        .build()))
                .volumesFrom(List.of("volumesFrom"))
                .workingDirectory("workingDirectory")
                .build())
        .deployTime(false)
        .displayName("displayName")
        .exclude(List.of("exclude"))
        .followSymlinks(SymlinkFollowMode.NEVER)
        .ignoreMode(IgnoreMode.GLOB)
        .readers(List.of(grantable))
        .sourceKMSKey(keyRef)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.BedrockAgentCore;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.Interfaces.KMS;

DockerImage dockerImage;
IGrantable grantable;
IKeyRef keyRef;
ILocalBundling localBundling;

var assetToolSchema = new AssetToolSchema("path", new AssetOptions {
    AssetHash = "assetHash",
    AssetHashType = AssetHashType.SOURCE,
    Bundling = new BundlingOptions {
        Image = dockerImage,

        // the properties below are optional
        BundlingFileAccess = BundlingFileAccess.VOLUME_COPY,
        Command = new [] { "command" },
        Entrypoint = new [] { "entrypoint" },
        Environment = new Dictionary<string, string> {
            { "environmentKey", "environment" }
        },
        Local = localBundling,
        Network = "network",
        OutputType = BundlingOutput.ARCHIVED,
        Platform = "platform",
        SecurityOpt = "securityOpt",
        User = "user",
        Volumes = new [] { new DockerVolume {
            ContainerPath = "containerPath",
            HostPath = "hostPath",

            // the properties below are optional
            Consistency = DockerVolumeConsistency.CONSISTENT
        } },
        VolumesFrom = new [] { "volumesFrom" },
        WorkingDirectory = "workingDirectory"
    },
    DeployTime = false,
    DisplayName = "displayName",
    Exclude = new [] { "exclude" },
    FollowSymlinks = SymlinkFollowMode.NEVER,
    IgnoreMode = IgnoreMode.GLOB,
    Readers = new [] { grantable },
    SourceKMSKey = keyRef
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var dockerImage DockerImage
var grantable IGrantable
var keyRef IKeyRef
var localBundling ILocalBundling

assetToolSchema := awscdk.Aws_bedrockagentcore.NewAssetToolSchema(jsii.String("path"), &AssetOptions{
	AssetHash: jsii.String("assetHash"),
	AssetHashType: cdk.AssetHashType_SOURCE,
	Bundling: &BundlingOptions{
		Image: dockerImage,

		// the properties below are optional
		BundlingFileAccess: cdk.BundlingFileAccess_VOLUME_COPY,
		Command: []*string{
			jsii.String("command"),
		},
		Entrypoint: []*string{
			jsii.String("entrypoint"),
		},
		Environment: map[string]*string{
			"environmentKey": jsii.String("environment"),
		},
		Local: localBundling,
		Network: jsii.String("network"),
		OutputType: cdk.BundlingOutput_ARCHIVED,
		Platform: jsii.String("platform"),
		SecurityOpt: jsii.String("securityOpt"),
		User: jsii.String("user"),
		Volumes: []DockerVolume{
			&DockerVolume{
				ContainerPath: jsii.String("containerPath"),
				HostPath: jsii.String("hostPath"),

				// the properties below are optional
				Consistency: cdk.DockerVolumeConsistency_CONSISTENT,
			},
		},
		VolumesFrom: []*string{
			jsii.String("volumesFrom"),
		},
		WorkingDirectory: jsii.String("workingDirectory"),
	},
	DeployTime: jsii.Boolean(false),
	DisplayName: jsii.String("displayName"),
	Exclude: []*string{
		jsii.String("exclude"),
	},
	FollowSymlinks: cdk.SymlinkFollowMode_NEVER,
	IgnoreMode: cdk.IgnoreMode_GLOB,
	Readers: []IGrantable{
		grantable,
	},
	SourceKMSKey: keyRef,
})

Initializer ​

ts
new AssetToolSchema(path: string, options?: AssetOptions)
python
AssetToolSchema(path: str, options: typing.Optional[AssetOptions] = None)
java
new AssetToolSchema(String path, AssetOptions options)
csharp
new AssetToolSchema(string path, AssetOptions? options = null)
go
NewAssetToolSchema(Path *string, Options AssetOptions)

Properties ​

bucketOwnerAccountIdstringbucket_owner_account_idstrbucketOwnerAccountIdStringBucketOwnerAccountIdstringBucketOwnerAccountId*string#
The account ID of the S3 bucket owner for cross-account access.
inlineSchemaToolDefinition[]inline_schematyping.List[ToolDefinition]inlineSchemaList<ToolDefinition>InlineSchemaToolDefinition[]InlineSchema*[]ToolDefinition#
The inline tool schema definition as a string, if using an inline schema.

Can be in JSON or YAML format.

s3FileLocations3_fileLocations3FileLocationS3FileLocationS3FileLocation#
The S3 location of the tool schema file, if using an S3-based schema.

Contains the bucket name and object key information.

Methods ​

bind(scope: Construct): voiddef bind(self, scope: Construct) -> Nonepublic void bind(Construct scope)public void Bind(Construct scope)func Bind(Scope Construct)#
Binds this tool schema to a construct scope.

This method initializes the S3 asset if it hasn't been initialized yet. Must be called before rendering the schema as CFN properties.

1 parameter

Parameters

  • scopescopescopescopeScope — - The construct scope to bind to.
fromInline(schema: ToolDefinition[]): InlineToolSchema@staticmethod def from_inline(schema: typing.List[ToolDefinition]) -> InlineToolSchemapublic static InlineToolSchema fromInline(List<ToolDefinition> schema)public static InlineToolSchema FromInline(ToolDefinition[] schema)func FromInline(Schema *[]ToolDefinition) InlineToolSchemastatic#
Creates a Tool Schema from an inline string.
1 parameter

Parameters

  • schemaschemaschemaschemaSchema — - the JSON or YAML payload defining the OpenAPI schema for the action group.
fromLocalAsset(path: string): ToolSchema@staticmethod def from_local_asset(path: str) -> ToolSchemapublic static ToolSchema fromLocalAsset(String path)public static ToolSchema FromLocalAsset(string path)func FromLocalAsset(Path *string) ToolSchemastatic#
Creates a tool Schema from a local file.
1 parameter

Parameters

  • pathpathpathpathPath — - the path to the local file containing the function schema for the tool.
fromS3File(bucket: IBucket, objectKey: string, bucketOwnerAccountId?: string): S3ToolSchema@staticmethod def from_s3_file(bucket: IBucket, object_key: str, bucket_owner_account_id: typing.Optional[str] = None) -> S3ToolSchemapublic static S3ToolSchema fromS3File(IBucket bucket, String objectKey, String bucketOwnerAccountId)public static S3ToolSchema FromS3File(IBucket bucket, string objectKey, string? bucketOwnerAccountId = null)func FromS3File(Bucket IBucket, ObjectKey *string, BucketOwnerAccountId *string) S3ToolSchemastatic#
Creates a Tool Schema from an S3 File.
3 parameters

Parameters

  • bucketbucketbucketbucketBucket — - the bucket containing the local file containing the OpenAPI schema for the action group.
  • objectKeyobject_keyobjectKeyobjectKeyObjectKey — - object key in the bucket.
  • bucketOwnerAccountIdbucket_owner_account_idbucketOwnerAccountIdbucketOwnerAccountIdBucketOwnerAccountId — - optional The account ID of the Amazon S3 bucket owner.
grantPermissionsToRole(role: IRole): voiddef grant_permissions_to_role(self, role: IRole) -> Nonepublic void grantPermissionsToRole(IRole role)public void GrantPermissionsToRole(IRole role)func GrantPermissionsToRole(Role IRole)#
Grant permissions to the role.