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

NAP-275/domain mapping #39

Merged
merged 3 commits into from
Aug 17, 2021
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
12 changes: 12 additions & 0 deletions experimental/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ output "event_handler_endpoint" {
value = google_cloud_run_service.event_handler.status[0]["url"]
}

output "event_handler_dns_data" {
value = try(google_cloud_run_domain_mapping.event_handler[0].status[0]["resource_records"][0].rrdata, null)
}

output "event_handler_dns_name" {
value = try(google_cloud_run_domain_mapping.event_handler[0].status[0]["resource_records"][0].name, null)
}

output "event_handler_dns_type" {
value = try(google_cloud_run_domain_mapping.event_handler[0].status[0]["resource_records"][0].type, null)
}

output "event_handler_name_servers" {
value = try(module.event_hander_dns[0].name_servers, null)
}
Expand Down
6 changes: 3 additions & 3 deletions experimental/terraform/resource_event_handler.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ resource "google_cloud_run_domain_mapping" "event_handler" {
# conditionally use this module
count = length(var.mapped_domain) > 0 ? 1 : 0
location = var.google_domain_mapping_region
name = "dora.${var.mapped_domain}"
name = "${var.subdomain}.${var.mapped_domain}"

metadata {
namespace = var.google_project_id
Expand All @@ -59,7 +59,7 @@ resource "google_cloud_run_domain_mapping" "event_handler" {

module "event_hander_dns" {
source = "./cloud-dns"
count = length(var.mapped_domain) > 0 ? 1 : 0
count = length(var.mapped_domain) > 0 && var.google_dns ? 1 : 0

project_id = var.google_project_id
name = replace(replace(lower(trimspace(var.mapped_domain)), ".", "-"), "/[^a-z0-9\\-]/", "")
Expand All @@ -69,7 +69,7 @@ module "event_hander_dns" {

recordsets = [
{
name = "dora"
name = "${var.subdomain}"
type = "CNAME"
ttl = 3600
records = [
Expand Down
26 changes: 19 additions & 7 deletions experimental/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ variable "google_region" {
default = "us-central1"
}

variable "google_dns" {
description = "To create a Google Cloud DNS zone and records for event handler"
default = false
type = bool
}

variable "google_domain_mapping_region" {
type = string
description = "Domain mapping region"
Expand Down Expand Up @@ -65,6 +71,15 @@ variable "mapped_domain" {
default = ""
}

/* The default for normal usage is true, because VCS webhooks need to call the endpoint over the
public internet (with auth provided by the security token). But some deployments (including CI
E2E tests on Google infra) will require this to be false. */
variable "make_event_handler_public" {
description = "If true, the event handler endpoint will be accessible by unauthenticated users."
type = bool
default = true
}

variable "owner" {
type = string
description = "The owner of code repository"
Expand All @@ -80,11 +95,8 @@ variable "repository" {
description = "The name of the git repository"
}

/* The default for normal usage is true, because VCS webhooks need to call the endpoint over the
public internet (with auth provided by the security token). But some deployments (including CI
E2E tests on Google infra) will require this to be false. */
variable "make_event_handler_public" {
description = "If true, the event handler endpoint will be accessible by unauthenticated users."
type = bool
default = true
variable "subdomain" {
description = "The prefix added to the `mapped_domain`, of event handler, use to create a record within Google Cloud DNS."
default = "dora"
type = string
}