CloudWatchSetAlarmStateAction

class aws_cdk.aws_iot_actions.CloudWatchSetAlarmStateAction(alarm, *, alarm_state_to_set, reason=None, role=None)

Bases: object

(experimental) The action to change the state of an Amazon CloudWatch alarm.

Stability:

experimental

ExampleMetadata:

infused

Example:

import aws_cdk.aws_cloudwatch as cloudwatch


metric = cloudwatch.Metric(
    namespace="MyNamespace",
    metric_name="MyMetric",
    dimensions={"MyDimension": "MyDimensionValue"}
)
alarm = cloudwatch.Alarm(self, "MyAlarm",
    metric=metric,
    threshold=100,
    evaluation_periods=3,
    datapoints_to_alarm=2
)

topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id FROM 'device/+/data'"),
    actions=[
        actions.CloudWatchSetAlarmStateAction(alarm,
            reason="AWS Iot Rule action is triggered",
            alarm_state_to_set=cloudwatch.AlarmState.ALARM
        )
    ]
)
Parameters:
  • alarm (IAlarm) –

  • alarm_state_to_set (AlarmState) – (experimental) The value of the alarm state to set.

  • reason (Optional[str]) – (experimental) The reason for the alarm change. Default: None

  • role (Optional[IRole]) – (experimental) The IAM role that allows access to AWS service. Default: a new role will be created

Stability:

experimental

Methods

bind(topic_rule)

(experimental) Returns the topic rule action specification.

Parameters:

topic_rule (ITopicRule) –

Stability:

experimental

Return type:

ActionConfig