aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 6.85 kB
JavaScript
;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=require("../../../aws-iam");return iam=()=>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 RuntimeBase extends core_1().Resource{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.RuntimeBase",version:"2.257.0"};get runtimeRef(){return{agentRuntimeId:this.agentRuntimeId,agentRuntimeArn:this.agentRuntimeArn}}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;