Skip to content

Commit

Permalink
Pull subdomain info from Nullstone instead of calculating.
Browse files Browse the repository at this point in the history
  • Loading branch information
BSick7 committed Dec 14, 2024
1 parent fb22e8c commit eb2f390
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 48 deletions.
40 changes: 20 additions & 20 deletions .terraform.lock.hcl

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

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# 0.1.1 (Dec 14, 2024)
* Pull subdomain info from Nullstone instead of calculating.
* Upgrade `ns` terraform provider.

# 0.1.0 (Dec 13, 2024)
* Initial draft
22 changes: 0 additions & 22 deletions calculate.tf

This file was deleted.

2 changes: 1 addition & 1 deletion cert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module "cert" {
scope = ""

subdomains = {
(local.dns_name) = local.zone_id
(local.subdomain_name) = local.subdomain_zone_id
}
}

Expand Down
2 changes: 1 addition & 1 deletion dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "google_dns_managed_zone" "this" {
resource "aws_route53_record" "this-delegation" {
provider = aws.domain

name = local.subdomain
name = local.subdomain_part
zone_id = local.domain_zone_id
type = "NS"
ttl = 300
Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "name" {
value = local.dns_name
value = local.subdomain_name
description = "string ||| The name of the created subdomain. (Format: '{{dns_name}}[.{{env}}].{{domain}}')"
}

Expand All @@ -9,12 +9,12 @@ output "fqdn" {
}

output "zone_id" {
value = local.zone_id
value = local.subdomain_zone_id
description = "string ||| Google DNS Managed Zone ID (Format: projects/{{project}}/managedZones/{{name}})."
}

output "nameservers" {
value = local.nameservers
value = local.subdomain_nameservers
description = "list(string) ||| List of Nameservers for Google DNS Managed Zone."
}

Expand Down
12 changes: 11 additions & 1 deletion subdomain.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
data "ns_subdomain" "this" {
stack_id = data.ns_workspace.this.stack_id
block_id = data.ns_workspace.this.block_id
env_id = data.ns_workspace.this.env_id
}

locals {
subdomain_dns_name = data.ns_subdomain.this.dns_name
subdomain_part = data.ns_subdomain.this.subdomain_name
fqdn = data.ns_subdomain.this.fqdn

// zone_id refers to google_dns_managed_zone.this.name; however, we need this variable to wait on the resource to be created
// We're going to take google_dns_managed_zone.this.id and parse out the name (since id is computed during creation)
// Format: projects/{{project}}/managedZones/{{name}}
subdomain_zone_id = regex("^projects/[^/]+/managedZones/([^/]+)$", google_dns_managed_zone.this.id)[0]

subdomain_name = trimsuffix(google_dns_managed_zone.this.dns_name, ".")
subdomain_nameservers = [for ns in google_dns_managed_zone.this.name_servers : trimsuffix(ns, ".")]
}

0 comments on commit eb2f390

Please sign in to comment.