From 7fc6743a9d84929760f842856b4bb9f7d8589583 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 10 Jan 2019 07:36:33 -0800 Subject: [PATCH] Remove old-style Terraform examples (#2848) Signed-off-by: Modular Magician --- ..._monitoring_alert_policy_generated_test.go | 99 +++++++++++++++++++ ...pute_interconnect_attachment.html.markdown | 17 ++-- .../r/monitoring_alert_policy.html.markdown | 13 ++- 3 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 google/resource_monitoring_alert_policy_generated_test.go diff --git a/google/resource_monitoring_alert_policy_generated_test.go b/google/resource_monitoring_alert_policy_generated_test.go new file mode 100644 index 00000000..b4bb96d3 --- /dev/null +++ b/google/resource_monitoring_alert_policy_generated_test.go @@ -0,0 +1,99 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package google + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccMonitoringAlertPolicy_monitoringAlertPolicyBasicExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(10), + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckMonitoringAlertPolicyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMonitoringAlertPolicy_monitoringAlertPolicyBasicExample(context), + }, + { + ResourceName: "google_monitoring_alert_policy.alert_policy", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccMonitoringAlertPolicy_monitoringAlertPolicyBasicExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_monitoring_alert_policy" "alert_policy" { + display_name = "My Alert Policy-%{random_suffix}" + combiner = "OR" + conditions = [ + { + display_name = "test condition" + condition_threshold { + filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"" + duration = "60s" + comparison = "COMPARISON_GT" + aggregations = [ + { + alignment_period = "60s" + per_series_aligner = "ALIGN_RATE" + } + ] + } + } + ] +} +`, context) +} + +func testAccCheckMonitoringAlertPolicyDestroy(s *terraform.State) error { + for name, rs := range s.RootModule().Resources { + if rs.Type != "google_monitoring_alert_policy" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := testAccProvider.Meta().(*Config) + + url, err := replaceVarsForTest(rs, "https://monitoring.googleapis.com/v3/{{name}}") + if err != nil { + return err + } + + _, err = sendRequest(config, "GET", url, nil) + if err == nil { + return fmt.Errorf("MonitoringAlertPolicy still exists at %s", url) + } + } + + return nil +} diff --git a/website/docs/r/compute_interconnect_attachment.html.markdown b/website/docs/r/compute_interconnect_attachment.html.markdown index 50129118..46d6642c 100644 --- a/website/docs/r/compute_interconnect_attachment.html.markdown +++ b/website/docs/r/compute_interconnect_attachment.html.markdown @@ -26,19 +26,20 @@ information, see Creating VLAN Attachments. -## Example Usage +## Example Usage - Interconnect Attachment Basic + ```hcl -resource "google_compute_router" "foobar" { - name = "my-router" - network = "${google_compute_network.foobar.name}" -} - -resource "google_compute_interconnect_attachment" "default" { - name = "test-interconnect" +resource "google_compute_interconnect_attachment" "on_prem" { + name = "on-prem-attachment" interconnect = "my-interconnect-id" router = "${google_compute_router.foobar.self_link}" } + +resource "google_compute_router" "foobar" { + name = "router" + network = "${google_compute_network.foobar.name}" +} ``` ## Argument Reference diff --git a/website/docs/r/monitoring_alert_policy.html.markdown b/website/docs/r/monitoring_alert_policy.html.markdown index cb0aafc7..c9ed4870 100644 --- a/website/docs/r/monitoring_alert_policy.html.markdown +++ b/website/docs/r/monitoring_alert_policy.html.markdown @@ -34,12 +34,17 @@ To get more information about AlertPolicy, see: * How-to Guides * [Official Documentation](https://cloud.google.com/monitoring/alerts/) -## Example Usage + +## Example Usage - Monitoring Alert Policy Basic + -### Basic Usage ```hcl -resource "google_monitoring_alert_policy" "basic" { - display_name = "Test Policy Basic" +resource "google_monitoring_alert_policy" "alert_policy" { + display_name = "My Alert Policy" combiner = "OR" conditions = [ {