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

Introduce Action Group resource of Azure Monitor #1419

Merged
merged 12 commits into from
Aug 1, 2018
5 changes: 5 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ type ArmClient struct {
keyVaultManagementClient keyVault.BaseClient

// Monitor
actionGroupsClient insights.ActionGroupsClient
monitorAlertRulesClient insights.AlertRulesClient

// MSI
Expand Down Expand Up @@ -727,6 +728,10 @@ func (c *ArmClient) registerKeyVaultClients(endpoint, subscriptionId string, aut
}

func (c *ArmClient) registerMonitorClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) {
actionGroupsClient := insights.NewActionGroupsClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&actionGroupsClient.Client, auth)
c.actionGroupsClient = actionGroupsClient

arc := insights.NewAlertRulesClientWithBaseURI(endpoint, subscriptionId)
setUserAgent(&arc.Client)
arc.Authorizer = auth
Expand Down
77 changes: 77 additions & 0 deletions azurerm/import_arm_action_group_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMActionGroup_importBasic(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, you could move the import tests in with the regular tests if you would like. It looks like this is the direction that other providers are going, so we may want to do this as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to resource_arm_action_group_test.go

resourceName := "azurerm_action_group.test"

ri := acctest.RandInt()
config := testAccAzureRMActionGroup_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMActionGroupDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMActionGroup_importEmpty(t *testing.T) {
resourceName := "azurerm_action_group.test"

ri := acctest.RandInt()
config := testAccAzureRMActionGroup_empty(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMActionGroupDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMActionGroup_importDisabledEmpty(t *testing.T) {
resourceName := "azurerm_action_group.test"

ri := acctest.RandInt()
config := testAccAzureRMActionGroup_disabledEmpty(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMActionGroupDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: map[string]*schema.Resource{
"azurerm_action_group": resourceArmActionGroup(),
"azurerm_azuread_application": resourceArmActiveDirectoryApplication(),
"azurerm_application_gateway": resourceArmApplicationGateway(),
"azurerm_application_insights": resourceArmApplicationInsights(),
Expand Down
Loading