github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/wafregional/rule.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 an WAF Regional Rule Resource for use with Application Load Balancer.
    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.NewRule(ctx, "wafrule", &wafregional.RuleArgs{
    45  //				Name:       pulumi.String("tfWAFRule"),
    46  //				MetricName: pulumi.String("tfWAFRule"),
    47  //				Predicates: wafregional.RulePredicateArray{
    48  //					&wafregional.RulePredicateArgs{
    49  //						Type:    pulumi.String("IPMatch"),
    50  //						DataId:  ipset.ID(),
    51  //						Negated: pulumi.Bool(false),
    52  //					},
    53  //				},
    54  //			})
    55  //			if err != nil {
    56  //				return err
    57  //			}
    58  //			return nil
    59  //		})
    60  //	}
    61  //
    62  // ```
    63  // <!--End PulumiCodeChooser -->
    64  //
    65  // ## Nested Fields
    66  //
    67  // ### `predicate`
    68  //
    69  // See the [WAF Documentation](https://docs.aws.amazon.com/waf/latest/APIReference/API_Predicate.html) for more information.
    70  //
    71  // #### Arguments
    72  //
    73  // * `type` - (Required) The type of predicate in a rule. Valid values: `ByteMatch`, `GeoMatch`, `IPMatch`, `RegexMatch`, `SizeConstraint`, `SqlInjectionMatch`, or `XssMatch`
    74  // * `dataId` - (Required) The unique identifier of a predicate, such as the ID of a `ByteMatchSet` or `IPSet`.
    75  // * `negated` - (Required) Whether to use the settings or the negated settings that you specified in the objects.
    76  //
    77  // ## Import
    78  //
    79  // Using `pulumi import`, import WAF Regional Rule using the id. For example:
    80  //
    81  // ```sh
    82  // $ pulumi import aws:wafregional/rule:Rule wafrule a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc
    83  // ```
    84  type Rule struct {
    85  	pulumi.CustomResourceState
    86  
    87  	// The ARN of the WAF Regional Rule.
    88  	Arn pulumi.StringOutput `pulumi:"arn"`
    89  	// The name or description for the Amazon CloudWatch metric of this rule.
    90  	MetricName pulumi.StringOutput `pulumi:"metricName"`
    91  	// The name or description of the rule.
    92  	Name pulumi.StringOutput `pulumi:"name"`
    93  	// The objects to include in a rule (documented below).
    94  	Predicates RulePredicateArrayOutput `pulumi:"predicates"`
    95  	// 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.
    96  	Tags pulumi.StringMapOutput `pulumi:"tags"`
    97  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
    98  	//
    99  	// Deprecated: Please use `tags` instead.
   100  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   101  }
   102  
   103  // NewRule registers a new resource with the given unique name, arguments, and options.
   104  func NewRule(ctx *pulumi.Context,
   105  	name string, args *RuleArgs, opts ...pulumi.ResourceOption) (*Rule, error) {
   106  	if args == nil {
   107  		return nil, errors.New("missing one or more required arguments")
   108  	}
   109  
   110  	if args.MetricName == nil {
   111  		return nil, errors.New("invalid value for required argument 'MetricName'")
   112  	}
   113  	opts = internal.PkgResourceDefaultOpts(opts)
   114  	var resource Rule
   115  	err := ctx.RegisterResource("aws:wafregional/rule:Rule", name, args, &resource, opts...)
   116  	if err != nil {
   117  		return nil, err
   118  	}
   119  	return &resource, nil
   120  }
   121  
   122  // GetRule gets an existing Rule resource's state with the given name, ID, and optional
   123  // state properties that are used to uniquely qualify the lookup (nil if not required).
   124  func GetRule(ctx *pulumi.Context,
   125  	name string, id pulumi.IDInput, state *RuleState, opts ...pulumi.ResourceOption) (*Rule, error) {
   126  	var resource Rule
   127  	err := ctx.ReadResource("aws:wafregional/rule:Rule", name, id, state, &resource, opts...)
   128  	if err != nil {
   129  		return nil, err
   130  	}
   131  	return &resource, nil
   132  }
   133  
   134  // Input properties used for looking up and filtering Rule resources.
   135  type ruleState struct {
   136  	// The ARN of the WAF Regional Rule.
   137  	Arn *string `pulumi:"arn"`
   138  	// The name or description for the Amazon CloudWatch metric of this rule.
   139  	MetricName *string `pulumi:"metricName"`
   140  	// The name or description of the rule.
   141  	Name *string `pulumi:"name"`
   142  	// The objects to include in a rule (documented below).
   143  	Predicates []RulePredicate `pulumi:"predicates"`
   144  	// 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.
   145  	Tags map[string]string `pulumi:"tags"`
   146  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   147  	//
   148  	// Deprecated: Please use `tags` instead.
   149  	TagsAll map[string]string `pulumi:"tagsAll"`
   150  }
   151  
   152  type RuleState struct {
   153  	// The ARN of the WAF Regional Rule.
   154  	Arn pulumi.StringPtrInput
   155  	// The name or description for the Amazon CloudWatch metric of this rule.
   156  	MetricName pulumi.StringPtrInput
   157  	// The name or description of the rule.
   158  	Name pulumi.StringPtrInput
   159  	// The objects to include in a rule (documented below).
   160  	Predicates RulePredicateArrayInput
   161  	// 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.
   162  	Tags pulumi.StringMapInput
   163  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   164  	//
   165  	// Deprecated: Please use `tags` instead.
   166  	TagsAll pulumi.StringMapInput
   167  }
   168  
   169  func (RuleState) ElementType() reflect.Type {
   170  	return reflect.TypeOf((*ruleState)(nil)).Elem()
   171  }
   172  
   173  type ruleArgs struct {
   174  	// The name or description for the Amazon CloudWatch metric of this rule.
   175  	MetricName string `pulumi:"metricName"`
   176  	// The name or description of the rule.
   177  	Name *string `pulumi:"name"`
   178  	// The objects to include in a rule (documented below).
   179  	Predicates []RulePredicate `pulumi:"predicates"`
   180  	// 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.
   181  	Tags map[string]string `pulumi:"tags"`
   182  }
   183  
   184  // The set of arguments for constructing a Rule resource.
   185  type RuleArgs struct {
   186  	// The name or description for the Amazon CloudWatch metric of this rule.
   187  	MetricName pulumi.StringInput
   188  	// The name or description of the rule.
   189  	Name pulumi.StringPtrInput
   190  	// The objects to include in a rule (documented below).
   191  	Predicates RulePredicateArrayInput
   192  	// 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.
   193  	Tags pulumi.StringMapInput
   194  }
   195  
   196  func (RuleArgs) ElementType() reflect.Type {
   197  	return reflect.TypeOf((*ruleArgs)(nil)).Elem()
   198  }
   199  
   200  type RuleInput interface {
   201  	pulumi.Input
   202  
   203  	ToRuleOutput() RuleOutput
   204  	ToRuleOutputWithContext(ctx context.Context) RuleOutput
   205  }
   206  
   207  func (*Rule) ElementType() reflect.Type {
   208  	return reflect.TypeOf((**Rule)(nil)).Elem()
   209  }
   210  
   211  func (i *Rule) ToRuleOutput() RuleOutput {
   212  	return i.ToRuleOutputWithContext(context.Background())
   213  }
   214  
   215  func (i *Rule) ToRuleOutputWithContext(ctx context.Context) RuleOutput {
   216  	return pulumi.ToOutputWithContext(ctx, i).(RuleOutput)
   217  }
   218  
   219  // RuleArrayInput is an input type that accepts RuleArray and RuleArrayOutput values.
   220  // You can construct a concrete instance of `RuleArrayInput` via:
   221  //
   222  //	RuleArray{ RuleArgs{...} }
   223  type RuleArrayInput interface {
   224  	pulumi.Input
   225  
   226  	ToRuleArrayOutput() RuleArrayOutput
   227  	ToRuleArrayOutputWithContext(context.Context) RuleArrayOutput
   228  }
   229  
   230  type RuleArray []RuleInput
   231  
   232  func (RuleArray) ElementType() reflect.Type {
   233  	return reflect.TypeOf((*[]*Rule)(nil)).Elem()
   234  }
   235  
   236  func (i RuleArray) ToRuleArrayOutput() RuleArrayOutput {
   237  	return i.ToRuleArrayOutputWithContext(context.Background())
   238  }
   239  
   240  func (i RuleArray) ToRuleArrayOutputWithContext(ctx context.Context) RuleArrayOutput {
   241  	return pulumi.ToOutputWithContext(ctx, i).(RuleArrayOutput)
   242  }
   243  
   244  // RuleMapInput is an input type that accepts RuleMap and RuleMapOutput values.
   245  // You can construct a concrete instance of `RuleMapInput` via:
   246  //
   247  //	RuleMap{ "key": RuleArgs{...} }
   248  type RuleMapInput interface {
   249  	pulumi.Input
   250  
   251  	ToRuleMapOutput() RuleMapOutput
   252  	ToRuleMapOutputWithContext(context.Context) RuleMapOutput
   253  }
   254  
   255  type RuleMap map[string]RuleInput
   256  
   257  func (RuleMap) ElementType() reflect.Type {
   258  	return reflect.TypeOf((*map[string]*Rule)(nil)).Elem()
   259  }
   260  
   261  func (i RuleMap) ToRuleMapOutput() RuleMapOutput {
   262  	return i.ToRuleMapOutputWithContext(context.Background())
   263  }
   264  
   265  func (i RuleMap) ToRuleMapOutputWithContext(ctx context.Context) RuleMapOutput {
   266  	return pulumi.ToOutputWithContext(ctx, i).(RuleMapOutput)
   267  }
   268  
   269  type RuleOutput struct{ *pulumi.OutputState }
   270  
   271  func (RuleOutput) ElementType() reflect.Type {
   272  	return reflect.TypeOf((**Rule)(nil)).Elem()
   273  }
   274  
   275  func (o RuleOutput) ToRuleOutput() RuleOutput {
   276  	return o
   277  }
   278  
   279  func (o RuleOutput) ToRuleOutputWithContext(ctx context.Context) RuleOutput {
   280  	return o
   281  }
   282  
   283  // The ARN of the WAF Regional Rule.
   284  func (o RuleOutput) Arn() pulumi.StringOutput {
   285  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   286  }
   287  
   288  // The name or description for the Amazon CloudWatch metric of this rule.
   289  func (o RuleOutput) MetricName() pulumi.StringOutput {
   290  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.MetricName }).(pulumi.StringOutput)
   291  }
   292  
   293  // The name or description of the rule.
   294  func (o RuleOutput) Name() pulumi.StringOutput {
   295  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   296  }
   297  
   298  // The objects to include in a rule (documented below).
   299  func (o RuleOutput) Predicates() RulePredicateArrayOutput {
   300  	return o.ApplyT(func(v *Rule) RulePredicateArrayOutput { return v.Predicates }).(RulePredicateArrayOutput)
   301  }
   302  
   303  // 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.
   304  func (o RuleOutput) Tags() pulumi.StringMapOutput {
   305  	return o.ApplyT(func(v *Rule) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   306  }
   307  
   308  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   309  //
   310  // Deprecated: Please use `tags` instead.
   311  func (o RuleOutput) TagsAll() pulumi.StringMapOutput {
   312  	return o.ApplyT(func(v *Rule) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   313  }
   314  
   315  type RuleArrayOutput struct{ *pulumi.OutputState }
   316  
   317  func (RuleArrayOutput) ElementType() reflect.Type {
   318  	return reflect.TypeOf((*[]*Rule)(nil)).Elem()
   319  }
   320  
   321  func (o RuleArrayOutput) ToRuleArrayOutput() RuleArrayOutput {
   322  	return o
   323  }
   324  
   325  func (o RuleArrayOutput) ToRuleArrayOutputWithContext(ctx context.Context) RuleArrayOutput {
   326  	return o
   327  }
   328  
   329  func (o RuleArrayOutput) Index(i pulumi.IntInput) RuleOutput {
   330  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Rule {
   331  		return vs[0].([]*Rule)[vs[1].(int)]
   332  	}).(RuleOutput)
   333  }
   334  
   335  type RuleMapOutput struct{ *pulumi.OutputState }
   336  
   337  func (RuleMapOutput) ElementType() reflect.Type {
   338  	return reflect.TypeOf((*map[string]*Rule)(nil)).Elem()
   339  }
   340  
   341  func (o RuleMapOutput) ToRuleMapOutput() RuleMapOutput {
   342  	return o
   343  }
   344  
   345  func (o RuleMapOutput) ToRuleMapOutputWithContext(ctx context.Context) RuleMapOutput {
   346  	return o
   347  }
   348  
   349  func (o RuleMapOutput) MapIndex(k pulumi.StringInput) RuleOutput {
   350  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Rule {
   351  		return vs[0].(map[string]*Rule)[vs[1].(string)]
   352  	}).(RuleOutput)
   353  }
   354  
   355  func init() {
   356  	pulumi.RegisterInputType(reflect.TypeOf((*RuleInput)(nil)).Elem(), &Rule{})
   357  	pulumi.RegisterInputType(reflect.TypeOf((*RuleArrayInput)(nil)).Elem(), RuleArray{})
   358  	pulumi.RegisterInputType(reflect.TypeOf((*RuleMapInput)(nil)).Elem(), RuleMap{})
   359  	pulumi.RegisterOutputType(RuleOutput{})
   360  	pulumi.RegisterOutputType(RuleArrayOutput{})
   361  	pulumi.RegisterOutputType(RuleMapOutput{})
   362  }