/
getAlarm.go
260 lines (224 loc) · 19.3 KB
/
getAlarm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
// Code generated by pulumi-language-go DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package cloudwatch
import (
"context"
"reflect"
"github.com/pulumi/pulumi-aws-native/sdk/go/aws"
"github.com/pulumi/pulumi-aws-native/sdk/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The “AWS::CloudWatch::Alarm“ type specifies an alarm and associates it with the specified metric or metric math expression.
//
// When this operation creates an alarm, the alarm state is immediately set to ``INSUFFICIENT_DATA``. The alarm is then evaluated and its state is set appropriately. Any actions associated with the new state are then executed.
// When you update an existing alarm, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
func LookupAlarm(ctx *pulumi.Context, args *LookupAlarmArgs, opts ...pulumi.InvokeOption) (*LookupAlarmResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv LookupAlarmResult
err := ctx.Invoke("aws-native:cloudwatch:getAlarm", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
type LookupAlarmArgs struct {
// The name of the alarm. If you don't specify a name, CFN generates a unique physical ID and uses that ID for the alarm name.
// If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
AlarmName string `pulumi:"alarmName"`
}
type LookupAlarmResult struct {
// Indicates whether actions should be executed during any changes to the alarm state. The default is TRUE.
ActionsEnabled *bool `pulumi:"actionsEnabled"`
// The list of actions to execute when this alarm transitions into an ALARM state from any other state. Specify each action as an Amazon Resource Name (ARN). For more information about creating alarms and the actions that you can specify, see [PutMetricAlarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html) in the *API Reference*.
AlarmActions []string `pulumi:"alarmActions"`
// The description of the alarm.
AlarmDescription *string `pulumi:"alarmDescription"`
Arn *string `pulumi:"arn"`
// The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand.
ComparisonOperator *string `pulumi:"comparisonOperator"`
// The number of datapoints that must be breaching to trigger the alarm. This is used only if you are setting an "M out of N" alarm. In that case, this value is the M, and the value that you set for ``EvaluationPeriods`` is the N value. For more information, see [Evaluating an Alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarm-evaluation) in the *User Guide*.
// If you omit this parameter, CW uses the same value here that you set for ``EvaluationPeriods``, and the alarm goes to alarm state if that many consecutive periods are breaching.
DatapointsToAlarm *int `pulumi:"datapointsToAlarm"`
// The dimensions for the metric associated with the alarm. For an alarm based on a math expression, you can't specify ``Dimensions``. Instead, you use ``Metrics``.
Dimensions []AlarmDimension `pulumi:"dimensions"`
// Used only for alarms based on percentiles. If ``ignore``, the alarm state does not change during periods with too few data points to be statistically significant. If ``evaluate`` or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.
EvaluateLowSampleCountPercentile *string `pulumi:"evaluateLowSampleCountPercentile"`
// The number of periods over which data is compared to the specified threshold. If you are setting an alarm that requires that a number of consecutive data points be breaching to trigger the alarm, this value specifies that number. If you are setting an "M out of N" alarm, this value is the N, and ``DatapointsToAlarm`` is the M.
// For more information, see [Evaluating an Alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarm-evaluation) in the *User Guide*.
EvaluationPeriods *int `pulumi:"evaluationPeriods"`
// The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
// For an alarm based on a metric, you must specify either ``Statistic`` or ``ExtendedStatistic`` but not both.
// For an alarm based on a math expression, you can't specify ``ExtendedStatistic``. Instead, you use ``Metrics``.
ExtendedStatistic *string `pulumi:"extendedStatistic"`
// The actions to execute when this alarm transitions to the ``INSUFFICIENT_DATA`` state from any other state. Each action is specified as an Amazon Resource Name (ARN).
InsufficientDataActions []string `pulumi:"insufficientDataActions"`
// The name of the metric associated with the alarm. This is required for an alarm based on a metric. For an alarm based on a math expression, you use ``Metrics`` instead and you can't specify ``MetricName``.
MetricName *string `pulumi:"metricName"`
// An array that enables you to create an alarm based on the result of a metric math expression. Each item in the array either retrieves a metric or performs a math expression.
// If you specify the ``Metrics`` parameter, you cannot specify ``MetricName``, ``Dimensions``, ``Period``, ``Namespace``, ``Statistic``, ``ExtendedStatistic``, or ``Unit``.
Metrics []AlarmMetricDataQuery `pulumi:"metrics"`
// The namespace of the metric associated with the alarm. This is required for an alarm based on a metric. For an alarm based on a math expression, you can't specify ``Namespace`` and you use ``Metrics`` instead.
// For a list of namespaces for metrics from AWS services, see [Services That Publish Metrics.](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html)
Namespace *string `pulumi:"namespace"`
// The actions to execute when this alarm transitions to the ``OK`` state from any other state. Each action is specified as an Amazon Resource Name (ARN).
OkActions []string `pulumi:"okActions"`
// The period, in seconds, over which the statistic is applied. This is required for an alarm based on a metric. Valid values are 10, 30, 60, and any multiple of 60.
// For an alarm based on a math expression, you can't specify ``Period``, and instead you use the ``Metrics`` parameter.
// *Minimum:* 10
Period *int `pulumi:"period"`
// The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use ``ExtendedStatistic``.
// For an alarm based on a metric, you must specify either ``Statistic`` or ``ExtendedStatistic`` but not both.
// For an alarm based on a math expression, you can't specify ``Statistic``. Instead, you use ``Metrics``.
Statistic *string `pulumi:"statistic"`
Tags []aws.Tag `pulumi:"tags"`
// The value to compare with the specified statistic.
Threshold *float64 `pulumi:"threshold"`
// In an alarm based on an anomaly detection model, this is the ID of the ``ANOMALY_DETECTION_BAND`` function used as the threshold for the alarm.
ThresholdMetricId *string `pulumi:"thresholdMetricId"`
// Sets how this alarm is to handle missing data points. Valid values are ``breaching``, ``notBreaching``, ``ignore``, and ``missing``. For more information, see [Configuring How Alarms Treat Missing Data](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-and-missing-data) in the *Amazon User Guide*.
// If you omit this parameter, the default behavior of ``missing`` is used.
TreatMissingData *string `pulumi:"treatMissingData"`
// The unit of the metric associated with the alarm. Specify this only if you are creating an alarm based on a single metric. Do not specify this if you are specifying a ``Metrics`` array.
// You can specify the following values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, or None.
Unit *string `pulumi:"unit"`
}
func LookupAlarmOutput(ctx *pulumi.Context, args LookupAlarmOutputArgs, opts ...pulumi.InvokeOption) LookupAlarmResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupAlarmResult, error) {
args := v.(LookupAlarmArgs)
r, err := LookupAlarm(ctx, &args, opts...)
var s LookupAlarmResult
if r != nil {
s = *r
}
return s, err
}).(LookupAlarmResultOutput)
}
type LookupAlarmOutputArgs struct {
// The name of the alarm. If you don't specify a name, CFN generates a unique physical ID and uses that ID for the alarm name.
// If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
AlarmName pulumi.StringInput `pulumi:"alarmName"`
}
func (LookupAlarmOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupAlarmArgs)(nil)).Elem()
}
type LookupAlarmResultOutput struct{ *pulumi.OutputState }
func (LookupAlarmResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupAlarmResult)(nil)).Elem()
}
func (o LookupAlarmResultOutput) ToLookupAlarmResultOutput() LookupAlarmResultOutput {
return o
}
func (o LookupAlarmResultOutput) ToLookupAlarmResultOutputWithContext(ctx context.Context) LookupAlarmResultOutput {
return o
}
// Indicates whether actions should be executed during any changes to the alarm state. The default is TRUE.
func (o LookupAlarmResultOutput) ActionsEnabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *bool { return v.ActionsEnabled }).(pulumi.BoolPtrOutput)
}
// The list of actions to execute when this alarm transitions into an ALARM state from any other state. Specify each action as an Amazon Resource Name (ARN). For more information about creating alarms and the actions that you can specify, see [PutMetricAlarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html) in the *API Reference*.
func (o LookupAlarmResultOutput) AlarmActions() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupAlarmResult) []string { return v.AlarmActions }).(pulumi.StringArrayOutput)
}
// The description of the alarm.
func (o LookupAlarmResultOutput) AlarmDescription() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.AlarmDescription }).(pulumi.StringPtrOutput)
}
func (o LookupAlarmResultOutput) Arn() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.Arn }).(pulumi.StringPtrOutput)
}
// The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand.
func (o LookupAlarmResultOutput) ComparisonOperator() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.ComparisonOperator }).(pulumi.StringPtrOutput)
}
// The number of datapoints that must be breaching to trigger the alarm. This is used only if you are setting an "M out of N" alarm. In that case, this value is the M, and the value that you set for “EvaluationPeriods“ is the N value. For more information, see [Evaluating an Alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarm-evaluation) in the *User Guide*.
//
// If you omit this parameter, CW uses the same value here that you set for ``EvaluationPeriods``, and the alarm goes to alarm state if that many consecutive periods are breaching.
func (o LookupAlarmResultOutput) DatapointsToAlarm() pulumi.IntPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *int { return v.DatapointsToAlarm }).(pulumi.IntPtrOutput)
}
// The dimensions for the metric associated with the alarm. For an alarm based on a math expression, you can't specify “Dimensions“. Instead, you use “Metrics“.
func (o LookupAlarmResultOutput) Dimensions() AlarmDimensionArrayOutput {
return o.ApplyT(func(v LookupAlarmResult) []AlarmDimension { return v.Dimensions }).(AlarmDimensionArrayOutput)
}
// Used only for alarms based on percentiles. If “ignore“, the alarm state does not change during periods with too few data points to be statistically significant. If “evaluate“ or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.
func (o LookupAlarmResultOutput) EvaluateLowSampleCountPercentile() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.EvaluateLowSampleCountPercentile }).(pulumi.StringPtrOutput)
}
// The number of periods over which data is compared to the specified threshold. If you are setting an alarm that requires that a number of consecutive data points be breaching to trigger the alarm, this value specifies that number. If you are setting an "M out of N" alarm, this value is the N, and “DatapointsToAlarm“ is the M.
//
// For more information, see [Evaluating an Alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarm-evaluation) in the *User Guide*.
func (o LookupAlarmResultOutput) EvaluationPeriods() pulumi.IntPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *int { return v.EvaluationPeriods }).(pulumi.IntPtrOutput)
}
// The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
//
// For an alarm based on a metric, you must specify either ``Statistic`` or ``ExtendedStatistic`` but not both.
// For an alarm based on a math expression, you can't specify ``ExtendedStatistic``. Instead, you use ``Metrics``.
func (o LookupAlarmResultOutput) ExtendedStatistic() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.ExtendedStatistic }).(pulumi.StringPtrOutput)
}
// The actions to execute when this alarm transitions to the “INSUFFICIENT_DATA“ state from any other state. Each action is specified as an Amazon Resource Name (ARN).
func (o LookupAlarmResultOutput) InsufficientDataActions() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupAlarmResult) []string { return v.InsufficientDataActions }).(pulumi.StringArrayOutput)
}
// The name of the metric associated with the alarm. This is required for an alarm based on a metric. For an alarm based on a math expression, you use “Metrics“ instead and you can't specify “MetricName“.
func (o LookupAlarmResultOutput) MetricName() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.MetricName }).(pulumi.StringPtrOutput)
}
// An array that enables you to create an alarm based on the result of a metric math expression. Each item in the array either retrieves a metric or performs a math expression.
//
// If you specify the ``Metrics`` parameter, you cannot specify ``MetricName``, ``Dimensions``, ``Period``, ``Namespace``, ``Statistic``, ``ExtendedStatistic``, or ``Unit``.
func (o LookupAlarmResultOutput) Metrics() AlarmMetricDataQueryArrayOutput {
return o.ApplyT(func(v LookupAlarmResult) []AlarmMetricDataQuery { return v.Metrics }).(AlarmMetricDataQueryArrayOutput)
}
// The namespace of the metric associated with the alarm. This is required for an alarm based on a metric. For an alarm based on a math expression, you can't specify “Namespace“ and you use “Metrics“ instead.
//
// For a list of namespaces for metrics from AWS services, see [Services That Publish Metrics.](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html)
func (o LookupAlarmResultOutput) Namespace() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.Namespace }).(pulumi.StringPtrOutput)
}
// The actions to execute when this alarm transitions to the “OK“ state from any other state. Each action is specified as an Amazon Resource Name (ARN).
func (o LookupAlarmResultOutput) OkActions() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupAlarmResult) []string { return v.OkActions }).(pulumi.StringArrayOutput)
}
// The period, in seconds, over which the statistic is applied. This is required for an alarm based on a metric. Valid values are 10, 30, 60, and any multiple of 60.
//
// For an alarm based on a math expression, you can't specify ``Period``, and instead you use the ``Metrics`` parameter.
// *Minimum:* 10
func (o LookupAlarmResultOutput) Period() pulumi.IntPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *int { return v.Period }).(pulumi.IntPtrOutput)
}
// The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use “ExtendedStatistic“.
//
// For an alarm based on a metric, you must specify either ``Statistic`` or ``ExtendedStatistic`` but not both.
// For an alarm based on a math expression, you can't specify ``Statistic``. Instead, you use ``Metrics``.
func (o LookupAlarmResultOutput) Statistic() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.Statistic }).(pulumi.StringPtrOutput)
}
func (o LookupAlarmResultOutput) Tags() aws.TagArrayOutput {
return o.ApplyT(func(v LookupAlarmResult) []aws.Tag { return v.Tags }).(aws.TagArrayOutput)
}
// The value to compare with the specified statistic.
func (o LookupAlarmResultOutput) Threshold() pulumi.Float64PtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *float64 { return v.Threshold }).(pulumi.Float64PtrOutput)
}
// In an alarm based on an anomaly detection model, this is the ID of the “ANOMALY_DETECTION_BAND“ function used as the threshold for the alarm.
func (o LookupAlarmResultOutput) ThresholdMetricId() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.ThresholdMetricId }).(pulumi.StringPtrOutput)
}
// Sets how this alarm is to handle missing data points. Valid values are “breaching“, “notBreaching“, “ignore“, and “missing“. For more information, see [Configuring How Alarms Treat Missing Data](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-and-missing-data) in the *Amazon User Guide*.
//
// If you omit this parameter, the default behavior of ``missing`` is used.
func (o LookupAlarmResultOutput) TreatMissingData() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.TreatMissingData }).(pulumi.StringPtrOutput)
}
// The unit of the metric associated with the alarm. Specify this only if you are creating an alarm based on a single metric. Do not specify this if you are specifying a “Metrics“ array.
//
// You can specify the following values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, or None.
func (o LookupAlarmResultOutput) Unit() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupAlarmResult) *string { return v.Unit }).(pulumi.StringPtrOutput)
}
func init() {
pulumi.RegisterOutputType(LookupAlarmResultOutput{})
}