UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 4.32 kB
"use strict";var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompositeAlarm=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var alarm_base_1=()=>{var tmp=require("./alarm-base");return alarm_base_1=()=>tmp,tmp},cloudwatch_generated_1=()=>{var tmp=require("./cloudwatch.generated");return cloudwatch_generated_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};let CompositeAlarm=class CompositeAlarm2 extends alarm_base_1().AlarmBase{static fromCompositeAlarmName(scope,id,compositeAlarmName){const stack=core_1().Stack.of(scope);return this.fromCompositeAlarmArn(scope,id,stack.formatArn({service:"cloudwatch",resource:"alarm",resourceName:compositeAlarmName,arnFormat:core_1().ArnFormat.COLON_RESOURCE_NAME}))}static fromCompositeAlarmArn(scope,id,compositeAlarmArn){class Import extends alarm_base_1().AlarmBase{constructor(){super(...arguments),this.alarmArn=compositeAlarmArn,this.alarmName=core_1().Stack.of(scope).splitArn(compositeAlarmArn,core_1().ArnFormat.COLON_RESOURCE_NAME).resourceName}}return new Import(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props.compositeAlarmName??core_1().Lazy.string({produce:()=>this.generateUniqueId()})});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_CompositeAlarmProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,CompositeAlarm2),error}if((0,metadata_resource_1().addConstructMetadata)(this,props),props.alarmRule.renderAlarmRule().length>10240)throw new(core_1()).ValidationError("Alarm Rule expression cannot be greater than 10240 characters, please reduce the conditions in the Alarm Rule",this);let extensionPeriod=props.actionsSuppressorExtensionPeriod,waitPeriod=props.actionsSuppressorWaitPeriod;if(props.actionsSuppressor===void 0){if(extensionPeriod!==void 0||waitPeriod!==void 0)throw new(core_1()).ValidationError("ActionsSuppressor Extension/Wait Periods require an ActionsSuppressor to be set.",this)}else extensionPeriod=extensionPeriod??core_1().Duration.minutes(1),waitPeriod=waitPeriod??core_1().Duration.minutes(1);this.alarmRule=props.alarmRule.renderAlarmRule();const alarm=new(cloudwatch_generated_1()).CfnCompositeAlarm(this,"Resource",{alarmName:this.physicalName,alarmRule:this.alarmRule,alarmDescription:props.alarmDescription,actionsEnabled:props.actionsEnabled,alarmActions:core_1().Lazy.list({produce:()=>this.alarmActionArns}),insufficientDataActions:core_1().Lazy.list({produce:()=>this.insufficientDataActionArns}),okActions:core_1().Lazy.list({produce:()=>this.okActionArns}),actionsSuppressor:props.actionsSuppressor?.alarmArn,actionsSuppressorExtensionPeriod:extensionPeriod?.toSeconds(),actionsSuppressorWaitPeriod:waitPeriod?.toSeconds()});this.alarmName=this.getResourceNameAttribute(alarm.ref),this.alarmArn=this.getResourceArnAttribute(alarm.attrArn,{service:"cloudwatch",resource:"alarm",resourceName:this.physicalName,arnFormat:core_1().ArnFormat.COLON_RESOURCE_NAME})}generateUniqueId(){const name=core_1().Names.uniqueId(this);return name.length>240?name.substring(0,120)+name.substring(name.length-120):name}};exports.CompositeAlarm=CompositeAlarm,_a=JSII_RTTI_SYMBOL_1,CompositeAlarm[_a]={fqn:"aws-cdk-lib.aws_cloudwatch.CompositeAlarm",version:"2.202.0"},CompositeAlarm.PROPERTY_INJECTION_ID="aws-cdk-lib.aws-cloudwatch.CompositeAlarm",exports.CompositeAlarm=CompositeAlarm=__decorate([prop_injectable_1().propertyInjectable],CompositeAlarm);