Skip to content

Commit

Permalink
Merge pull request #17 from johanneswuerbach/data-managed-zone
Browse files Browse the repository at this point in the history
feat: re-use google_dns_managed_zone data source
  • Loading branch information
johanneswuerbach authored Apr 23, 2024
2 parents 94ec176 + cd05912 commit 839a8df
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 49 deletions.
1 change: 0 additions & 1 deletion examples/dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ graph LR;
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| managed\_zone | The name of the zone in which this record set will reside. | `string` | n/a | yes |
| managed\_zone\_dns\_name | The DNS name of the managed zone. | `string` | n/a | yes |
| project | GCP project ID | `string` | n/a | yes |
| region | GCP region | `string` | n/a | yes |
| name | Name of the example application | `string` | `"hum-rp-dns-example"` | no |
Expand Down
3 changes: 1 addition & 2 deletions examples/dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ module "dns_basic" {
project = var.project
region = var.region

managed_zone = var.managed_zone
managed_zone_dns_name = var.managed_zone_dns_name
managed_zone = var.managed_zone
}

resource "humanitec_resource_definition_criteria" "dns_basic" {
Expand Down
3 changes: 0 additions & 3 deletions examples/dns/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# The name of the zone in which this record set will reside.
managed_zone = ""

# The DNS name of the managed zone.
managed_zone_dns_name = ""

# Name of the example application
name = "hum-rp-dns-example"

Expand Down
5 changes: 0 additions & 5 deletions examples/dns/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ variable "managed_zone" {
type = string
}

variable "managed_zone_dns_name" {
description = "The DNS name of the managed zone."
type = string
}

variable "name" {
description = "Name of the example application"
type = string
Expand Down
1 change: 0 additions & 1 deletion humanitec-resource-defs/dns/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
|------|-------------|------|---------|:--------:|
| driver\_account | The ID of the Resource Account which should be used. | `string` | n/a | yes |
| managed\_zone | The name of the zone in which this record set will reside. | `string` | n/a | yes |
| managed\_zone\_dns\_name | The DNS name of the managed zone. | `string` | n/a | yes |
| prefix | n/a | `string` | n/a | yes |
| project | n/a | `string` | n/a | yes |
| region | GCP region | `string` | n/a | yes |
Expand Down
15 changes: 7 additions & 8 deletions humanitec-resource-defs/dns/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ resource "humanitec_resource_definition" "main" {
}

variables = {
project = var.project
region = var.region
app_id = "$${context.app.id}"
env_id = "$${context.env.id}"
res_id = "$${context.res.id}"
managed_zone = var.managed_zone
managed_zone_dns_name = var.managed_zone_dns_name
subdomain = "$${context.app.id}-$${context.env.id}"
project = var.project
region = var.region
app_id = "$${context.app.id}"
env_id = "$${context.env.id}"
res_id = "$${context.res.id}"
managed_zone = var.managed_zone
subdomain = "$${context.app.id}-$${context.env.id}"
}
})
}
Expand Down
3 changes: 0 additions & 3 deletions humanitec-resource-defs/dns/basic/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ driver_account = ""
# The name of the zone in which this record set will reside.
managed_zone = ""

# The DNS name of the managed zone.
managed_zone_dns_name = ""

prefix = ""
project = ""

Expand Down
5 changes: 0 additions & 5 deletions humanitec-resource-defs/dns/basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,3 @@ variable "managed_zone" {
description = "The name of the zone in which this record set will reside."
type = string
}

variable "managed_zone_dns_name" {
description = "The DNS name of the managed zone."
type = string
}
6 changes: 3 additions & 3 deletions modules/dns/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| google | ~> 5.17 |
| google | ~> 5.26 |

### Providers

| Name | Version |
|------|---------|
| google | ~> 5.17 |
| google | ~> 5.26 |

### Resources

| Name | Type |
|------|------|
| [google_dns_record_set.main](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_record_set) | resource |
| [google_dns_managed_zone.main](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/dns_managed_zone) | data source |

### Inputs

Expand All @@ -25,7 +26,6 @@
| app\_id | n/a | `string` | n/a | yes |
| env\_id | n/a | `string` | n/a | yes |
| managed\_zone | The name of the zone in which this record set will reside. | `string` | n/a | yes |
| managed\_zone\_dns\_name | The DNS name of the managed zone. | `string` | n/a | yes |
| project | GCP project ID | `string` | n/a | yes |
| region | GCP region | `string` | n/a | yes |
| res\_id | n/a | `string` | n/a | yes |
Expand Down
14 changes: 5 additions & 9 deletions modules/dns/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Disabled due to https://github.com/hashicorp/terraform-provider-google/issues/16832
# data "google_dns_managed_zone" "main" {
# name = var.managed_zone
# }
data "google_dns_managed_zone" "main" {
name = var.managed_zone
}

locals {
types = ["A", "AAAA", "CNAME"]
Expand All @@ -13,11 +12,8 @@ locals {
}

resource "google_dns_record_set" "main" {
# name = "${var.subdomain}.${data.google_dns_managed_zone.main.dns_name}"
# managed_zone = data.google_dns_managed_zone.main.name

name = "${var.subdomain}.${var.managed_zone_dns_name}"
managed_zone = var.managed_zone
name = "${var.subdomain}.${data.google_dns_managed_zone.main.dns_name}"
managed_zone = data.google_dns_managed_zone.main.name
type = local.type
ttl = 300

Expand Down
2 changes: 1 addition & 1 deletion modules/dns/basic/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.17"
version = "~> 5.26"
}
}

Expand Down
3 changes: 0 additions & 3 deletions modules/dns/basic/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ ipv6_address = ""
# The name of the zone in which this record set will reside.
managed_zone = ""

# The DNS name of the managed zone.
managed_zone_dns_name = ""

# A valid fully qualified domain name that the DNS name should resolve to.
name = ""

Expand Down
5 changes: 0 additions & 5 deletions modules/dns/basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ variable "managed_zone" {
type = string
}

variable "managed_zone_dns_name" {
description = "The DNS name of the managed zone."
type = string
}

variable "ip_address" {
description = "The IPv4 address that the DNS name should resolve to."
type = string
Expand Down

0 comments on commit 839a8df

Please sign in to comment.