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

Support for routingPolicy in DNS Routing policies #11038

Comments

@kaushalringle
Copy link

kaushalringle commented Feb 4, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

How can I add DNS routing policies to google_dns_record_set for WRR routing policy which can be seen here https://cloud.google.com/dns/docs/zones/manage-routing-policies , Terraform resource only shows options for rrdatas here https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_record_set#rrdatas.

for eg I want add routingPolicy instead of rrdatas so the options like weight can be added, snap of the API call looks like this

"routingPolicy": {
        "wrr": {
          "item": [
            {
              "weight": .5,
              "rrdata": [
                "10.X.X.A"
              ]
            },
            {
              "weight": .5,
              "rrdata": [
                "10.X.X.B"
              ]
            }
          ]
        }
      }

New or Affected Resource(s)

  • google_dns_record_set

Potential Terraform Configuration

Which would look something like this

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.

resource "google_dns_record_set" "a" {
  name         = "backend.${google_dns_managed_zone.prod.dns_name}"
  managed_zone = google_dns_managed_zone.prod.name
  type         = "A"
  ttl          = 300

  routingPolicy = {
        "wrr": {
          "item": [
            {
              "weight": .5,
              "rrdata": [
                "10.X.X.A"
              ]
            },
            {
              "weight": .5,
              "rrdata": [
                "10.X.X.B"
              ]
            }
          ]
  }
}

resource "google_dns_managed_zone" "prod" {
  name     = "prod-zone"
  dns_name = "prod.mydomain.com."
}

References

Google Docs --> https://cloud.google.com/dns/docs/zones/manage-routing-policies
Terraform Resource --> https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_record_set#adding-an-a-record

@rileykarson
Copy link
Collaborator

Note: Our implementation of this resource is not based on the ResourceRecordSet API, so this may required a new resource. @c2thorn to investigate.

@c2thorn
Copy link
Collaborator

c2thorn commented Feb 7, 2022

This field is only available via the v1beta1 or v2beta1 versions of the DNS client library. Right now, both google and google-beta providers use the v1 version, so implementing this would require extensive testing to make sure the google-beta version does not break users. Otherwise, it should be possible via the same resource

@erikjoh
Copy link

erikjoh commented Feb 24, 2022

Hi!
Looks like routingPolicy is now available in v1.
https://cloud.google.com/dns/docs/reference/v1/resourceRecordSets
In addition to routingPolicy.wrr we would be interested in routingPolicy.geo as well (and I assume that field would also be supported).

@c2thorn c2thorn removed their assignment Feb 24, 2022
@rileykarson rileykarson added this to the Goals milestone Feb 28, 2022
@rosmo
Copy link

rosmo commented Mar 2, 2022

I'd suggest a more Terraform'y approach:

routing_policy {
  wrr {
    item {
      rrdatas = [ "10.X.X.A" ]
      weight = 0.5
    }
    item {
      rrdatas = [ "10.X.X.B" ]
      weight = 1.0
    }
  } 
  geo {
    item {
      rrdatas = [ "10.X.X.C" ]
      weight = 1.0
    }
  } 
}

@ms185570
Copy link

Would this issue also cover the geo-based option for DNS records?

@kanata2
Copy link

kanata2 commented Apr 7, 2022

I'm working on this issue at GoogleCloudPlatform/magic-modules#5909.
Please feel free to comment if you have any opinion about the implementation.

sample in current implementation:

resource "google_dns_record_set" "sample" {
  ...
  // rrdatas      = ["127.0.0.1", "127.0.0.2"]

  routing_policy {
    // geo {
    //   region  = "asia-northeast1"
    //   rrdatas = ["127.0.0.1"]
    // }

    // geo {
    //   region  = "asia-east1"
    //   rrdatas = ["127.0.0.2"]
    // }

    wrr {
      weight  = 90.0
      rrdatas = ["127.0.0.1"]
    }

    wrr {
      weight  = 10.0
      rrdatas = ["127.0.0.2"]
    }
  }
}

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.