Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path_matcher in region url maps #2810

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4298.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
google_compute_region_url_map: removed requirement for default_service, as it should be a choice of default_service or default_url_redirect
```
12 changes: 6 additions & 6 deletions google-beta/resource_compute_region_url_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,20 @@ you create the resource.`,
Description: `The list of named PathMatchers to use against the URL.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `The name to which this PathMatcher is referred by the HostRule.`,
},
"default_service": {
Type: schema.TypeString,
Required: true,
Optional: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
Description: `A reference to a RegionBackendService resource. This will be used if
none of the pathRules defined by this PathMatcher is matched by
the URL's path portion.`,
ExactlyOneOf: []string{},
},
"name": {
Type: schema.TypeString,
Required: true,
Description: `The name to which this PathMatcher is referred by the HostRule.`,
},
"default_url_redirect": {
Type: schema.TypeList,
Optional: true,
Expand Down
46 changes: 46 additions & 0 deletions google-beta/resource_compute_region_url_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ func TestAccComputeRegionUrlMap_defaultUrlRedirect(t *testing.T) {
})
}

func TestAccComputeRegionUrlMap_defaultUrlRedirectWithinPathMatcher(t *testing.T) {
t.Parallel()

randomSuffix := randString(t, 10)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeUrlMapDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRegionUrlMap_defaultUrlRedirectWithinPathMatcherConfig(randomSuffix),
},
{
ResourceName: "google_compute_region_url_map.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeRegionUrlMap_basic1(randomSuffix string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {
Expand Down Expand Up @@ -853,3 +875,27 @@ resource "google_compute_region_url_map" "foobar" {
}
`, randomSuffix)
}

func testAccComputeRegionUrlMap_defaultUrlRedirectWithinPathMatcherConfig(randomSuffix string) string {
return fmt.Sprintf(`
resource "google_compute_region_url_map" "foobar" {
name = "urlmap-test-%s"
default_url_redirect {
https_redirect = true
strip_query = false
}
host_rule {
hosts = ["mysite.com"]
path_matcher = "allpaths"
}

path_matcher {
name = "allpaths"
default_url_redirect {
https_redirect = true
strip_query = false
}
}
}
`, randomSuffix)
}
2 changes: 1 addition & 1 deletion website/docs/r/compute_region_url_map.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ The `host_rule` block supports:
The `path_matcher` block supports:

* `default_service` -
(Required)
(Optional)
A reference to a RegionBackendService resource. This will be used if
none of the pathRules defined by this PathMatcher is matched by
the URL's path portion.
Expand Down