-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
azurerm_sentinel_alert_rule_fusion
- remove existing check for built in rule
#27653
Conversation
@@ -50,6 +41,7 @@ resource "azurerm_sentinel_alert_rule_fusion" "example" { | |||
The following arguments are supported: | |||
|
|||
* `name` - (Required) The name which should be used for this Sentinel Fusion Alert Rule. Changing this forces a new Sentinel Fusion Alert Rule to be created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can name ONLY be BuiltInFusion
? if so could we please add that as a default, make the property optional, and deprecate it.
or can additional rules be added? or the existing ones name renamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the already existing rules with different names, for new created ones, it can only be BuiltInFusion
just triggered another testing, maybe we can wait for it. |
* `name` - (Optional) The name which should be used for this Sentinel Fusion Alert Rule. Changing this forces a new Sentinel Fusion Alert Rule to be created. | ||
**Note:** The `name` is deprecated and will be removed in v5.0 version of the provider. The Fusion Alert Rule is enabled by default with the name `BuiltInFusion`, more details could be found [here](https://learn.microsoft.com/en-us/azure/sentinel/configure-fusion-rules#configure-scheduled-analytics-rules-for-fusion-detections). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't follow our guidelines for breaking changes.
Please also make sure the upgrade guide is updated with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, sorry for missed that part.
updated testing result
|
* `name` - (Optional) The name which should be used for this Sentinel Fusion Alert Rule. Changing this forces a new Sentinel Fusion Alert Rule to be created. Defaults to `BuiltInFusion` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't advertise or encourage the use of deprecated properties which is why we remove them from the documentation entirely.
* `name` - (Optional) The name which should be used for this Sentinel Fusion Alert Rule. Changing this forces a new Sentinel Fusion Alert Rule to be created. Defaults to `BuiltInFusion` |
kindly bubble this PR up |
if _, err := client.CreateOrUpdate(ctx, id, params); err != nil { | ||
return fmt.Errorf("creating Sentinel Alert Rule Fusion %q: %+v", id, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string formatter for the IDs contain detailed information about the resource's name, we would be unnecessarily repeating ourselves by adding that in the error message.
if _, err := client.CreateOrUpdate(ctx, id, params); err != nil { | |
return fmt.Errorf("creating Sentinel Alert Rule Fusion %q: %+v", id, err) | |
} | |
if _, err := client.CreateOrUpdate(ctx, id, params); err != nil { | |
return fmt.Errorf("creating %s: %+v", id, err) | |
} |
|
||
resp, err := client.Get(ctx, *id) | ||
if err != nil { | ||
return fmt.Errorf("retrieving %q: %+v", id, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("retrieving %q: %+v", id, err) | |
return fmt.Errorf("retrieving %s: %+v", id, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hasn't been updated
ForceNew: true, | ||
ValidateFunc: validation.StringIsNotEmpty, | ||
}, | ||
Schema: resourceSentinelAlertRuleFusionSchema(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the schema in-lined here
} | ||
|
||
if err = assertAlertRuleKind(resp.Model, alertrules.AlertRuleKindFusion); err != nil { | ||
return fmt.Errorf("asserting alert rule of %q: %+v", id, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("asserting alert rule of %q: %+v", id, err) | |
return fmt.Errorf("asserting alert rule of %s: %+v", id, err) |
payload := resp.Model.(alertrules.FusionAlertRule) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't follow the pattern that we expect for the update function which
- nil check Model
- nil check Properties
- Patch changes in to Properties/Model
This particular case will deviate slightly since this is a discriminated type and it's generally good practice to check that the type assertion we're doing is successful and throwing an error if it isnt. Can you please update this to
payload := resp.Model.(alertrules.FusionAlertRule) | |
if resp.Model == nil { | |
return fmt.Errorf("retrieving %s: `model` was nil", id) | |
} | |
payload, ok := resp.Model.(alertrules.FusionAlertRule) | |
if !ok { | |
return fmt.Errorf("retrieving %s: expected an alert rule of type `Fusion`, got %q", pointer.From(resp.Model.AlertRule().Type)) | |
} | |
if payload.Properties == nil { | |
return fmt.Errorf("retrieving %s: `properties` was nil", id) | |
} |
if payload.Properties == nil { | ||
payload.Properties = &alertrules.FusionAlertRuleProperties{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
if payload.Properties == nil { | |
payload.Properties = &alertrules.FusionAlertRuleProperties{} | |
} |
if payload.Properties == nil { | ||
payload.Properties = &alertrules.FusionAlertRuleProperties{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
if payload.Properties == nil { | |
payload.Properties = &alertrules.FusionAlertRuleProperties{} | |
} |
if payload.Properties != nil { | ||
payload.Properties.Description = nil | ||
payload.Properties.DisplayName = nil | ||
payload.Properties.LastModifiedUtc = nil | ||
payload.Properties.Severity = nil | ||
payload.Properties.Tactics = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to nil check this anymore since we're doing it further up
if payload.Properties != nil { | |
payload.Properties.Description = nil | |
payload.Properties.DisplayName = nil | |
payload.Properties.LastModifiedUtc = nil | |
payload.Properties.Severity = nil | |
payload.Properties.Tactics = nil | |
} | |
payload.Properties.Description = nil | |
payload.Properties.DisplayName = nil | |
payload.Properties.LastModifiedUtc = nil | |
payload.Properties.Severity = nil | |
payload.Properties.Tactics = nil |
} | ||
|
||
d.SetId(id.ID()) | ||
if _, err := client.CreateOrUpdate(ctx, *id, payload); err != nil { | ||
return fmt.Errorf("creating Sentinel Alert Rule Fusion %q: %+v", id, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("creating Sentinel Alert Rule Fusion %q: %+v", id, err) | |
return fmt.Errorf("updating %s: %+v", id, err) |
|
||
### `azurerm_sentinel_alert_rule_fusion` | ||
|
||
* The deprecated `name` property has been removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been put inside the ```markdown box where we've put examples of how the breaking changes should be documented, this should be moved down out of this block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ziyeqf can you please provide testing evidence in 5.0 mode as well
4.0 test result
5.0
|
### `azurerm_sentinel_alert_rule_fusion` | ||
|
||
* The deprecated `name` property has been removed. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As specified in point 4 for breaking schema changes these should be listed in alphabetical order, so should be put before all the storage changes above
|
||
resp, err := client.Get(ctx, *id) | ||
if err != nil { | ||
return fmt.Errorf("retrieving %q: %+v", id, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hasn't been updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ziyeqf LGTM 🦖
The only one fusion alert rule is enabled by default ( source ), so removing the existing check and update the document.
In my opinion we can deprecate the
name
andtemplate_alert_rule_guid
and remove them in v5.0, however this will be a breaking change, and the resource also needs to be refactored to typed sdk, to make the resource able to be used, I just removed the existing check in this PR.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_sentinel_alert_rule_fusion
- remove existing check for built in rule [azurerm_sentinel_alert_rule_fusion
- remove existing check for built in rule #27653]This is a (please select all that apply):
Related Issue(s)
Note
If this PR changes meaningfully during the course of review please update the title and description as required.