Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WAFv2 challenge action to rule_action_override #31127

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/31127.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_wafv2_web_acl: Added `rule_group_reference_statement.rule_action_override.action_to_use.challenge` argument
```
9 changes: 5 additions & 4 deletions internal/service/wafv2/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,11 @@ func actionToUseSchema() *schema.Schema {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered refactoring here?

Seems like the challenge feature has been added throughout a number of PRs:
6774a21
13228fd

The same map schema is maintained at 3 places, so it seems inevitable that this issue will happen again.

As the documentation references back the action_to_use to the action block, it would make sense to create an action schema and use that.

"allow": allowConfigSchema(),
"block": blockConfigSchema(),
"captcha": captchaConfigSchema(),
"count": countConfigSchema(),
"allow": allowConfigSchema(),
"block": blockConfigSchema(),
"captcha": captchaConfigSchema(),
"challenge": challengeConfigSchema(),
"count": countConfigSchema(),
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions internal/service/wafv2/web_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,14 @@ func TestAccWAFV2WebACL_ManagedRuleGroup_basic(t *testing.T) {
"statement.0.managed_rule_group_statement.0.rule_action_override.0.action_to_use.0.allow.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.0.action_to_use.0.block.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.0.action_to_use.0.captcha.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.0.action_to_use.0.challenge.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.0.action_to_use.0.count.#": "1",
"statement.0.managed_rule_group_statement.0.rule_action_override.0.name": "SizeRestrictions_QUERYSTRING",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.action_to_use.#": "1",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.action_to_use.0.allow.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.action_to_use.0.block.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.action_to_use.0.captcha.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.action_to_use.0.challenge.#": "0",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.action_to_use.0.count.#": "1",
"statement.0.managed_rule_group_statement.0.rule_action_override.1.name": "NoUserAgent_HEADER",
"statement.0.managed_rule_group_statement.0.scope_down_statement.#": "1",
Expand Down
Loading