Skip to content

put_alarm_mute_rule async

put_alarm_mute_rule(
    *,
    config_overrides: Optional[AsyncCloudWatchClientConfig] = None,
    name: Optional[Name] = None,
    description: Optional[AlarmDescription] = None,
    rule: Optional[Rule] = None,
    mute_targets: Optional[MuteTargets] = None,
    tags: Optional[TagList] = None,
    start_date: Optional[Timestamp] = None,
    expire_date: Optional[Timestamp] = None,
) -> None

Creates or updates an alarm mute rule.

Alarm mute rules automatically mute alarm actions during predefined time windows. When a mute rule is active, targeted alarms continue to evaluate metrics and transition between states, but their configured actions (such as Amazon SNS notifications or Auto Scaling actions) are muted.

You can create mute rules with recurring schedules using cron expressions or one-time mute windows using at expressions. Each mute rule can target up to 100 specific alarms by name.

If you specify a rule name that already exists, this operation updates the existing rule with the new configuration.

Permissions

To create or update a mute rule, you must have the cloudwatch:PutAlarmMuteRule permission on two types of resources: the alarm mute rule resource itself, and each alarm that the rule targets.

For example, If you want to allow a user to create mute rules that target only specific alarms named "WebServerCPUAlarm" and "DatabaseConnectionAlarm", you would create an IAM policy with one statement granting cloudwatch:PutAlarmMuteRule on the alarm mute rule resource (arn:aws:cloudwatch:[REGION]:123456789012:alarm-mute-rule:*), and another statement granting cloudwatch:PutAlarmMuteRule on the targeted alarm resources (arn:aws:cloudwatch:[REGION]:123456789012:alarm:WebServerCPUAlarm and arn:aws:cloudwatch:[REGION]:123456789012:alarm:DatabaseConnectionAlarm).

You can also use IAM policy conditions to allow targeting alarms based on resource tags. For example, you can restrict users to create/update mute rules to only target alarms that have a specific tag key-value pair, such as Team=TeamA.

Parameters:

  • name (Optional[Name], default: None ) –

    The name of the alarm mute rule. This name must be unique within your Amazon Web Services account and region.

  • description (Optional[AlarmDescription], default: None ) –

    A description of the alarm mute rule that helps you identify its purpose.

  • rule (Optional[Rule], default: None ) –

    The configuration that defines when and how long alarms should be muted.

  • mute_targets (Optional[MuteTargets], default: None ) –

    Specifies which alarms this rule applies to.

  • tags (Optional[TagList], default: None ) –

    A list of key-value pairs to associate with the alarm mute rule. You can use tags to categorize and manage your mute rules.

  • start_date (Optional[Timestamp], default: None ) –

    The date and time after which the mute rule takes effect, specified as a timestamp in ISO 8601 format (for example, 2026-04-15T08:00:00Z). If not specified, the mute rule takes effect immediately upon creation and the mutes are applied as per the schedule expression.

  • expire_date (Optional[Timestamp], default: None ) –

    The date and time when the mute rule expires and is no longer evaluated, specified as a timestamp in ISO 8601 format (for example, 2026-12-31T23:59:59Z). After this time, the rule status becomes EXPIRED and will no longer mute the targeted alarms.

Raises:

Source code in docs_src/capo_cloudwatch/_services/async_cloud_watch.py
async def put_alarm_mute_rule(
    self,
    *,
    config_overrides: Optional[AsyncCloudWatchClientConfig] = None,
    name: Optional["capo_cloudwatch.types.name.Name"] = None,
    description: Optional[
        "capo_cloudwatch.types.alarm_description.AlarmDescription"
    ] = None,
    rule: Optional["capo_cloudwatch.types.rule.Rule"] = None,
    mute_targets: Optional["capo_cloudwatch.types.mute_targets.MuteTargets"] = None,
    tags: Optional["capo_cloudwatch.types.tag_list.TagList"] = None,
    start_date: Optional["capo_cloudwatch.types.timestamp.Timestamp"] = None,
    expire_date: Optional["capo_cloudwatch.types.timestamp.Timestamp"] = None,
) -> None:
    """<p>Creates or updates an alarm mute rule.</p> <p>Alarm mute rules automatically mute alarm actions during predefined time windows. When a mute rule is active, targeted alarms continue to evaluate metrics and transition between states, but their configured actions (such as Amazon SNS notifications or Auto Scaling actions) are muted.</p> <p>You can create mute rules with recurring schedules using <code>cron</code> expressions or one-time mute windows using <code>at</code> expressions. Each mute rule can target up to 100 specific alarms by name.</p> <p>If you specify a rule name that already exists, this operation updates the existing rule with the new configuration.</p> <p> <b>Permissions</b> </p> <p>To create or update a mute rule, you must have the <code>cloudwatch:PutAlarmMuteRule</code> permission on two types of resources: the alarm mute rule resource itself, and each alarm that the rule targets.</p> <p>For example, If you want to allow a user to create mute rules that target only specific alarms named "WebServerCPUAlarm" and "DatabaseConnectionAlarm", you would create an IAM policy with one statement granting <code>cloudwatch:PutAlarmMuteRule</code> on the alarm mute rule resource (<code>arn:aws:cloudwatch:[REGION]:123456789012:alarm-mute-rule:*</code>), and another statement granting <code>cloudwatch:PutAlarmMuteRule</code> on the targeted alarm resources (<code>arn:aws:cloudwatch:[REGION]:123456789012:alarm:WebServerCPUAlarm</code> and <code>arn:aws:cloudwatch:[REGION]:123456789012:alarm:DatabaseConnectionAlarm</code>).</p> <p>You can also use IAM policy conditions to allow targeting alarms based on resource tags. For example, you can restrict users to create/update mute rules to only target alarms that have a specific tag key-value pair, such as <code>Team=TeamA</code>.</p>

    Args:
        name: <p>The name of the alarm mute rule. This name must be unique within your Amazon Web Services account and region.</p>
        description: <p>A description of the alarm mute rule that helps you identify its purpose.</p>
        rule: <p>The configuration that defines when and how long alarms should be muted.</p>
        mute_targets: <p>Specifies which alarms this rule applies to.</p>
        tags: <p>A list of key-value pairs to associate with the alarm mute rule. You can use tags to categorize and manage your mute rules.</p>
        start_date: <p>The date and time after which the mute rule takes effect, specified as a timestamp in ISO 8601 format (for example, <code>2026-04-15T08:00:00Z</code>). If not specified, the mute rule takes effect immediately upon creation and the mutes are applied as per the schedule expression.</p>
        expire_date: <p>The date and time when the mute rule expires and is no longer evaluated, specified as a timestamp in ISO 8601 format (for example, <code>2026-12-31T23:59:59Z</code>). After this time, the rule status becomes EXPIRED and will no longer mute the targeted alarms.</p>

    Raises:
        capo_cloudwatch.errors.limit_exceeded_fault.LimitExceededFault: <p>The quota for alarms for this customer has already been reached.</p>
        capo_cloudwatch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatch.types.put_alarm_mute_rule_input.PutAlarmMuteRuleInput]",
    ) -> AsyncOperationResponse[None]:
        import capo_cloudwatch._operations.granite_service_version20100801.put_alarm_mute_rule

        (
            output,
            http_response,
        ) = await capo_cloudwatch._operations.granite_service_version20100801.put_alarm_mute_rule.async_put_alarm_mute_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutAlarmMuteRule")
    )
    input_: capo_cloudwatch.types.put_alarm_mute_rule_input.PutAlarmMuteRuleInput = {}
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if rule is not None:
        input_["rule"] = rule
    if mute_targets is not None:
        input_["mute_targets"] = mute_targets
    if tags is not None:
        input_["tags"] = tags
    if start_date is not None:
        input_["start_date"] = start_date
    if expire_date is not None:
        input_["expire_date"] = expire_date

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output