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

Promote region* compute services to GA #6245

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
15 changes: 15 additions & 0 deletions .changelog/3381.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:new-resource
`google_compute_region_url_map` is now GA
```
```release-note:new-resource
`google_compute_region_target_http_proxy` is now GA
```
```release-note:new-resource
`google_compute_region_target_https_proxy` is now GA
```
```release-note:enhancement
compute: Promoted the following `google_compute_backend_service` fields to GA: `circuit_breakers`, `consistent_hash`, `custom_request_headers`, `locality_lb_policy`, `outlier_detection`
```
```release-note:enhancement
compute: Promoted the following `google_compute_region_backend_service` fields to GA: `affinity_cookie_ttl_sec`,`circuit_breakers`, `consistent_hash`, `failover_policy`, `locality_lb_policy`, `outlier_detection`, `log_config`, `failover`
```
7 changes: 5 additions & 2 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ func Provider() terraform.ResourceProvider {
return provider
}

// Generated resources: 122
// Generated resources: 125
// Generated IAM resources: 51
// Total generated resources: 173
// Total generated resources: 176
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -613,6 +613,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_compute_node_template": resourceComputeNodeTemplate(),
"google_compute_region_autoscaler": resourceComputeRegionAutoscaler(),
"google_compute_region_disk": resourceComputeRegionDisk(),
"google_compute_region_url_map": resourceComputeRegionUrlMap(),
"google_compute_region_health_check": resourceComputeRegionHealthCheck(),
"google_compute_resource_policy": resourceComputeResourcePolicy(),
"google_compute_route": resourceComputeRoute(),
Expand All @@ -630,6 +631,8 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_compute_subnetwork_iam_policy": ResourceIamPolicy(ComputeSubnetworkIamSchema, ComputeSubnetworkIamUpdaterProducer, ComputeSubnetworkIdParseFunc),
"google_compute_target_http_proxy": resourceComputeTargetHttpProxy(),
"google_compute_target_https_proxy": resourceComputeTargetHttpsProxy(),
"google_compute_region_target_http_proxy": resourceComputeRegionTargetHttpProxy(),
"google_compute_region_target_https_proxy": resourceComputeRegionTargetHttpsProxy(),
"google_compute_target_instance": resourceComputeTargetInstance(),
"google_compute_target_ssl_proxy": resourceComputeTargetSslProxy(),
"google_compute_target_tcp_proxy": resourceComputeTargetTcpProxy(),
Expand Down
1,614 changes: 1,509 additions & 105 deletions google/resource_compute_backend_service.go

Large diffs are not rendered by default.

312 changes: 312 additions & 0 deletions google/resource_compute_backend_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,182 @@ func TestAccComputeBackendService_withMaxConnectionsPerEndpoint(t *testing.T) {
})
}

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

serviceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
checkName := fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBackendService_withCustomHeaders(serviceName, checkName),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendService_basic(serviceName, checkName),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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

fr := fmt.Sprintf("forwardrule-test-%s", randString(t, 10))
proxy := fmt.Sprintf("forwardrule-test-%s", randString(t, 10))
backend := fmt.Sprintf("forwardrule-test-%s", randString(t, 10))
hc := fmt.Sprintf("forwardrule-test-%s", randString(t, 10))
urlmap := fmt.Sprintf("forwardrule-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBackendService_internalLoadBalancing(fr, proxy, backend, hc, urlmap),
},
{
ResourceName: "google_compute_backend_service.backend_service",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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

serviceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
checkName := fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBackendService_withLogConfig(serviceName, checkName, 0.7),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendService_withLogConfig(serviceName, checkName, 0.4),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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

backendName := fmt.Sprintf("foo-%s", randString(t, 10))
checkName := fmt.Sprintf("bar-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBackendService_trafficDirectorBasic(backendName, checkName),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendService_trafficDirectorUpdateBasic(backendName, checkName),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeBackendService_trafficDirectorBasic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = [google_compute_health_check.health_check.self_link]
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
locality_lb_policy = "RING_HASH"
circuit_breakers {
max_connections = 10
}
consistent_hash {
http_cookie {
ttl {
seconds = 11
nanos = 1234
}
name = "mycookie"
}
}
outlier_detection {
consecutive_errors = 2
}
}

resource "google_compute_health_check" "health_check" {
name = "%s"
http_health_check {
port = 80
}
}
`, serviceName, checkName)
}

func testAccComputeBackendService_trafficDirectorUpdateBasic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = [google_compute_health_check.health_check.self_link]
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
locality_lb_policy = "RANDOM"
circuit_breakers {
max_connections = 10
}
outlier_detection {
consecutive_errors = 2
}
}

resource "google_compute_health_check" "health_check" {
name = "%s"
http_health_check {
port = 80
}
}
`, serviceName, checkName)
}

func testAccComputeBackendService_basic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
Expand Down Expand Up @@ -1063,3 +1239,139 @@ resource "google_compute_health_check" "default" {
}
`, service, maxRate, instance, neg, network, network, check)
}

func testAccComputeBackendService_withCustomHeaders(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = [google_compute_http_health_check.zero.self_link]

custom_request_headers = ["Client-Region: {client_region}", "Client-Rtt: {client_rtt_msec}"]
}

resource "google_compute_http_health_check" "zero" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
`, serviceName, checkName)
}

func testAccComputeBackendService_internalLoadBalancing(fr, proxy, backend, hc, urlmap string) string {
return fmt.Sprintf(`
resource "google_compute_global_forwarding_rule" "forwarding_rule" {
name = "%s"
target = google_compute_target_http_proxy.default.self_link
port_range = "80"
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
ip_address = "0.0.0.0"
}

resource "google_compute_target_http_proxy" "default" {
name = "%s"
description = "a description"
url_map = google_compute_url_map.default.self_link
}

resource "google_compute_backend_service" "backend_service" {
name = "%s"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "INTERNAL_SELF_MANAGED"

backend {
group = google_compute_instance_group_manager.foobar.instance_group
balancing_mode = "RATE"
capacity_scaler = 0.4
max_rate_per_instance = 50
}

health_checks = [google_compute_health_check.default.self_link]
}

resource "google_compute_health_check" "default" {
name = "%s"
check_interval_sec = 1
timeout_sec = 1

tcp_health_check {
port = "80"
}
}

resource "google_compute_url_map" "default" {
name = "%s"
description = "a description"
default_service = google_compute_backend_service.backend_service.self_link

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

path_matcher {
name = "allpaths"
default_service = google_compute_backend_service.backend_service.self_link

path_rule {
paths = ["/*"]
service = google_compute_backend_service.backend_service.self_link
}
}
}

data "google_compute_image" "debian_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_instance_group_manager" "foobar" {
name = "igm-internal"
version {
instance_template = google_compute_instance_template.foobar.self_link
name = "primary"
}
base_instance_name = "foobar"
zone = "us-central1-f"
target_size = 1
}

resource "google_compute_instance_template" "foobar" {
name = "instance-template-internal"
machine_type = "n1-standard-1"

network_interface {
network = "default"
}

disk {
source_image = data.google_compute_image.debian_image.self_link
auto_delete = true
boot = true
}
}
`, fr, proxy, backend, hc, urlmap)
}

func testAccComputeBackendService_withLogConfig(serviceName, checkName string, sampleRate float64) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = [google_compute_http_health_check.zero.self_link]

log_config {
enable = true
sample_rate = %v
}
}

resource "google_compute_http_health_check" "zero" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
`, serviceName, sampleRate, checkName)
}
Loading