Skip to content

DescribeAlarms

Source: src/AWS/CloudWatch/DescribeAlarms.ts

Runtime binding for cloudwatch:DescribeAlarms — read the current state and configuration of the bound alarms. Bind it to one or more Alarm / CompositeAlarm resources; the alarm names are injected automatically.

Provide CloudWatch.DescribeAlarmsHttp on the hosting Lambda Function to satisfy the requirement.

const alarm = yield* CloudWatch.Alarm("HighErrors", {
MetricName: "Errors",
Namespace: "AWS/Lambda",
Statistic: "Sum",
Period: 60,
EvaluationPeriods: 1,
Threshold: 1,
ComparisonOperator: "GreaterThanOrEqualToThreshold",
});
// init — grants cloudwatch:DescribeAlarms on the alarm
const describeAlarms = yield* AWS.CloudWatch.DescribeAlarms(alarm);
// runtime
const result = yield* describeAlarms();
const state = result.MetricAlarms?.[0]?.StateValue; // "OK" | "ALARM" | ...