github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/wafregional/webAcl.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 Regional Web ACL Resource for use with Application Load Balancer. 16 // 17 // ## Example Usage 18 // 19 // ### Regular Rule 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // ipset, err := wafregional.NewIpSet(ctx, "ipset", &wafregional.IpSetArgs{ 35 // Name: pulumi.String("tfIPSet"), 36 // IpSetDescriptors: wafregional.IpSetIpSetDescriptorArray{ 37 // &wafregional.IpSetIpSetDescriptorArgs{ 38 // Type: pulumi.String("IPV4"), 39 // Value: pulumi.String("192.0.7.0/24"), 40 // }, 41 // }, 42 // }) 43 // if err != nil { 44 // return err 45 // } 46 // wafrule, err := wafregional.NewRule(ctx, "wafrule", &wafregional.RuleArgs{ 47 // Name: pulumi.String("tfWAFRule"), 48 // MetricName: pulumi.String("tfWAFRule"), 49 // Predicates: wafregional.RulePredicateArray{ 50 // &wafregional.RulePredicateArgs{ 51 // DataId: ipset.ID(), 52 // Negated: pulumi.Bool(false), 53 // Type: pulumi.String("IPMatch"), 54 // }, 55 // }, 56 // }) 57 // if err != nil { 58 // return err 59 // } 60 // _, err = wafregional.NewWebAcl(ctx, "wafacl", &wafregional.WebAclArgs{ 61 // Name: pulumi.String("tfWebACL"), 62 // MetricName: pulumi.String("tfWebACL"), 63 // DefaultAction: &wafregional.WebAclDefaultActionArgs{ 64 // Type: pulumi.String("ALLOW"), 65 // }, 66 // Rules: wafregional.WebAclRuleArray{ 67 // &wafregional.WebAclRuleArgs{ 68 // Action: &wafregional.WebAclRuleActionArgs{ 69 // Type: pulumi.String("BLOCK"), 70 // }, 71 // Priority: pulumi.Int(1), 72 // RuleId: wafrule.ID(), 73 // Type: pulumi.String("REGULAR"), 74 // }, 75 // }, 76 // }) 77 // if err != nil { 78 // return err 79 // } 80 // return nil 81 // }) 82 // } 83 // 84 // ``` 85 // <!--End PulumiCodeChooser --> 86 // 87 // ### Group Rule 88 // 89 // <!--Start PulumiCodeChooser --> 90 // ```go 91 // package main 92 // 93 // import ( 94 // 95 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional" 96 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 97 // 98 // ) 99 // 100 // func main() { 101 // pulumi.Run(func(ctx *pulumi.Context) error { 102 // _, err := wafregional.NewWebAcl(ctx, "example", &wafregional.WebAclArgs{ 103 // Name: pulumi.String("example"), 104 // MetricName: pulumi.String("example"), 105 // DefaultAction: &wafregional.WebAclDefaultActionArgs{ 106 // Type: pulumi.String("ALLOW"), 107 // }, 108 // Rules: wafregional.WebAclRuleArray{ 109 // &wafregional.WebAclRuleArgs{ 110 // Priority: pulumi.Int(1), 111 // RuleId: pulumi.Any(exampleAwsWafregionalRuleGroup.Id), 112 // Type: pulumi.String("GROUP"), 113 // OverrideAction: &wafregional.WebAclRuleOverrideActionArgs{ 114 // Type: pulumi.String("NONE"), 115 // }, 116 // }, 117 // }, 118 // }) 119 // if err != nil { 120 // return err 121 // } 122 // return nil 123 // }) 124 // } 125 // 126 // ``` 127 // <!--End PulumiCodeChooser --> 128 // 129 // ### Logging 130 // 131 // > *NOTE:* The Kinesis Firehose Delivery Stream name must begin with `aws-waf-logs-`. See the [AWS WAF Developer Guide](https://docs.aws.amazon.com/waf/latest/developerguide/logging.html) for more information about enabling WAF logging. 132 // 133 // <!--Start PulumiCodeChooser --> 134 // ```go 135 // package main 136 // 137 // import ( 138 // 139 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional" 140 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 141 // 142 // ) 143 // 144 // func main() { 145 // pulumi.Run(func(ctx *pulumi.Context) error { 146 // _, err := wafregional.NewWebAcl(ctx, "example", &wafregional.WebAclArgs{ 147 // LoggingConfiguration: &wafregional.WebAclLoggingConfigurationArgs{ 148 // LogDestination: pulumi.Any(exampleAwsKinesisFirehoseDeliveryStream.Arn), 149 // RedactedFields: &wafregional.WebAclLoggingConfigurationRedactedFieldsArgs{ 150 // FieldToMatches: wafregional.WebAclLoggingConfigurationRedactedFieldsFieldToMatchArray{ 151 // &wafregional.WebAclLoggingConfigurationRedactedFieldsFieldToMatchArgs{ 152 // Type: pulumi.String("URI"), 153 // }, 154 // &wafregional.WebAclLoggingConfigurationRedactedFieldsFieldToMatchArgs{ 155 // Data: pulumi.String("referer"), 156 // Type: pulumi.String("HEADER"), 157 // }, 158 // }, 159 // }, 160 // }, 161 // }) 162 // if err != nil { 163 // return err 164 // } 165 // return nil 166 // }) 167 // } 168 // 169 // ``` 170 // <!--End PulumiCodeChooser --> 171 // 172 // ## Import 173 // 174 // Using `pulumi import`, import WAF Regional Web ACL using the id. For example: 175 // 176 // ```sh 177 // $ pulumi import aws:wafregional/webAcl:WebAcl wafacl a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc 178 // ``` 179 type WebAcl struct { 180 pulumi.CustomResourceState 181 182 // Amazon Resource Name (ARN) of the WAF Regional WebACL. 183 Arn pulumi.StringOutput `pulumi:"arn"` 184 // The action that you want AWS WAF Regional to take when a request doesn't match the criteria in any of the rules that are associated with the web ACL. 185 DefaultAction WebAclDefaultActionOutput `pulumi:"defaultAction"` 186 // Configuration block to enable WAF logging. Detailed below. 187 LoggingConfiguration WebAclLoggingConfigurationPtrOutput `pulumi:"loggingConfiguration"` 188 // The name or description for the Amazon CloudWatch metric of this web ACL. 189 MetricName pulumi.StringOutput `pulumi:"metricName"` 190 // The name or description of the web ACL. 191 Name pulumi.StringOutput `pulumi:"name"` 192 // Set of configuration blocks containing rules for the web ACL. Detailed below. 193 Rules WebAclRuleArrayOutput `pulumi:"rules"` 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 pulumi.StringMapOutput `pulumi:"tags"` 196 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 197 // 198 // Deprecated: Please use `tags` instead. 199 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 200 } 201 202 // NewWebAcl registers a new resource with the given unique name, arguments, and options. 203 func NewWebAcl(ctx *pulumi.Context, 204 name string, args *WebAclArgs, opts ...pulumi.ResourceOption) (*WebAcl, error) { 205 if args == nil { 206 return nil, errors.New("missing one or more required arguments") 207 } 208 209 if args.DefaultAction == nil { 210 return nil, errors.New("invalid value for required argument 'DefaultAction'") 211 } 212 if args.MetricName == nil { 213 return nil, errors.New("invalid value for required argument 'MetricName'") 214 } 215 opts = internal.PkgResourceDefaultOpts(opts) 216 var resource WebAcl 217 err := ctx.RegisterResource("aws:wafregional/webAcl:WebAcl", name, args, &resource, opts...) 218 if err != nil { 219 return nil, err 220 } 221 return &resource, nil 222 } 223 224 // GetWebAcl gets an existing WebAcl resource's state with the given name, ID, and optional 225 // state properties that are used to uniquely qualify the lookup (nil if not required). 226 func GetWebAcl(ctx *pulumi.Context, 227 name string, id pulumi.IDInput, state *WebAclState, opts ...pulumi.ResourceOption) (*WebAcl, error) { 228 var resource WebAcl 229 err := ctx.ReadResource("aws:wafregional/webAcl:WebAcl", name, id, state, &resource, opts...) 230 if err != nil { 231 return nil, err 232 } 233 return &resource, nil 234 } 235 236 // Input properties used for looking up and filtering WebAcl resources. 237 type webAclState struct { 238 // Amazon Resource Name (ARN) of the WAF Regional WebACL. 239 Arn *string `pulumi:"arn"` 240 // The action that you want AWS WAF Regional to take when a request doesn't match the criteria in any of the rules that are associated with the web ACL. 241 DefaultAction *WebAclDefaultAction `pulumi:"defaultAction"` 242 // Configuration block to enable WAF logging. Detailed below. 243 LoggingConfiguration *WebAclLoggingConfiguration `pulumi:"loggingConfiguration"` 244 // The name or description for the Amazon CloudWatch metric of this web ACL. 245 MetricName *string `pulumi:"metricName"` 246 // The name or description of the web ACL. 247 Name *string `pulumi:"name"` 248 // Set of configuration blocks containing rules for the web ACL. Detailed below. 249 Rules []WebAclRule `pulumi:"rules"` 250 // 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. 251 Tags map[string]string `pulumi:"tags"` 252 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 253 // 254 // Deprecated: Please use `tags` instead. 255 TagsAll map[string]string `pulumi:"tagsAll"` 256 } 257 258 type WebAclState struct { 259 // Amazon Resource Name (ARN) of the WAF Regional WebACL. 260 Arn pulumi.StringPtrInput 261 // The action that you want AWS WAF Regional to take when a request doesn't match the criteria in any of the rules that are associated with the web ACL. 262 DefaultAction WebAclDefaultActionPtrInput 263 // Configuration block to enable WAF logging. Detailed below. 264 LoggingConfiguration WebAclLoggingConfigurationPtrInput 265 // The name or description for the Amazon CloudWatch metric of this web ACL. 266 MetricName pulumi.StringPtrInput 267 // The name or description of the web ACL. 268 Name pulumi.StringPtrInput 269 // Set of configuration blocks containing rules for the web ACL. Detailed below. 270 Rules WebAclRuleArrayInput 271 // 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. 272 Tags pulumi.StringMapInput 273 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 274 // 275 // Deprecated: Please use `tags` instead. 276 TagsAll pulumi.StringMapInput 277 } 278 279 func (WebAclState) ElementType() reflect.Type { 280 return reflect.TypeOf((*webAclState)(nil)).Elem() 281 } 282 283 type webAclArgs struct { 284 // The action that you want AWS WAF Regional to take when a request doesn't match the criteria in any of the rules that are associated with the web ACL. 285 DefaultAction WebAclDefaultAction `pulumi:"defaultAction"` 286 // Configuration block to enable WAF logging. Detailed below. 287 LoggingConfiguration *WebAclLoggingConfiguration `pulumi:"loggingConfiguration"` 288 // The name or description for the Amazon CloudWatch metric of this web ACL. 289 MetricName string `pulumi:"metricName"` 290 // The name or description of the web ACL. 291 Name *string `pulumi:"name"` 292 // Set of configuration blocks containing rules for the web ACL. Detailed below. 293 Rules []WebAclRule `pulumi:"rules"` 294 // 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. 295 Tags map[string]string `pulumi:"tags"` 296 } 297 298 // The set of arguments for constructing a WebAcl resource. 299 type WebAclArgs struct { 300 // The action that you want AWS WAF Regional to take when a request doesn't match the criteria in any of the rules that are associated with the web ACL. 301 DefaultAction WebAclDefaultActionInput 302 // Configuration block to enable WAF logging. Detailed below. 303 LoggingConfiguration WebAclLoggingConfigurationPtrInput 304 // The name or description for the Amazon CloudWatch metric of this web ACL. 305 MetricName pulumi.StringInput 306 // The name or description of the web ACL. 307 Name pulumi.StringPtrInput 308 // Set of configuration blocks containing rules for the web ACL. Detailed below. 309 Rules WebAclRuleArrayInput 310 // 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. 311 Tags pulumi.StringMapInput 312 } 313 314 func (WebAclArgs) ElementType() reflect.Type { 315 return reflect.TypeOf((*webAclArgs)(nil)).Elem() 316 } 317 318 type WebAclInput interface { 319 pulumi.Input 320 321 ToWebAclOutput() WebAclOutput 322 ToWebAclOutputWithContext(ctx context.Context) WebAclOutput 323 } 324 325 func (*WebAcl) ElementType() reflect.Type { 326 return reflect.TypeOf((**WebAcl)(nil)).Elem() 327 } 328 329 func (i *WebAcl) ToWebAclOutput() WebAclOutput { 330 return i.ToWebAclOutputWithContext(context.Background()) 331 } 332 333 func (i *WebAcl) ToWebAclOutputWithContext(ctx context.Context) WebAclOutput { 334 return pulumi.ToOutputWithContext(ctx, i).(WebAclOutput) 335 } 336 337 // WebAclArrayInput is an input type that accepts WebAclArray and WebAclArrayOutput values. 338 // You can construct a concrete instance of `WebAclArrayInput` via: 339 // 340 // WebAclArray{ WebAclArgs{...} } 341 type WebAclArrayInput interface { 342 pulumi.Input 343 344 ToWebAclArrayOutput() WebAclArrayOutput 345 ToWebAclArrayOutputWithContext(context.Context) WebAclArrayOutput 346 } 347 348 type WebAclArray []WebAclInput 349 350 func (WebAclArray) ElementType() reflect.Type { 351 return reflect.TypeOf((*[]*WebAcl)(nil)).Elem() 352 } 353 354 func (i WebAclArray) ToWebAclArrayOutput() WebAclArrayOutput { 355 return i.ToWebAclArrayOutputWithContext(context.Background()) 356 } 357 358 func (i WebAclArray) ToWebAclArrayOutputWithContext(ctx context.Context) WebAclArrayOutput { 359 return pulumi.ToOutputWithContext(ctx, i).(WebAclArrayOutput) 360 } 361 362 // WebAclMapInput is an input type that accepts WebAclMap and WebAclMapOutput values. 363 // You can construct a concrete instance of `WebAclMapInput` via: 364 // 365 // WebAclMap{ "key": WebAclArgs{...} } 366 type WebAclMapInput interface { 367 pulumi.Input 368 369 ToWebAclMapOutput() WebAclMapOutput 370 ToWebAclMapOutputWithContext(context.Context) WebAclMapOutput 371 } 372 373 type WebAclMap map[string]WebAclInput 374 375 func (WebAclMap) ElementType() reflect.Type { 376 return reflect.TypeOf((*map[string]*WebAcl)(nil)).Elem() 377 } 378 379 func (i WebAclMap) ToWebAclMapOutput() WebAclMapOutput { 380 return i.ToWebAclMapOutputWithContext(context.Background()) 381 } 382 383 func (i WebAclMap) ToWebAclMapOutputWithContext(ctx context.Context) WebAclMapOutput { 384 return pulumi.ToOutputWithContext(ctx, i).(WebAclMapOutput) 385 } 386 387 type WebAclOutput struct{ *pulumi.OutputState } 388 389 func (WebAclOutput) ElementType() reflect.Type { 390 return reflect.TypeOf((**WebAcl)(nil)).Elem() 391 } 392 393 func (o WebAclOutput) ToWebAclOutput() WebAclOutput { 394 return o 395 } 396 397 func (o WebAclOutput) ToWebAclOutputWithContext(ctx context.Context) WebAclOutput { 398 return o 399 } 400 401 // Amazon Resource Name (ARN) of the WAF Regional WebACL. 402 func (o WebAclOutput) Arn() pulumi.StringOutput { 403 return o.ApplyT(func(v *WebAcl) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 404 } 405 406 // The action that you want AWS WAF Regional to take when a request doesn't match the criteria in any of the rules that are associated with the web ACL. 407 func (o WebAclOutput) DefaultAction() WebAclDefaultActionOutput { 408 return o.ApplyT(func(v *WebAcl) WebAclDefaultActionOutput { return v.DefaultAction }).(WebAclDefaultActionOutput) 409 } 410 411 // Configuration block to enable WAF logging. Detailed below. 412 func (o WebAclOutput) LoggingConfiguration() WebAclLoggingConfigurationPtrOutput { 413 return o.ApplyT(func(v *WebAcl) WebAclLoggingConfigurationPtrOutput { return v.LoggingConfiguration }).(WebAclLoggingConfigurationPtrOutput) 414 } 415 416 // The name or description for the Amazon CloudWatch metric of this web ACL. 417 func (o WebAclOutput) MetricName() pulumi.StringOutput { 418 return o.ApplyT(func(v *WebAcl) pulumi.StringOutput { return v.MetricName }).(pulumi.StringOutput) 419 } 420 421 // The name or description of the web ACL. 422 func (o WebAclOutput) Name() pulumi.StringOutput { 423 return o.ApplyT(func(v *WebAcl) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 424 } 425 426 // Set of configuration blocks containing rules for the web ACL. Detailed below. 427 func (o WebAclOutput) Rules() WebAclRuleArrayOutput { 428 return o.ApplyT(func(v *WebAcl) WebAclRuleArrayOutput { return v.Rules }).(WebAclRuleArrayOutput) 429 } 430 431 // 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. 432 func (o WebAclOutput) Tags() pulumi.StringMapOutput { 433 return o.ApplyT(func(v *WebAcl) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 434 } 435 436 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 437 // 438 // Deprecated: Please use `tags` instead. 439 func (o WebAclOutput) TagsAll() pulumi.StringMapOutput { 440 return o.ApplyT(func(v *WebAcl) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 441 } 442 443 type WebAclArrayOutput struct{ *pulumi.OutputState } 444 445 func (WebAclArrayOutput) ElementType() reflect.Type { 446 return reflect.TypeOf((*[]*WebAcl)(nil)).Elem() 447 } 448 449 func (o WebAclArrayOutput) ToWebAclArrayOutput() WebAclArrayOutput { 450 return o 451 } 452 453 func (o WebAclArrayOutput) ToWebAclArrayOutputWithContext(ctx context.Context) WebAclArrayOutput { 454 return o 455 } 456 457 func (o WebAclArrayOutput) Index(i pulumi.IntInput) WebAclOutput { 458 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *WebAcl { 459 return vs[0].([]*WebAcl)[vs[1].(int)] 460 }).(WebAclOutput) 461 } 462 463 type WebAclMapOutput struct{ *pulumi.OutputState } 464 465 func (WebAclMapOutput) ElementType() reflect.Type { 466 return reflect.TypeOf((*map[string]*WebAcl)(nil)).Elem() 467 } 468 469 func (o WebAclMapOutput) ToWebAclMapOutput() WebAclMapOutput { 470 return o 471 } 472 473 func (o WebAclMapOutput) ToWebAclMapOutputWithContext(ctx context.Context) WebAclMapOutput { 474 return o 475 } 476 477 func (o WebAclMapOutput) MapIndex(k pulumi.StringInput) WebAclOutput { 478 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *WebAcl { 479 return vs[0].(map[string]*WebAcl)[vs[1].(string)] 480 }).(WebAclOutput) 481 } 482 483 func init() { 484 pulumi.RegisterInputType(reflect.TypeOf((*WebAclInput)(nil)).Elem(), &WebAcl{}) 485 pulumi.RegisterInputType(reflect.TypeOf((*WebAclArrayInput)(nil)).Elem(), WebAclArray{}) 486 pulumi.RegisterInputType(reflect.TypeOf((*WebAclMapInput)(nil)).Elem(), WebAclMap{}) 487 pulumi.RegisterOutputType(WebAclOutput{}) 488 pulumi.RegisterOutputType(WebAclArrayOutput{}) 489 pulumi.RegisterOutputType(WebAclMapOutput{}) 490 }