2018-10-05 19:32:57 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// *** 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"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
2018-10-26 18:03:43 +00:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2018-10-05 19:32:57 +00:00
|
|
|
)
|
|
|
|
|
2018-11-09 21:02:03 +00:00
|
|
|
func TestAccComputeTargetHttpProxy_targetHttpProxyBasicExample(t *testing.T) {
|
2018-10-05 19:32:57 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckComputeTargetHttpProxyDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
{
|
2018-11-09 21:02:03 +00:00
|
|
|
Config: testAccComputeTargetHttpProxy_targetHttpProxyBasicExample(acctest.RandString(10)),
|
2018-10-05 19:32:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
ResourceName: "google_compute_target_http_proxy.default",
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-11-09 21:02:03 +00:00
|
|
|
func testAccComputeTargetHttpProxy_targetHttpProxyBasicExample(val string) string {
|
2018-10-05 19:32:57 +00:00
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_compute_target_http_proxy" "default" {
|
|
|
|
name = "test-proxy-%s"
|
|
|
|
url_map = "${google_compute_url_map.default.self_link}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_url_map" "default" {
|
|
|
|
name = "url-map-%s"
|
|
|
|
default_service = "${google_compute_backend_service.default.self_link}"
|
|
|
|
|
|
|
|
host_rule {
|
|
|
|
hosts = ["mysite.com"]
|
|
|
|
path_matcher = "allpaths"
|
|
|
|
}
|
|
|
|
|
|
|
|
path_matcher {
|
|
|
|
name = "allpaths"
|
|
|
|
default_service = "${google_compute_backend_service.default.self_link}"
|
|
|
|
|
|
|
|
path_rule {
|
|
|
|
paths = ["/*"]
|
|
|
|
service = "${google_compute_backend_service.default.self_link}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_backend_service" "default" {
|
|
|
|
name = "backend-service-%s"
|
|
|
|
port_name = "http"
|
|
|
|
protocol = "HTTP"
|
|
|
|
timeout_sec = 10
|
|
|
|
|
|
|
|
health_checks = ["${google_compute_http_health_check.default.self_link}"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_http_health_check" "default" {
|
|
|
|
name = "http-health-check-%s"
|
|
|
|
request_path = "/"
|
|
|
|
check_interval_sec = 1
|
|
|
|
timeout_sec = 1
|
|
|
|
}
|
|
|
|
`, val, val, val, val,
|
|
|
|
)
|
|
|
|
}
|
2018-10-26 18:03:43 +00:00
|
|
|
|
|
|
|
func testAccCheckComputeTargetHttpProxyDestroy(s *terraform.State) error {
|
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "google_compute_target_http_proxy" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
|
|
|
|
|
|
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpProxies/{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = sendRequest(config, "GET", url, nil)
|
|
|
|
if err == nil {
|
|
|
|
return fmt.Errorf("ComputeTargetHttpProxy still exists at %s", url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|