blockstream-satellite-api/terraform/network.tf

100 lines
3.1 KiB
Terraform
Raw Normal View History

2019-03-07 12:29:43 -08:00
# IP address
resource "google_compute_global_address" "lb" {
name = "satellite-api-client-lb-${local.env}"
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
resource "google_compute_global_forwarding_rule" "rule-https" {
name = "satellite-api-https-forwarding-rule-${local.env}"
2019-05-31 07:23:30 -07:00
target = google_compute_target_https_proxy.https-proxy[0].self_link
2019-03-07 12:29:43 -08:00
port_range = "443"
ip_protocol = "TCP"
2019-05-31 07:23:30 -07:00
ip_address = google_compute_global_address.lb[0].address
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
}
resource "google_compute_global_forwarding_rule" "rule-http" {
name = "satellite-api-http-forwarding-rule-${local.env}"
2019-05-31 07:23:30 -07:00
target = google_compute_target_http_proxy.http-proxy[0].self_link
2019-03-07 12:29:43 -08:00
port_range = "80"
ip_protocol = "TCP"
2019-05-31 07:23:30 -07:00
ip_address = google_compute_global_address.lb[0].address
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
}
# Target proxies
resource "google_compute_target_http_proxy" "http-proxy" {
name = "satellite-api-http-proxy-${local.env}"
2019-05-31 07:23:30 -07:00
url_map = google_compute_url_map.http[0].self_link
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
}
resource "google_compute_target_https_proxy" "https-proxy" {
name = "satellite-api-https-proxy-${local.env}"
2019-05-31 07:23:30 -07:00
url_map = google_compute_url_map.https[0].self_link
2019-06-06 07:33:01 -07:00
ssl_certificates = [var.ssl_cert]
project = var.project
2019-05-31 07:23:30 -07:00
count = local.create_mainnet
2019-03-07 12:29:43 -08:00
}
# URL maps
resource "google_compute_url_map" "http" {
name = "satellite-api-http-urlmap-${local.env}"
2019-05-31 07:23:30 -07:00
default_service = data.terraform_remote_state.blc-mainnet.outputs.blc_backend_service_mainnet
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
host_rule {
2019-06-06 07:33:01 -07:00
hosts = [var.host]
2019-03-07 12:29:43 -08:00
path_matcher = "allpaths"
}
path_matcher {
name = "allpaths"
2019-05-31 07:23:30 -07:00
default_service = data.terraform_remote_state.blc-mainnet.outputs.blc_backend_service_mainnet
2019-03-07 12:29:43 -08:00
path_rule {
paths = ["/*"]
2019-05-31 07:23:30 -07:00
service = data.terraform_remote_state.blc-mainnet.outputs.blc_backend_service_mainnet
2019-03-07 12:29:43 -08:00
}
path_rule {
paths = ["/testnet", "/testnet/*", "/api", "/api/*"]
2019-05-31 07:23:30 -07:00
service = data.terraform_remote_state.blc-testnet.outputs.blc_backend_service_testnet
2019-03-07 12:29:43 -08:00
}
}
}
resource "google_compute_url_map" "https" {
name = "satellite-api-https-urlmap-${local.env}"
2019-05-31 07:23:30 -07:00
default_service = data.terraform_remote_state.blc-mainnet.outputs.blc_backend_service_mainnet
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
host_rule {
2019-06-06 07:33:01 -07:00
hosts = [var.host]
2019-03-07 12:29:43 -08:00
path_matcher = "allpaths"
}
2019-03-07 12:29:43 -08:00
path_matcher {
name = "allpaths"
2019-05-31 07:23:30 -07:00
default_service = data.terraform_remote_state.blc-mainnet.outputs.blc_backend_service_mainnet
2019-03-07 12:29:43 -08:00
path_rule {
paths = ["/*"]
2019-05-31 07:23:30 -07:00
service = data.terraform_remote_state.blc-mainnet.outputs.blc_backend_service_mainnet
2019-03-07 12:29:43 -08:00
}
path_rule {
paths = ["/testnet", "/testnet/*", "/api", "/api/*"]
2019-05-31 07:23:30 -07:00
service = data.terraform_remote_state.blc-testnet.outputs.blc_backend_service_testnet
2019-03-07 12:29:43 -08:00
}
}
}
2019-05-31 07:23:30 -07:00