github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/securityhub/insight.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 securityhub
     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 Security Hub custom insight resource. See the [Managing custom insights section](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-custom-insights.html) of the AWS User Guide for more information.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Filter by AWS account ID
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/securityhub"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			example, err := securityhub.NewAccount(ctx, "example", nil)
    35  //			if err != nil {
    36  //				return err
    37  //			}
    38  //			_, err = securityhub.NewInsight(ctx, "example", &securityhub.InsightArgs{
    39  //				Filters: &securityhub.InsightFiltersArgs{
    40  //					AwsAccountIds: securityhub.InsightFiltersAwsAccountIdArray{
    41  //						&securityhub.InsightFiltersAwsAccountIdArgs{
    42  //							Comparison: pulumi.String("EQUALS"),
    43  //							Value:      pulumi.String("1234567890"),
    44  //						},
    45  //						&securityhub.InsightFiltersAwsAccountIdArgs{
    46  //							Comparison: pulumi.String("EQUALS"),
    47  //							Value:      pulumi.String("09876543210"),
    48  //						},
    49  //					},
    50  //				},
    51  //				GroupByAttribute: pulumi.String("AwsAccountId"),
    52  //				Name:             pulumi.String("example-insight"),
    53  //			}, pulumi.DependsOn([]pulumi.Resource{
    54  //				example,
    55  //			}))
    56  //			if err != nil {
    57  //				return err
    58  //			}
    59  //			return nil
    60  //		})
    61  //	}
    62  //
    63  // ```
    64  // <!--End PulumiCodeChooser -->
    65  //
    66  // ### Filter by date range
    67  //
    68  // <!--Start PulumiCodeChooser -->
    69  // ```go
    70  // package main
    71  //
    72  // import (
    73  //
    74  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/securityhub"
    75  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    76  //
    77  // )
    78  //
    79  //	func main() {
    80  //		pulumi.Run(func(ctx *pulumi.Context) error {
    81  //			example, err := securityhub.NewAccount(ctx, "example", nil)
    82  //			if err != nil {
    83  //				return err
    84  //			}
    85  //			_, err = securityhub.NewInsight(ctx, "example", &securityhub.InsightArgs{
    86  //				Filters: &securityhub.InsightFiltersArgs{
    87  //					CreatedAts: securityhub.InsightFiltersCreatedAtArray{
    88  //						&securityhub.InsightFiltersCreatedAtArgs{
    89  //							DateRange: &securityhub.InsightFiltersCreatedAtDateRangeArgs{
    90  //								Unit:  pulumi.String("DAYS"),
    91  //								Value: pulumi.Int(5),
    92  //							},
    93  //						},
    94  //					},
    95  //				},
    96  //				GroupByAttribute: pulumi.String("CreatedAt"),
    97  //				Name:             pulumi.String("example-insight"),
    98  //			}, pulumi.DependsOn([]pulumi.Resource{
    99  //				example,
   100  //			}))
   101  //			if err != nil {
   102  //				return err
   103  //			}
   104  //			return nil
   105  //		})
   106  //	}
   107  //
   108  // ```
   109  // <!--End PulumiCodeChooser -->
   110  //
   111  // ### Filter by destination IPv4 address
   112  //
   113  // <!--Start PulumiCodeChooser -->
   114  // ```go
   115  // package main
   116  //
   117  // import (
   118  //
   119  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/securityhub"
   120  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   121  //
   122  // )
   123  //
   124  //	func main() {
   125  //		pulumi.Run(func(ctx *pulumi.Context) error {
   126  //			example, err := securityhub.NewAccount(ctx, "example", nil)
   127  //			if err != nil {
   128  //				return err
   129  //			}
   130  //			_, err = securityhub.NewInsight(ctx, "example", &securityhub.InsightArgs{
   131  //				Filters: &securityhub.InsightFiltersArgs{
   132  //					NetworkDestinationIpv4s: securityhub.InsightFiltersNetworkDestinationIpv4Array{
   133  //						&securityhub.InsightFiltersNetworkDestinationIpv4Args{
   134  //							Cidr: pulumi.String("10.0.0.0/16"),
   135  //						},
   136  //					},
   137  //				},
   138  //				GroupByAttribute: pulumi.String("NetworkDestinationIpV4"),
   139  //				Name:             pulumi.String("example-insight"),
   140  //			}, pulumi.DependsOn([]pulumi.Resource{
   141  //				example,
   142  //			}))
   143  //			if err != nil {
   144  //				return err
   145  //			}
   146  //			return nil
   147  //		})
   148  //	}
   149  //
   150  // ```
   151  // <!--End PulumiCodeChooser -->
   152  //
   153  // ### Filter by finding's confidence
   154  //
   155  // <!--Start PulumiCodeChooser -->
   156  // ```go
   157  // package main
   158  //
   159  // import (
   160  //
   161  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/securityhub"
   162  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   163  //
   164  // )
   165  //
   166  //	func main() {
   167  //		pulumi.Run(func(ctx *pulumi.Context) error {
   168  //			example, err := securityhub.NewAccount(ctx, "example", nil)
   169  //			if err != nil {
   170  //				return err
   171  //			}
   172  //			_, err = securityhub.NewInsight(ctx, "example", &securityhub.InsightArgs{
   173  //				Filters: &securityhub.InsightFiltersArgs{
   174  //					Confidences: securityhub.InsightFiltersConfidenceArray{
   175  //						&securityhub.InsightFiltersConfidenceArgs{
   176  //							Gte: pulumi.String("80"),
   177  //						},
   178  //					},
   179  //				},
   180  //				GroupByAttribute: pulumi.String("Confidence"),
   181  //				Name:             pulumi.String("example-insight"),
   182  //			}, pulumi.DependsOn([]pulumi.Resource{
   183  //				example,
   184  //			}))
   185  //			if err != nil {
   186  //				return err
   187  //			}
   188  //			return nil
   189  //		})
   190  //	}
   191  //
   192  // ```
   193  // <!--End PulumiCodeChooser -->
   194  //
   195  // ### Filter by resource tags
   196  //
   197  // <!--Start PulumiCodeChooser -->
   198  // ```go
   199  // package main
   200  //
   201  // import (
   202  //
   203  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/securityhub"
   204  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   205  //
   206  // )
   207  //
   208  //	func main() {
   209  //		pulumi.Run(func(ctx *pulumi.Context) error {
   210  //			example, err := securityhub.NewAccount(ctx, "example", nil)
   211  //			if err != nil {
   212  //				return err
   213  //			}
   214  //			_, err = securityhub.NewInsight(ctx, "example", &securityhub.InsightArgs{
   215  //				Filters: &securityhub.InsightFiltersArgs{
   216  //					ResourceTags: securityhub.InsightFiltersResourceTagArray{
   217  //						&securityhub.InsightFiltersResourceTagArgs{
   218  //							Comparison: pulumi.String("EQUALS"),
   219  //							Key:        pulumi.String("Environment"),
   220  //							Value:      pulumi.String("Production"),
   221  //						},
   222  //					},
   223  //				},
   224  //				GroupByAttribute: pulumi.String("ResourceTags"),
   225  //				Name:             pulumi.String("example-insight"),
   226  //			}, pulumi.DependsOn([]pulumi.Resource{
   227  //				example,
   228  //			}))
   229  //			if err != nil {
   230  //				return err
   231  //			}
   232  //			return nil
   233  //		})
   234  //	}
   235  //
   236  // ```
   237  // <!--End PulumiCodeChooser -->
   238  //
   239  // ## Import
   240  //
   241  // Using `pulumi import`, import Security Hub insights using the ARN. For example:
   242  //
   243  // ```sh
   244  // $ pulumi import aws:securityhub/insight:Insight example arn:aws:securityhub:us-west-2:1234567890:insight/1234567890/custom/91299ed7-abd0-4e44-a858-d0b15e37141a
   245  // ```
   246  type Insight struct {
   247  	pulumi.CustomResourceState
   248  
   249  	// ARN of the insight.
   250  	Arn pulumi.StringOutput `pulumi:"arn"`
   251  	// A configuration block including one or more (up to 10 distinct) attributes used to filter the findings included in the insight. The insight only includes findings that match criteria defined in the filters. See filters below for more details.
   252  	Filters InsightFiltersOutput `pulumi:"filters"`
   253  	// The attribute used to group the findings for the insight e.g., if an insight is grouped by `ResourceId`, then the insight produces a list of resource identifiers.
   254  	GroupByAttribute pulumi.StringOutput `pulumi:"groupByAttribute"`
   255  	// The name of the custom insight.
   256  	Name pulumi.StringOutput `pulumi:"name"`
   257  }
   258  
   259  // NewInsight registers a new resource with the given unique name, arguments, and options.
   260  func NewInsight(ctx *pulumi.Context,
   261  	name string, args *InsightArgs, opts ...pulumi.ResourceOption) (*Insight, error) {
   262  	if args == nil {
   263  		return nil, errors.New("missing one or more required arguments")
   264  	}
   265  
   266  	if args.Filters == nil {
   267  		return nil, errors.New("invalid value for required argument 'Filters'")
   268  	}
   269  	if args.GroupByAttribute == nil {
   270  		return nil, errors.New("invalid value for required argument 'GroupByAttribute'")
   271  	}
   272  	opts = internal.PkgResourceDefaultOpts(opts)
   273  	var resource Insight
   274  	err := ctx.RegisterResource("aws:securityhub/insight:Insight", name, args, &resource, opts...)
   275  	if err != nil {
   276  		return nil, err
   277  	}
   278  	return &resource, nil
   279  }
   280  
   281  // GetInsight gets an existing Insight resource's state with the given name, ID, and optional
   282  // state properties that are used to uniquely qualify the lookup (nil if not required).
   283  func GetInsight(ctx *pulumi.Context,
   284  	name string, id pulumi.IDInput, state *InsightState, opts ...pulumi.ResourceOption) (*Insight, error) {
   285  	var resource Insight
   286  	err := ctx.ReadResource("aws:securityhub/insight:Insight", name, id, state, &resource, opts...)
   287  	if err != nil {
   288  		return nil, err
   289  	}
   290  	return &resource, nil
   291  }
   292  
   293  // Input properties used for looking up and filtering Insight resources.
   294  type insightState struct {
   295  	// ARN of the insight.
   296  	Arn *string `pulumi:"arn"`
   297  	// A configuration block including one or more (up to 10 distinct) attributes used to filter the findings included in the insight. The insight only includes findings that match criteria defined in the filters. See filters below for more details.
   298  	Filters *InsightFilters `pulumi:"filters"`
   299  	// The attribute used to group the findings for the insight e.g., if an insight is grouped by `ResourceId`, then the insight produces a list of resource identifiers.
   300  	GroupByAttribute *string `pulumi:"groupByAttribute"`
   301  	// The name of the custom insight.
   302  	Name *string `pulumi:"name"`
   303  }
   304  
   305  type InsightState struct {
   306  	// ARN of the insight.
   307  	Arn pulumi.StringPtrInput
   308  	// A configuration block including one or more (up to 10 distinct) attributes used to filter the findings included in the insight. The insight only includes findings that match criteria defined in the filters. See filters below for more details.
   309  	Filters InsightFiltersPtrInput
   310  	// The attribute used to group the findings for the insight e.g., if an insight is grouped by `ResourceId`, then the insight produces a list of resource identifiers.
   311  	GroupByAttribute pulumi.StringPtrInput
   312  	// The name of the custom insight.
   313  	Name pulumi.StringPtrInput
   314  }
   315  
   316  func (InsightState) ElementType() reflect.Type {
   317  	return reflect.TypeOf((*insightState)(nil)).Elem()
   318  }
   319  
   320  type insightArgs struct {
   321  	// A configuration block including one or more (up to 10 distinct) attributes used to filter the findings included in the insight. The insight only includes findings that match criteria defined in the filters. See filters below for more details.
   322  	Filters InsightFilters `pulumi:"filters"`
   323  	// The attribute used to group the findings for the insight e.g., if an insight is grouped by `ResourceId`, then the insight produces a list of resource identifiers.
   324  	GroupByAttribute string `pulumi:"groupByAttribute"`
   325  	// The name of the custom insight.
   326  	Name *string `pulumi:"name"`
   327  }
   328  
   329  // The set of arguments for constructing a Insight resource.
   330  type InsightArgs struct {
   331  	// A configuration block including one or more (up to 10 distinct) attributes used to filter the findings included in the insight. The insight only includes findings that match criteria defined in the filters. See filters below for more details.
   332  	Filters InsightFiltersInput
   333  	// The attribute used to group the findings for the insight e.g., if an insight is grouped by `ResourceId`, then the insight produces a list of resource identifiers.
   334  	GroupByAttribute pulumi.StringInput
   335  	// The name of the custom insight.
   336  	Name pulumi.StringPtrInput
   337  }
   338  
   339  func (InsightArgs) ElementType() reflect.Type {
   340  	return reflect.TypeOf((*insightArgs)(nil)).Elem()
   341  }
   342  
   343  type InsightInput interface {
   344  	pulumi.Input
   345  
   346  	ToInsightOutput() InsightOutput
   347  	ToInsightOutputWithContext(ctx context.Context) InsightOutput
   348  }
   349  
   350  func (*Insight) ElementType() reflect.Type {
   351  	return reflect.TypeOf((**Insight)(nil)).Elem()
   352  }
   353  
   354  func (i *Insight) ToInsightOutput() InsightOutput {
   355  	return i.ToInsightOutputWithContext(context.Background())
   356  }
   357  
   358  func (i *Insight) ToInsightOutputWithContext(ctx context.Context) InsightOutput {
   359  	return pulumi.ToOutputWithContext(ctx, i).(InsightOutput)
   360  }
   361  
   362  // InsightArrayInput is an input type that accepts InsightArray and InsightArrayOutput values.
   363  // You can construct a concrete instance of `InsightArrayInput` via:
   364  //
   365  //	InsightArray{ InsightArgs{...} }
   366  type InsightArrayInput interface {
   367  	pulumi.Input
   368  
   369  	ToInsightArrayOutput() InsightArrayOutput
   370  	ToInsightArrayOutputWithContext(context.Context) InsightArrayOutput
   371  }
   372  
   373  type InsightArray []InsightInput
   374  
   375  func (InsightArray) ElementType() reflect.Type {
   376  	return reflect.TypeOf((*[]*Insight)(nil)).Elem()
   377  }
   378  
   379  func (i InsightArray) ToInsightArrayOutput() InsightArrayOutput {
   380  	return i.ToInsightArrayOutputWithContext(context.Background())
   381  }
   382  
   383  func (i InsightArray) ToInsightArrayOutputWithContext(ctx context.Context) InsightArrayOutput {
   384  	return pulumi.ToOutputWithContext(ctx, i).(InsightArrayOutput)
   385  }
   386  
   387  // InsightMapInput is an input type that accepts InsightMap and InsightMapOutput values.
   388  // You can construct a concrete instance of `InsightMapInput` via:
   389  //
   390  //	InsightMap{ "key": InsightArgs{...} }
   391  type InsightMapInput interface {
   392  	pulumi.Input
   393  
   394  	ToInsightMapOutput() InsightMapOutput
   395  	ToInsightMapOutputWithContext(context.Context) InsightMapOutput
   396  }
   397  
   398  type InsightMap map[string]InsightInput
   399  
   400  func (InsightMap) ElementType() reflect.Type {
   401  	return reflect.TypeOf((*map[string]*Insight)(nil)).Elem()
   402  }
   403  
   404  func (i InsightMap) ToInsightMapOutput() InsightMapOutput {
   405  	return i.ToInsightMapOutputWithContext(context.Background())
   406  }
   407  
   408  func (i InsightMap) ToInsightMapOutputWithContext(ctx context.Context) InsightMapOutput {
   409  	return pulumi.ToOutputWithContext(ctx, i).(InsightMapOutput)
   410  }
   411  
   412  type InsightOutput struct{ *pulumi.OutputState }
   413  
   414  func (InsightOutput) ElementType() reflect.Type {
   415  	return reflect.TypeOf((**Insight)(nil)).Elem()
   416  }
   417  
   418  func (o InsightOutput) ToInsightOutput() InsightOutput {
   419  	return o
   420  }
   421  
   422  func (o InsightOutput) ToInsightOutputWithContext(ctx context.Context) InsightOutput {
   423  	return o
   424  }
   425  
   426  // ARN of the insight.
   427  func (o InsightOutput) Arn() pulumi.StringOutput {
   428  	return o.ApplyT(func(v *Insight) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   429  }
   430  
   431  // A configuration block including one or more (up to 10 distinct) attributes used to filter the findings included in the insight. The insight only includes findings that match criteria defined in the filters. See filters below for more details.
   432  func (o InsightOutput) Filters() InsightFiltersOutput {
   433  	return o.ApplyT(func(v *Insight) InsightFiltersOutput { return v.Filters }).(InsightFiltersOutput)
   434  }
   435  
   436  // The attribute used to group the findings for the insight e.g., if an insight is grouped by `ResourceId`, then the insight produces a list of resource identifiers.
   437  func (o InsightOutput) GroupByAttribute() pulumi.StringOutput {
   438  	return o.ApplyT(func(v *Insight) pulumi.StringOutput { return v.GroupByAttribute }).(pulumi.StringOutput)
   439  }
   440  
   441  // The name of the custom insight.
   442  func (o InsightOutput) Name() pulumi.StringOutput {
   443  	return o.ApplyT(func(v *Insight) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   444  }
   445  
   446  type InsightArrayOutput struct{ *pulumi.OutputState }
   447  
   448  func (InsightArrayOutput) ElementType() reflect.Type {
   449  	return reflect.TypeOf((*[]*Insight)(nil)).Elem()
   450  }
   451  
   452  func (o InsightArrayOutput) ToInsightArrayOutput() InsightArrayOutput {
   453  	return o
   454  }
   455  
   456  func (o InsightArrayOutput) ToInsightArrayOutputWithContext(ctx context.Context) InsightArrayOutput {
   457  	return o
   458  }
   459  
   460  func (o InsightArrayOutput) Index(i pulumi.IntInput) InsightOutput {
   461  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Insight {
   462  		return vs[0].([]*Insight)[vs[1].(int)]
   463  	}).(InsightOutput)
   464  }
   465  
   466  type InsightMapOutput struct{ *pulumi.OutputState }
   467  
   468  func (InsightMapOutput) ElementType() reflect.Type {
   469  	return reflect.TypeOf((*map[string]*Insight)(nil)).Elem()
   470  }
   471  
   472  func (o InsightMapOutput) ToInsightMapOutput() InsightMapOutput {
   473  	return o
   474  }
   475  
   476  func (o InsightMapOutput) ToInsightMapOutputWithContext(ctx context.Context) InsightMapOutput {
   477  	return o
   478  }
   479  
   480  func (o InsightMapOutput) MapIndex(k pulumi.StringInput) InsightOutput {
   481  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Insight {
   482  		return vs[0].(map[string]*Insight)[vs[1].(string)]
   483  	}).(InsightOutput)
   484  }
   485  
   486  func init() {
   487  	pulumi.RegisterInputType(reflect.TypeOf((*InsightInput)(nil)).Elem(), &Insight{})
   488  	pulumi.RegisterInputType(reflect.TypeOf((*InsightArrayInput)(nil)).Elem(), InsightArray{})
   489  	pulumi.RegisterInputType(reflect.TypeOf((*InsightMapInput)(nil)).Elem(), InsightMap{})
   490  	pulumi.RegisterOutputType(InsightOutput{})
   491  	pulumi.RegisterOutputType(InsightArrayOutput{})
   492  	pulumi.RegisterOutputType(InsightMapOutput{})
   493  }