github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/waf/ruleGroup.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 waf
     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 WAF Rule Group Resource
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/waf"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			example, err := waf.NewRule(ctx, "example", &waf.RuleArgs{
    33  //				Name:       pulumi.String("example"),
    34  //				MetricName: pulumi.String("example"),
    35  //			})
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			_, err = waf.NewRuleGroup(ctx, "example", &waf.RuleGroupArgs{
    40  //				Name:       pulumi.String("example"),
    41  //				MetricName: pulumi.String("example"),
    42  //				ActivatedRules: waf.RuleGroupActivatedRuleArray{
    43  //					&waf.RuleGroupActivatedRuleArgs{
    44  //						Action: &waf.RuleGroupActivatedRuleActionArgs{
    45  //							Type: pulumi.String("COUNT"),
    46  //						},
    47  //						Priority: pulumi.Int(50),
    48  //						RuleId:   example.ID(),
    49  //					},
    50  //				},
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			return nil
    56  //		})
    57  //	}
    58  //
    59  // ```
    60  // <!--End PulumiCodeChooser -->
    61  //
    62  // ## Import
    63  //
    64  // Using `pulumi import`, import WAF Rule Group using the id. For example:
    65  //
    66  // ```sh
    67  // $ pulumi import aws:waf/ruleGroup:RuleGroup example a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc
    68  // ```
    69  type RuleGroup struct {
    70  	pulumi.CustomResourceState
    71  
    72  	// A list of activated rules, see below
    73  	ActivatedRules RuleGroupActivatedRuleArrayOutput `pulumi:"activatedRules"`
    74  	// The ARN of the WAF rule group.
    75  	Arn pulumi.StringOutput `pulumi:"arn"`
    76  	// A friendly name for the metrics from the rule group
    77  	MetricName pulumi.StringOutput `pulumi:"metricName"`
    78  	// Name of the rule group. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
    79  	Name pulumi.StringOutput `pulumi:"name"`
    80  	// 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.
    81  	Tags pulumi.StringMapOutput `pulumi:"tags"`
    82  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
    83  	//
    84  	// Deprecated: Please use `tags` instead.
    85  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
    86  }
    87  
    88  // NewRuleGroup registers a new resource with the given unique name, arguments, and options.
    89  func NewRuleGroup(ctx *pulumi.Context,
    90  	name string, args *RuleGroupArgs, opts ...pulumi.ResourceOption) (*RuleGroup, error) {
    91  	if args == nil {
    92  		return nil, errors.New("missing one or more required arguments")
    93  	}
    94  
    95  	if args.MetricName == nil {
    96  		return nil, errors.New("invalid value for required argument 'MetricName'")
    97  	}
    98  	opts = internal.PkgResourceDefaultOpts(opts)
    99  	var resource RuleGroup
   100  	err := ctx.RegisterResource("aws:waf/ruleGroup:RuleGroup", name, args, &resource, opts...)
   101  	if err != nil {
   102  		return nil, err
   103  	}
   104  	return &resource, nil
   105  }
   106  
   107  // GetRuleGroup gets an existing RuleGroup resource's state with the given name, ID, and optional
   108  // state properties that are used to uniquely qualify the lookup (nil if not required).
   109  func GetRuleGroup(ctx *pulumi.Context,
   110  	name string, id pulumi.IDInput, state *RuleGroupState, opts ...pulumi.ResourceOption) (*RuleGroup, error) {
   111  	var resource RuleGroup
   112  	err := ctx.ReadResource("aws:waf/ruleGroup:RuleGroup", name, id, state, &resource, opts...)
   113  	if err != nil {
   114  		return nil, err
   115  	}
   116  	return &resource, nil
   117  }
   118  
   119  // Input properties used for looking up and filtering RuleGroup resources.
   120  type ruleGroupState struct {
   121  	// A list of activated rules, see below
   122  	ActivatedRules []RuleGroupActivatedRule `pulumi:"activatedRules"`
   123  	// The ARN of the WAF rule group.
   124  	Arn *string `pulumi:"arn"`
   125  	// A friendly name for the metrics from the rule group
   126  	MetricName *string `pulumi:"metricName"`
   127  	// Name of the rule group. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   128  	Name *string `pulumi:"name"`
   129  	// 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.
   130  	Tags map[string]string `pulumi:"tags"`
   131  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   132  	//
   133  	// Deprecated: Please use `tags` instead.
   134  	TagsAll map[string]string `pulumi:"tagsAll"`
   135  }
   136  
   137  type RuleGroupState struct {
   138  	// A list of activated rules, see below
   139  	ActivatedRules RuleGroupActivatedRuleArrayInput
   140  	// The ARN of the WAF rule group.
   141  	Arn pulumi.StringPtrInput
   142  	// A friendly name for the metrics from the rule group
   143  	MetricName pulumi.StringPtrInput
   144  	// Name of the rule group. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   145  	Name pulumi.StringPtrInput
   146  	// 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.
   147  	Tags pulumi.StringMapInput
   148  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   149  	//
   150  	// Deprecated: Please use `tags` instead.
   151  	TagsAll pulumi.StringMapInput
   152  }
   153  
   154  func (RuleGroupState) ElementType() reflect.Type {
   155  	return reflect.TypeOf((*ruleGroupState)(nil)).Elem()
   156  }
   157  
   158  type ruleGroupArgs struct {
   159  	// A list of activated rules, see below
   160  	ActivatedRules []RuleGroupActivatedRule `pulumi:"activatedRules"`
   161  	// A friendly name for the metrics from the rule group
   162  	MetricName string `pulumi:"metricName"`
   163  	// Name of the rule group. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   164  	Name *string `pulumi:"name"`
   165  	// 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.
   166  	Tags map[string]string `pulumi:"tags"`
   167  }
   168  
   169  // The set of arguments for constructing a RuleGroup resource.
   170  type RuleGroupArgs struct {
   171  	// A list of activated rules, see below
   172  	ActivatedRules RuleGroupActivatedRuleArrayInput
   173  	// A friendly name for the metrics from the rule group
   174  	MetricName pulumi.StringInput
   175  	// Name of the rule group. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   176  	Name pulumi.StringPtrInput
   177  	// 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.
   178  	Tags pulumi.StringMapInput
   179  }
   180  
   181  func (RuleGroupArgs) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*ruleGroupArgs)(nil)).Elem()
   183  }
   184  
   185  type RuleGroupInput interface {
   186  	pulumi.Input
   187  
   188  	ToRuleGroupOutput() RuleGroupOutput
   189  	ToRuleGroupOutputWithContext(ctx context.Context) RuleGroupOutput
   190  }
   191  
   192  func (*RuleGroup) ElementType() reflect.Type {
   193  	return reflect.TypeOf((**RuleGroup)(nil)).Elem()
   194  }
   195  
   196  func (i *RuleGroup) ToRuleGroupOutput() RuleGroupOutput {
   197  	return i.ToRuleGroupOutputWithContext(context.Background())
   198  }
   199  
   200  func (i *RuleGroup) ToRuleGroupOutputWithContext(ctx context.Context) RuleGroupOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(RuleGroupOutput)
   202  }
   203  
   204  // RuleGroupArrayInput is an input type that accepts RuleGroupArray and RuleGroupArrayOutput values.
   205  // You can construct a concrete instance of `RuleGroupArrayInput` via:
   206  //
   207  //	RuleGroupArray{ RuleGroupArgs{...} }
   208  type RuleGroupArrayInput interface {
   209  	pulumi.Input
   210  
   211  	ToRuleGroupArrayOutput() RuleGroupArrayOutput
   212  	ToRuleGroupArrayOutputWithContext(context.Context) RuleGroupArrayOutput
   213  }
   214  
   215  type RuleGroupArray []RuleGroupInput
   216  
   217  func (RuleGroupArray) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*[]*RuleGroup)(nil)).Elem()
   219  }
   220  
   221  func (i RuleGroupArray) ToRuleGroupArrayOutput() RuleGroupArrayOutput {
   222  	return i.ToRuleGroupArrayOutputWithContext(context.Background())
   223  }
   224  
   225  func (i RuleGroupArray) ToRuleGroupArrayOutputWithContext(ctx context.Context) RuleGroupArrayOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(RuleGroupArrayOutput)
   227  }
   228  
   229  // RuleGroupMapInput is an input type that accepts RuleGroupMap and RuleGroupMapOutput values.
   230  // You can construct a concrete instance of `RuleGroupMapInput` via:
   231  //
   232  //	RuleGroupMap{ "key": RuleGroupArgs{...} }
   233  type RuleGroupMapInput interface {
   234  	pulumi.Input
   235  
   236  	ToRuleGroupMapOutput() RuleGroupMapOutput
   237  	ToRuleGroupMapOutputWithContext(context.Context) RuleGroupMapOutput
   238  }
   239  
   240  type RuleGroupMap map[string]RuleGroupInput
   241  
   242  func (RuleGroupMap) ElementType() reflect.Type {
   243  	return reflect.TypeOf((*map[string]*RuleGroup)(nil)).Elem()
   244  }
   245  
   246  func (i RuleGroupMap) ToRuleGroupMapOutput() RuleGroupMapOutput {
   247  	return i.ToRuleGroupMapOutputWithContext(context.Background())
   248  }
   249  
   250  func (i RuleGroupMap) ToRuleGroupMapOutputWithContext(ctx context.Context) RuleGroupMapOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(RuleGroupMapOutput)
   252  }
   253  
   254  type RuleGroupOutput struct{ *pulumi.OutputState }
   255  
   256  func (RuleGroupOutput) ElementType() reflect.Type {
   257  	return reflect.TypeOf((**RuleGroup)(nil)).Elem()
   258  }
   259  
   260  func (o RuleGroupOutput) ToRuleGroupOutput() RuleGroupOutput {
   261  	return o
   262  }
   263  
   264  func (o RuleGroupOutput) ToRuleGroupOutputWithContext(ctx context.Context) RuleGroupOutput {
   265  	return o
   266  }
   267  
   268  // A list of activated rules, see below
   269  func (o RuleGroupOutput) ActivatedRules() RuleGroupActivatedRuleArrayOutput {
   270  	return o.ApplyT(func(v *RuleGroup) RuleGroupActivatedRuleArrayOutput { return v.ActivatedRules }).(RuleGroupActivatedRuleArrayOutput)
   271  }
   272  
   273  // The ARN of the WAF rule group.
   274  func (o RuleGroupOutput) Arn() pulumi.StringOutput {
   275  	return o.ApplyT(func(v *RuleGroup) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   276  }
   277  
   278  // A friendly name for the metrics from the rule group
   279  func (o RuleGroupOutput) MetricName() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *RuleGroup) pulumi.StringOutput { return v.MetricName }).(pulumi.StringOutput)
   281  }
   282  
   283  // Name of the rule group. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   284  func (o RuleGroupOutput) Name() pulumi.StringOutput {
   285  	return o.ApplyT(func(v *RuleGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   286  }
   287  
   288  // 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.
   289  func (o RuleGroupOutput) Tags() pulumi.StringMapOutput {
   290  	return o.ApplyT(func(v *RuleGroup) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   291  }
   292  
   293  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   294  //
   295  // Deprecated: Please use `tags` instead.
   296  func (o RuleGroupOutput) TagsAll() pulumi.StringMapOutput {
   297  	return o.ApplyT(func(v *RuleGroup) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   298  }
   299  
   300  type RuleGroupArrayOutput struct{ *pulumi.OutputState }
   301  
   302  func (RuleGroupArrayOutput) ElementType() reflect.Type {
   303  	return reflect.TypeOf((*[]*RuleGroup)(nil)).Elem()
   304  }
   305  
   306  func (o RuleGroupArrayOutput) ToRuleGroupArrayOutput() RuleGroupArrayOutput {
   307  	return o
   308  }
   309  
   310  func (o RuleGroupArrayOutput) ToRuleGroupArrayOutputWithContext(ctx context.Context) RuleGroupArrayOutput {
   311  	return o
   312  }
   313  
   314  func (o RuleGroupArrayOutput) Index(i pulumi.IntInput) RuleGroupOutput {
   315  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RuleGroup {
   316  		return vs[0].([]*RuleGroup)[vs[1].(int)]
   317  	}).(RuleGroupOutput)
   318  }
   319  
   320  type RuleGroupMapOutput struct{ *pulumi.OutputState }
   321  
   322  func (RuleGroupMapOutput) ElementType() reflect.Type {
   323  	return reflect.TypeOf((*map[string]*RuleGroup)(nil)).Elem()
   324  }
   325  
   326  func (o RuleGroupMapOutput) ToRuleGroupMapOutput() RuleGroupMapOutput {
   327  	return o
   328  }
   329  
   330  func (o RuleGroupMapOutput) ToRuleGroupMapOutputWithContext(ctx context.Context) RuleGroupMapOutput {
   331  	return o
   332  }
   333  
   334  func (o RuleGroupMapOutput) MapIndex(k pulumi.StringInput) RuleGroupOutput {
   335  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RuleGroup {
   336  		return vs[0].(map[string]*RuleGroup)[vs[1].(string)]
   337  	}).(RuleGroupOutput)
   338  }
   339  
   340  func init() {
   341  	pulumi.RegisterInputType(reflect.TypeOf((*RuleGroupInput)(nil)).Elem(), &RuleGroup{})
   342  	pulumi.RegisterInputType(reflect.TypeOf((*RuleGroupArrayInput)(nil)).Elem(), RuleGroupArray{})
   343  	pulumi.RegisterInputType(reflect.TypeOf((*RuleGroupMapInput)(nil)).Elem(), RuleGroupMap{})
   344  	pulumi.RegisterOutputType(RuleGroupOutput{})
   345  	pulumi.RegisterOutputType(RuleGroupArrayOutput{})
   346  	pulumi.RegisterOutputType(RuleGroupMapOutput{})
   347  }