mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
123 lines
3.0 KiB
Go
123 lines
3.0 KiB
Go
|
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// *** 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"
|
||
|
)
|
||
|
|
||
|
func TestAccComputeUrlMap_urlMapBasicExample(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
CheckDestroy: testAccCheckComputeUrlMapDestroy,
|
||
|
Steps: []resource.TestStep{
|
||
|
{
|
||
|
Config: testAccComputeUrlMap_urlMapBasicExample(acctest.RandString(10)),
|
||
|
},
|
||
|
{
|
||
|
ResourceName: "google_compute_url_map.urlmap",
|
||
|
ImportState: true,
|
||
|
ImportStateVerify: true,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccComputeUrlMap_urlMapBasicExample(val string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
resource "google_compute_url_map" "urlmap" {
|
||
|
name = "urlmap-%s"
|
||
|
description = "a description"
|
||
|
|
||
|
default_service = "${google_compute_backend_service.home.self_link}"
|
||
|
|
||
|
host_rule {
|
||
|
hosts = ["mysite.com"]
|
||
|
path_matcher = "allpaths"
|
||
|
}
|
||
|
|
||
|
path_matcher {
|
||
|
name = "allpaths"
|
||
|
default_service = "${google_compute_backend_service.home.self_link}"
|
||
|
|
||
|
path_rule {
|
||
|
paths = ["/home"]
|
||
|
service = "${google_compute_backend_service.home.self_link}"
|
||
|
}
|
||
|
|
||
|
path_rule {
|
||
|
paths = ["/login"]
|
||
|
service = "${google_compute_backend_service.login.self_link}"
|
||
|
}
|
||
|
|
||
|
path_rule {
|
||
|
paths = ["/static"]
|
||
|
service = "${google_compute_backend_bucket.static.self_link}"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
test {
|
||
|
service = "${google_compute_backend_service.home.self_link}"
|
||
|
host = "hi.com"
|
||
|
path = "/home"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
resource "google_compute_backend_service" "login" {
|
||
|
name = "login-%s"
|
||
|
port_name = "http"
|
||
|
protocol = "HTTP"
|
||
|
timeout_sec = 10
|
||
|
|
||
|
health_checks = ["${google_compute_http_health_check.default.self_link}"]
|
||
|
}
|
||
|
|
||
|
resource "google_compute_backend_service" "home" {
|
||
|
name = "home-%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 = "health-check-%s"
|
||
|
request_path = "/"
|
||
|
check_interval_sec = 1
|
||
|
timeout_sec = 1
|
||
|
}
|
||
|
|
||
|
resource "google_compute_backend_bucket" "static" {
|
||
|
name = "static-asset-backend-bucket-%s"
|
||
|
bucket_name = "${google_storage_bucket.static.name}"
|
||
|
enable_cdn = true
|
||
|
}
|
||
|
|
||
|
resource "google_storage_bucket" "static" {
|
||
|
name = "static-asset-bucket-%s"
|
||
|
location = "US"
|
||
|
}
|
||
|
`, val, val, val, val, val, val,
|
||
|
)
|
||
|
}
|