aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 6.12 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AgentRuntimeArtifact=exports.AgentCoreRuntime=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var assets=()=>{var tmp=require("../../../aws-ecr-assets");return assets=()=>tmp,tmp},s3=()=>{var tmp=require("../../../aws-s3");return s3=()=>tmp,tmp},s3_assets=()=>{var tmp=require("../../../aws-s3-assets");return s3_assets=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../../core/lib/errors");return errors_1=()=>tmp,tmp},helpers_internal_1=()=>{var tmp=require("../../../core/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp};class AgentCoreRuntime{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.AgentCoreRuntime",version:"2.257.0"};static PYTHON_3_10=new AgentCoreRuntime("PYTHON_3_10");static PYTHON_3_11=new AgentCoreRuntime("PYTHON_3_11");static PYTHON_3_12=new AgentCoreRuntime("PYTHON_3_12");static PYTHON_3_13=new AgentCoreRuntime("PYTHON_3_13");static PYTHON_3_14=new AgentCoreRuntime("PYTHON_3_14");static NODE_22=new AgentCoreRuntime("NODE_22");static of(value){return new AgentCoreRuntime(value)}value;constructor(value){this.value=value}toString(){return this.value}}exports.AgentCoreRuntime=AgentCoreRuntime;class AgentRuntimeArtifact{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.AgentRuntimeArtifact",version:"2.257.0"};static fromEcrRepository(repository,tag="latest"){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecr_IRepository(repository)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromEcrRepository),error}return new EcrImage(repository,tag)}static fromAsset(directory,options={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_ecr_assets_DockerImageAssetOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromAsset),error}return new AssetImage(directory,options)}static fromS3(s3Location,runtime,entrypoint){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_Location(s3Location),jsiiDeprecationWarnings().aws_cdk_lib_aws_bedrockagentcore_AgentCoreRuntime(runtime)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromS3),error}return new S3Image(s3Location,runtime,entrypoint)}static fromCodeAsset(options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_bedrockagentcore_CodeAssetOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromCodeAsset),error}return new CodeAsset(options)}static fromImageUri(containerUri){return new ImageUriArtifact(containerUri)}}exports.AgentRuntimeArtifact=AgentRuntimeArtifact;class EcrImage extends AgentRuntimeArtifact{repository;tag;bound=!1;constructor(repository,tag){super(),this.repository=repository,this.tag=tag}bind(_scope,runtime){!this.bound&&runtime.role&&(this.repository.grantPull(runtime.role),this.bound=!0)}_render(){return{containerUri:this.repository.repositoryUriForTag(this.tag)}}}class AssetImage extends AgentRuntimeArtifact{directory;options;asset;bound=!1;constructor(directory,options={}){super(),this.directory=directory,this.options=options}bind(scope,runtime){this.asset||(this.asset=new(assets()).DockerImageAsset(scope,"AgentRuntimeArtifact",{directory:this.directory,...this.options})),this.bound||(this.asset.repository.grantPull(runtime.role),this.bound=!0)}_render(){if(!this.asset)throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`AssetNotInitialized`,"Asset not initialized. Call bind() before _render()");return{containerUri:this.asset.imageUri}}}class S3Image extends AgentRuntimeArtifact{s3Location;runtime;entrypoint;bound=!1;constructor(s3Location,runtime,entrypoint){super(),this.s3Location=s3Location,this.runtime=runtime,this.entrypoint=entrypoint}bind(scope,runtime){!this.bound&&runtime.role&&(core_1().Token.isUnresolved(this.s3Location.bucketName)||core_1().Stack.of(scope).resolve(this.s3Location.bucketName),s3().Bucket.fromBucketName(scope,`${this.s3Location.bucketName}CodeArchive`,this.s3Location.bucketName).grantRead(runtime.role),this.bound=!0)}_render(){const s3Config={bucket:this.s3Location.bucketName,prefix:this.s3Location.objectKey};return this.s3Location.objectVersion&&(s3Config.versionId=this.s3Location.objectVersion),{code:{s3:s3Config},runtime:this.runtime.value,entryPoint:this.entrypoint}}}class CodeAsset extends AgentRuntimeArtifact{asset;bound=!1;path;runtime;entrypoint;options;constructor(props){super();const{path,runtime,entrypoint,...options}=props;this.path=path,this.runtime=runtime,this.entrypoint=entrypoint,this.options=options}bind(scope,runtime){this.asset||(this.asset=new(s3_assets()).Asset(scope,"AgentRuntimeArtifact",{path:this.path,...this.options})),!this.bound&&runtime.role&&(this.asset.bucket.grantRead(runtime.role),this.bound=!0)}_render(){if(!this.asset)throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`AssetNotInitialized`,"Asset not initialized. Call bind() before _render()");return{code:{s3:{bucket:this.asset.bucket.bucketName,prefix:this.asset.s3ObjectKey}},runtime:this.runtime.value,entryPoint:this.entrypoint}}}class ImageUriArtifact extends AgentRuntimeArtifact{containerUri;constructor(containerUri){super(),this.containerUri=containerUri;const ecrPattern=/^\d{12}\.dkr\.ecr\.([a-z0-9-]+)\.amazonaws\.com\/((?:[a-z0-9]+(?:[._-][a-z0-9]+)*\/)*[a-z0-9]+(?:[._-][a-z0-9]+)*)([:@]\S+)$/;if(!core_1().Token.isUnresolved(containerUri)&&!ecrPattern.test(containerUri))throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`InvalidEcrContainerUri`,`Invalid ECR container URI format: ${containerUri}. Must be an ECR URI: {account}.dkr.ecr.{region}.amazonaws.com/{repository}:{tag}`)}bind(_scope,_runtime){}_render(){return{containerUri:this.containerUri}}}