Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ScheduledQueryRulesAlertV2Model struct {
type ScheduledQueryRulesAlertV2ActionsModel struct {
ActionGroups []string `tfschema:"action_groups"`
CustomProperties map[string]string `tfschema:"custom_properties"`
EmailSubject string `tfschema:"email_subject"`
}

type ScheduledQueryRulesAlertV2CriteriaModel struct {
Expand Down Expand Up @@ -294,6 +295,11 @@ func (r ScheduledQueryRulesAlertV2Resource) Arguments() map[string]*pluginsdk.Sc
Type: pluginsdk.TypeString,
},
},
"email_subject": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
},
},
},
Expand Down Expand Up @@ -763,6 +769,16 @@ func expandScheduledQueryRulesAlertV2ActionsModel(inputList []ScheduledQueryRule
CustomProperties: &input.CustomProperties,
}

if input.EmailSubject != "" {
m := map[string]string{
"Email.Subject": input.EmailSubject,
}
output.ActionProperties = &m
} else {
m := map[string]string{}
output.ActionProperties = &m
}

return &output
}

Expand Down Expand Up @@ -844,6 +860,12 @@ func flattenScheduledQueryRulesAlertV2ActionsModel(input *scheduledqueryrules.Ac
output.CustomProperties = *input.CustomProperties
}

if input.ActionProperties != nil {
if s, ok := (*input.ActionProperties)["Email.Subject"]; ok {
output.EmailSubject = s
}
}

return append(outputList, output)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "test" {
custom_properties = {
key = "value"
}
email_subject = "acctest subject v1"
}
tags = {
Expand Down Expand Up @@ -363,6 +364,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "test" {
key = "value"
key2 = "value2"
}
email_subject = "acctest subject v2"
}
tags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "example" {
key = "value"
key2 = "value2"
}
email_subject = "Email Header"
}
identity {
Expand Down Expand Up @@ -164,6 +165,8 @@ An `action` block supports the following:

* `custom_properties` - (Optional) Specifies the properties of an alert payload.

* `email_subject` - (Optional) Custom subject override for all email ids in Azure action group.

---

A `criteria` block supports the following:
Expand Down
Loading