aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 8.28 kB
JavaScript
;var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__setModuleDefault=exports&&exports.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}):function(o,v){o.default=v}),__importStar=exports&&exports.__importStar||(function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)Object.prototype.hasOwnProperty.call(o2,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k=ownKeys(mod),i=0;i<k.length;i++)k[i]!=="default"&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.RuntimeBase=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var perms_1=()=>{var tmp=require("./perms");return perms_1=()=>tmp,tmp},aws_cloudwatch_1=()=>{var tmp=require("../../../aws-cloudwatch");return aws_cloudwatch_1=()=>tmp,tmp},iam=()=>{var tmp=__importStar(require("../../../aws-iam"));return iam=()=>tmp,tmp},logs=()=>{var tmp=__importStar(require("../../../aws-logs"));return logs=()=>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};const DEFAULT_ENDPOINT_NAME="DEFAULT";class RuntimeBase extends core_1().Resource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.RuntimeBase",version:"2.260.0"};get runtimeRef(){return{agentRuntimeId:this.agentRuntimeId,agentRuntimeArn:this.agentRuntimeArn}}get applicationLogGroup(){return this._applicationLogGroup||(this._applicationLogGroup=logs().LogGroup.fromLogGroupName(this,"ApplicationLogGroup",`/aws/bedrock-agentcore/runtimes/${this.agentRuntimeId}-${DEFAULT_ENDPOINT_NAME}`)),this._applicationLogGroup}_applicationLogGroup;get connections(){if(!this._connections)throw new(errors_1()).ValidationError((0,helpers_internal_1().lit)`VpcNotConfigured`,"Cannot manage network access without configuring a VPC",this);return this._connections}_connections;constructor(scope,id,props={}){super(scope,id,props);try{jsiiDeprecationWarnings().aws_cdk_lib_ResourceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,RuntimeBase),error}}grant(actions,resources){return iam().Grant.addToPrincipal({grantee:this.role,actions,resourceArns:resources})}addToRolePolicy(statement){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_PolicyStatement(statement)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addToRolePolicy),error}return this.role.addToPrincipalPolicy(statement),this}grantInvokeRuntime(grantee){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grantInvokeRuntime),error}return iam().Grant.addToPrincipal({grantee,actions:perms_1().RUNTIME_INVOKE_PERMS,resourceArns:[this.runtimeRef.agentRuntimeArn,`${this.runtimeRef.agentRuntimeArn}/*`]})}grantInvokeRuntimeForUser(grantee){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grantInvokeRuntimeForUser),error}return iam().Grant.addToPrincipal({grantee,actions:perms_1().RUNTIME_INVOKE_USER_PERMS,resourceArns:[this.runtimeRef.agentRuntimeArn,`${this.runtimeRef.agentRuntimeArn}/*`]})}grantInvoke(grantee){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IGrantable(grantee)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grantInvoke),error}return iam().Grant.addToPrincipal({grantee,actions:[...perms_1().RUNTIME_INVOKE_PERMS,...perms_1().RUNTIME_INVOKE_USER_PERMS],resourceArns:[this.runtimeRef.agentRuntimeArn,`${this.runtimeRef.agentRuntimeArn}/*`]})}metric(metricName,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metric),error}const metricProps={namespace:"AWS/Bedrock-AgentCore",metricName,...props,dimensionsMap:{Resource:this.runtimeRef.agentRuntimeArn,...props?.dimensionsMap}};return this.configureMetric(metricProps)}metricInvocations(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricInvocations),error}return this.metric("Invocations",{statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricInvocationsAggregated(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricInvocationsAggregated),error}return this.metric("Invocations",{dimensionsMap:{Resource:"All"},statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricThrottles(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricThrottles),error}return this.metric("Throttles",{statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricSystemErrors(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricSystemErrors),error}return this.metric("SystemErrors",{statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricUserErrors(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricUserErrors),error}return this.metric("UserErrors",{statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricLatency(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricLatency),error}return this.metric("Latency",{statistic:aws_cloudwatch_1().Stats.AVERAGE,...props})}metricTotalErrors(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricTotalErrors),error}return this.metric("TotalErrors",{statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricSessionCount(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricSessionCount),error}return this.metric("SessionCount",{statistic:aws_cloudwatch_1().Stats.SUM,...props})}metricSessionsAggregated(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_MetricOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.metricSessionsAggregated),error}return this.metric("Sessions",{dimensionsMap:{Resource:"All"},statistic:aws_cloudwatch_1().Stats.SUM,...props})}configureMetric(props){return new(aws_cloudwatch_1()).Metric({...props,region:props?.region??this.stack.region,account:props?.account??this.stack.account})}}exports.RuntimeBase=RuntimeBase;