Skip to content

Commit

Permalink
feat: Add routing policy wrr and geo to google_dns_record_set (#67)
Browse files Browse the repository at this point in the history
Co-authored-by: Imran Nayer <[email protected]>
  • Loading branch information
dennislapchenko and imrannayer committed Nov 9, 2023
1 parent 72618f2 commit 1eed464
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Functional examples are included in the [examples](./examples/) directory.
| name | Zone name, must be unique within the project. | `string` | n/a | yes |
| private\_visibility\_config\_networks | List of VPC self links that can see this zone. | `list(string)` | `[]` | no |
| project\_id | Project id for the zone. | `string` | n/a | yes |
| recordsets | List of DNS record objects to manage, in the standard terraform dns structure. | <pre>list(object({<br> name = string<br> type = string<br> ttl = number<br> records = list(string)<br> }))</pre> | `[]` | no |
| recordsets | List of DNS record objects to manage, in the standard terraform dns structure. | <pre>list(object({<br> name = string<br> type = string<br> ttl = number<br> records = optional(list(string), null)<br><br> routing_policy = optional(object({<br> wrr = optional(list(object({<br> weight = number<br> records = list(string)<br> })), [])<br> geo = optional(list(object({<br> location = string<br> records = list(string)<br> })), [])<br> }))<br> }))</pre> | `[]` | no |
| service\_namespace\_url | The fully qualified or partial URL of the service directory namespace that should be associated with the zone. This should be formatted like https://servicedirectory.googleapis.com/v1/projects/{project}/locations/{location}/namespaces/{namespace_id} or simply projects/{project}/locations/{location}/namespaces/{namespace\_id}. | `string` | `""` | no |
| target\_name\_server\_addresses | List of target name servers for forwarding zone. | `list(map(any))` | `[]` | no |
| target\_network | Peering network. | `string` | `""` | no |
Expand Down
23 changes: 23 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,29 @@ resource "google_dns_record_set" "cloud-static-records" {

rrdatas = each.value.records

dynamic "routing_policy" {
for_each = toset(each.value.routing_policy != null ? ["create"] : [])
content {
dynamic "wrr" {
for_each = each.value.routing_policy.wrr
iterator = wrr
content {
weight = wrr.value.weight
rrdatas = wrr.value.records
}
}

dynamic "geo" {
for_each = each.value.routing_policy.geo
iterator = geo
content {
location = geo.value.location
rrdatas = geo.value.records
}
}
}
}

depends_on = [
google_dns_managed_zone.private,
google_dns_managed_zone.public,
Expand Down
14 changes: 13 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,20 @@ variable "recordsets" {
name = string
type = string
ttl = number
records = list(string)
records = optional(list(string), null)

routing_policy = optional(object({
wrr = optional(list(object({
weight = number
records = list(string)
})), [])
geo = optional(list(object({
location = string
records = list(string)
})), [])
}))
}))

description = "List of DNS record objects to manage, in the standard terraform dns structure."
default = []
}
Expand Down

0 comments on commit 1eed464

Please sign in to comment.