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:

AlarmName string

The name for the composite alarm. This name must be unique within the region.

AlarmRule 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.

ActionsEnabled bool

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

AlarmActions 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.

AlarmDescription string

The description for the composite alarm.

InsufficientDataActions List<string>

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.

OkActions 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.

Tags 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.

AlarmName string

The name for the composite alarm. This name must be unique within the region.

AlarmRule 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.

ActionsEnabled bool

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

AlarmActions []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.

AlarmDescription string

The description for the composite alarm.

InsufficientDataActions []string

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.

OkActions []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.

Tags 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.

alarmName String

The name for the composite alarm. This name must be unique within the region.

alarmRule 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.

actionsEnabled Boolean

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

alarmActions 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.

alarmDescription String

The description for the composite alarm.

insufficientDataActions List<String>

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.

okActions 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.

tags 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.

alarmName string

The name for the composite alarm. This name must be unique within the region.

alarmRule 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.

actionsEnabled boolean

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

alarmActions 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.

alarmDescription string

The description for the composite alarm.

insufficientDataActions string[]

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.

okActions 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.

tags {[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_actions Sequence[str]

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.

tags 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.

alarmName String

The name for the composite alarm. This name must be unique within the region.

alarmRule 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.

actionsEnabled Boolean

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

alarmActions 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.

alarmDescription String

The description for the composite alarm.

insufficientDataActions List<String>

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.

okActions 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.

tags 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:

Arn string

The ARN of the composite alarm.

Id string

The provider-assigned unique ID for this managed resource.

TagsAll Dictionary<string, string>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Arn string

The ARN of the composite alarm.

Id string

The provider-assigned unique ID for this managed resource.

TagsAll map[string]string

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

arn String

The ARN of the composite alarm.

id String

The provider-assigned unique ID for this managed resource.

tagsAll Map<String,String>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

arn string

The ARN of the composite alarm.

id string

The provider-assigned unique ID for this managed resource.

tagsAll {[key: string]: string}

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

arn str

The ARN of the composite alarm.

id str

The provider-assigned unique ID for this managed resource.

tags_all Mapping[str, str]

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

arn String

The ARN of the composite alarm.

id String

The provider-assigned unique ID for this managed resource.

tagsAll Map<String>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

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.
The following state arguments are supported:
ActionsEnabled bool

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

AlarmActions 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.

AlarmDescription string

The description for the composite alarm.

AlarmName string

The name for the composite alarm. This name must be unique within the region.

AlarmRule 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.

InsufficientDataActions List<string>

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.

OkActions 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.

Tags 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.

TagsAll Dictionary<string, string>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

ActionsEnabled bool

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

AlarmActions []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.

AlarmDescription string

The description for the composite alarm.

AlarmName string

The name for the composite alarm. This name must be unique within the region.

AlarmRule 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.

InsufficientDataActions []string

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.

OkActions []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.

Tags 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.

TagsAll map[string]string

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

actionsEnabled Boolean

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

alarmActions 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.

alarmDescription String

The description for the composite alarm.

alarmName String

The name for the composite alarm. This name must be unique within the region.

alarmRule 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.

insufficientDataActions List<String>

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.

okActions 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.

tags 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.

tagsAll Map<String,String>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

actionsEnabled boolean

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

alarmActions 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.

alarmDescription string

The description for the composite alarm.

alarmName string

The name for the composite alarm. This name must be unique within the region.

alarmRule 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.

insufficientDataActions string[]

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.

okActions 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.

tags {[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.

tagsAll {[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_actions Sequence[str]

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.

tags 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.

tags_all Mapping[str, str]

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

actionsEnabled Boolean

Indicates whether actions should be executed during any changes to the alarm state of the composite alarm. Defaults to true.

alarmActions 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.

alarmDescription String

The description for the composite alarm.

alarmName String

The name for the composite alarm. This name must be unique within the region.

alarmRule 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.

insufficientDataActions List<String>

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.

okActions 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.

tags 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.

tagsAll 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
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.