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

Add path_rules to RegionUrlMap #1489

Merged
merged 1 commit into from
Dec 9, 2019
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
1,760 changes: 1,741 additions & 19 deletions google-beta/resource_compute_region_url_map.go

Large diffs are not rendered by default.

224 changes: 224 additions & 0 deletions google-beta/resource_compute_region_url_map_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,230 @@ resource "google_compute_region_health_check" "default" {
`, context)
}

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

context := map[string]interface{}{
"random_suffix": acctest.RandString(10),
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
CheckDestroy: testAccCheckComputeRegionUrlMapDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeRegionUrlMap_regionUrlMapL7IlbPathExample(context),
},
},
})
}

func testAccComputeRegionUrlMap_regionUrlMapL7IlbPathExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_region_url_map" "regionurlmap" {
provider = "google-beta"
name = "regionurlmap%{random_suffix}"
description = "a description"
default_service = google_compute_region_backend_service.home.self_link

host_rule {
hosts = ["mysite.com"]
path_matcher = "allpaths"
}

path_matcher {
name = "allpaths"
default_service = google_compute_region_backend_service.home.self_link

path_rule {
paths = ["/home"]
route_action {
cors_policy {
allow_credentials = true
allow_headers = ["Allowed content"]
allow_methods = ["GET"]
allow_origins = ["Allowed origin"]
expose_headers = ["Exposed header"]
max_age = 30
disabled = false
}
fault_injection_policy {
abort {
http_status = 234
percentage = 5.6
}
delay {
fixed_delay {
seconds = 0
nanos = 50000
}
percentage = 7.8
}
}
request_mirror_policy {
backend_service = google_compute_region_backend_service.home.self_link
}
retry_policy {
num_retries = 4
per_try_timeout {
seconds = 30
}
retry_conditions = ["5xx", "deadline-exceeded"]
}
timeout {
seconds = 20
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
}
weighted_backend_services {
backend_service = google_compute_region_backend_service.home.self_link
weight = 400
header_action {
request_headers_to_remove = ["RemoveMe"]
request_headers_to_add {
header_name = "AddMe"
header_value = "MyValue"
replace = true
}
response_headers_to_remove = ["RemoveMe"]
response_headers_to_add {
header_name = "AddMe"
header_value = "MyValue"
replace = false
}
}
}
}
}
}

test {
service = google_compute_region_backend_service.home.self_link
host = "hi.com"
path = "/home"
}
}

resource "google_compute_region_backend_service" "home" {
provider = "google-beta"
name = "home%{random_suffix}"
protocol = "HTTP"
timeout_sec = 10

health_checks = [google_compute_region_health_check.default.self_link]
load_balancing_scheme = "INTERNAL_MANAGED"
}

resource "google_compute_region_health_check" "default" {
provider = "google-beta"
name = "health-check%{random_suffix}"
http_health_check {
port = 80
}
}
`, context)
}

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

context := map[string]interface{}{
"random_suffix": acctest.RandString(10),
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
CheckDestroy: testAccCheckComputeRegionUrlMapDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeRegionUrlMap_regionUrlMapL7IlbPathPartialExample(context),
},
},
})
}

func testAccComputeRegionUrlMap_regionUrlMapL7IlbPathPartialExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_region_url_map" "regionurlmap" {
provider = "google-beta"
name = "regionurlmap%{random_suffix}"
description = "a description"
default_service = google_compute_region_backend_service.home.self_link

host_rule {
hosts = ["mysite.com"]
path_matcher = "allpaths"
}

path_matcher {
name = "allpaths"
default_service = google_compute_region_backend_service.home.self_link

path_rule {
paths = ["/home"]
route_action {
retry_policy {
num_retries = 4
per_try_timeout {
seconds = 30
}
retry_conditions = ["5xx", "deadline-exceeded"]
}
timeout {
seconds = 20
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
}
weighted_backend_services {
backend_service = google_compute_region_backend_service.home.self_link
weight = 400
header_action {
response_headers_to_add {
header_name = "AddMe"
header_value = "MyValue"
replace = false
}
}
}
}
}
}

test {
service = google_compute_region_backend_service.home.self_link
host = "hi.com"
path = "/home"
}
}

resource "google_compute_region_backend_service" "home" {
provider = "google-beta"
name = "home%{random_suffix}"
protocol = "HTTP"
timeout_sec = 10

health_checks = [google_compute_region_health_check.default.self_link]
load_balancing_scheme = "INTERNAL_MANAGED"
}

resource "google_compute_region_health_check" "default" {
provider = "google-beta"
name = "health-check%{random_suffix}"
http_health_check {
port = 80
}
}
`, context)
}

func testAccCheckComputeRegionUrlMapDestroy(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_compute_region_url_map" {
Expand Down
Loading