/
detector.go
357 lines (304 loc) · 18.5 KB
/
detector.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
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package guardduty
import (
"context"
"reflect"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a resource to manage an Amazon GuardDuty detector.
//
// > **NOTE:** Deleting this resource is equivalent to "disabling" GuardDuty for an AWS region, which removes all existing findings. You can set the `enable` attribute to `false` to instead "suspend" monitoring and feedback reporting while keeping existing data. See the [Suspending or Disabling Amazon GuardDuty documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_suspend-disable.html) for more information.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/guardduty"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := guardduty.NewDetector(ctx, "MyDetector", &guardduty.DetectorArgs{
// Enable: pulumi.Bool(true),
// Datasources: &guardduty.DetectorDatasourcesArgs{
// S3Logs: &guardduty.DetectorDatasourcesS3LogsArgs{
// Enable: pulumi.Bool(true),
// },
// Kubernetes: &guardduty.DetectorDatasourcesKubernetesArgs{
// AuditLogs: &guardduty.DetectorDatasourcesKubernetesAuditLogsArgs{
// Enable: pulumi.Bool(false),
// },
// },
// MalwareProtection: &guardduty.DetectorDatasourcesMalwareProtectionArgs{
// ScanEc2InstanceWithFindings: &guardduty.DetectorDatasourcesMalwareProtectionScanEc2InstanceWithFindingsArgs{
// EbsVolumes: &guardduty.DetectorDatasourcesMalwareProtectionScanEc2InstanceWithFindingsEbsVolumesArgs{
// Enable: pulumi.Bool(true),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import GuardDuty detectors using the detector ID. For example:
//
// ```sh
// $ pulumi import aws:guardduty/detector:Detector MyDetector 00b00fd5aecc0ab60a708659477e9617
// ```
// The ID of the detector can be retrieved via the [AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/guardduty/list-detectors.html) using `aws guardduty list-detectors`.
type Detector struct {
pulumi.CustomResourceState
// The AWS account ID of the GuardDuty detector
AccountId pulumi.StringOutput `pulumi:"accountId"`
// Amazon Resource Name (ARN) of the GuardDuty detector
Arn pulumi.StringOutput `pulumi:"arn"`
// Describes which data sources will be enabled for the detector. See Data Sources below for more details. [Deprecated](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty-feature-object-api-changes-march2023.html) in favor of `guardduty.DetectorFeature` resources.
Datasources DetectorDatasourcesOutput `pulumi:"datasources"`
// Enable monitoring and feedback reporting. Setting to `false` is equivalent to "suspending" GuardDuty. Defaults to `true`.
Enable pulumi.BoolPtrOutput `pulumi:"enable"`
// Specifies the frequency of notifications sent for subsequent finding occurrences. If the detector is a GuardDuty member account, the value is determined by the GuardDuty primary account and cannot be modified, otherwise defaults to `SIX_HOURS`. For standalone and GuardDuty primary accounts, it must be configured in this provider to enable drift detection. Valid values for standalone and primary accounts: `FIFTEEN_MINUTES`, `ONE_HOUR`, `SIX_HOURS`. See [AWS Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings_cloudwatch.html#guardduty_findings_cloudwatch_notification_frequency) for more information.
FindingPublishingFrequency pulumi.StringOutput `pulumi:"findingPublishingFrequency"`
// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
}
// NewDetector registers a new resource with the given unique name, arguments, and options.
func NewDetector(ctx *pulumi.Context,
name string, args *DetectorArgs, opts ...pulumi.ResourceOption) (*Detector, error) {
if args == nil {
args = &DetectorArgs{}
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Detector
err := ctx.RegisterResource("aws:guardduty/detector:Detector", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDetector gets an existing Detector resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetDetector(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DetectorState, opts ...pulumi.ResourceOption) (*Detector, error) {
var resource Detector
err := ctx.ReadResource("aws:guardduty/detector:Detector", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Detector resources.
type detectorState struct {
// The AWS account ID of the GuardDuty detector
AccountId *string `pulumi:"accountId"`
// Amazon Resource Name (ARN) of the GuardDuty detector
Arn *string `pulumi:"arn"`
// Describes which data sources will be enabled for the detector. See Data Sources below for more details. [Deprecated](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty-feature-object-api-changes-march2023.html) in favor of `guardduty.DetectorFeature` resources.
Datasources *DetectorDatasources `pulumi:"datasources"`
// Enable monitoring and feedback reporting. Setting to `false` is equivalent to "suspending" GuardDuty. Defaults to `true`.
Enable *bool `pulumi:"enable"`
// Specifies the frequency of notifications sent for subsequent finding occurrences. If the detector is a GuardDuty member account, the value is determined by the GuardDuty primary account and cannot be modified, otherwise defaults to `SIX_HOURS`. For standalone and GuardDuty primary accounts, it must be configured in this provider to enable drift detection. Valid values for standalone and primary accounts: `FIFTEEN_MINUTES`, `ONE_HOUR`, `SIX_HOURS`. See [AWS Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings_cloudwatch.html#guardduty_findings_cloudwatch_notification_frequency) for more information.
FindingPublishingFrequency *string `pulumi:"findingPublishingFrequency"`
// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll map[string]string `pulumi:"tagsAll"`
}
type DetectorState struct {
// The AWS account ID of the GuardDuty detector
AccountId pulumi.StringPtrInput
// Amazon Resource Name (ARN) of the GuardDuty detector
Arn pulumi.StringPtrInput
// Describes which data sources will be enabled for the detector. See Data Sources below for more details. [Deprecated](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty-feature-object-api-changes-march2023.html) in favor of `guardduty.DetectorFeature` resources.
Datasources DetectorDatasourcesPtrInput
// Enable monitoring and feedback reporting. Setting to `false` is equivalent to "suspending" GuardDuty. Defaults to `true`.
Enable pulumi.BoolPtrInput
// Specifies the frequency of notifications sent for subsequent finding occurrences. If the detector is a GuardDuty member account, the value is determined by the GuardDuty primary account and cannot be modified, otherwise defaults to `SIX_HOURS`. For standalone and GuardDuty primary accounts, it must be configured in this provider to enable drift detection. Valid values for standalone and primary accounts: `FIFTEEN_MINUTES`, `ONE_HOUR`, `SIX_HOURS`. See [AWS Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings_cloudwatch.html#guardduty_findings_cloudwatch_notification_frequency) for more information.
FindingPublishingFrequency pulumi.StringPtrInput
// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll pulumi.StringMapInput
}
func (DetectorState) ElementType() reflect.Type {
return reflect.TypeOf((*detectorState)(nil)).Elem()
}
type detectorArgs struct {
// Describes which data sources will be enabled for the detector. See Data Sources below for more details. [Deprecated](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty-feature-object-api-changes-march2023.html) in favor of `guardduty.DetectorFeature` resources.
Datasources *DetectorDatasources `pulumi:"datasources"`
// Enable monitoring and feedback reporting. Setting to `false` is equivalent to "suspending" GuardDuty. Defaults to `true`.
Enable *bool `pulumi:"enable"`
// Specifies the frequency of notifications sent for subsequent finding occurrences. If the detector is a GuardDuty member account, the value is determined by the GuardDuty primary account and cannot be modified, otherwise defaults to `SIX_HOURS`. For standalone and GuardDuty primary accounts, it must be configured in this provider to enable drift detection. Valid values for standalone and primary accounts: `FIFTEEN_MINUTES`, `ONE_HOUR`, `SIX_HOURS`. See [AWS Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings_cloudwatch.html#guardduty_findings_cloudwatch_notification_frequency) for more information.
FindingPublishingFrequency *string `pulumi:"findingPublishingFrequency"`
// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a Detector resource.
type DetectorArgs struct {
// Describes which data sources will be enabled for the detector. See Data Sources below for more details. [Deprecated](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty-feature-object-api-changes-march2023.html) in favor of `guardduty.DetectorFeature` resources.
Datasources DetectorDatasourcesPtrInput
// Enable monitoring and feedback reporting. Setting to `false` is equivalent to "suspending" GuardDuty. Defaults to `true`.
Enable pulumi.BoolPtrInput
// Specifies the frequency of notifications sent for subsequent finding occurrences. If the detector is a GuardDuty member account, the value is determined by the GuardDuty primary account and cannot be modified, otherwise defaults to `SIX_HOURS`. For standalone and GuardDuty primary accounts, it must be configured in this provider to enable drift detection. Valid values for standalone and primary accounts: `FIFTEEN_MINUTES`, `ONE_HOUR`, `SIX_HOURS`. See [AWS Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings_cloudwatch.html#guardduty_findings_cloudwatch_notification_frequency) for more information.
FindingPublishingFrequency pulumi.StringPtrInput
// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
}
func (DetectorArgs) ElementType() reflect.Type {
return reflect.TypeOf((*detectorArgs)(nil)).Elem()
}
type DetectorInput interface {
pulumi.Input
ToDetectorOutput() DetectorOutput
ToDetectorOutputWithContext(ctx context.Context) DetectorOutput
}
func (*Detector) ElementType() reflect.Type {
return reflect.TypeOf((**Detector)(nil)).Elem()
}
func (i *Detector) ToDetectorOutput() DetectorOutput {
return i.ToDetectorOutputWithContext(context.Background())
}
func (i *Detector) ToDetectorOutputWithContext(ctx context.Context) DetectorOutput {
return pulumi.ToOutputWithContext(ctx, i).(DetectorOutput)
}
// DetectorArrayInput is an input type that accepts DetectorArray and DetectorArrayOutput values.
// You can construct a concrete instance of `DetectorArrayInput` via:
//
// DetectorArray{ DetectorArgs{...} }
type DetectorArrayInput interface {
pulumi.Input
ToDetectorArrayOutput() DetectorArrayOutput
ToDetectorArrayOutputWithContext(context.Context) DetectorArrayOutput
}
type DetectorArray []DetectorInput
func (DetectorArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Detector)(nil)).Elem()
}
func (i DetectorArray) ToDetectorArrayOutput() DetectorArrayOutput {
return i.ToDetectorArrayOutputWithContext(context.Background())
}
func (i DetectorArray) ToDetectorArrayOutputWithContext(ctx context.Context) DetectorArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(DetectorArrayOutput)
}
// DetectorMapInput is an input type that accepts DetectorMap and DetectorMapOutput values.
// You can construct a concrete instance of `DetectorMapInput` via:
//
// DetectorMap{ "key": DetectorArgs{...} }
type DetectorMapInput interface {
pulumi.Input
ToDetectorMapOutput() DetectorMapOutput
ToDetectorMapOutputWithContext(context.Context) DetectorMapOutput
}
type DetectorMap map[string]DetectorInput
func (DetectorMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Detector)(nil)).Elem()
}
func (i DetectorMap) ToDetectorMapOutput() DetectorMapOutput {
return i.ToDetectorMapOutputWithContext(context.Background())
}
func (i DetectorMap) ToDetectorMapOutputWithContext(ctx context.Context) DetectorMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(DetectorMapOutput)
}
type DetectorOutput struct{ *pulumi.OutputState }
func (DetectorOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Detector)(nil)).Elem()
}
func (o DetectorOutput) ToDetectorOutput() DetectorOutput {
return o
}
func (o DetectorOutput) ToDetectorOutputWithContext(ctx context.Context) DetectorOutput {
return o
}
// The AWS account ID of the GuardDuty detector
func (o DetectorOutput) AccountId() pulumi.StringOutput {
return o.ApplyT(func(v *Detector) pulumi.StringOutput { return v.AccountId }).(pulumi.StringOutput)
}
// Amazon Resource Name (ARN) of the GuardDuty detector
func (o DetectorOutput) Arn() pulumi.StringOutput {
return o.ApplyT(func(v *Detector) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
}
// Describes which data sources will be enabled for the detector. See Data Sources below for more details. [Deprecated](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty-feature-object-api-changes-march2023.html) in favor of `guardduty.DetectorFeature` resources.
func (o DetectorOutput) Datasources() DetectorDatasourcesOutput {
return o.ApplyT(func(v *Detector) DetectorDatasourcesOutput { return v.Datasources }).(DetectorDatasourcesOutput)
}
// Enable monitoring and feedback reporting. Setting to `false` is equivalent to "suspending" GuardDuty. Defaults to `true`.
func (o DetectorOutput) Enable() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Detector) pulumi.BoolPtrOutput { return v.Enable }).(pulumi.BoolPtrOutput)
}
// Specifies the frequency of notifications sent for subsequent finding occurrences. If the detector is a GuardDuty member account, the value is determined by the GuardDuty primary account and cannot be modified, otherwise defaults to `SIX_HOURS`. For standalone and GuardDuty primary accounts, it must be configured in this provider to enable drift detection. Valid values for standalone and primary accounts: `FIFTEEN_MINUTES`, `ONE_HOUR`, `SIX_HOURS`. See [AWS Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings_cloudwatch.html#guardduty_findings_cloudwatch_notification_frequency) for more information.
func (o DetectorOutput) FindingPublishingFrequency() pulumi.StringOutput {
return o.ApplyT(func(v *Detector) pulumi.StringOutput { return v.FindingPublishingFrequency }).(pulumi.StringOutput)
}
// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
func (o DetectorOutput) Tags() pulumi.StringMapOutput {
return o.ApplyT(func(v *Detector) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
}
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
func (o DetectorOutput) TagsAll() pulumi.StringMapOutput {
return o.ApplyT(func(v *Detector) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
}
type DetectorArrayOutput struct{ *pulumi.OutputState }
func (DetectorArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Detector)(nil)).Elem()
}
func (o DetectorArrayOutput) ToDetectorArrayOutput() DetectorArrayOutput {
return o
}
func (o DetectorArrayOutput) ToDetectorArrayOutputWithContext(ctx context.Context) DetectorArrayOutput {
return o
}
func (o DetectorArrayOutput) Index(i pulumi.IntInput) DetectorOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Detector {
return vs[0].([]*Detector)[vs[1].(int)]
}).(DetectorOutput)
}
type DetectorMapOutput struct{ *pulumi.OutputState }
func (DetectorMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Detector)(nil)).Elem()
}
func (o DetectorMapOutput) ToDetectorMapOutput() DetectorMapOutput {
return o
}
func (o DetectorMapOutput) ToDetectorMapOutputWithContext(ctx context.Context) DetectorMapOutput {
return o
}
func (o DetectorMapOutput) MapIndex(k pulumi.StringInput) DetectorOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Detector {
return vs[0].(map[string]*Detector)[vs[1].(string)]
}).(DetectorOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*DetectorInput)(nil)).Elem(), &Detector{})
pulumi.RegisterInputType(reflect.TypeOf((*DetectorArrayInput)(nil)).Elem(), DetectorArray{})
pulumi.RegisterInputType(reflect.TypeOf((*DetectorMapInput)(nil)).Elem(), DetectorMap{})
pulumi.RegisterOutputType(DetectorOutput{})
pulumi.RegisterOutputType(DetectorArrayOutput{})
pulumi.RegisterOutputType(DetectorMapOutput{})
}