github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/wafregional/rateBasedRule.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 wafregional
     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 Rate Based Rule 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/wafregional"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			ipset, err := wafregional.NewIpSet(ctx, "ipset", &wafregional.IpSetArgs{
    33  //				Name: pulumi.String("tfIPSet"),
    34  //				IpSetDescriptors: wafregional.IpSetIpSetDescriptorArray{
    35  //					&wafregional.IpSetIpSetDescriptorArgs{
    36  //						Type:  pulumi.String("IPV4"),
    37  //						Value: pulumi.String("192.0.7.0/24"),
    38  //					},
    39  //				},
    40  //			})
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			_, err = wafregional.NewRateBasedRule(ctx, "wafrule", &wafregional.RateBasedRuleArgs{
    45  //				Name:       pulumi.String("tfWAFRule"),
    46  //				MetricName: pulumi.String("tfWAFRule"),
    47  //				RateKey:    pulumi.String("IP"),
    48  //				RateLimit:  pulumi.Int(100),
    49  //				Predicates: wafregional.RateBasedRulePredicateArray{
    50  //					&wafregional.RateBasedRulePredicateArgs{
    51  //						DataId:  ipset.ID(),
    52  //						Negated: pulumi.Bool(false),
    53  //						Type:    pulumi.String("IPMatch"),
    54  //					},
    55  //				},
    56  //			}, pulumi.DependsOn([]pulumi.Resource{
    57  //				ipset,
    58  //			}))
    59  //			if err != nil {
    60  //				return err
    61  //			}
    62  //			return nil
    63  //		})
    64  //	}
    65  //
    66  // ```
    67  // <!--End PulumiCodeChooser -->
    68  //
    69  // ## Import
    70  //
    71  // Using `pulumi import`, import WAF Regional Rate Based Rule using the id. For example:
    72  //
    73  // ```sh
    74  // $ pulumi import aws:wafregional/rateBasedRule:RateBasedRule wafrule a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc
    75  // ```
    76  type RateBasedRule struct {
    77  	pulumi.CustomResourceState
    78  
    79  	// The ARN of the WAF Regional Rate Based Rule.
    80  	Arn pulumi.StringOutput `pulumi:"arn"`
    81  	// The name or description for the Amazon CloudWatch metric of this rule.
    82  	MetricName pulumi.StringOutput `pulumi:"metricName"`
    83  	// The name or description of the rule.
    84  	Name pulumi.StringOutput `pulumi:"name"`
    85  	// The objects to include in a rule (documented below).
    86  	Predicates RateBasedRulePredicateArrayOutput `pulumi:"predicates"`
    87  	// Valid value is IP.
    88  	RateKey pulumi.StringOutput `pulumi:"rateKey"`
    89  	// The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
    90  	RateLimit pulumi.IntOutput `pulumi:"rateLimit"`
    91  	// 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.
    92  	Tags pulumi.StringMapOutput `pulumi:"tags"`
    93  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
    94  	//
    95  	// Deprecated: Please use `tags` instead.
    96  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
    97  }
    98  
    99  // NewRateBasedRule registers a new resource with the given unique name, arguments, and options.
   100  func NewRateBasedRule(ctx *pulumi.Context,
   101  	name string, args *RateBasedRuleArgs, opts ...pulumi.ResourceOption) (*RateBasedRule, error) {
   102  	if args == nil {
   103  		return nil, errors.New("missing one or more required arguments")
   104  	}
   105  
   106  	if args.MetricName == nil {
   107  		return nil, errors.New("invalid value for required argument 'MetricName'")
   108  	}
   109  	if args.RateKey == nil {
   110  		return nil, errors.New("invalid value for required argument 'RateKey'")
   111  	}
   112  	if args.RateLimit == nil {
   113  		return nil, errors.New("invalid value for required argument 'RateLimit'")
   114  	}
   115  	opts = internal.PkgResourceDefaultOpts(opts)
   116  	var resource RateBasedRule
   117  	err := ctx.RegisterResource("aws:wafregional/rateBasedRule:RateBasedRule", name, args, &resource, opts...)
   118  	if err != nil {
   119  		return nil, err
   120  	}
   121  	return &resource, nil
   122  }
   123  
   124  // GetRateBasedRule gets an existing RateBasedRule resource's state with the given name, ID, and optional
   125  // state properties that are used to uniquely qualify the lookup (nil if not required).
   126  func GetRateBasedRule(ctx *pulumi.Context,
   127  	name string, id pulumi.IDInput, state *RateBasedRuleState, opts ...pulumi.ResourceOption) (*RateBasedRule, error) {
   128  	var resource RateBasedRule
   129  	err := ctx.ReadResource("aws:wafregional/rateBasedRule:RateBasedRule", name, id, state, &resource, opts...)
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  	return &resource, nil
   134  }
   135  
   136  // Input properties used for looking up and filtering RateBasedRule resources.
   137  type rateBasedRuleState struct {
   138  	// The ARN of the WAF Regional Rate Based Rule.
   139  	Arn *string `pulumi:"arn"`
   140  	// The name or description for the Amazon CloudWatch metric of this rule.
   141  	MetricName *string `pulumi:"metricName"`
   142  	// The name or description of the rule.
   143  	Name *string `pulumi:"name"`
   144  	// The objects to include in a rule (documented below).
   145  	Predicates []RateBasedRulePredicate `pulumi:"predicates"`
   146  	// Valid value is IP.
   147  	RateKey *string `pulumi:"rateKey"`
   148  	// The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
   149  	RateLimit *int `pulumi:"rateLimit"`
   150  	// 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.
   151  	Tags map[string]string `pulumi:"tags"`
   152  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   153  	//
   154  	// Deprecated: Please use `tags` instead.
   155  	TagsAll map[string]string `pulumi:"tagsAll"`
   156  }
   157  
   158  type RateBasedRuleState struct {
   159  	// The ARN of the WAF Regional Rate Based Rule.
   160  	Arn pulumi.StringPtrInput
   161  	// The name or description for the Amazon CloudWatch metric of this rule.
   162  	MetricName pulumi.StringPtrInput
   163  	// The name or description of the rule.
   164  	Name pulumi.StringPtrInput
   165  	// The objects to include in a rule (documented below).
   166  	Predicates RateBasedRulePredicateArrayInput
   167  	// Valid value is IP.
   168  	RateKey pulumi.StringPtrInput
   169  	// The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
   170  	RateLimit pulumi.IntPtrInput
   171  	// 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.
   172  	Tags pulumi.StringMapInput
   173  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   174  	//
   175  	// Deprecated: Please use `tags` instead.
   176  	TagsAll pulumi.StringMapInput
   177  }
   178  
   179  func (RateBasedRuleState) ElementType() reflect.Type {
   180  	return reflect.TypeOf((*rateBasedRuleState)(nil)).Elem()
   181  }
   182  
   183  type rateBasedRuleArgs struct {
   184  	// The name or description for the Amazon CloudWatch metric of this rule.
   185  	MetricName string `pulumi:"metricName"`
   186  	// The name or description of the rule.
   187  	Name *string `pulumi:"name"`
   188  	// The objects to include in a rule (documented below).
   189  	Predicates []RateBasedRulePredicate `pulumi:"predicates"`
   190  	// Valid value is IP.
   191  	RateKey string `pulumi:"rateKey"`
   192  	// The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
   193  	RateLimit int `pulumi:"rateLimit"`
   194  	// 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.
   195  	Tags map[string]string `pulumi:"tags"`
   196  }
   197  
   198  // The set of arguments for constructing a RateBasedRule resource.
   199  type RateBasedRuleArgs struct {
   200  	// The name or description for the Amazon CloudWatch metric of this rule.
   201  	MetricName pulumi.StringInput
   202  	// The name or description of the rule.
   203  	Name pulumi.StringPtrInput
   204  	// The objects to include in a rule (documented below).
   205  	Predicates RateBasedRulePredicateArrayInput
   206  	// Valid value is IP.
   207  	RateKey pulumi.StringInput
   208  	// The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
   209  	RateLimit pulumi.IntInput
   210  	// 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.
   211  	Tags pulumi.StringMapInput
   212  }
   213  
   214  func (RateBasedRuleArgs) ElementType() reflect.Type {
   215  	return reflect.TypeOf((*rateBasedRuleArgs)(nil)).Elem()
   216  }
   217  
   218  type RateBasedRuleInput interface {
   219  	pulumi.Input
   220  
   221  	ToRateBasedRuleOutput() RateBasedRuleOutput
   222  	ToRateBasedRuleOutputWithContext(ctx context.Context) RateBasedRuleOutput
   223  }
   224  
   225  func (*RateBasedRule) ElementType() reflect.Type {
   226  	return reflect.TypeOf((**RateBasedRule)(nil)).Elem()
   227  }
   228  
   229  func (i *RateBasedRule) ToRateBasedRuleOutput() RateBasedRuleOutput {
   230  	return i.ToRateBasedRuleOutputWithContext(context.Background())
   231  }
   232  
   233  func (i *RateBasedRule) ToRateBasedRuleOutputWithContext(ctx context.Context) RateBasedRuleOutput {
   234  	return pulumi.ToOutputWithContext(ctx, i).(RateBasedRuleOutput)
   235  }
   236  
   237  // RateBasedRuleArrayInput is an input type that accepts RateBasedRuleArray and RateBasedRuleArrayOutput values.
   238  // You can construct a concrete instance of `RateBasedRuleArrayInput` via:
   239  //
   240  //	RateBasedRuleArray{ RateBasedRuleArgs{...} }
   241  type RateBasedRuleArrayInput interface {
   242  	pulumi.Input
   243  
   244  	ToRateBasedRuleArrayOutput() RateBasedRuleArrayOutput
   245  	ToRateBasedRuleArrayOutputWithContext(context.Context) RateBasedRuleArrayOutput
   246  }
   247  
   248  type RateBasedRuleArray []RateBasedRuleInput
   249  
   250  func (RateBasedRuleArray) ElementType() reflect.Type {
   251  	return reflect.TypeOf((*[]*RateBasedRule)(nil)).Elem()
   252  }
   253  
   254  func (i RateBasedRuleArray) ToRateBasedRuleArrayOutput() RateBasedRuleArrayOutput {
   255  	return i.ToRateBasedRuleArrayOutputWithContext(context.Background())
   256  }
   257  
   258  func (i RateBasedRuleArray) ToRateBasedRuleArrayOutputWithContext(ctx context.Context) RateBasedRuleArrayOutput {
   259  	return pulumi.ToOutputWithContext(ctx, i).(RateBasedRuleArrayOutput)
   260  }
   261  
   262  // RateBasedRuleMapInput is an input type that accepts RateBasedRuleMap and RateBasedRuleMapOutput values.
   263  // You can construct a concrete instance of `RateBasedRuleMapInput` via:
   264  //
   265  //	RateBasedRuleMap{ "key": RateBasedRuleArgs{...} }
   266  type RateBasedRuleMapInput interface {
   267  	pulumi.Input
   268  
   269  	ToRateBasedRuleMapOutput() RateBasedRuleMapOutput
   270  	ToRateBasedRuleMapOutputWithContext(context.Context) RateBasedRuleMapOutput
   271  }
   272  
   273  type RateBasedRuleMap map[string]RateBasedRuleInput
   274  
   275  func (RateBasedRuleMap) ElementType() reflect.Type {
   276  	return reflect.TypeOf((*map[string]*RateBasedRule)(nil)).Elem()
   277  }
   278  
   279  func (i RateBasedRuleMap) ToRateBasedRuleMapOutput() RateBasedRuleMapOutput {
   280  	return i.ToRateBasedRuleMapOutputWithContext(context.Background())
   281  }
   282  
   283  func (i RateBasedRuleMap) ToRateBasedRuleMapOutputWithContext(ctx context.Context) RateBasedRuleMapOutput {
   284  	return pulumi.ToOutputWithContext(ctx, i).(RateBasedRuleMapOutput)
   285  }
   286  
   287  type RateBasedRuleOutput struct{ *pulumi.OutputState }
   288  
   289  func (RateBasedRuleOutput) ElementType() reflect.Type {
   290  	return reflect.TypeOf((**RateBasedRule)(nil)).Elem()
   291  }
   292  
   293  func (o RateBasedRuleOutput) ToRateBasedRuleOutput() RateBasedRuleOutput {
   294  	return o
   295  }
   296  
   297  func (o RateBasedRuleOutput) ToRateBasedRuleOutputWithContext(ctx context.Context) RateBasedRuleOutput {
   298  	return o
   299  }
   300  
   301  // The ARN of the WAF Regional Rate Based Rule.
   302  func (o RateBasedRuleOutput) Arn() pulumi.StringOutput {
   303  	return o.ApplyT(func(v *RateBasedRule) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   304  }
   305  
   306  // The name or description for the Amazon CloudWatch metric of this rule.
   307  func (o RateBasedRuleOutput) MetricName() pulumi.StringOutput {
   308  	return o.ApplyT(func(v *RateBasedRule) pulumi.StringOutput { return v.MetricName }).(pulumi.StringOutput)
   309  }
   310  
   311  // The name or description of the rule.
   312  func (o RateBasedRuleOutput) Name() pulumi.StringOutput {
   313  	return o.ApplyT(func(v *RateBasedRule) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   314  }
   315  
   316  // The objects to include in a rule (documented below).
   317  func (o RateBasedRuleOutput) Predicates() RateBasedRulePredicateArrayOutput {
   318  	return o.ApplyT(func(v *RateBasedRule) RateBasedRulePredicateArrayOutput { return v.Predicates }).(RateBasedRulePredicateArrayOutput)
   319  }
   320  
   321  // Valid value is IP.
   322  func (o RateBasedRuleOutput) RateKey() pulumi.StringOutput {
   323  	return o.ApplyT(func(v *RateBasedRule) pulumi.StringOutput { return v.RateKey }).(pulumi.StringOutput)
   324  }
   325  
   326  // The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100.
   327  func (o RateBasedRuleOutput) RateLimit() pulumi.IntOutput {
   328  	return o.ApplyT(func(v *RateBasedRule) pulumi.IntOutput { return v.RateLimit }).(pulumi.IntOutput)
   329  }
   330  
   331  // 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.
   332  func (o RateBasedRuleOutput) Tags() pulumi.StringMapOutput {
   333  	return o.ApplyT(func(v *RateBasedRule) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   334  }
   335  
   336  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   337  //
   338  // Deprecated: Please use `tags` instead.
   339  func (o RateBasedRuleOutput) TagsAll() pulumi.StringMapOutput {
   340  	return o.ApplyT(func(v *RateBasedRule) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   341  }
   342  
   343  type RateBasedRuleArrayOutput struct{ *pulumi.OutputState }
   344  
   345  func (RateBasedRuleArrayOutput) ElementType() reflect.Type {
   346  	return reflect.TypeOf((*[]*RateBasedRule)(nil)).Elem()
   347  }
   348  
   349  func (o RateBasedRuleArrayOutput) ToRateBasedRuleArrayOutput() RateBasedRuleArrayOutput {
   350  	return o
   351  }
   352  
   353  func (o RateBasedRuleArrayOutput) ToRateBasedRuleArrayOutputWithContext(ctx context.Context) RateBasedRuleArrayOutput {
   354  	return o
   355  }
   356  
   357  func (o RateBasedRuleArrayOutput) Index(i pulumi.IntInput) RateBasedRuleOutput {
   358  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RateBasedRule {
   359  		return vs[0].([]*RateBasedRule)[vs[1].(int)]
   360  	}).(RateBasedRuleOutput)
   361  }
   362  
   363  type RateBasedRuleMapOutput struct{ *pulumi.OutputState }
   364  
   365  func (RateBasedRuleMapOutput) ElementType() reflect.Type {
   366  	return reflect.TypeOf((*map[string]*RateBasedRule)(nil)).Elem()
   367  }
   368  
   369  func (o RateBasedRuleMapOutput) ToRateBasedRuleMapOutput() RateBasedRuleMapOutput {
   370  	return o
   371  }
   372  
   373  func (o RateBasedRuleMapOutput) ToRateBasedRuleMapOutputWithContext(ctx context.Context) RateBasedRuleMapOutput {
   374  	return o
   375  }
   376  
   377  func (o RateBasedRuleMapOutput) MapIndex(k pulumi.StringInput) RateBasedRuleOutput {
   378  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RateBasedRule {
   379  		return vs[0].(map[string]*RateBasedRule)[vs[1].(string)]
   380  	}).(RateBasedRuleOutput)
   381  }
   382  
   383  func init() {
   384  	pulumi.RegisterInputType(reflect.TypeOf((*RateBasedRuleInput)(nil)).Elem(), &RateBasedRule{})
   385  	pulumi.RegisterInputType(reflect.TypeOf((*RateBasedRuleArrayInput)(nil)).Elem(), RateBasedRuleArray{})
   386  	pulumi.RegisterInputType(reflect.TypeOf((*RateBasedRuleMapInput)(nil)).Elem(), RateBasedRuleMap{})
   387  	pulumi.RegisterOutputType(RateBasedRuleOutput{})
   388  	pulumi.RegisterOutputType(RateBasedRuleArrayOutput{})
   389  	pulumi.RegisterOutputType(RateBasedRuleMapOutput{})
   390  }