Skip to content

Commit

Permalink
Merge pull request #787 from Vizzuality/infrastructure/remove_legacy_…
Browse files Browse the repository at this point in the history
…redirect_domain

Infrastructure/remove legacy redirect domain
  • Loading branch information
Agnieszka Figiel authored Nov 28, 2023
2 parents 8ed11c3 + e5be3f9 commit 2aafbc5
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 96 deletions.
58 changes: 28 additions & 30 deletions infrastructure/base/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions infrastructure/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ module "staging" {
backend_min_scale = 0
frontend_max_scale = 1
backend_max_scale = 1
redirect_domain = var.redirect_domain
dns_zone_name = module.dns.dns_zone_name
redirect_dns_zone_name = module.redirect_dns.dns_zone_name
subdomain = "staging"
uptime_alert_email = var.uptime_alert_email
from_email_address = var.from_email_address
Expand Down Expand Up @@ -70,9 +68,7 @@ module "production" {
frontend_min_scale = 1
backend_min_scale = 1
cors_origin = "https://${var.domain}"
redirect_domain = var.redirect_domain
dns_zone_name = module.dns.dns_zone_name
redirect_dns_zone_name = module.redirect_dns.dns_zone_name
uptime_alert_email = var.uptime_alert_email
from_email_address = var.from_email_address
instance_role = "production"
Expand All @@ -91,12 +87,6 @@ module "dns" {
name = "hecoinvest"
}

module "redirect_dns" {
source = "./modules/dns"
domain = var.redirect_domain
name = "heco-redirect"
}

module "sendgrid_dns_entries" {
source = "./modules/sendgrid_dns_entries"
domain = var.domain
Expand Down
3 changes: 0 additions & 3 deletions infrastructure/base/modules/env/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
locals {
domain = var.subdomain == "" ? var.domain : "${var.subdomain}.${var.domain}"
redirect_domain = var.subdomain == "" ? var.redirect_domain : "${var.subdomain}.${var.redirect_domain}"
}

module "network" {
Expand Down Expand Up @@ -567,8 +566,6 @@ module "load_balancer" {
frontend_cloud_run_name = module.frontend_cloudrun.name
domain = var.domain
dns_managed_zone_name = var.dns_zone_name
redirect_domain = var.redirect_domain
redirect_domain_dns_managed_zone_name = var.redirect_dns_zone_name
subdomain = var.subdomain
}

Expand Down
10 changes: 0 additions & 10 deletions infrastructure/base/modules/env/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,11 @@ variable "dns_zone_name" {
description = "Name for the GCP DNS Zone"
}

variable "redirect_dns_zone_name" {
type = string
description = "Name for the GCP redirect DNS Zone"
}

variable "domain" {
type = string
description = "Base domain for the DNS zone"
}

variable "redirect_domain" {
type = string
description = "Legacy domain to redirect"
}

variable "subdomain" {
type = string
default = ""
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/base/modules/gcr/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ resource "google_artifact_registry_repository" "repository" {
repository_id = var.name
description = "Docker image repository for ${var.name}"
format = "DOCKER"

cleanup_policy_dry_run = true
}
26 changes: 1 addition & 25 deletions infrastructure/base/modules/load-balancer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ resource "google_compute_global_address" "ip_address" {

locals {
domain = var.subdomain == "" ? var.domain : "${var.subdomain}.${var.domain}"
redirect_domain = var.subdomain == "" ? var.redirect_domain : "${var.subdomain}.${var.redirect_domain}"
}

# ------------------------------------------------------------------------------
Expand All @@ -33,7 +32,7 @@ resource "google_compute_managed_ssl_certificate" "load-balancer-certificate" {
name = "${var.name}-lb-cert"

managed {
domains = [local.domain, local.redirect_domain]
domains = [local.domain]
}
}

Expand Down Expand Up @@ -82,20 +81,6 @@ resource "google_compute_url_map" "load-balancer-url-map" {
service = google_compute_backend_service.backend_service.id
}
}

host_rule {
hosts = [local.redirect_domain]
path_matcher = "redirect"
}

path_matcher {
name = "redirect"
default_url_redirect {
strip_query = false
host_redirect = local.domain
https_redirect = true
}
}
}

resource "google_compute_region_network_endpoint_group" "cloudrun_backend_neg" {
Expand Down Expand Up @@ -148,12 +133,3 @@ resource "google_dns_record_set" "frontend-dns-record-set" {
rrdatas = [google_compute_global_address.ip_address.address]
}

# DNS record
resource "google_dns_record_set" "redirect-dns-record-set" {
project = var.project
name = "${local.redirect_domain}."
type = "A"
ttl = 3600
managed_zone = var.redirect_domain_dns_managed_zone_name
rrdatas = [google_compute_global_address.ip_address.address]
}
9 changes: 0 additions & 9 deletions infrastructure/base/modules/load-balancer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,3 @@ variable "subdomain" {
description = "If set, it will be prepended to the domain to form a subdomain."
}

variable "redirect_domain" {
type = string
description = "Legacy domain to redirect"
}

variable "redirect_domain_dns_managed_zone_name" {
type = string
description = "Name of the DNS Zone"
}
5 changes: 0 additions & 5 deletions infrastructure/base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ variable "uptime_alert_email" {
description = "Email address to which uptime alerts should be sent"
}

variable "redirect_domain" {
type = string
description = "Legacy domain to redirect"
}

variable "from_email_address" {
type = string
description = "Email address from which to send emails"
Expand Down
1 change: 0 additions & 1 deletion infrastructure/base/vars/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ staging_project_name = "staging-heco"
production_project_name = "heco"

domain = "hecoinvest.org"
redirect_domain = "heco.vizzuality.com"
google_analytics_key = "changeMe"
uptime_alert_email = "[email protected]"
6 changes: 3 additions & 3 deletions infrastructure/base/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.20"
version = "~> 5.7"
}

google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.20"
version = "~> 5.7"
}

random = {
source = "hashicorp/random"
version = "~> 3.1.0"
}
}
required_version = "1.2.4"
required_version = "1.4.7"
}

provider "google" {
Expand Down

0 comments on commit 2aafbc5

Please sign in to comment.