1 | ;
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.CompositeAlarm = void 0;
|
5 | const jsiiDeprecationWarnings = require("../.warnings.jsii.js");
|
6 | const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
7 | const core_1 = require("@aws-cdk/core");
|
8 | const alarm_base_1 = require("./alarm-base");
|
9 | const cloudwatch_generated_1 = require("./cloudwatch.generated");
|
10 | /**
|
11 | * A Composite Alarm based on Alarm Rule.
|
12 | */
|
13 | class CompositeAlarm extends alarm_base_1.AlarmBase {
|
14 | constructor(scope, id, props) {
|
15 | super(scope, id, {
|
16 | physicalName: props.compositeAlarmName ?? core_1.Lazy.string({ produce: () => this.generateUniqueId() }),
|
17 | });
|
18 | try {
|
19 | jsiiDeprecationWarnings._aws_cdk_aws_cloudwatch_CompositeAlarmProps(props);
|
20 | }
|
21 | catch (error) {
|
22 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
23 | Error.captureStackTrace(error, CompositeAlarm);
|
24 | }
|
25 | throw error;
|
26 | }
|
27 | if (props.alarmRule.renderAlarmRule().length > 10240) {
|
28 | throw new Error('Alarm Rule expression cannot be greater than 10240 characters, please reduce the conditions in the Alarm Rule');
|
29 | }
|
30 | this.alarmRule = props.alarmRule.renderAlarmRule();
|
31 | const alarm = new cloudwatch_generated_1.CfnCompositeAlarm(this, 'Resource', {
|
32 | alarmName: this.physicalName,
|
33 | alarmRule: this.alarmRule,
|
34 | alarmDescription: props.alarmDescription,
|
35 | actionsEnabled: props.actionsEnabled,
|
36 | alarmActions: core_1.Lazy.list({ produce: () => this.alarmActionArns }),
|
37 | insufficientDataActions: core_1.Lazy.list({ produce: (() => this.insufficientDataActionArns) }),
|
38 | okActions: core_1.Lazy.list({ produce: () => this.okActionArns }),
|
39 | });
|
40 | this.alarmName = this.getResourceNameAttribute(alarm.ref);
|
41 | this.alarmArn = this.getResourceArnAttribute(alarm.attrArn, {
|
42 | service: 'cloudwatch',
|
43 | resource: 'alarm',
|
44 | resourceName: this.physicalName,
|
45 | arnFormat: core_1.ArnFormat.COLON_RESOURCE_NAME,
|
46 | });
|
47 | }
|
48 | /**
|
49 | * Import an existing CloudWatch composite alarm provided an Name.
|
50 | *
|
51 | * @param scope The parent creating construct (usually `this`)
|
52 | * @param id The construct's name
|
53 | * @param compositeAlarmName Composite Alarm Name
|
54 | */
|
55 | static fromCompositeAlarmName(scope, id, compositeAlarmName) {
|
56 | const stack = core_1.Stack.of(scope);
|
57 | return this.fromCompositeAlarmArn(scope, id, stack.formatArn({
|
58 | service: 'cloudwatch',
|
59 | resource: 'alarm',
|
60 | resourceName: compositeAlarmName,
|
61 | }));
|
62 | }
|
63 | /**
|
64 | * Import an existing CloudWatch composite alarm provided an ARN.
|
65 | *
|
66 | * @param scope The parent creating construct (usually `this`)
|
67 | * @param id The construct's name
|
68 | * @param compositeAlarmArn Composite Alarm ARN (i.e. arn:aws:cloudwatch:<region>:<account-id>:alarm/CompositeAlarmName)
|
69 | */
|
70 | static fromCompositeAlarmArn(scope, id, compositeAlarmArn) {
|
71 | class Import extends alarm_base_1.AlarmBase {
|
72 | constructor() {
|
73 | super(...arguments);
|
74 | this.alarmArn = compositeAlarmArn;
|
75 | this.alarmName = core_1.Stack.of(scope).splitArn(compositeAlarmArn, core_1.ArnFormat.SLASH_RESOURCE_NAME).resourceName;
|
76 | }
|
77 | }
|
78 | return new Import(scope, id);
|
79 | }
|
80 | generateUniqueId() {
|
81 | const name = core_1.Names.uniqueId(this);
|
82 | if (name.length > 240) {
|
83 | return name.substring(0, 120) + name.substring(name.length - 120);
|
84 | }
|
85 | return name;
|
86 | }
|
87 | }
|
88 | exports.CompositeAlarm = CompositeAlarm;
|
89 | _a = JSII_RTTI_SYMBOL_1;
|
90 | CompositeAlarm[_a] = { fqn: "@aws-cdk/aws-cloudwatch.CompositeAlarm", version: "1.198.0" };
|
91 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJm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