aws.cloudwatch.CompositeAlarm
Provides a CloudWatch Composite Alarm resource.
NOTE: An alarm (composite or metric) cannot be destroyed when there are other composite alarms depending on it. This can lead to a cyclical dependency on update, as the provider will unsuccessfully attempt to destroy alarms before updating the rule. Consider using
depends_on
, references to alarm names, and two-stage updates.
Example Usage
using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.CloudWatch.CompositeAlarm("example", new()
{
AlarmDescription = "This is a composite alarm!",
AlarmName = "example-composite-alarm",
AlarmActions = aws_sns_topic.Example.Arn,
OkActions = aws_sns_topic.Example.Arn,
AlarmRule = @$"ALARM({aws_cloudwatch_metric_alarm.Alpha.Alarm_name}) OR
ALARM({aws_cloudwatch_metric_alarm.Bravo.Alarm_name})
",
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudwatch.NewCompositeAlarm(ctx, "example", &cloudwatch.CompositeAlarmArgs{
AlarmDescription: pulumi.String("This is a composite alarm!"),
AlarmName: pulumi.String("example-composite-alarm"),
AlarmActions: pulumi.Any(aws_sns_topic.Example.Arn),
OkActions: pulumi.Any(aws_sns_topic.Example.Arn),
AlarmRule: pulumi.String(fmt.Sprintf("ALARM(%v) OR\nALARM(%v)\n", aws_cloudwatch_metric_alarm.Alpha.Alarm_name, aws_cloudwatch_metric_alarm.Bravo.Alarm_name)),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.CompositeAlarm;
import com.pulumi.aws.cloudwatch.CompositeAlarmArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new CompositeAlarm("example", CompositeAlarmArgs.builder()
.alarmDescription("This is a composite alarm!")
.alarmName("example-composite-alarm")
.alarmActions(aws_sns_topic.example().arn())
.okActions(aws_sns_topic.example().arn())
.alarmRule("""
ALARM(%s) OR
ALARM(%s)
", aws_cloudwatch_metric_alarm.alpha().alarm_name(),aws_cloudwatch_metric_alarm.bravo().alarm_name()))
.build());
}
}
import pulumi
import pulumi_aws as aws
example = aws.cloudwatch.CompositeAlarm("example",
alarm_description="This is a composite alarm!",
alarm_name="example-composite-alarm",
alarm_actions=aws_sns_topic["example"]["arn"],
ok_actions=aws_sns_topic["example"]["arn"],
alarm_rule=f"""ALARM({aws_cloudwatch_metric_alarm["alpha"]["alarm_name"]}) OR
ALARM({aws_cloudwatch_metric_alarm["bravo"]["alarm_name"]})
""")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.cloudwatch.CompositeAlarm("example", {
alarmDescription: "This is a composite alarm!",
alarmName: "example-composite-alarm",
alarmActions: aws_sns_topic.example.arn,
okActions: aws_sns_topic.example.arn,
alarmRule: `ALARM(${aws_cloudwatch_metric_alarm.alpha.alarm_name}) OR
ALARM(${aws_cloudwatch_metric_alarm.bravo.alarm_name})
`,
});
resources:
example:
type: aws:cloudwatch:CompositeAlarm
properties:
alarmDescription: This is a composite alarm!
alarmName: example-composite-alarm
alarmActions: ${aws_sns_topic.example.arn}
okActions: ${aws_sns_topic.example.arn}
alarmRule: |
ALARM(${aws_cloudwatch_metric_alarm.alpha.alarm_name}) OR
ALARM(${aws_cloudwatch_metric_alarm.bravo.alarm_name})
Create CompositeAlarm Resource
new CompositeAlarm(name: string, args: CompositeAlarmArgs, opts?: CustomResourceOptions);
@overload
def CompositeAlarm(resource_name: str,
opts: Optional[ResourceOptions] = None,
actions_enabled: Optional[bool] = None,
alarm_actions: Optional[Sequence[str]] = None,
alarm_description: Optional[str] = None,
alarm_name: Optional[str] = None,
alarm_rule: Optional[str] = None,
insufficient_data_actions: Optional[Sequence[str]] = None,
ok_actions: Optional[Sequence[str]] = None,
tags: Optional[Mapping[str, str]] = None)
@overload
def CompositeAlarm(resource_name: str,
args: CompositeAlarmArgs,
opts: Optional[ResourceOptions] = None)
func NewCompositeAlarm(ctx *Context, name string, args CompositeAlarmArgs, opts ...ResourceOption) (*CompositeAlarm, error)
public CompositeAlarm(string name, CompositeAlarmArgs args, CustomResourceOptions? opts = null)
public CompositeAlarm(String name, CompositeAlarmArgs args)
public CompositeAlarm(String name, CompositeAlarmArgs args, CustomResourceOptions options)
type: aws:cloudwatch:CompositeAlarm
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CompositeAlarmArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args CompositeAlarmArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args CompositeAlarmArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CompositeAlarmArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CompositeAlarmArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
CompositeAlarm Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The CompositeAlarm resource accepts the following input properties:
- Alarm
Name string The name for the composite alarm. This name must be unique within the region.
- Alarm
Rule string An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- Actions
Enabled bool Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- Alarm
Actions List<string> The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Alarm
Description string The description for the composite alarm.
- Insufficient
Data List<string>Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Ok
Actions List<string> The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Dictionary<string, string>
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- Alarm
Name string The name for the composite alarm. This name must be unique within the region.
- Alarm
Rule string An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- Actions
Enabled bool Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- Alarm
Actions []string The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Alarm
Description string The description for the composite alarm.
- Insufficient
Data []stringActions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Ok
Actions []string The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- map[string]string
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- alarm
Name String The name for the composite alarm. This name must be unique within the region.
- alarm
Rule String An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- actions
Enabled Boolean Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm
Actions List<String> The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm
Description String The description for the composite alarm.
- insufficient
Data List<String>Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok
Actions List<String> The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Map<String,String>
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- alarm
Name string The name for the composite alarm. This name must be unique within the region.
- alarm
Rule string An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- actions
Enabled boolean Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm
Actions string[] The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm
Description string The description for the composite alarm.
- insufficient
Data string[]Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok
Actions string[] The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- {[key: string]: string}
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- alarm_
name str The name for the composite alarm. This name must be unique within the region.
- alarm_
rule str An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- actions_
enabled bool Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm_
actions Sequence[str] The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm_
description str The description for the composite alarm.
- insufficient_
data_ Sequence[str]actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok_
actions Sequence[str] The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Mapping[str, str]
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- alarm
Name String The name for the composite alarm. This name must be unique within the region.
- alarm
Rule String An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- actions
Enabled Boolean Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm
Actions List<String> The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm
Description String The description for the composite alarm.
- insufficient
Data List<String>Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok
Actions List<String> The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Map<String>
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Outputs
All input properties are implicitly available as output properties. Additionally, the CompositeAlarm resource produces the following output properties:
Look up Existing CompositeAlarm Resource
Get an existing CompositeAlarm resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: CompositeAlarmState, opts?: CustomResourceOptions): CompositeAlarm
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
actions_enabled: Optional[bool] = None,
alarm_actions: Optional[Sequence[str]] = None,
alarm_description: Optional[str] = None,
alarm_name: Optional[str] = None,
alarm_rule: Optional[str] = None,
arn: Optional[str] = None,
insufficient_data_actions: Optional[Sequence[str]] = None,
ok_actions: Optional[Sequence[str]] = None,
tags: Optional[Mapping[str, str]] = None,
tags_all: Optional[Mapping[str, str]] = None) -> CompositeAlarm
func GetCompositeAlarm(ctx *Context, name string, id IDInput, state *CompositeAlarmState, opts ...ResourceOption) (*CompositeAlarm, error)
public static CompositeAlarm Get(string name, Input<string> id, CompositeAlarmState? state, CustomResourceOptions? opts = null)
public static CompositeAlarm get(String name, Output<String> id, CompositeAlarmState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Actions
Enabled bool Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- Alarm
Actions List<string> The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Alarm
Description string The description for the composite alarm.
- Alarm
Name string The name for the composite alarm. This name must be unique within the region.
- Alarm
Rule string An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- Arn string
The ARN of the composite alarm.
- Insufficient
Data List<string>Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Ok
Actions List<string> The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Dictionary<string, string>
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- Actions
Enabled bool Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- Alarm
Actions []string The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Alarm
Description string The description for the composite alarm.
- Alarm
Name string The name for the composite alarm. This name must be unique within the region.
- Alarm
Rule string An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- Arn string
The ARN of the composite alarm.
- Insufficient
Data []stringActions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Ok
Actions []string The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- map[string]string
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- map[string]string
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- actions
Enabled Boolean Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm
Actions List<String> The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm
Description String The description for the composite alarm.
- alarm
Name String The name for the composite alarm. This name must be unique within the region.
- alarm
Rule String An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- arn String
The ARN of the composite alarm.
- insufficient
Data List<String>Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok
Actions List<String> The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Map<String,String>
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Map<String,String>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- actions
Enabled boolean Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm
Actions string[] The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm
Description string The description for the composite alarm.
- alarm
Name string The name for the composite alarm. This name must be unique within the region.
- alarm
Rule string An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- arn string
The ARN of the composite alarm.
- insufficient
Data string[]Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok
Actions string[] The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- {[key: string]: string}
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- actions_
enabled bool Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm_
actions Sequence[str] The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm_
description str The description for the composite alarm.
- alarm_
name str The name for the composite alarm. This name must be unique within the region.
- alarm_
rule str An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- arn str
The ARN of the composite alarm.
- insufficient_
data_ Sequence[str]actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok_
actions Sequence[str] The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Mapping[str, str]
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- actions
Enabled Boolean Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to
true
.- alarm
Actions List<String> The set of actions to execute when this alarm transitions to the
ALARM
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- alarm
Description String The description for the composite alarm.
- alarm
Name String The name for the composite alarm. This name must be unique within the region.
- alarm
Rule String An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see Creating a Composite Alarm. The maximum length is 10240 characters.
- arn String
The ARN of the composite alarm.
- insufficient
Data List<String>Actions The set of actions to execute when this alarm transitions to the
INSUFFICIENT_DATA
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- ok
Actions List<String> The set of actions to execute when this alarm transitions to an
OK
state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed.- Map<String>
A map of tags to associate with the alarm. Up to 50 tags are allowed. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Map<String>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
Import
Use the alarm_name
to import a CloudWatch Composite Alarm. For example
$ pulumi import aws:cloudwatch/compositeAlarm:CompositeAlarm test my-alarm
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.