azurerm_cdn_frontdoor_firewall_policy - add support for log_scrubbing block#28834
azurerm_cdn_frontdoor_firewall_policy - add support for log_scrubbing block#28834
azurerm_cdn_frontdoor_firewall_policy - add support for log_scrubbing block#28834Conversation
jackofallops
left a comment
There was a problem hiding this comment.
Thanks @WodansSon - Just a few things to take a look at below if you could? Should be good to go when those are addressed (assuming tests pass, ofc!)
| "enabled": { | ||
| Type: pluginsdk.TypeBool, | ||
| Optional: true, | ||
| Default: true, | ||
| }, | ||
|
|
||
| "rule": { | ||
| Type: pluginsdk.TypeList, | ||
| MaxItems: 100, | ||
| Optional: true, | ||
| Elem: &pluginsdk.Resource{ |
There was a problem hiding this comment.
Is there a default rule / behaviour here if log_scrubbing is enabled, but no rules are defined? Just wondering, if there's no default behaviour, if these should be Required / MinItems instead to ensure the block does something?
(The test cases suggest that your design is fine, but I wanted to be sure since it's a little confusing to have this without rules?)
| "enabled": { | |
| Type: pluginsdk.TypeBool, | |
| Optional: true, | |
| Default: true, | |
| }, | |
| "rule": { | |
| Type: pluginsdk.TypeList, | |
| MaxItems: 100, | |
| Optional: true, | |
| Elem: &pluginsdk.Resource{ | |
| "enabled": { | |
| Type: pluginsdk.TypeBool, | |
| Required: true, | |
| }, | |
| "rule": { | |
| Type: pluginsdk.TypeList, | |
| MaxItems: 100, | |
| Minitems: 1, | |
| Elem: &pluginsdk.Resource{ |
There was a problem hiding this comment.
No, there isn't a default behavior, per the service team:
Correction on the behavior of the LogScrubbing state.
- If LogScrubbing
Stateis set toEnabledbut no scrubbingrules are configured, it will result in a no op (no operation). - For log scrubbing to take effect, both the
LogScrubbingState(Enabled) and at least one ScrubbingRulewithStateEnabled must be configured.
| // NOTE: If the 'operator' is set to 'Equals' the 'selector' cannot be 'nil'... | ||
| if *item.Selector == "" { |
There was a problem hiding this comment.
This looks a little off? We're checking for empty, not nil here? To avoid a panic, should this be:
| // NOTE: If the 'operator' is set to 'Equals' the 'selector' cannot be 'nil'... | |
| if *item.Selector == "" { | |
| // NOTE: If the 'operator' is set to 'Equals' the 'selector' cannot be 'nil'... | |
| if pointer.From(item.Selector) == "" { |
since we're only setting item.Selector if there's a v["selector"] value present?
| // NOTE: If the 'operator' is set to 'EqualsAny' the 'selector' must be 'nil'... | ||
| if *item.Selector != "" { |
There was a problem hiding this comment.
Again here, should this be?
| // NOTE: If the 'operator' is set to 'EqualsAny' the 'selector' must be 'nil'... | |
| if *item.Selector != "" { | |
| // NOTE: If the 'operator' is set to 'EqualsAny' the 'selector' must be 'nil'... | |
| if item.Selector == nil { |
| } | ||
|
|
||
| func TestAccCdnFrontDoorFirewallPolicy_logScrubbingComplete(t *testing.T) { | ||
| // NOTE: Regression test case for issue #19088 |
There was a problem hiding this comment.
copy paste error?
| // NOTE: Regression test case for issue #19088 |
There was a problem hiding this comment.
Yes sir... DOH! 🤣 Fixed.
| tmp := r.template(data) | ||
| return fmt.Sprintf(` | ||
| %s | ||
|
|
||
| resource "azurerm_cdn_frontdoor_firewall_policy" "test" { | ||
| name = "accTestWAF%d" | ||
| resource_group_name = azurerm_resource_group.test.name | ||
| sku_name = azurerm_cdn_frontdoor_profile.test.sku_name | ||
| mode = "Prevention" | ||
|
|
||
| log_scrubbing { | ||
| enabled = true | ||
| } | ||
| } | ||
| `, tmp, data.RandomInteger) |
There was a problem hiding this comment.
We're pushing away from this pattern as it's unnecessary to assign the template to a var when it can be passed into the test directly. Would you mind updating these? (Just the new tests, don't worry about the others in the file, we'll be sorting this out more broadly in the future, just want to avoid more instances of it where possible. 🙈 )
| tmp := r.template(data) | |
| return fmt.Sprintf(` | |
| %s | |
| resource "azurerm_cdn_frontdoor_firewall_policy" "test" { | |
| name = "accTestWAF%d" | |
| resource_group_name = azurerm_resource_group.test.name | |
| sku_name = azurerm_cdn_frontdoor_profile.test.sku_name | |
| mode = "Prevention" | |
| log_scrubbing { | |
| enabled = true | |
| } | |
| } | |
| `, tmp, data.RandomInteger) | |
| return fmt.Sprintf(` | |
| %s | |
| resource "azurerm_cdn_frontdoor_firewall_policy" "test" { | |
| name = "accTestWAF%d" | |
| resource_group_name = azurerm_resource_group.test.name | |
| sku_name = azurerm_cdn_frontdoor_profile.test.sku_name | |
| mode = "Prevention" | |
| log_scrubbing { | |
| enabled = true | |
| } | |
| } | |
| `, r.template(data), data.RandomInteger) |
There was a problem hiding this comment.
Since I will already be in the code I might as well just update all of them. Fixed.
|
|
||
| * `enabled` - (Optional) Is log scrubbing enabled? Possible values are `true` or `false`. Defaults to `true`. | ||
|
|
||
| * `rule` - (Optional) One or more `scrubbing_rule` blocks as defined below. |
There was a problem hiding this comment.
| * `rule` - (Optional) One or more `scrubbing_rule` blocks as defined below. | |
| * `rule` - (Optional) One or more `rule` blocks as defined below. |
There was a problem hiding this comment.
Same as above, the managed_rule also uses rule so I gave it a different name in the documentation trying to not confuse the end user when they are looking up what the scrubbing_rule block contains.
jackofallops
left a comment
There was a problem hiding this comment.
Thanks @WodansSon - Just a few things to take a look at below if you could? Should be good to go when those are addressed (assuming tests pass, ofc!)
jackofallops
left a comment
There was a problem hiding this comment.
Thanks for the changes/responses @WodansSon - Given the external limitation, I don't think we will have to suck up a deviation from naming convention for now. I think once that's done, this should be good to go. Sorry for the back-and-forth.
| Default: true, | ||
| }, | ||
|
|
||
| "rule": { |
There was a problem hiding this comment.
As noted in the docs, if this doesn't match it will be difficult/frustrating for users to work out the correct block name. Since this is a limitation of the Registry docs, I don't think we have a choice here but to deviate from the convention due to the duplication of the block name in this resource.
| "rule": { | |
| "scrubbing_rule": { |
jackofallops
left a comment
There was a problem hiding this comment.
Thanks @WodansSon for the changes, this LGTM now 👍
* Update CHANGELOG.md #28843 * Update CHANGELOG.md for #28748 * Update CHANGELOG.md for #28881 * Update CHANGELOG.md for #28909 * Update CHANGELOG.md fold in patch release and expand starred entry correctly * Update CHANGELOG.md remove duplicate entry for 28843 * Update CHANGELOG.md #28066 * Update CHANGELOG.md for #28902 and fix ordering * Update CHANGELOG.md for #28848 * Update CHANGELOG.md #27622 * Update CHANGELOG.md for #28271 * Update CHANGELOG.md update format * Update CHANGELOG.md #28934 * Update for #28619 #28598 * Update CHANGELOG.md #28940 * Update CHANGELOG.md for #28880 * Update CHANGELOG.md for #28617 * Update CHANGELOG.md #28721 * Update CHANGELOG.md #28949 * Update previous entry for 4.16.0 * Update CHANGELOG.md for #28834 * prep for release --------- Co-authored-by: Matthew Frahry <mbfrahry@gmail.com> Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> Co-authored-by: catriona-m <86247157+catriona-m@users.noreply.github.com> Co-authored-by: stephybun <steph@hashicorp.com> Co-authored-by: Wodans Son <20408400+WodansSon@users.noreply.github.com> Co-authored-by: jackofallops <ste@hashicorp.com>
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |


Community Note
Description
PR Checklist
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_cdn_frontdoor_firewall_policy- add support for thelog_scrubbingcode block [GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #28236
Note
If this PR changes meaningfully during the course of review please update the title and description as required.