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_monitor_action_group - add support for the use_common_alert_schema webhook property #4483

Merged
merged 7 commits into from
Oct 15, 2019
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
5 changes: 5 additions & 0 deletions azurerm/data_source_monitor_action_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func dataSourceArmMonitorActionGroup() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"use_common_alert_schema": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion azurerm/data_source_monitor_diagnostic_categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/monitor/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monitor

import (
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)

Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_autoscale_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_metric_alertrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
18 changes: 15 additions & 3 deletions azurerm/resource_arm_monitor_action_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down Expand Up @@ -114,6 +114,11 @@ func resourceArmMonitorActionGroup() *schema.Resource {
Required: true,
ValidateFunc: validate.NoEmptyStrings,
},
"use_common_alert_schema": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand Down Expand Up @@ -281,8 +286,9 @@ func expandMonitorActionGroupWebHookReceiver(v []interface{}) *[]insights.Webhoo
for _, receiverValue := range v {
val := receiverValue.(map[string]interface{})
receiver := insights.WebhookReceiver{
Name: utils.String(val["name"].(string)),
ServiceURI: utils.String(val["service_uri"].(string)),
Name: utils.String(val["name"].(string)),
ServiceURI: utils.String(val["service_uri"].(string)),
UseCommonAlertSchema: utils.Bool(val["use_common_alert_schema"].(bool)),
}
receivers = append(receivers, receiver)
}
Expand All @@ -300,6 +306,7 @@ func flattenMonitorActionGroupEmailReceiver(receivers *[]insights.EmailReceiver)
if receiver.EmailAddress != nil {
val["email_address"] = *receiver.EmailAddress
}

result = append(result, val)
}
}
Expand All @@ -320,6 +327,7 @@ func flattenMonitorActionGroupSmsReceiver(receivers *[]insights.SmsReceiver) []i
if receiver.PhoneNumber != nil {
val["phone_number"] = *receiver.PhoneNumber
}

result = append(result, val)
}
}
Expand All @@ -337,6 +345,10 @@ func flattenMonitorActionGroupWebHookReceiver(receivers *[]insights.WebhookRecei
if receiver.ServiceURI != nil {
val["service_uri"] = *receiver.ServiceURI
}
if receiver.UseCommonAlertSchema != nil {
val["use_common_alert_schema"] = *receiver.UseCommonAlertSchema
}

result = append(result, val)
}
}
Expand Down
8 changes: 6 additions & 2 deletions azurerm/resource_arm_monitor_action_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestAccAzureRMMonitorActionGroup_webhookReceiver(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "sms_receiver.#", "0"),
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.#", "1"),
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.0.service_uri", "http://example.com/alert"),
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.0.use_common_alert_schema", "true"),
),
},
{
Expand Down Expand Up @@ -186,6 +187,7 @@ func TestAccAzureRMMonitorActionGroup_complete(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.#", "2"),
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.0.service_uri", "http://example.com/alert"),
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.1.service_uri", "https://backup.example.com/warning"),
resource.TestCheckResourceAttr(resourceName, "webhook_receiver.1.use_common_alert_schema", "true"),
),
},
{
Expand Down Expand Up @@ -422,7 +424,8 @@ resource "azurerm_monitor_action_group" "test" {

webhook_receiver {
name = "callmyapiaswell"
service_uri = "http://example.com/alert"
service_uri = "http://example.com/alert"
use_common_alert_schema = true
}
}
`, rInt, location, rInt)
Expand Down Expand Up @@ -469,7 +472,8 @@ resource "azurerm_monitor_action_group" "test" {

webhook_receiver {
name = "callmybackupapi"
service_uri = "https://backup.example.com/warning"
service_uri = "https://backup.example.com/warning"
use_common_alert_schema = true
}
}
`, rInt, location, rInt)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_monitor_activity_log_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_monitor_autoscale_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_monitor_diagnostic_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_monitor_log_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_monitor_metric_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_monitor_metric_alertrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfT
github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3 h1:ZSTrOEhiM5J5RFxEaFvMZVEAM1KvT1YzbEOwB2EAGjA=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading