Skip to content

Commit

Permalink
WAFv2: Remove 'body.oversize_handling'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Oct 3, 2022
1 parent e8aa32c commit 7a292ba
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 76 deletions.
8 changes: 0 additions & 8 deletions .changelog/26506.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
```release-note:breaking-change
resource/aws_wafv2_web_acl: Add Required `oversize_handling` attribute to the `field_to_match.body` block
```

```release-note:breaking-change
resource/aws_wafv2_rule_group: Add Required `oversize_handling` attribute to the `field_to_match.body` block
```

```release-note:enhancement
resource/aws_wafv2_web_acl: Add `headers` attribute to the `field_to_match` block
```
Expand Down
34 changes: 2 additions & 32 deletions internal/service/wafv2/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func expandFieldToMatch(l []interface{}) *wafv2.FieldToMatch {
}

if v, ok := m["body"]; ok && len(v.([]interface{})) > 0 {
f.Body = expandBody(m["body"].([]interface{}))
f.Body = &wafv2.Body{}
}

if v, ok := m["cookies"]; ok && len(v.([]interface{})) > 0 {
Expand Down Expand Up @@ -727,22 +727,6 @@ func expandXSSMatchStatement(l []interface{}) *wafv2.XssMatchStatement {
}
}

func expandBody(l []interface{}) *wafv2.Body {
if len(l) == 0 || l[0] == nil {
return nil
}

m := l[0].(map[string]interface{})

apiObject := &wafv2.Body{}

if v, ok := m["oversize_handling"].(string); ok && v != "" {
apiObject.OversizeHandling = aws.String(v)
}

return apiObject
}

func expandHeaders(l []interface{}) *wafv2.Headers {
if len(l) == 0 || l[0] == nil {
return nil
Expand Down Expand Up @@ -1335,7 +1319,7 @@ func flattenFieldToMatch(f *wafv2.FieldToMatch) interface{} {
}

if f.Body != nil {
m["body"] = flattenBody(f.Body)
m["body"] = make([]map[string]interface{}, 1)
}

if f.Cookies != nil {
Expand Down Expand Up @@ -1629,20 +1613,6 @@ func flattenVisibilityConfig(config *wafv2.VisibilityConfig) interface{} {
return []interface{}{m}
}

func flattenBody(s *wafv2.Body) interface{} {
if s == nil {
return []interface{}{}
}

m := map[string]interface{}{}

if v := s.OversizeHandling; v != nil {
m["oversize_handling"] = aws.StringValue(v)
}

return []interface{}{m}
}

func flattenHeaders(s *wafv2.Headers) interface{} {
if s == nil {
return []interface{}{}
Expand Down
15 changes: 1 addition & 14 deletions internal/service/wafv2/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func fieldToMatchBaseSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"all_query_arguments": emptySchema(),
"body": bodySchema(),
"body": emptySchema(),
"cookies": cookiesSchema(),
"headers": headersSchema(),
"json_body": jsonBodySchema(),
Expand Down Expand Up @@ -657,19 +657,6 @@ func customResponseBodySchema() *schema.Schema {
}
}

func bodySchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"oversize_handling": oversizeHandlingSchema(),
},
},
}
}

func cookiesSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Expand Down
17 changes: 4 additions & 13 deletions website/docs/r/wafv2_rule_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ resource "aws_wafv2_rule_group" "example" {
}
statement {
geo_match_statement {
country_codes = ["US", "NL"]
}
Expand Down Expand Up @@ -144,9 +145,7 @@ resource "aws_wafv2_rule_group" "example" {
sqli_match_statement {
field_to_match {
body {
oversize_handling = "MATCH"
}
body {}
}
text_transformation {
Expand Down Expand Up @@ -494,10 +493,10 @@ The part of a web request that you want AWS WAF to inspect. Include the single `
The `field_to_match` block supports the following arguments:

~> **NOTE:** Only one of `all_query_arguments`, `body`, `cookies`, `headers`, `json_body`, `method`, `query_string`, `single_header`, `single_query_argument`, or `uri_path` can be specified.
An empty configuration block `{}` should be used when specifying `all_query_arguments`, `method`, or `query_string` attributes.
An empty configuration block `{}` should be used when specifying `all_query_arguments`, `body`, `method`, or `query_string` attributes.

* `all_query_arguments` - (Optional) Inspect all query arguments.
* `body` - (Optional) Inspect the request body, which immediately follows the request headers. See [Body](#body) below for details.
* `body` - (Optional) Inspect the request body, which immediately follows the request headers.
* `cookies` - (Optional) Inspect the cookies in the web request. See [Cookies](#cookies) below for details.
* `headers` - (Optional) Inspect the request headers. See [Headers](#headers) below for details.
* `json_body` - (Optional) Inspect the request body as JSON. See [JSON Body](#json-body) for details.
Expand Down Expand Up @@ -528,14 +527,6 @@ The `ip_set_forwarded_ip_config` block supports the following arguments:
* `header_name` - (Required) - The name of the HTTP header to use for the IP address.
* `position` - (Required) - The position in the header to search for the IP address. Valid values include: `FIRST`, `LAST`, or `ANY`. If `ANY` is specified and the header contains more than 10 IP addresses, AWS WAFv2 inspects the last 10.

### Body

Inspect the request body, which immediately follows the request headers.

The `body` block supports the following arguments:

* `oversize_handling` - (Required) Oversize handling tells AWS WAF what to do with a web request when the request component that the rule inspects is over the limits. Valid values include the following: `CONTINUE`, `MATCH`, `NO_MATCH`. See the AWS [documentation](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) for more information.

### Headers

Inspect the request headers.
Expand Down
10 changes: 1 addition & 9 deletions website/docs/r/wafv2_web_acl.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ The part of a web request that you want AWS WAF to inspect. Include the single `
The `field_to_match` block supports the following arguments:

~> **NOTE:** Only one of `all_query_arguments`, `body`, `cookies`, `headers`, `json_body`, `method`, `query_string`, `single_header`, `single_query_argument`, or `uri_path` can be specified.
An empty configuration block `{}` should be used when specifying `all_query_arguments`, `method`, or `query_string` attributes.
An empty configuration block `{}` should be used when specifying `all_query_arguments`, `body`, `method`, or `query_string` attributes.

* `all_query_arguments` - (Optional) Inspect all query arguments.
* `body` - (Optional) Inspect the request body, which immediately follows the request headers. See [Body](#body) below for details.
Expand Down Expand Up @@ -580,14 +580,6 @@ The `ip_set_forwarded_ip_config` block supports the following arguments:
* `header_name` - (Required) - Name of the HTTP header to use for the IP address.
* `position` - (Required) - Position in the header to search for the IP address. Valid values include: `FIRST`, `LAST`, or `ANY`. If `ANY` is specified and the header contains more than 10 IP addresses, AWS WAFv2 inspects the last 10.

### Body

Inspect the request body, which immediately follows the request headers.

The `body` block supports the following arguments:

* `oversize_handling` - (Required) Oversize handling tells AWS WAF what to do with a web request when the request component that the rule inspects is over the limits. Valid values include the following: `CONTINUE`, `MATCH`, `NO_MATCH`. See the AWS [documentation](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) for more information.

### Headers

Inspect the request headers.
Expand Down

0 comments on commit 7a292ba

Please sign in to comment.