Skip to content

Commit

Permalink
Data Source: azurerm_monitor_action_group - add support for `aad_au…
Browse files Browse the repository at this point in the history
…th` attribute (#10876)
  • Loading branch information
jackofallops authored Mar 8, 2021
1 parent 1929483 commit afebfc3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,29 @@ func dataSourceMonitorActionGroup() *schema.Resource {
},
"use_common_alert_schema": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Computed: true,
},
"aad_auth": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"object_id": {
Type: schema.TypeString,
Computed: true,
},

"identifier_uri": {
Type: schema.TypeString,
Computed: true,
},

"tenant_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func TestAccDataSourceMonitorActionGroup_complete(t *testing.T) {
laName := fmt.Sprintf("acctestLA-%d", data.RandomInteger)
webhookName := "webhook_alert"
resGroup := fmt.Sprintf("acctestRG-%d", data.RandomInteger)
aaResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/AutomationAccounts/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, aaName)
aaWebhookResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/AutomationAccounts/%s/webhooks/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, aaName, webhookName)
aaResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/automationAccounts/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, aaName)
aaWebhookResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/automationAccounts/%s/webhooks/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, aaName, webhookName)
faResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, faName)
laResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Logic/workflows/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, laName)

Expand All @@ -99,21 +99,24 @@ func TestAccDataSourceMonitorActionGroup_complete(t *testing.T) {
check.That(data.ResourceName).Key("sms_receiver.#").HasValue("2"),
check.That(data.ResourceName).Key("sms_receiver.0.country_code").HasValue("1"),
check.That(data.ResourceName).Key("sms_receiver.0.phone_number").HasValue("1231231234"),
check.That(data.ResourceName).Key("sms_receiver.1.country_code").HasValue("86"),
check.That(data.ResourceName).Key("sms_receiver.1.phone_number").HasValue("13888888888"),
check.That(data.ResourceName).Key("sms_receiver.1.country_code").HasValue("1"),
check.That(data.ResourceName).Key("sms_receiver.1.phone_number").HasValue("5551238888"),
check.That(data.ResourceName).Key("webhook_receiver.#").HasValue("2"),
check.That(data.ResourceName).Key("webhook_receiver.0.service_uri").HasValue("http://example.com/alert"),
check.That(data.ResourceName).Key("webhook_receiver.1.service_uri").HasValue("https://backup.example.com/warning"),
check.That(data.ResourceName).Key("webhook_receiver.1.use_common_alert_schema").HasValue("false"),
check.That(data.ResourceName).Key("webhook_receiver.1.aad_auth.#").HasValue("0"),
check.That(data.ResourceName).Key("automation_runbook_receiver.#").HasValue("1"),
check.That(data.ResourceName).Key("automation_runbook_receiver.0.automation_account_id").HasValue(aaResourceID),
check.That(data.ResourceName).Key("automation_runbook_receiver.0.runbook_name").HasValue(webhookName),
check.That(data.ResourceName).Key("automation_runbook_receiver.0.webhook_resource_id").HasValue(aaWebhookResourceID),
check.That(data.ResourceName).Key("automation_runbook_receiver.0.service_uri").HasValue("https://s13events.azure-automation.net/webhooks?token=randomtoken"),
check.That(data.ResourceName).Key("automation_runbook_receiver.0.use_common_alert_schema").HasValue("false"),
check.That(data.ResourceName).Key("voice_receiver.#").HasValue("1"),
check.That(data.ResourceName).Key("voice_receiver.#").HasValue("2"),
check.That(data.ResourceName).Key("voice_receiver.0.country_code").HasValue("1"),
check.That(data.ResourceName).Key("voice_receiver.0.phone_number").HasValue("1231231234"),
check.That(data.ResourceName).Key("voice_receiver.1.country_code").HasValue("1"),
check.That(data.ResourceName).Key("voice_receiver.1.phone_number").HasValue("5551238888"),
check.That(data.ResourceName).Key("logic_app_receiver.#").HasValue("1"),
check.That(data.ResourceName).Key("logic_app_receiver.0.resource_id").HasValue(laResourceID),
check.That(data.ResourceName).Key("logic_app_receiver.0.callback_url").HasValue("http://test-host:100/workflows/fb9c8d79b15f41ce9b12861862f43546/versions/08587100027316071865/triggers/manualTrigger/paths/invoke?api-version=2015-08-01-preview&sp=%2Fversions%2F08587100027316071865%2Ftriggers%2FmanualTrigger%2Frun&sv=1.0&sig=IxEQ_ygZf6WNEQCbjV0Vs6p6Y4DyNEJVAa86U5B4xhk"),
Expand Down Expand Up @@ -181,6 +184,10 @@ data "azurerm_monitor_action_group" "test" {
}

func (MonitorActionGroupDataSource) complete(data acceptance.TestData) string {
aaName := fmt.Sprintf("acctestAA-%d", data.RandomInteger)
webhookName := "webhook_alert"
resGroup := fmt.Sprintf("acctestRG-%d", data.RandomInteger)
aaWebhookResourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automation/automationAccounts/%s/webhooks/%s", os.Getenv("ARM_SUBSCRIPTION_ID"), resGroup, aaName, webhookName)
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -193,7 +200,7 @@ resource "azurerm_resource_group" "test" {
resource "azurerm_monitor_action_group" "test" {
name = "acctestActionGroup-%d"
resource_group_name = "${azurerm_resource_group.test.name}"
resource_group_name = azurerm_resource_group.test.name
short_name = "acctestag"
email_receiver {
Expand Down Expand Up @@ -227,9 +234,9 @@ resource "azurerm_monitor_action_group" "test" {
}
sms_receiver {
name = "remotesupport"
country_code = "86"
phone_number = "13888888888"
name = "remotesupportmsg"
country_code = "1"
phone_number = "5551238888"
}
webhook_receiver {
Expand All @@ -244,36 +251,36 @@ resource "azurerm_monitor_action_group" "test" {
automation_runbook_receiver {
name = "action_name_1"
automation_account_id = "${azurerm_automation_account.test.id}"
runbook_name = "my runbook"
webhook_resource_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-runbooks/providers/microsoft.automation/automationaccounts/aaa001/webhooks/webhook_alert"
automation_account_id = azurerm_automation_account.test.id
runbook_name = "webhook_alert"
webhook_resource_id = "%s"
is_global_runbook = true
service_uri = "https://s13events.azure-automation.net/webhooks?token=randomtoken"
use_common_alert_schema = false
}
voice_receiver {
name = "oncallmsg"
name = "oncall"
country_code = "1"
phone_number = "1231231234"
}
voice_receiver {
name = "remotesupport"
country_code = "86"
phone_number = "13888888888"
country_code = "1"
phone_number = "5551238888"
}
logic_app_receiver {
name = "logicappaction"
resource_id = "${azurerm_logic_app_workflow.test.id}"
resource_id = azurerm_logic_app_workflow.test.id
callback_url = "http://test-host:100/workflows/fb9c8d79b15f41ce9b12861862f43546/versions/08587100027316071865/triggers/manualTrigger/paths/invoke?api-version=2015-08-01-preview&sp=%%2Fversions%%2F08587100027316071865%%2Ftriggers%%2FmanualTrigger%%2Frun&sv=1.0&sig=IxEQ_ygZf6WNEQCbjV0Vs6p6Y4DyNEJVAa86U5B4xhk"
use_common_alert_schema = false
}
azure_function_receiver {
name = "funcaction"
function_app_resource_id = "${azurerm_function_app.test.id}"
function_app_resource_id = azurerm_function_app.test.id
function_name = "myfunc"
http_trigger_url = "https://example.com/trigger"
use_common_alert_schema = false
Expand All @@ -288,36 +295,38 @@ resource "azurerm_monitor_action_group" "test" {
resource "azurerm_automation_account" "test" {
name = "acctestAA-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "Basic"
}
resource "azurerm_automation_runbook" "test" {
name = "Get-AzureVMTutorial"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
automation_account_name = "${azurerm_automation_account.test.name}"
log_verbose = "true"
log_progress = "true"
description = "This is an test runbook"
runbook_type = "PowerShellWorkflow"
publish_content_link {
uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1"
}
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
automation_account_name = azurerm_automation_account.test.name
log_verbose = "true"
log_progress = "true"
description = "This is a test runbook for terraform acceptance test"
runbook_type = "PowerShell"
content = <<CONTENT
# Some test content
# for Terraform acceptance test
CONTENT
}
resource "azurerm_logic_app_workflow" "test" {
name = "acctestLA-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_logic_app_trigger_http_request" "test" {
name = "some-http-trigger"
logic_app_id = "${azurerm_logic_app_workflow.test.id}"
logic_app_id = azurerm_logic_app_workflow.test.id
schema = <<SCHEMA
{
Expand All @@ -333,16 +342,16 @@ SCHEMA
resource "azurerm_storage_account" "test" {
name = "acctestsa%s"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestSP-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
tier = "Standard"
Expand All @@ -352,16 +361,16 @@ resource "azurerm_app_service_plan" "test" {
resource "azurerm_function_app" "test" {
name = "acctestFA-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
app_service_plan_id = "${azurerm_app_service_plan.test.id}"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
storage_account_name = azurerm_storage_account.test.name
storage_account_access_key = azurerm_storage_account.test.primary_access_key
}
data "azurerm_monitor_action_group" "test" {
name = "${azurerm_monitor_action_group.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
name = azurerm_monitor_action_group.test.name
resource_group_name = azurerm_resource_group.test.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomString, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, aaWebhookResourceID, data.RandomInteger, data.RandomInteger, data.RandomString, data.RandomInteger, data.RandomInteger)
}

0 comments on commit afebfc3

Please sign in to comment.