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

feat: Add routing policy wrr and geo to google_dns_record_set #67

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
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