Skip to content

Commit b985284

Browse files
committed
feat(monitor): add email_subject support to scheduled query rules alert v2
1 parent 6139cf2 commit b985284

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

internal/services/monitor/monitor_scheduled_query_rules_alert_v2_resource.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type ScheduledQueryRulesAlertV2Model struct {
4848
type ScheduledQueryRulesAlertV2ActionsModel struct {
4949
ActionGroups []string `tfschema:"action_groups"`
5050
CustomProperties map[string]string `tfschema:"custom_properties"`
51+
EmailSubject string `tfschema:"email_subject"`
5152
}
5253

5354
type ScheduledQueryRulesAlertV2CriteriaModel struct {
@@ -294,6 +295,11 @@ func (r ScheduledQueryRulesAlertV2Resource) Arguments() map[string]*pluginsdk.Sc
294295
Type: pluginsdk.TypeString,
295296
},
296297
},
298+
"email_subject": {
299+
Type: pluginsdk.TypeString,
300+
Optional: true,
301+
ValidateFunc: validation.StringIsNotEmpty,
302+
},
297303
},
298304
},
299305
},
@@ -763,6 +769,16 @@ func expandScheduledQueryRulesAlertV2ActionsModel(inputList []ScheduledQueryRule
763769
CustomProperties: &input.CustomProperties,
764770
}
765771

772+
if input.EmailSubject != "" {
773+
m := map[string]string{
774+
"Email.Subject": input.EmailSubject,
775+
}
776+
output.ActionProperties = &m
777+
} else {
778+
m := map[string]string{}
779+
output.ActionProperties = &m
780+
}
781+
766782
return &output
767783
}
768784

@@ -844,6 +860,12 @@ func flattenScheduledQueryRulesAlertV2ActionsModel(input *scheduledqueryrules.Ac
844860
output.CustomProperties = *input.CustomProperties
845861
}
846862

863+
if input.ActionProperties != nil {
864+
if s, ok := (*input.ActionProperties)["Email.Subject"]; ok {
865+
output.EmailSubject = s
866+
}
867+
}
868+
847869
return append(outputList, output)
848870
}
849871

internal/services/monitor/monitor_scheduled_query_rules_alert_v2_resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "test" {
305305
custom_properties = {
306306
key = "value"
307307
}
308+
email_subject = "acctest subject v1"
308309
}
309310
310311
tags = {
@@ -363,6 +364,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "test" {
363364
key = "value"
364365
key2 = "value2"
365366
}
367+
email_subject = "acctest subject v2"
366368
}
367369
368370
tags = {

website/docs/r/monitor_scheduled_query_rules_alert_v2.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "example" {
8787
key = "value"
8888
key2 = "value2"
8989
}
90+
email_subject = "Email Header"
9091
}
9192
9293
identity {
@@ -164,6 +165,8 @@ An `action` block supports the following:
164165

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

168+
* `email_subject` - (Optional) Custom subject override for all email ids in Azure action group.
169+
167170
---
168171

169172
A `criteria` block supports the following:

0 commit comments

Comments
 (0)