github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/securityhub/automationRule.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  // Resource for managing an AWS Security Hub Automation Rule.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    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  //			_, err := securityhub.NewAutomationRule(ctx, "example", &securityhub.AutomationRuleArgs{
    35  //				Description: pulumi.String("Elevate finding severity to CRITICAL when specific resources such as an S3 bucket is at risk"),
    36  //				RuleName:    pulumi.String("Elevate severity of findings that relate to important resources"),
    37  //				RuleOrder:   pulumi.Int(1),
    38  //				Actions: securityhub.AutomationRuleActionArray{
    39  //					&securityhub.AutomationRuleActionArgs{
    40  //						FindingFieldsUpdate: &securityhub.AutomationRuleActionFindingFieldsUpdateArgs{
    41  //							Severity: &securityhub.AutomationRuleActionFindingFieldsUpdateSeverityArgs{
    42  //								Label:   pulumi.String("CRITICAL"),
    43  //								Product: pulumi.Float64(0),
    44  //							},
    45  //							Note: &securityhub.AutomationRuleActionFindingFieldsUpdateNoteArgs{
    46  //								Text:      pulumi.String("This is a critical resource. Please review ASAP."),
    47  //								UpdatedBy: pulumi.String("sechub-automation"),
    48  //							},
    49  //							Types: pulumi.StringArray{
    50  //								pulumi.String("Software and Configuration Checks/Industry and Regulatory Standards"),
    51  //							},
    52  //							UserDefinedFields: pulumi.StringMap{
    53  //								"key": pulumi.String("value"),
    54  //							},
    55  //						},
    56  //						Type: pulumi.String("FINDING_FIELDS_UPDATE"),
    57  //					},
    58  //				},
    59  //				Criteria: &securityhub.AutomationRuleCriteriaArgs{
    60  //					ResourceIds: securityhub.AutomationRuleCriteriaResourceIdArray{
    61  //						&securityhub.AutomationRuleCriteriaResourceIdArgs{
    62  //							Comparison: pulumi.String("EQUALS"),
    63  //							Value:      pulumi.String("arn:aws:s3:::examplebucket/*"),
    64  //						},
    65  //					},
    66  //				},
    67  //			})
    68  //			if err != nil {
    69  //				return err
    70  //			}
    71  //			return nil
    72  //		})
    73  //	}
    74  //
    75  // ```
    76  // <!--End PulumiCodeChooser -->
    77  //
    78  // ## Import
    79  //
    80  // Using `pulumi import`, import Security Hub automation rule using their ARN. For example:
    81  //
    82  // ```sh
    83  // $ pulumi import aws:securityhub/automationRule:AutomationRule example arn:aws:securityhub:us-west-2:123456789012:automation-rule/473eddde-f5c4-4ae5-85c7-e922f271fffc
    84  // ```
    85  type AutomationRule struct {
    86  	pulumi.CustomResourceState
    87  
    88  	// A block that specifies one or more actions to update finding fields if a finding matches the conditions specified in `Criteria`. Documented below.
    89  	Actions AutomationRuleActionArrayOutput `pulumi:"actions"`
    90  	// The ARN of the Security Hub automation rule.
    91  	Arn pulumi.StringOutput `pulumi:"arn"`
    92  	// A block that specifies a set of ASFF finding field attributes and corresponding expected values that Security Hub uses to filter findings. Documented below.
    93  	Criteria AutomationRuleCriteriaPtrOutput `pulumi:"criteria"`
    94  	// The description of the rule.
    95  	Description pulumi.StringOutput `pulumi:"description"`
    96  	// Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. Defaults to `false`.
    97  	IsTerminal pulumi.BoolOutput `pulumi:"isTerminal"`
    98  	// The name of the rule.
    99  	RuleName pulumi.StringOutput `pulumi:"ruleName"`
   100  	// An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub applies rules with lower values for this parameter first.
   101  	RuleOrder pulumi.IntOutput `pulumi:"ruleOrder"`
   102  	// Whether the rule is active after it is created.
   103  	RuleStatus pulumi.StringOutput    `pulumi:"ruleStatus"`
   104  	Tags       pulumi.StringMapOutput `pulumi:"tags"`
   105  	// Deprecated: Please use `tags` instead.
   106  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   107  }
   108  
   109  // NewAutomationRule registers a new resource with the given unique name, arguments, and options.
   110  func NewAutomationRule(ctx *pulumi.Context,
   111  	name string, args *AutomationRuleArgs, opts ...pulumi.ResourceOption) (*AutomationRule, error) {
   112  	if args == nil {
   113  		return nil, errors.New("missing one or more required arguments")
   114  	}
   115  
   116  	if args.Description == nil {
   117  		return nil, errors.New("invalid value for required argument 'Description'")
   118  	}
   119  	if args.RuleName == nil {
   120  		return nil, errors.New("invalid value for required argument 'RuleName'")
   121  	}
   122  	if args.RuleOrder == nil {
   123  		return nil, errors.New("invalid value for required argument 'RuleOrder'")
   124  	}
   125  	opts = internal.PkgResourceDefaultOpts(opts)
   126  	var resource AutomationRule
   127  	err := ctx.RegisterResource("aws:securityhub/automationRule:AutomationRule", name, args, &resource, opts...)
   128  	if err != nil {
   129  		return nil, err
   130  	}
   131  	return &resource, nil
   132  }
   133  
   134  // GetAutomationRule gets an existing AutomationRule resource's state with the given name, ID, and optional
   135  // state properties that are used to uniquely qualify the lookup (nil if not required).
   136  func GetAutomationRule(ctx *pulumi.Context,
   137  	name string, id pulumi.IDInput, state *AutomationRuleState, opts ...pulumi.ResourceOption) (*AutomationRule, error) {
   138  	var resource AutomationRule
   139  	err := ctx.ReadResource("aws:securityhub/automationRule:AutomationRule", name, id, state, &resource, opts...)
   140  	if err != nil {
   141  		return nil, err
   142  	}
   143  	return &resource, nil
   144  }
   145  
   146  // Input properties used for looking up and filtering AutomationRule resources.
   147  type automationRuleState struct {
   148  	// A block that specifies one or more actions to update finding fields if a finding matches the conditions specified in `Criteria`. Documented below.
   149  	Actions []AutomationRuleAction `pulumi:"actions"`
   150  	// The ARN of the Security Hub automation rule.
   151  	Arn *string `pulumi:"arn"`
   152  	// A block that specifies a set of ASFF finding field attributes and corresponding expected values that Security Hub uses to filter findings. Documented below.
   153  	Criteria *AutomationRuleCriteria `pulumi:"criteria"`
   154  	// The description of the rule.
   155  	Description *string `pulumi:"description"`
   156  	// Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. Defaults to `false`.
   157  	IsTerminal *bool `pulumi:"isTerminal"`
   158  	// The name of the rule.
   159  	RuleName *string `pulumi:"ruleName"`
   160  	// An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub applies rules with lower values for this parameter first.
   161  	RuleOrder *int `pulumi:"ruleOrder"`
   162  	// Whether the rule is active after it is created.
   163  	RuleStatus *string           `pulumi:"ruleStatus"`
   164  	Tags       map[string]string `pulumi:"tags"`
   165  	// Deprecated: Please use `tags` instead.
   166  	TagsAll map[string]string `pulumi:"tagsAll"`
   167  }
   168  
   169  type AutomationRuleState struct {
   170  	// A block that specifies one or more actions to update finding fields if a finding matches the conditions specified in `Criteria`. Documented below.
   171  	Actions AutomationRuleActionArrayInput
   172  	// The ARN of the Security Hub automation rule.
   173  	Arn pulumi.StringPtrInput
   174  	// A block that specifies a set of ASFF finding field attributes and corresponding expected values that Security Hub uses to filter findings. Documented below.
   175  	Criteria AutomationRuleCriteriaPtrInput
   176  	// The description of the rule.
   177  	Description pulumi.StringPtrInput
   178  	// Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. Defaults to `false`.
   179  	IsTerminal pulumi.BoolPtrInput
   180  	// The name of the rule.
   181  	RuleName pulumi.StringPtrInput
   182  	// An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub applies rules with lower values for this parameter first.
   183  	RuleOrder pulumi.IntPtrInput
   184  	// Whether the rule is active after it is created.
   185  	RuleStatus pulumi.StringPtrInput
   186  	Tags       pulumi.StringMapInput
   187  	// Deprecated: Please use `tags` instead.
   188  	TagsAll pulumi.StringMapInput
   189  }
   190  
   191  func (AutomationRuleState) ElementType() reflect.Type {
   192  	return reflect.TypeOf((*automationRuleState)(nil)).Elem()
   193  }
   194  
   195  type automationRuleArgs struct {
   196  	// A block that specifies one or more actions to update finding fields if a finding matches the conditions specified in `Criteria`. Documented below.
   197  	Actions []AutomationRuleAction `pulumi:"actions"`
   198  	// A block that specifies a set of ASFF finding field attributes and corresponding expected values that Security Hub uses to filter findings. Documented below.
   199  	Criteria *AutomationRuleCriteria `pulumi:"criteria"`
   200  	// The description of the rule.
   201  	Description string `pulumi:"description"`
   202  	// Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. Defaults to `false`.
   203  	IsTerminal *bool `pulumi:"isTerminal"`
   204  	// The name of the rule.
   205  	RuleName string `pulumi:"ruleName"`
   206  	// An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub applies rules with lower values for this parameter first.
   207  	RuleOrder int `pulumi:"ruleOrder"`
   208  	// Whether the rule is active after it is created.
   209  	RuleStatus *string           `pulumi:"ruleStatus"`
   210  	Tags       map[string]string `pulumi:"tags"`
   211  }
   212  
   213  // The set of arguments for constructing a AutomationRule resource.
   214  type AutomationRuleArgs struct {
   215  	// A block that specifies one or more actions to update finding fields if a finding matches the conditions specified in `Criteria`. Documented below.
   216  	Actions AutomationRuleActionArrayInput
   217  	// A block that specifies a set of ASFF finding field attributes and corresponding expected values that Security Hub uses to filter findings. Documented below.
   218  	Criteria AutomationRuleCriteriaPtrInput
   219  	// The description of the rule.
   220  	Description pulumi.StringInput
   221  	// Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. Defaults to `false`.
   222  	IsTerminal pulumi.BoolPtrInput
   223  	// The name of the rule.
   224  	RuleName pulumi.StringInput
   225  	// An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub applies rules with lower values for this parameter first.
   226  	RuleOrder pulumi.IntInput
   227  	// Whether the rule is active after it is created.
   228  	RuleStatus pulumi.StringPtrInput
   229  	Tags       pulumi.StringMapInput
   230  }
   231  
   232  func (AutomationRuleArgs) ElementType() reflect.Type {
   233  	return reflect.TypeOf((*automationRuleArgs)(nil)).Elem()
   234  }
   235  
   236  type AutomationRuleInput interface {
   237  	pulumi.Input
   238  
   239  	ToAutomationRuleOutput() AutomationRuleOutput
   240  	ToAutomationRuleOutputWithContext(ctx context.Context) AutomationRuleOutput
   241  }
   242  
   243  func (*AutomationRule) ElementType() reflect.Type {
   244  	return reflect.TypeOf((**AutomationRule)(nil)).Elem()
   245  }
   246  
   247  func (i *AutomationRule) ToAutomationRuleOutput() AutomationRuleOutput {
   248  	return i.ToAutomationRuleOutputWithContext(context.Background())
   249  }
   250  
   251  func (i *AutomationRule) ToAutomationRuleOutputWithContext(ctx context.Context) AutomationRuleOutput {
   252  	return pulumi.ToOutputWithContext(ctx, i).(AutomationRuleOutput)
   253  }
   254  
   255  // AutomationRuleArrayInput is an input type that accepts AutomationRuleArray and AutomationRuleArrayOutput values.
   256  // You can construct a concrete instance of `AutomationRuleArrayInput` via:
   257  //
   258  //	AutomationRuleArray{ AutomationRuleArgs{...} }
   259  type AutomationRuleArrayInput interface {
   260  	pulumi.Input
   261  
   262  	ToAutomationRuleArrayOutput() AutomationRuleArrayOutput
   263  	ToAutomationRuleArrayOutputWithContext(context.Context) AutomationRuleArrayOutput
   264  }
   265  
   266  type AutomationRuleArray []AutomationRuleInput
   267  
   268  func (AutomationRuleArray) ElementType() reflect.Type {
   269  	return reflect.TypeOf((*[]*AutomationRule)(nil)).Elem()
   270  }
   271  
   272  func (i AutomationRuleArray) ToAutomationRuleArrayOutput() AutomationRuleArrayOutput {
   273  	return i.ToAutomationRuleArrayOutputWithContext(context.Background())
   274  }
   275  
   276  func (i AutomationRuleArray) ToAutomationRuleArrayOutputWithContext(ctx context.Context) AutomationRuleArrayOutput {
   277  	return pulumi.ToOutputWithContext(ctx, i).(AutomationRuleArrayOutput)
   278  }
   279  
   280  // AutomationRuleMapInput is an input type that accepts AutomationRuleMap and AutomationRuleMapOutput values.
   281  // You can construct a concrete instance of `AutomationRuleMapInput` via:
   282  //
   283  //	AutomationRuleMap{ "key": AutomationRuleArgs{...} }
   284  type AutomationRuleMapInput interface {
   285  	pulumi.Input
   286  
   287  	ToAutomationRuleMapOutput() AutomationRuleMapOutput
   288  	ToAutomationRuleMapOutputWithContext(context.Context) AutomationRuleMapOutput
   289  }
   290  
   291  type AutomationRuleMap map[string]AutomationRuleInput
   292  
   293  func (AutomationRuleMap) ElementType() reflect.Type {
   294  	return reflect.TypeOf((*map[string]*AutomationRule)(nil)).Elem()
   295  }
   296  
   297  func (i AutomationRuleMap) ToAutomationRuleMapOutput() AutomationRuleMapOutput {
   298  	return i.ToAutomationRuleMapOutputWithContext(context.Background())
   299  }
   300  
   301  func (i AutomationRuleMap) ToAutomationRuleMapOutputWithContext(ctx context.Context) AutomationRuleMapOutput {
   302  	return pulumi.ToOutputWithContext(ctx, i).(AutomationRuleMapOutput)
   303  }
   304  
   305  type AutomationRuleOutput struct{ *pulumi.OutputState }
   306  
   307  func (AutomationRuleOutput) ElementType() reflect.Type {
   308  	return reflect.TypeOf((**AutomationRule)(nil)).Elem()
   309  }
   310  
   311  func (o AutomationRuleOutput) ToAutomationRuleOutput() AutomationRuleOutput {
   312  	return o
   313  }
   314  
   315  func (o AutomationRuleOutput) ToAutomationRuleOutputWithContext(ctx context.Context) AutomationRuleOutput {
   316  	return o
   317  }
   318  
   319  // A block that specifies one or more actions to update finding fields if a finding matches the conditions specified in `Criteria`. Documented below.
   320  func (o AutomationRuleOutput) Actions() AutomationRuleActionArrayOutput {
   321  	return o.ApplyT(func(v *AutomationRule) AutomationRuleActionArrayOutput { return v.Actions }).(AutomationRuleActionArrayOutput)
   322  }
   323  
   324  // The ARN of the Security Hub automation rule.
   325  func (o AutomationRuleOutput) Arn() pulumi.StringOutput {
   326  	return o.ApplyT(func(v *AutomationRule) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   327  }
   328  
   329  // A block that specifies a set of ASFF finding field attributes and corresponding expected values that Security Hub uses to filter findings. Documented below.
   330  func (o AutomationRuleOutput) Criteria() AutomationRuleCriteriaPtrOutput {
   331  	return o.ApplyT(func(v *AutomationRule) AutomationRuleCriteriaPtrOutput { return v.Criteria }).(AutomationRuleCriteriaPtrOutput)
   332  }
   333  
   334  // The description of the rule.
   335  func (o AutomationRuleOutput) Description() pulumi.StringOutput {
   336  	return o.ApplyT(func(v *AutomationRule) pulumi.StringOutput { return v.Description }).(pulumi.StringOutput)
   337  }
   338  
   339  // Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. Defaults to `false`.
   340  func (o AutomationRuleOutput) IsTerminal() pulumi.BoolOutput {
   341  	return o.ApplyT(func(v *AutomationRule) pulumi.BoolOutput { return v.IsTerminal }).(pulumi.BoolOutput)
   342  }
   343  
   344  // The name of the rule.
   345  func (o AutomationRuleOutput) RuleName() pulumi.StringOutput {
   346  	return o.ApplyT(func(v *AutomationRule) pulumi.StringOutput { return v.RuleName }).(pulumi.StringOutput)
   347  }
   348  
   349  // An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub applies rules with lower values for this parameter first.
   350  func (o AutomationRuleOutput) RuleOrder() pulumi.IntOutput {
   351  	return o.ApplyT(func(v *AutomationRule) pulumi.IntOutput { return v.RuleOrder }).(pulumi.IntOutput)
   352  }
   353  
   354  // Whether the rule is active after it is created.
   355  func (o AutomationRuleOutput) RuleStatus() pulumi.StringOutput {
   356  	return o.ApplyT(func(v *AutomationRule) pulumi.StringOutput { return v.RuleStatus }).(pulumi.StringOutput)
   357  }
   358  
   359  func (o AutomationRuleOutput) Tags() pulumi.StringMapOutput {
   360  	return o.ApplyT(func(v *AutomationRule) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   361  }
   362  
   363  // Deprecated: Please use `tags` instead.
   364  func (o AutomationRuleOutput) TagsAll() pulumi.StringMapOutput {
   365  	return o.ApplyT(func(v *AutomationRule) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   366  }
   367  
   368  type AutomationRuleArrayOutput struct{ *pulumi.OutputState }
   369  
   370  func (AutomationRuleArrayOutput) ElementType() reflect.Type {
   371  	return reflect.TypeOf((*[]*AutomationRule)(nil)).Elem()
   372  }
   373  
   374  func (o AutomationRuleArrayOutput) ToAutomationRuleArrayOutput() AutomationRuleArrayOutput {
   375  	return o
   376  }
   377  
   378  func (o AutomationRuleArrayOutput) ToAutomationRuleArrayOutputWithContext(ctx context.Context) AutomationRuleArrayOutput {
   379  	return o
   380  }
   381  
   382  func (o AutomationRuleArrayOutput) Index(i pulumi.IntInput) AutomationRuleOutput {
   383  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *AutomationRule {
   384  		return vs[0].([]*AutomationRule)[vs[1].(int)]
   385  	}).(AutomationRuleOutput)
   386  }
   387  
   388  type AutomationRuleMapOutput struct{ *pulumi.OutputState }
   389  
   390  func (AutomationRuleMapOutput) ElementType() reflect.Type {
   391  	return reflect.TypeOf((*map[string]*AutomationRule)(nil)).Elem()
   392  }
   393  
   394  func (o AutomationRuleMapOutput) ToAutomationRuleMapOutput() AutomationRuleMapOutput {
   395  	return o
   396  }
   397  
   398  func (o AutomationRuleMapOutput) ToAutomationRuleMapOutputWithContext(ctx context.Context) AutomationRuleMapOutput {
   399  	return o
   400  }
   401  
   402  func (o AutomationRuleMapOutput) MapIndex(k pulumi.StringInput) AutomationRuleOutput {
   403  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *AutomationRule {
   404  		return vs[0].(map[string]*AutomationRule)[vs[1].(string)]
   405  	}).(AutomationRuleOutput)
   406  }
   407  
   408  func init() {
   409  	pulumi.RegisterInputType(reflect.TypeOf((*AutomationRuleInput)(nil)).Elem(), &AutomationRule{})
   410  	pulumi.RegisterInputType(reflect.TypeOf((*AutomationRuleArrayInput)(nil)).Elem(), AutomationRuleArray{})
   411  	pulumi.RegisterInputType(reflect.TypeOf((*AutomationRuleMapInput)(nil)).Elem(), AutomationRuleMap{})
   412  	pulumi.RegisterOutputType(AutomationRuleOutput{})
   413  	pulumi.RegisterOutputType(AutomationRuleArrayOutput{})
   414  	pulumi.RegisterOutputType(AutomationRuleMapOutput{})
   415  }