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

New Resource: azurerm_metric_alertrule #478

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cf51bdd
Added vendor dependency for github.com/Azure/azure-sdk-for-go/arm/mon…
dominik-lekse Oct 31, 2017
307ba31
Changed field AlertRule from an implicitly to an explicitly defined f…
dominik-lekse Oct 31, 2017
719ecfa
Added resource azurerm_metric_alertrule
dominik-lekse Oct 31, 2017
58f792c
Added documentation for azurerm_metric_alertrule resource
dominik-lekse Nov 1, 2017
9e8595a
Merge branch 'master' into public-feature/metric-alertrule
dominik-lekse Jan 7, 2018
477f76a
Updated vendor dependency for github.com/Azure/azure-sdk-for-go/arm/m…
dominik-lekse Jan 7, 2018
91c3d22
Merge branch 'master' into public-feature/metric-alertrule
dominik-lekse Jan 15, 2018
09c1ac8
Added vendor dependency to github.com/Azure/azure-sdk-for-go/services…
dominik-lekse Jan 15, 2018
eab63bb
Migrated resource metric alertrule to new monitor SDK
dominik-lekse Jan 15, 2018
5c5b351
Removed old monitor SDK
dominik-lekse Jan 15, 2018
6feb073
Changes to metric_alertrule resource based on review
dominik-lekse Jan 16, 2018
d4024f2
Merge branch 'master' into public-feature/metric-alertrule
dominik-lekse Jan 16, 2018
7a279de
Fixed example emails and urls in metric_alertrule documentation
dominik-lekse Jan 16, 2018
869ffaa
Changes to metric_alertrule resource based on review
dominik-lekse Jan 23, 2018
149f0ff
Fixed ordering of importes in metric_alertrule resource.
dominik-lekse Jan 23, 2018
804b3cd
Merge branch 'master' into public-feature/metric-alertrule
tombuildsstuff Jan 24, 2018
8510427
Merge branch 'master' into public-feature/metric-alertrule
tombuildsstuff Jan 24, 2018
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
13 changes: 13 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/scheduler"
"github.com/Azure/azure-sdk-for-go/arm/search"
keyVault "github.com/Azure/azure-sdk-for-go/dataplane/keyvault"
"github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights"
"github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus"
"github.com/Azure/azure-sdk-for-go/services/sql/mgmt/2015-05-01-preview/sql"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-06-01/storage"
Expand Down Expand Up @@ -154,6 +155,9 @@ type ArmClient struct {
sqlFirewallRulesClient sql.FirewallRulesClient
sqlServersClient sql.ServersClient

// Monitor
monitorAlertRulesClient insights.AlertRulesClient

// Networking
watcherClient network.WatchersClient

Expand Down Expand Up @@ -636,6 +640,7 @@ func getArmClient(c *authentication.Config) (*ArmClient, error) {
client.registerDatabases(endpoint, c.SubscriptionID, auth, sender)
client.registerDisks(endpoint, c.SubscriptionID, auth, sender)
client.registerKeyVaultClients(endpoint, c.SubscriptionID, auth, keyVaultAuth, sender)
client.registerMonitorClients(endpoint, c.SubscriptionID, auth, sender)
client.registerNetworkingClients(endpoint, c.SubscriptionID, auth, sender)
client.registerRedisClients(endpoint, c.SubscriptionID, auth, sender)
client.registerResourcesClients(endpoint, c.SubscriptionID, auth, sender)
Expand Down Expand Up @@ -837,6 +842,14 @@ func (c *ArmClient) registerKeyVaultClients(endpoint, subscriptionId string, aut
c.keyVaultManagementClient = keyVaultManagementClient
}

func (c *ArmClient) registerMonitorClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) {
arc := insights.NewAlertRulesClientWithBaseURI(endpoint, subscriptionId)
setUserAgent(&arc.Client)
arc.Authorizer = auth
arc.Sender = autorest.CreateSender(withRequestLogging())
c.monitorAlertRulesClient = arc
}

func (c *ArmClient) registerNetworkingClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) {
// TODO: move the other networking stuff in here, gradually
watchersClient := network.NewWatchersClientWithBaseURI(endpoint, subscriptionId)
Expand Down
31 changes: 31 additions & 0 deletions azurerm/import_arm_metric_alertrule_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package azurerm

import (
"testing"

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

func TestAccAzureRMMetricAlertRule_importVirtualMachineCpu(t *testing.T) {
resourceName := "azurerm_metric_alertrule.test"

ri := acctest.RandInt()
config := testAccAzureRMMetricAlertRule_virtualMachineCpu(ri, testLocation(), true)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMMetricAlertRuleDestroy,
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 @@ -130,6 +130,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_log_analytics_workspace": resourceArmLogAnalyticsWorkspace(),
"azurerm_managed_disk": resourceArmManagedDisk(),
"azurerm_management_lock": resourceArmManagementLock(),
"azurerm_metric_alertrule": resourceArmMetricAlertRule(),
"azurerm_mysql_configuration": resourceArmMySQLConfiguration(),
"azurerm_mysql_database": resourceArmMySqlDatabase(),
"azurerm_mysql_firewall_rule": resourceArmMySqlFirewallRule(),
Expand Down
Loading