github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/guardduty/publishingDestination.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package guardduty 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a resource to manage a GuardDuty PublishingDestination. Requires an existing GuardDuty Detector. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "fmt" 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/guardduty" 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 30 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms" 31 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3" 32 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 33 // 34 // ) 35 // 36 // func main() { 37 // pulumi.Run(func(ctx *pulumi.Context) error { 38 // current, err := aws.GetCallerIdentity(ctx, nil, nil) 39 // if err != nil { 40 // return err 41 // } 42 // currentGetRegion, err := aws.GetRegion(ctx, nil, nil) 43 // if err != nil { 44 // return err 45 // } 46 // gdBucket, err := s3.NewBucketV2(ctx, "gd_bucket", &s3.BucketV2Args{ 47 // Bucket: pulumi.String("example"), 48 // ForceDestroy: pulumi.Bool(true), 49 // }) 50 // if err != nil { 51 // return err 52 // } 53 // bucketPol := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{ 54 // Statements: iam.GetPolicyDocumentStatementArray{ 55 // &iam.GetPolicyDocumentStatementArgs{ 56 // Sid: pulumi.String("Allow PutObject"), 57 // Actions: pulumi.StringArray{ 58 // pulumi.String("s3:PutObject"), 59 // }, 60 // Resources: pulumi.StringArray{ 61 // gdBucket.Arn.ApplyT(func(arn string) (string, error) { 62 // return fmt.Sprintf("%v/*", arn), nil 63 // }).(pulumi.StringOutput), 64 // }, 65 // Principals: iam.GetPolicyDocumentStatementPrincipalArray{ 66 // &iam.GetPolicyDocumentStatementPrincipalArgs{ 67 // Type: pulumi.String("Service"), 68 // Identifiers: pulumi.StringArray{ 69 // pulumi.String("guardduty.amazonaws.com"), 70 // }, 71 // }, 72 // }, 73 // }, 74 // &iam.GetPolicyDocumentStatementArgs{ 75 // Sid: pulumi.String("Allow GetBucketLocation"), 76 // Actions: pulumi.StringArray{ 77 // pulumi.String("s3:GetBucketLocation"), 78 // }, 79 // Resources: pulumi.StringArray{ 80 // gdBucket.Arn, 81 // }, 82 // Principals: iam.GetPolicyDocumentStatementPrincipalArray{ 83 // &iam.GetPolicyDocumentStatementPrincipalArgs{ 84 // Type: pulumi.String("Service"), 85 // Identifiers: pulumi.StringArray{ 86 // pulumi.String("guardduty.amazonaws.com"), 87 // }, 88 // }, 89 // }, 90 // }, 91 // }, 92 // }, nil) 93 // kmsPol, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 94 // Statements: []iam.GetPolicyDocumentStatement{ 95 // { 96 // Sid: pulumi.StringRef("Allow GuardDuty to encrypt findings"), 97 // Actions: []string{ 98 // "kms:GenerateDataKey", 99 // }, 100 // Resources: []string{ 101 // fmt.Sprintf("arn:aws:kms:%v:%v:key/*", currentGetRegion.Name, current.AccountId), 102 // }, 103 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 104 // { 105 // Type: "Service", 106 // Identifiers: []string{ 107 // "guardduty.amazonaws.com", 108 // }, 109 // }, 110 // }, 111 // }, 112 // { 113 // Sid: pulumi.StringRef("Allow all users to modify/delete key (test only)"), 114 // Actions: []string{ 115 // "kms:*", 116 // }, 117 // Resources: []string{ 118 // fmt.Sprintf("arn:aws:kms:%v:%v:key/*", currentGetRegion.Name, current.AccountId), 119 // }, 120 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 121 // { 122 // Type: "AWS", 123 // Identifiers: []string{ 124 // fmt.Sprintf("arn:aws:iam::%v:root", current.AccountId), 125 // }, 126 // }, 127 // }, 128 // }, 129 // }, 130 // }, nil) 131 // if err != nil { 132 // return err 133 // } 134 // testGd, err := guardduty.NewDetector(ctx, "test_gd", &guardduty.DetectorArgs{ 135 // Enable: pulumi.Bool(true), 136 // }) 137 // if err != nil { 138 // return err 139 // } 140 // _, err = s3.NewBucketAclV2(ctx, "gd_bucket_acl", &s3.BucketAclV2Args{ 141 // Bucket: gdBucket.ID(), 142 // Acl: pulumi.String("private"), 143 // }) 144 // if err != nil { 145 // return err 146 // } 147 // gdBucketPolicy, err := s3.NewBucketPolicy(ctx, "gd_bucket_policy", &s3.BucketPolicyArgs{ 148 // Bucket: gdBucket.ID(), 149 // Policy: bucketPol.ApplyT(func(bucketPol iam.GetPolicyDocumentResult) (*string, error) { 150 // return &bucketPol.Json, nil 151 // }).(pulumi.StringPtrOutput), 152 // }) 153 // if err != nil { 154 // return err 155 // } 156 // gdKey, err := kms.NewKey(ctx, "gd_key", &kms.KeyArgs{ 157 // Description: pulumi.String("Temporary key for AccTest of TF"), 158 // DeletionWindowInDays: pulumi.Int(7), 159 // Policy: pulumi.String(kmsPol.Json), 160 // }) 161 // if err != nil { 162 // return err 163 // } 164 // _, err = guardduty.NewPublishingDestination(ctx, "test", &guardduty.PublishingDestinationArgs{ 165 // DetectorId: testGd.ID(), 166 // DestinationArn: gdBucket.Arn, 167 // KmsKeyArn: gdKey.Arn, 168 // }, pulumi.DependsOn([]pulumi.Resource{ 169 // gdBucketPolicy, 170 // })) 171 // if err != nil { 172 // return err 173 // } 174 // return nil 175 // }) 176 // } 177 // 178 // ``` 179 // <!--End PulumiCodeChooser --> 180 // 181 // > **Note:** Please do not use this simple example for Bucket-Policy and KMS Key Policy in a production environment. It is much too open for such a use-case. Refer to the AWS documentation here: https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_exportfindings.html 182 // 183 // ## Import 184 // 185 // Using `pulumi import`, import GuardDuty PublishingDestination using the master GuardDuty detector ID and PublishingDestinationID. For example: 186 // 187 // ```sh 188 // $ pulumi import aws:guardduty/publishingDestination:PublishingDestination test a4b86f26fa42e7e7cf0d1c333ea77777:a4b86f27a0e464e4a7e0516d242f1234 189 // ``` 190 type PublishingDestination struct { 191 pulumi.CustomResourceState 192 193 // The bucket arn and prefix under which the findings get exported. Bucket-ARN is required, the prefix is optional and will be `AWSLogs/[Account-ID]/GuardDuty/[Region]/` if not provided 194 DestinationArn pulumi.StringOutput `pulumi:"destinationArn"` 195 // Currently there is only "S3" available as destination type which is also the default value 196 // 197 // > **Note:** In case of missing permissions (S3 Bucket Policy _or_ KMS Key permissions) the resource will fail to create. If the permissions are changed after resource creation, this can be asked from the AWS API via the "DescribePublishingDestination" call (https://docs.aws.amazon.com/cli/latest/reference/guardduty/describe-publishing-destination.html). 198 DestinationType pulumi.StringPtrOutput `pulumi:"destinationType"` 199 // The detector ID of the GuardDuty. 200 DetectorId pulumi.StringOutput `pulumi:"detectorId"` 201 // The ARN of the KMS key used to encrypt GuardDuty findings. GuardDuty enforces this to be encrypted. 202 KmsKeyArn pulumi.StringOutput `pulumi:"kmsKeyArn"` 203 } 204 205 // NewPublishingDestination registers a new resource with the given unique name, arguments, and options. 206 func NewPublishingDestination(ctx *pulumi.Context, 207 name string, args *PublishingDestinationArgs, opts ...pulumi.ResourceOption) (*PublishingDestination, error) { 208 if args == nil { 209 return nil, errors.New("missing one or more required arguments") 210 } 211 212 if args.DestinationArn == nil { 213 return nil, errors.New("invalid value for required argument 'DestinationArn'") 214 } 215 if args.DetectorId == nil { 216 return nil, errors.New("invalid value for required argument 'DetectorId'") 217 } 218 if args.KmsKeyArn == nil { 219 return nil, errors.New("invalid value for required argument 'KmsKeyArn'") 220 } 221 opts = internal.PkgResourceDefaultOpts(opts) 222 var resource PublishingDestination 223 err := ctx.RegisterResource("aws:guardduty/publishingDestination:PublishingDestination", name, args, &resource, opts...) 224 if err != nil { 225 return nil, err 226 } 227 return &resource, nil 228 } 229 230 // GetPublishingDestination gets an existing PublishingDestination resource's state with the given name, ID, and optional 231 // state properties that are used to uniquely qualify the lookup (nil if not required). 232 func GetPublishingDestination(ctx *pulumi.Context, 233 name string, id pulumi.IDInput, state *PublishingDestinationState, opts ...pulumi.ResourceOption) (*PublishingDestination, error) { 234 var resource PublishingDestination 235 err := ctx.ReadResource("aws:guardduty/publishingDestination:PublishingDestination", name, id, state, &resource, opts...) 236 if err != nil { 237 return nil, err 238 } 239 return &resource, nil 240 } 241 242 // Input properties used for looking up and filtering PublishingDestination resources. 243 type publishingDestinationState struct { 244 // The bucket arn and prefix under which the findings get exported. Bucket-ARN is required, the prefix is optional and will be `AWSLogs/[Account-ID]/GuardDuty/[Region]/` if not provided 245 DestinationArn *string `pulumi:"destinationArn"` 246 // Currently there is only "S3" available as destination type which is also the default value 247 // 248 // > **Note:** In case of missing permissions (S3 Bucket Policy _or_ KMS Key permissions) the resource will fail to create. If the permissions are changed after resource creation, this can be asked from the AWS API via the "DescribePublishingDestination" call (https://docs.aws.amazon.com/cli/latest/reference/guardduty/describe-publishing-destination.html). 249 DestinationType *string `pulumi:"destinationType"` 250 // The detector ID of the GuardDuty. 251 DetectorId *string `pulumi:"detectorId"` 252 // The ARN of the KMS key used to encrypt GuardDuty findings. GuardDuty enforces this to be encrypted. 253 KmsKeyArn *string `pulumi:"kmsKeyArn"` 254 } 255 256 type PublishingDestinationState struct { 257 // The bucket arn and prefix under which the findings get exported. Bucket-ARN is required, the prefix is optional and will be `AWSLogs/[Account-ID]/GuardDuty/[Region]/` if not provided 258 DestinationArn pulumi.StringPtrInput 259 // Currently there is only "S3" available as destination type which is also the default value 260 // 261 // > **Note:** In case of missing permissions (S3 Bucket Policy _or_ KMS Key permissions) the resource will fail to create. If the permissions are changed after resource creation, this can be asked from the AWS API via the "DescribePublishingDestination" call (https://docs.aws.amazon.com/cli/latest/reference/guardduty/describe-publishing-destination.html). 262 DestinationType pulumi.StringPtrInput 263 // The detector ID of the GuardDuty. 264 DetectorId pulumi.StringPtrInput 265 // The ARN of the KMS key used to encrypt GuardDuty findings. GuardDuty enforces this to be encrypted. 266 KmsKeyArn pulumi.StringPtrInput 267 } 268 269 func (PublishingDestinationState) ElementType() reflect.Type { 270 return reflect.TypeOf((*publishingDestinationState)(nil)).Elem() 271 } 272 273 type publishingDestinationArgs struct { 274 // The bucket arn and prefix under which the findings get exported. Bucket-ARN is required, the prefix is optional and will be `AWSLogs/[Account-ID]/GuardDuty/[Region]/` if not provided 275 DestinationArn string `pulumi:"destinationArn"` 276 // Currently there is only "S3" available as destination type which is also the default value 277 // 278 // > **Note:** In case of missing permissions (S3 Bucket Policy _or_ KMS Key permissions) the resource will fail to create. If the permissions are changed after resource creation, this can be asked from the AWS API via the "DescribePublishingDestination" call (https://docs.aws.amazon.com/cli/latest/reference/guardduty/describe-publishing-destination.html). 279 DestinationType *string `pulumi:"destinationType"` 280 // The detector ID of the GuardDuty. 281 DetectorId string `pulumi:"detectorId"` 282 // The ARN of the KMS key used to encrypt GuardDuty findings. GuardDuty enforces this to be encrypted. 283 KmsKeyArn string `pulumi:"kmsKeyArn"` 284 } 285 286 // The set of arguments for constructing a PublishingDestination resource. 287 type PublishingDestinationArgs struct { 288 // The bucket arn and prefix under which the findings get exported. Bucket-ARN is required, the prefix is optional and will be `AWSLogs/[Account-ID]/GuardDuty/[Region]/` if not provided 289 DestinationArn pulumi.StringInput 290 // Currently there is only "S3" available as destination type which is also the default value 291 // 292 // > **Note:** In case of missing permissions (S3 Bucket Policy _or_ KMS Key permissions) the resource will fail to create. If the permissions are changed after resource creation, this can be asked from the AWS API via the "DescribePublishingDestination" call (https://docs.aws.amazon.com/cli/latest/reference/guardduty/describe-publishing-destination.html). 293 DestinationType pulumi.StringPtrInput 294 // The detector ID of the GuardDuty. 295 DetectorId pulumi.StringInput 296 // The ARN of the KMS key used to encrypt GuardDuty findings. GuardDuty enforces this to be encrypted. 297 KmsKeyArn pulumi.StringInput 298 } 299 300 func (PublishingDestinationArgs) ElementType() reflect.Type { 301 return reflect.TypeOf((*publishingDestinationArgs)(nil)).Elem() 302 } 303 304 type PublishingDestinationInput interface { 305 pulumi.Input 306 307 ToPublishingDestinationOutput() PublishingDestinationOutput 308 ToPublishingDestinationOutputWithContext(ctx context.Context) PublishingDestinationOutput 309 } 310 311 func (*PublishingDestination) ElementType() reflect.Type { 312 return reflect.TypeOf((**PublishingDestination)(nil)).Elem() 313 } 314 315 func (i *PublishingDestination) ToPublishingDestinationOutput() PublishingDestinationOutput { 316 return i.ToPublishingDestinationOutputWithContext(context.Background()) 317 } 318 319 func (i *PublishingDestination) ToPublishingDestinationOutputWithContext(ctx context.Context) PublishingDestinationOutput { 320 return pulumi.ToOutputWithContext(ctx, i).(PublishingDestinationOutput) 321 } 322 323 // PublishingDestinationArrayInput is an input type that accepts PublishingDestinationArray and PublishingDestinationArrayOutput values. 324 // You can construct a concrete instance of `PublishingDestinationArrayInput` via: 325 // 326 // PublishingDestinationArray{ PublishingDestinationArgs{...} } 327 type PublishingDestinationArrayInput interface { 328 pulumi.Input 329 330 ToPublishingDestinationArrayOutput() PublishingDestinationArrayOutput 331 ToPublishingDestinationArrayOutputWithContext(context.Context) PublishingDestinationArrayOutput 332 } 333 334 type PublishingDestinationArray []PublishingDestinationInput 335 336 func (PublishingDestinationArray) ElementType() reflect.Type { 337 return reflect.TypeOf((*[]*PublishingDestination)(nil)).Elem() 338 } 339 340 func (i PublishingDestinationArray) ToPublishingDestinationArrayOutput() PublishingDestinationArrayOutput { 341 return i.ToPublishingDestinationArrayOutputWithContext(context.Background()) 342 } 343 344 func (i PublishingDestinationArray) ToPublishingDestinationArrayOutputWithContext(ctx context.Context) PublishingDestinationArrayOutput { 345 return pulumi.ToOutputWithContext(ctx, i).(PublishingDestinationArrayOutput) 346 } 347 348 // PublishingDestinationMapInput is an input type that accepts PublishingDestinationMap and PublishingDestinationMapOutput values. 349 // You can construct a concrete instance of `PublishingDestinationMapInput` via: 350 // 351 // PublishingDestinationMap{ "key": PublishingDestinationArgs{...} } 352 type PublishingDestinationMapInput interface { 353 pulumi.Input 354 355 ToPublishingDestinationMapOutput() PublishingDestinationMapOutput 356 ToPublishingDestinationMapOutputWithContext(context.Context) PublishingDestinationMapOutput 357 } 358 359 type PublishingDestinationMap map[string]PublishingDestinationInput 360 361 func (PublishingDestinationMap) ElementType() reflect.Type { 362 return reflect.TypeOf((*map[string]*PublishingDestination)(nil)).Elem() 363 } 364 365 func (i PublishingDestinationMap) ToPublishingDestinationMapOutput() PublishingDestinationMapOutput { 366 return i.ToPublishingDestinationMapOutputWithContext(context.Background()) 367 } 368 369 func (i PublishingDestinationMap) ToPublishingDestinationMapOutputWithContext(ctx context.Context) PublishingDestinationMapOutput { 370 return pulumi.ToOutputWithContext(ctx, i).(PublishingDestinationMapOutput) 371 } 372 373 type PublishingDestinationOutput struct{ *pulumi.OutputState } 374 375 func (PublishingDestinationOutput) ElementType() reflect.Type { 376 return reflect.TypeOf((**PublishingDestination)(nil)).Elem() 377 } 378 379 func (o PublishingDestinationOutput) ToPublishingDestinationOutput() PublishingDestinationOutput { 380 return o 381 } 382 383 func (o PublishingDestinationOutput) ToPublishingDestinationOutputWithContext(ctx context.Context) PublishingDestinationOutput { 384 return o 385 } 386 387 // The bucket arn and prefix under which the findings get exported. Bucket-ARN is required, the prefix is optional and will be `AWSLogs/[Account-ID]/GuardDuty/[Region]/` if not provided 388 func (o PublishingDestinationOutput) DestinationArn() pulumi.StringOutput { 389 return o.ApplyT(func(v *PublishingDestination) pulumi.StringOutput { return v.DestinationArn }).(pulumi.StringOutput) 390 } 391 392 // Currently there is only "S3" available as destination type which is also the default value 393 // 394 // > **Note:** In case of missing permissions (S3 Bucket Policy _or_ KMS Key permissions) the resource will fail to create. If the permissions are changed after resource creation, this can be asked from the AWS API via the "DescribePublishingDestination" call (https://docs.aws.amazon.com/cli/latest/reference/guardduty/describe-publishing-destination.html). 395 func (o PublishingDestinationOutput) DestinationType() pulumi.StringPtrOutput { 396 return o.ApplyT(func(v *PublishingDestination) pulumi.StringPtrOutput { return v.DestinationType }).(pulumi.StringPtrOutput) 397 } 398 399 // The detector ID of the GuardDuty. 400 func (o PublishingDestinationOutput) DetectorId() pulumi.StringOutput { 401 return o.ApplyT(func(v *PublishingDestination) pulumi.StringOutput { return v.DetectorId }).(pulumi.StringOutput) 402 } 403 404 // The ARN of the KMS key used to encrypt GuardDuty findings. GuardDuty enforces this to be encrypted. 405 func (o PublishingDestinationOutput) KmsKeyArn() pulumi.StringOutput { 406 return o.ApplyT(func(v *PublishingDestination) pulumi.StringOutput { return v.KmsKeyArn }).(pulumi.StringOutput) 407 } 408 409 type PublishingDestinationArrayOutput struct{ *pulumi.OutputState } 410 411 func (PublishingDestinationArrayOutput) ElementType() reflect.Type { 412 return reflect.TypeOf((*[]*PublishingDestination)(nil)).Elem() 413 } 414 415 func (o PublishingDestinationArrayOutput) ToPublishingDestinationArrayOutput() PublishingDestinationArrayOutput { 416 return o 417 } 418 419 func (o PublishingDestinationArrayOutput) ToPublishingDestinationArrayOutputWithContext(ctx context.Context) PublishingDestinationArrayOutput { 420 return o 421 } 422 423 func (o PublishingDestinationArrayOutput) Index(i pulumi.IntInput) PublishingDestinationOutput { 424 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PublishingDestination { 425 return vs[0].([]*PublishingDestination)[vs[1].(int)] 426 }).(PublishingDestinationOutput) 427 } 428 429 type PublishingDestinationMapOutput struct{ *pulumi.OutputState } 430 431 func (PublishingDestinationMapOutput) ElementType() reflect.Type { 432 return reflect.TypeOf((*map[string]*PublishingDestination)(nil)).Elem() 433 } 434 435 func (o PublishingDestinationMapOutput) ToPublishingDestinationMapOutput() PublishingDestinationMapOutput { 436 return o 437 } 438 439 func (o PublishingDestinationMapOutput) ToPublishingDestinationMapOutputWithContext(ctx context.Context) PublishingDestinationMapOutput { 440 return o 441 } 442 443 func (o PublishingDestinationMapOutput) MapIndex(k pulumi.StringInput) PublishingDestinationOutput { 444 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PublishingDestination { 445 return vs[0].(map[string]*PublishingDestination)[vs[1].(string)] 446 }).(PublishingDestinationOutput) 447 } 448 449 func init() { 450 pulumi.RegisterInputType(reflect.TypeOf((*PublishingDestinationInput)(nil)).Elem(), &PublishingDestination{}) 451 pulumi.RegisterInputType(reflect.TypeOf((*PublishingDestinationArrayInput)(nil)).Elem(), PublishingDestinationArray{}) 452 pulumi.RegisterInputType(reflect.TypeOf((*PublishingDestinationMapInput)(nil)).Elem(), PublishingDestinationMap{}) 453 pulumi.RegisterOutputType(PublishingDestinationOutput{}) 454 pulumi.RegisterOutputType(PublishingDestinationArrayOutput{}) 455 pulumi.RegisterOutputType(PublishingDestinationMapOutput{}) 456 }