Remove old-style Terraform examples (#2848)

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
The Magician 2019-01-10 07:36:33 -08:00 committed by Riley Karson
parent 54dd3ad6e4
commit 7fc6743a9d
3 changed files with 117 additions and 12 deletions

View File

@ -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
}

View File

@ -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

View File

@ -34,12 +34,17 @@ To get more information about AlertPolicy, see:
* How-to Guides
* [Official Documentation](https://cloud.google.com/monitoring/alerts/)
## Example Usage
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=monitoring_alert_policy_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## 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 = [
{