From d5e5aa9ec3478477868f222c4185ce20bc21520c Mon Sep 17 00:00:00 2001 From: nitram Date: Tue, 26 Feb 2019 14:03:37 -0800 Subject: [PATCH] add .space resources --- .gitlab-ci.yml | 8 ++++++++ terraform/blockstream-space.tf | 37 ++++++++++++++++++++++++++++++++++ terraform/data.tf | 4 ---- terraform/main.tf | 8 ++++---- terraform/modules/blc/data.tf | 2 +- terraform/outputs.tf | 2 +- terraform/variables.tf | 15 ++++++++++++++ 7 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 terraform/blockstream-space.tf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d317cfc..0a790ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -88,6 +88,10 @@ plan_misc: -var "instance_type=$INSTANCE_TYPE" -var "onion_host=$ONION_HOST" -var "prom_allowed_source_ip=$PROMETHEUS_ALLOWED_SOURCE_IP" + -var "prom_service_acct=$PROM_SA" + -var "satellite_lb=$SATELLITE_LB" + -var "satellite_api_lb=$SATELLITE_API_LB" + -var "satellite_api_lb_staging=$SATELLITE_API_LB_STAGING" -input=false) # Tag with staging_v.* to deploy staging (e.g. staging_v0.1.1) @@ -155,6 +159,10 @@ deploy_misc: -var "instance_type=$INSTANCE_TYPE" -var "onion_host=$ONION_HOST" -var "prom_allowed_source_ip=$PROMETHEUS_ALLOWED_SOURCE_IP" + -var "prom_service_acct=$PROM_SA" + -var "satellite_lb=$SATELLITE_LB" + -var "satellite_api_lb=$SATELLITE_API_LB" + -var "satellite_api_lb_staging=$SATELLITE_API_LB_STAGING" -input=false -auto-approve) # Pushing to this branch destroys the staging infrastructure diff --git a/terraform/blockstream-space.tf b/terraform/blockstream-space.tf new file mode 100644 index 0000000..f2c86b2 --- /dev/null +++ b/terraform/blockstream-space.tf @@ -0,0 +1,37 @@ +resource "google_dns_managed_zone" "blockstream-space" { + name = "blockstream-space" + dns_name = "blockstream.space." + description = "A long time ago, in a galaxy far, far away... P.S. Don't edit directly in Gcloud, but rather in the Satellite API repo (Otherwise, things break and Chase gets really mad)." + project = "${var.project}" + + labels = { + managed-by = "terraform" + } +} + +resource "google_dns_record_set" "a-satellite" { + name = "${google_dns_managed_zone.blockstream-space.dns_name}" + managed_zone = "${google_dns_managed_zone.blockstream-space.name}" + type = "A" + ttl = 300 + + rrdatas = ["${var.satellite_lb}"] +} + +resource "google_dns_record_set" "a-satellite-api" { + name = "api.${google_dns_managed_zone.blockstream-space.dns_name}" + managed_zone = "${google_dns_managed_zone.blockstream-space.name}" + type = "A" + ttl = 300 + + rrdatas = ["${var.satellite_api_lb}"] +} + +resource "google_dns_record_set" "a-satellite-api-staging" { + name = "staging-api.${google_dns_managed_zone.blockstream-space.dns_name}" + managed_zone = "${google_dns_managed_zone.blockstream-space.name}" + type = "A" + ttl = 300 + + rrdatas = ["${var.satellite_api_lb_staging}"] +} diff --git a/terraform/data.tf b/terraform/data.tf index b5038c5..6fc183a 100644 --- a/terraform/data.tf +++ b/terraform/data.tf @@ -8,8 +8,4 @@ data "terraform_remote_state" "blc-prod" { } workspace = "prod" - - defaults { - prometheus_service_account = "${var.prom_service_acct}" - } } diff --git a/terraform/main.tf b/terraform/main.tf index ee055b3..9a101c8 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -37,10 +37,10 @@ module "blc" { region = "${var.region}" zone = "${var.zone}" instance_type = "${var.instance_type[0]}" - host = "${var.host}" + host = ["${var.host}"] ssl_cert = ["${var.ssl_cert}"] timeout = "${var.timeout}" - prom_service_acct = "${data.terraform_remote_state.blc-prod.prometheus_service_account}" + prom_service_acct = "${var.prom_service_acct}" opsgenie_key = "${var.opsgenie_key}" rpcuser = "${var.rpcuser}" rpcpass = "${var.rpcpass}" @@ -67,7 +67,7 @@ module "tor" { zone = "${var.zone}" instance_type = "${var.instance_type[1]}" onion_host = "${var.onion_host}" - prom_service_acct = "${data.terraform_remote_state.blc-prod.prometheus_service_account}" + prom_service_acct = "${var.prom_service_acct}" } module "prometheus" { @@ -87,5 +87,5 @@ module "prometheus" { instance_type = "${var.instance_type[2]}" prom_allowed_source_ip = "${var.prom_allowed_source_ip}" opsgenie_key = "${var.opsgenie_key}" - prom_service_acct = "${terraform.workspace != "misc" ? data.terraform_remote_state.blc-prod.prometheus_service_account : ""}" + prom_service_acct = "${var.prom_service_acct}" } diff --git a/terraform/modules/blc/data.tf b/terraform/modules/blc/data.tf index 8235ded..2cd1bdb 100644 --- a/terraform/modules/blc/data.tf +++ b/terraform/modules/blc/data.tf @@ -29,7 +29,7 @@ data "template_file" "blc" { ionosphere_sse_docker = "${var.ionosphere_sse_docker}" node_exporter_docker = "${var.node_exporter_docker}" opsgenie_key = "${var.opsgenie_key}" - host = "${var.host}" + host = ["${var.host}"] } } diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 936c45a..effb241 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -2,6 +2,6 @@ output "blc_backend_service" { value = "${module.blc.backend_service}" } -output "prom_sa" { +output "prom_svc_acct" { value = "${module.prometheus.prom_svc_acct}" } diff --git a/terraform/variables.tf b/terraform/variables.tf index 3442343..0b7e2a1 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -110,6 +110,21 @@ variable "opsgenie_key" { default = "" } +variable "satellite_lb" { + type = "string" + default = "" +} + +variable "satellite_api_lb" { + type = "string" + default = "" +} + +variable "satellite_api_lb_staging" { + type = "string" + default = "" +} + # Overwritten by CI variable "ionosphere_docker" { type = "string"