blockstream-satellite-api/terraform/network.tf

55 lines
1.6 KiB
Terraform
Raw Normal View History

2019-03-07 12:29:43 -08:00
# IP address
2019-06-10 06:03:30 -07:00
resource "google_compute_address" "lb" {
2019-03-07 12:29:43 -08:00
name = "satellite-api-client-lb-${local.env}"
2019-06-10 06:03:30 -07:00
region = var.region
2019-05-31 07:23:30 -07:00
project = var.project
count = local.create_mainnet
2019-03-07 12:29:43 -08:00
}
# Forwarding rules
2019-06-10 06:03:30 -07:00
resource "google_compute_forwarding_rule" "rule-https" {
2019-03-07 12:29:43 -08:00
name = "satellite-api-https-forwarding-rule-${local.env}"
2019-06-13 09:01:23 -07:00
target = google_compute_target_pool.lb-pool[0].self_link
2019-03-07 12:29:43 -08:00
port_range = "443"
ip_protocol = "TCP"
2019-06-10 06:03:30 -07:00
ip_address = google_compute_address.lb[0].address
region = var.region
2019-06-06 07:33:01 -07:00
project = var.project
2019-05-31 07:23:30 -07:00
count = local.create_mainnet
2019-03-07 12:29:43 -08:00
}
2019-06-10 06:03:30 -07:00
resource "google_compute_forwarding_rule" "rule-http" {
2019-03-07 12:29:43 -08:00
name = "satellite-api-http-forwarding-rule-${local.env}"
2019-06-13 09:01:23 -07:00
target = google_compute_target_pool.lb-pool[0].self_link
2019-03-07 12:29:43 -08:00
port_range = "80"
ip_protocol = "TCP"
2019-06-10 06:03:30 -07:00
ip_address = google_compute_address.lb[0].address
region = var.region
2019-06-06 07:33:01 -07:00
project = var.project
2019-05-31 07:23:30 -07:00
count = local.create_mainnet
2019-03-07 12:29:43 -08:00
}
2019-06-13 09:01:23 -07:00
resource "google_compute_target_pool" "lb-pool" {
name = "satellite-api-lb-target-pool-${local.env}"
2019-06-10 06:03:30 -07:00
region = var.region
2019-06-06 07:33:01 -07:00
project = var.project
2019-05-31 07:23:30 -07:00
count = local.create_mainnet
2019-03-07 12:29:43 -08:00
2019-06-10 06:03:30 -07:00
health_checks = [
2019-06-13 09:01:23 -07:00
google_compute_http_health_check.lb-health[0].self_link
2019-06-10 06:03:30 -07:00
]
2019-03-07 12:29:43 -08:00
}
2019-06-13 09:01:23 -07:00
resource "google_compute_http_health_check" "lb-health" {
name = "satellite-api-lb-http-health-${local.env}"
2019-06-10 06:03:30 -07:00
project = var.project
count = local.create_mainnet
2019-03-07 12:29:43 -08:00
2019-06-10 06:03:30 -07:00
timeout_sec = 5
check_interval_sec = 10
2019-03-07 12:29:43 -08:00
2019-06-10 06:03:30 -07:00
host = "${local.env == "staging" ? "staging-" : ""}api.blockstream.space"
port = "80"
request_path = "/healthz"
2019-03-07 12:29:43 -08:00
}