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

azurerm_sentinel_alert_rule_scheduled - remove forcenew for alert_rule_template_version #25688

Merged
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
Original file line number Diff line number Diff line change
@@ -73,7 +73,6 @@ func resourceSentinelAlertRuleScheduled() *pluginsdk.Resource {
"alert_rule_template_version": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
},

"description": {
Original file line number Diff line number Diff line change
@@ -33,6 +33,28 @@ func TestAccSentinelAlertRuleScheduled_basic(t *testing.T) {
})
}

func TestAccSentinelAlertRuleScheduled_upgrade(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_sentinel_alert_rule_scheduled", "test")
r := SentinelAlertRuleScheduledResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.upgradeVersion(data, "1.0.4"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.upgradeVersion(data, "1.0.5"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccSentinelAlertRuleScheduled_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_sentinel_alert_rule_scheduled", "test")
r := SentinelAlertRuleScheduledResource{}
@@ -339,6 +361,28 @@ QUERY
`, r.template(data), data.RandomInteger)
}

func (r SentinelAlertRuleScheduledResource) upgradeVersion(data acceptance.TestData, version string) string {
return fmt.Sprintf(`
%s

resource "azurerm_sentinel_alert_rule_scheduled" "test" {
name = "acctest-SentinelAlertRule-Sche-%d"
log_analytics_workspace_id = azurerm_sentinel_log_analytics_workspace_onboarding.test.workspace_id
display_name = "Some Rule"
alert_rule_template_guid = "173f8699-6af5-484a-8b06-8c47ba89b380"
alert_rule_template_version = "%[3]s"
severity = "Medium"
query = <<QUERY
AzureActivity |
where OperationName == "Create or Update Virtual Machine" or OperationName =="Create Deployment" |
where ActivityStatus == "Succeeded" |
make-series dcount(ResourceId) default=0 on EventSubmissionTimestamp in range(ago(7d), now(), 1d) by Caller
QUERY

}
`, r.template(data), data.RandomInteger, version)
}

func (SentinelAlertRuleScheduledResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ The following arguments are supported:

* `alert_rule_template_guid` - (Optional) The GUID of the alert rule template which is used for this Sentinel Scheduled Alert Rule. Changing this forces a new Sentinel Scheduled Alert Rule to be created.

* `alert_rule_template_version` - (Optional) The version of the alert rule template which is used for this Sentinel Scheduled Alert Rule. Changing this forces a new Sentinel Scheduled Alert Rule to be created.
* `alert_rule_template_version` - (Optional) The version of the alert rule template which is used for this Sentinel Scheduled Alert Rule.

* `custom_details` - (Optional) A map of string key-value pairs of columns to be attached to this Sentinel Scheduled Alert Rule. The key will appear as the field name in alerts and the value is the event parameter you wish to surface in the alerts.