mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Make path_rule Optional in google_url_map's path_matcher block. (#118)
* Made path_rule optional for path_matcher in google_compute_url_map. * Updated google_compute_url_map docs. * Updated test configuration formatting.
This commit is contained in:
parent
19feb0a350
commit
aa48489a05
@ -90,7 +90,7 @@ func resourceComputeUrlMap() *schema.Resource {
|
|||||||
|
|
||||||
"path_rule": &schema.Schema{
|
"path_rule": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Required: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"paths": &schema.Schema{
|
"paths": &schema.Schema{
|
||||||
|
@ -82,6 +82,33 @@ func TestAccComputeUrlMap_advanced(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccComputeUrlMap_noPathRulesWithUpdate(t *testing.T) {
|
||||||
|
bsName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
|
||||||
|
hcName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
|
||||||
|
umName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeUrlMapDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccComputeUrlMap_noPathRules(bsName, hcName, umName),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckComputeUrlMapExists(
|
||||||
|
"google_compute_url_map.foobar"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccComputeUrlMap_basic1(bsName, hcName, umName),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckComputeUrlMapExists(
|
||||||
|
"google_compute_url_map.foobar"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckComputeUrlMapDestroy(s *terraform.State) error {
|
func testAccCheckComputeUrlMapDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
@ -152,6 +179,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "boop"
|
name = "boop"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/*"]
|
paths = ["/*"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -193,6 +221,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "blip"
|
name = "blip"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/*", "/home"]
|
paths = ["/*", "/home"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -238,6 +267,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "blop"
|
name = "blop"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/*", "/home"]
|
paths = ["/*", "/home"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -247,6 +277,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "blip"
|
name = "blip"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/*", "/home"]
|
paths = ["/*", "/home"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -290,6 +321,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "blep"
|
name = "blep"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/home"]
|
paths = ["/home"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -304,6 +336,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "blub"
|
name = "blub"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/*", "/blub"]
|
paths = ["/*", "/blub"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -313,6 +346,7 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
path_matcher {
|
path_matcher {
|
||||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
name = "blip"
|
name = "blip"
|
||||||
|
|
||||||
path_rule {
|
path_rule {
|
||||||
paths = ["/*", "/home"]
|
paths = ["/*", "/home"]
|
||||||
service = "${google_compute_backend_service.foobar.self_link}"
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
@ -320,3 +354,40 @@ resource "google_compute_url_map" "foobar" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||||
|
|
||||||
|
func testAccComputeUrlMap_noPathRules(bsName, hcName, umName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "google_compute_backend_service" "foobar" {
|
||||||
|
name = "urlmap-test-%s"
|
||||||
|
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_compute_http_health_check" "zero" {
|
||||||
|
name = "urlmap-test-%s"
|
||||||
|
request_path = "/"
|
||||||
|
check_interval_sec = 1
|
||||||
|
timeout_sec = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_compute_url_map" "foobar" {
|
||||||
|
name = "urlmap-test-%s"
|
||||||
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
|
|
||||||
|
host_rule {
|
||||||
|
hosts = ["mysite.com", "myothersite.com"]
|
||||||
|
path_matcher = "boop"
|
||||||
|
}
|
||||||
|
|
||||||
|
path_matcher {
|
||||||
|
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
|
name = "boop"
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
host = "mysite.com"
|
||||||
|
path = "/*"
|
||||||
|
service = "${google_compute_backend_service.foobar.self_link}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, bsName, hcName, umName)
|
||||||
|
}
|
||||||
|
@ -96,10 +96,7 @@ resource "google_storage_bucket" "static" {
|
|||||||
|
|
||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
* `default_service` - (Required) The URL of the backend service or backend bucket to use when none
|
* `default_service` - (Required) The backend service or backend bucket to use when none of the given rules match.
|
||||||
of the given rules match. See the documentation for formatting the service/bucket
|
|
||||||
URL
|
|
||||||
[here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#defaultService)
|
|
||||||
|
|
||||||
* `name` - (Required) A unique name for the resource, required by GCE.
|
* `name` - (Required) A unique name for the resource, required by GCE.
|
||||||
Changing this forces a new resource to be created.
|
Changing this forces a new resource to be created.
|
||||||
@ -108,50 +105,42 @@ The following arguments are supported:
|
|||||||
|
|
||||||
* `description` - (Optional) A brief description of this resource.
|
* `description` - (Optional) A brief description of this resource.
|
||||||
|
|
||||||
* `host_rule` - (Optional) A list of host rules. See below for configuration
|
* `host_rule` - (Optional) A list of host rules. Multiple blocks of this type are permitted. Structure is documented below.
|
||||||
options.
|
|
||||||
|
|
||||||
* `path_matcher` - (Optional) A list of paths to match. See below for
|
* `path_matcher` - (Optional) A list of paths to match. Structure is documented below.
|
||||||
configuration options.
|
|
||||||
|
|
||||||
* `project` - (Optional) The project in which the resource belongs. If it
|
* `project` - (Optional) The project in which the resource belongs. If it
|
||||||
is not provided, the provider project is used.
|
is not provided, the provider project is used.
|
||||||
|
|
||||||
* `test` - (Optional) The test to perform. See below for configuration options.
|
* `test` - (Optional) The test to perform. Multiple blocks of this type are permitted. Structure is documented below.
|
||||||
|
|
||||||
The `host_rule` block supports: (This block can be defined multiple times).
|
The `host_rule` block supports:
|
||||||
|
|
||||||
* `hosts` (Required) - A list of hosts to match against. See the documentation
|
* `hosts` (Required) - The list of [host patterns](https://cloud.google.com/compute/docs/reference/latest/urlMaps#hostRules.hosts)
|
||||||
for formatting each host
|
to match.
|
||||||
[here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#hostRules.hosts)
|
|
||||||
|
|
||||||
* `description` - (Optional) An optional description of the host rule.
|
* `description` - (Optional) An optional description of the host rule.
|
||||||
|
|
||||||
* `path_matcher` - (Required) The name of the `path_matcher` (defined below)
|
* `path_matcher` - (Required) The name of the `path_matcher` to apply this host rule to.
|
||||||
to apply this host rule to.
|
|
||||||
|
|
||||||
The `path_matcher` block supports: (This block can be defined multiple times)
|
The `path_matcher` block supports:
|
||||||
|
|
||||||
* `default_service` - (Required) The URL for the backend service or backend bucket to use if none
|
* `name` - (Required) The name of the `path_matcher` resource.
|
||||||
of the given paths match. See the documentation for formatting the service/bucket
|
|
||||||
URL [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatcher.defaultService)
|
|
||||||
|
|
||||||
* `name` - (Required) The name of the `path_matcher` resource. Used by the
|
* `default_service` - (Required) The backend service or backend bucket to use if none of the given paths match.
|
||||||
`host_rule` block above.
|
|
||||||
|
|
||||||
* `description` - (Optional) An optional description of the host rule.
|
* `description` - (Optional) An optional description of the host rule.
|
||||||
|
|
||||||
The `path_matcher.path_rule` sub-block supports: (This block can be defined
|
* `path_rule` - (Optional) A list of path rules. Multiple blocks of this type are permitted. Structure is documented below.
|
||||||
multiple times)
|
|
||||||
|
|
||||||
* `paths` - (Required) The list of paths to match against. See the
|
The `path_rule` block supports:
|
||||||
documentation for formatting these [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatchers.pathRules.paths)
|
|
||||||
|
|
||||||
* `service` - (Required) The URL for the backend service or backend bucket to use if any
|
* `paths` - (Required) The list of [paths](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatchers.pathRules.paths)
|
||||||
of the given paths match. See the documentation for formatting the service/bucket
|
to match against.
|
||||||
URL [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatcher.defaultService)
|
|
||||||
|
|
||||||
The optional `test` block supports: (This block can be defined multiple times)
|
* `service` - (Required) The backend service or backend bucket to use if any of the given paths match.
|
||||||
|
|
||||||
|
The `test` block supports:
|
||||||
|
|
||||||
* `service` - (Required) The backend service or backend bucket that should be matched by this test.
|
* `service` - (Required) The backend service or backend bucket that should be matched by this test.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user