generated from hashicorp/terraform-provider-scaffolding
/
metric_filter_resource_gen.go
373 lines (358 loc) · 18.8 KB
/
metric_filter_resource_gen.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Code generated by generators/resource/main.go; DO NOT EDIT.
package logs
import (
"context"
"regexp"
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-provider-awscc/internal/generic"
"github.com/hashicorp/terraform-provider-awscc/internal/registry"
)
func init() {
registry.AddResourceFactory("awscc_logs_metric_filter", metricFilterResource)
}
// metricFilterResource returns the Terraform awscc_logs_metric_filter resource.
// This Terraform resource corresponds to the CloudFormation AWS::Logs::MetricFilter resource.
func metricFilterResource(ctx context.Context) (resource.Resource, error) {
attributes := map[string]schema.Attribute{ /*START SCHEMA*/
// Property: FilterName
// CloudFormation resource type schema:
//
// {
// "description": "The name of the metric filter.",
// "maxLength": 512,
// "minLength": 1,
// "pattern": "^[^:*]{1,512}",
// "type": "string"
// }
"filter_name": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The name of the metric filter.",
Optional: true,
Computed: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 512),
stringvalidator.RegexMatches(regexp.MustCompile("^[^:*]{1,512}"), ""),
}, /*END VALIDATORS*/
PlanModifiers: []planmodifier.String{ /*START PLAN MODIFIERS*/
stringplanmodifier.UseStateForUnknown(),
stringplanmodifier.RequiresReplace(),
}, /*END PLAN MODIFIERS*/
}, /*END ATTRIBUTE*/
// Property: FilterPattern
// CloudFormation resource type schema:
//
// {
// "description": "A filter pattern for extracting metric data out of ingested log events. For more information, see [Filter and Pattern Syntax](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html).",
// "maxLength": 1024,
// "type": "string"
// }
"filter_pattern": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "A filter pattern for extracting metric data out of ingested log events. For more information, see [Filter and Pattern Syntax](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html).",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthAtMost(1024),
}, /*END VALIDATORS*/
}, /*END ATTRIBUTE*/
// Property: LogGroupName
// CloudFormation resource type schema:
//
// {
// "description": "The name of an existing log group that you want to associate with this metric filter.",
// "maxLength": 512,
// "minLength": 1,
// "pattern": "^[.\\-_/#A-Za-z0-9]{1,512}",
// "type": "string"
// }
"log_group_name": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The name of an existing log group that you want to associate with this metric filter.",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 512),
stringvalidator.RegexMatches(regexp.MustCompile("^[.\\-_/#A-Za-z0-9]{1,512}"), ""),
}, /*END VALIDATORS*/
PlanModifiers: []planmodifier.String{ /*START PLAN MODIFIERS*/
stringplanmodifier.RequiresReplace(),
}, /*END PLAN MODIFIERS*/
}, /*END ATTRIBUTE*/
// Property: MetricTransformations
// CloudFormation resource type schema:
//
// {
// "description": "The metric transformations.",
// "insertionOrder": false,
// "items": {
// "additionalProperties": false,
// "description": "``MetricTransformation`` is a property of the ``AWS::Logs::MetricFilter`` resource that describes how to transform log streams into a CloudWatch metric.",
// "properties": {
// "DefaultValue": {
// "description": "(Optional) The value to emit when a filter pattern does not match a log event. This value can be null.",
// "type": "number"
// },
// "Dimensions": {
// "description": "The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions.\n Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as ``IPAddress`` or ``requestID`` as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. \n CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified dimensions within a certain amount of time. This helps to prevent accidental high charges.\n You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see [Creating a Billing Alarm to Monitor Your Estimated Charges](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html).",
// "insertionOrder": false,
// "items": {
// "additionalProperties": false,
// "description": "Specifies the CW metric dimensions to publish with this metric.\n Because dimensions are part of the unique identifier for a metric, whenever a unique dimension name/value pair is extracted from your logs, you are creating a new variation of that metric.\n For more information about publishing dimensions with metrics created by metric filters, see [Publishing dimensions with metrics from values in JSON or space-delimited log events](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html#logs-metric-filters-dimensions).\n Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as ``IPAddress`` or ``requestID`` as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. \n To help prevent accidental high charges, Amazon disables a metric filter if it generates 1000 different name/value pairs for the dimensions that you have specified within a certain amount of time.\n You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see [Creating a Billing Alarm to Monitor Your Estimated Charges](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html).",
// "properties": {
// "Key": {
// "description": "The name for the CW metric dimension that the metric filter creates.\n Dimension names must contain only ASCII characters, must include at least one non-whitespace character, and cannot start with a colon (:).",
// "maxLength": 255,
// "minLength": 1,
// "type": "string"
// },
// "Value": {
// "description": "The log event field that will contain the value for this dimension. This dimension will only be published for a metric if the value is found in the log event. For example, ``$.eventType`` for JSON log events, or ``$server`` for space-delimited log events.",
// "maxLength": 255,
// "minLength": 1,
// "type": "string"
// }
// },
// "required": [
// "Key",
// "Value"
// ],
// "type": "object"
// },
// "maxItems": 3,
// "minItems": 1,
// "type": "array",
// "uniqueItems": true
// },
// "MetricName": {
// "description": "The name of the CloudWatch metric.",
// "maxLength": 255,
// "minLength": 1,
// "pattern": "",
// "type": "string"
// },
// "MetricNamespace": {
// "$comment": "Namespaces can be up to 256 characters long; valid characters include 0-9A-Za-z.-_/#",
// "description": "A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are similar. For more information, see [Namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace).",
// "maxLength": 256,
// "minLength": 1,
// "pattern": "^[0-9a-zA-Z\\.\\-_\\/#]{1,256}",
// "type": "string"
// },
// "MetricValue": {
// "description": "The value that is published to the CloudWatch metric. For example, if you're counting the occurrences of a particular term like ``Error``, specify 1 for the metric value. If you're counting the number of bytes transferred, reference the value that is in the log event by using $. followed by the name of the field that you specified in the filter pattern, such as ``$.size``.",
// "maxLength": 100,
// "minLength": 1,
// "pattern": ".{1,100}",
// "type": "string"
// },
// "Unit": {
// "description": "The unit to assign to the metric. If you omit this, the unit is set as ``None``.",
// "enum": [
// "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",
// "None"
// ],
// "type": "string"
// }
// },
// "required": [
// "MetricName",
// "MetricNamespace",
// "MetricValue"
// ],
// "type": "object"
// },
// "maxItems": 1,
// "minItems": 1,
// "type": "array"
// }
"metric_transformations": schema.ListNestedAttribute{ /*START ATTRIBUTE*/
NestedObject: schema.NestedAttributeObject{ /*START NESTED OBJECT*/
Attributes: map[string]schema.Attribute{ /*START SCHEMA*/
// Property: DefaultValue
"default_value": schema.Float64Attribute{ /*START ATTRIBUTE*/
Description: "(Optional) The value to emit when a filter pattern does not match a log event. This value can be null.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Float64{ /*START PLAN MODIFIERS*/
float64planmodifier.UseStateForUnknown(),
}, /*END PLAN MODIFIERS*/
}, /*END ATTRIBUTE*/
// Property: Dimensions
"dimensions": schema.SetNestedAttribute{ /*START ATTRIBUTE*/
NestedObject: schema.NestedAttributeObject{ /*START NESTED OBJECT*/
Attributes: map[string]schema.Attribute{ /*START SCHEMA*/
// Property: Key
"key": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The name for the CW metric dimension that the metric filter creates.\n Dimension names must contain only ASCII characters, must include at least one non-whitespace character, and cannot start with a colon (:).",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 255),
}, /*END VALIDATORS*/
}, /*END ATTRIBUTE*/
// Property: Value
"value": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The log event field that will contain the value for this dimension. This dimension will only be published for a metric if the value is found in the log event. For example, ``$.eventType`` for JSON log events, or ``$server`` for space-delimited log events.",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 255),
}, /*END VALIDATORS*/
}, /*END ATTRIBUTE*/
}, /*END SCHEMA*/
}, /*END NESTED OBJECT*/
Description: "The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions.\n Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as ``IPAddress`` or ``requestID`` as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. \n CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified dimensions within a certain amount of time. This helps to prevent accidental high charges.\n You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see [Creating a Billing Alarm to Monitor Your Estimated Charges](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html).",
Optional: true,
Computed: true,
Validators: []validator.Set{ /*START VALIDATORS*/
setvalidator.SizeBetween(1, 3),
}, /*END VALIDATORS*/
PlanModifiers: []planmodifier.Set{ /*START PLAN MODIFIERS*/
setplanmodifier.UseStateForUnknown(),
}, /*END PLAN MODIFIERS*/
}, /*END ATTRIBUTE*/
// Property: MetricName
"metric_name": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The name of the CloudWatch metric.",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 255),
}, /*END VALIDATORS*/
}, /*END ATTRIBUTE*/
// Property: MetricNamespace
"metric_namespace": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are similar. For more information, see [Namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace).",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 256),
stringvalidator.RegexMatches(regexp.MustCompile("^[0-9a-zA-Z\\.\\-_\\/#]{1,256}"), ""),
}, /*END VALIDATORS*/
}, /*END ATTRIBUTE*/
// Property: MetricValue
"metric_value": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The value that is published to the CloudWatch metric. For example, if you're counting the occurrences of a particular term like ``Error``, specify 1 for the metric value. If you're counting the number of bytes transferred, reference the value that is in the log event by using $. followed by the name of the field that you specified in the filter pattern, such as ``$.size``.",
Required: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.LengthBetween(1, 100),
stringvalidator.RegexMatches(regexp.MustCompile(".{1,100}"), ""),
}, /*END VALIDATORS*/
}, /*END ATTRIBUTE*/
// Property: Unit
"unit": schema.StringAttribute{ /*START ATTRIBUTE*/
Description: "The unit to assign to the metric. If you omit this, the unit is set as ``None``.",
Optional: true,
Computed: true,
Validators: []validator.String{ /*START VALIDATORS*/
stringvalidator.OneOf(
"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",
"None",
),
}, /*END VALIDATORS*/
PlanModifiers: []planmodifier.String{ /*START PLAN MODIFIERS*/
stringplanmodifier.UseStateForUnknown(),
}, /*END PLAN MODIFIERS*/
}, /*END ATTRIBUTE*/
}, /*END SCHEMA*/
}, /*END NESTED OBJECT*/
Description: "The metric transformations.",
Required: true,
Validators: []validator.List{ /*START VALIDATORS*/
listvalidator.SizeBetween(1, 1),
}, /*END VALIDATORS*/
PlanModifiers: []planmodifier.List{ /*START PLAN MODIFIERS*/
generic.Multiset(),
}, /*END PLAN MODIFIERS*/
}, /*END ATTRIBUTE*/
} /*END SCHEMA*/
// Corresponds to CloudFormation primaryIdentifier.
attributes["id"] = schema.StringAttribute{
Description: "Uniquely identifies the resource.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
}
schema := schema.Schema{
Description: "The ``AWS::Logs::MetricFilter`` resource specifies a metric filter that describes how CWL extracts information from logs and transforms it into Amazon CloudWatch metrics. If you have multiple metric filters that are associated with a log group, all the filters are applied to the log streams in that group.\n The maximum number of metric filters that can be associated with a log group is 100.",
Version: 1,
Attributes: attributes,
}
var opts generic.ResourceOptions
opts = opts.WithCloudFormationTypeName("AWS::Logs::MetricFilter").WithTerraformTypeName("awscc_logs_metric_filter")
opts = opts.WithTerraformSchema(schema)
opts = opts.WithAttributeNameMap(map[string]string{
"default_value": "DefaultValue",
"dimensions": "Dimensions",
"filter_name": "FilterName",
"filter_pattern": "FilterPattern",
"key": "Key",
"log_group_name": "LogGroupName",
"metric_name": "MetricName",
"metric_namespace": "MetricNamespace",
"metric_transformations": "MetricTransformations",
"metric_value": "MetricValue",
"unit": "Unit",
"value": "Value",
})
opts = opts.WithCreateTimeoutInMinutes(0).WithDeleteTimeoutInMinutes(0)
opts = opts.WithUpdateTimeoutInMinutes(0)
v, err := generic.NewResource(ctx, opts...)
if err != nil {
return nil, err
}
return v, nil
}