CloudWatchSetAlarmStateActionProps

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

Bases: CommonActionProps

(experimental) Configuration properties of an action for CloudWatch alarm.

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

  • 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

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
        )
    ]
)

Attributes

alarm_state_to_set

(experimental) The value of the alarm state to set.

Stability:

experimental

reason

(experimental) The reason for the alarm change.

Default:

None

Stability:

experimental

role

(experimental) The IAM role that allows access to AWS service.

Default:

a new role will be created

Stability:

experimental