diff --git a/route53/responses_test.go b/route53/responses_test.go
index 0844b462..7c1c0b73 100644
--- a/route53/responses_test.go
+++ b/route53/responses_test.go
@@ -120,3 +120,33 @@ var ListHostedZonesExample = `
false
100
`
+
+var ListHostedZonesByNameExample = `
+
+
+
+ /hostedzone/Z222222VVVVVVV
+ example2.com.
+ MyUniqueIdentifier2
+
+ This is my second hosted zone.
+ false
+
+ 17
+
+
+ /hostedzone/Z2682N5HXP0BZ4
+ example3.com.
+ MyUniqueIdentifier3
+
+ This is my third hosted zone.
+ false
+
+ 117
+
+
+ example2.com
+ Z222222VVVVVVV
+ false
+ 2
+`
diff --git a/route53/route53.go b/route53/route53.go
index 92d623f6..8ca68233 100644
--- a/route53/route53.go
+++ b/route53/route53.go
@@ -245,6 +245,38 @@ func (r *Route53) ListHostedZones(marker string, maxItems int) (*ListHostedZones
return out, err
}
+type ListHostedZonesByNameResponse struct {
+ HostedZones []HostedZone `xml:"HostedZones>HostedZone"`
+ DNSName string `xml:"DNSName"`
+ IsTruncated bool `xml:"IsTruncated"`
+ NextDNSName string `xml:"NextDNSName"`
+ NextHostedZoneId string `xml:"NextHostedZoneId"`
+ MaxItems int `xml:"MaxItems"`
+}
+
+func (r *Route53) ListHostedZonesByName(dnsName string, hostedZoneId string, maxItems int) (*ListHostedZonesByNameResponse, error) {
+ values := url.Values{}
+
+ if dnsName != "" {
+ values.Add("dnsname", dnsName)
+ }
+
+ if hostedZoneId != "" {
+ values.Add("hostedzoneid", hostedZoneId)
+ }
+
+ if maxItems != 0 {
+ values.Add("maxitems", strconv.Itoa(maxItems))
+ }
+
+ out := &ListHostedZonesByNameResponse{}
+ err := r.query("GET", fmt.Sprintf("/%s/hostedzonesbyname", APIVersion), values, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, err
+}
+
type GetChangeResponse struct {
ChangeInfo ChangeInfo `xml:"ChangeInfo"`
}
diff --git a/route53/route53_test.go b/route53/route53_test.go
index 092c8174..a2072a1d 100644
--- a/route53/route53_test.go
+++ b/route53/route53_test.go
@@ -176,6 +176,25 @@ func TestListHostedZones(t *testing.T) {
}
}
+func TestListHostedZonesByName(t *testing.T) {
+ testServer := makeTestServer()
+ client := makeClient(testServer)
+ testServer.Response(200, nil, ListHostedZonesByNameExample)
+
+ resp, err := client.ListHostedZonesByName("example2.com", "Z2682N5HXP0BZ4", 0)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if resp.HostedZones[0].Name != "example2.com." {
+ t.Fatalf("bad: %v", resp)
+ }
+
+ if resp.HostedZones[1].Name != "example3.com." {
+ t.Fatalf("bad: %v", resp)
+ }
+}
+
func decode(t *testing.T, r io.Reader, out interface{}) {
var buf1 bytes.Buffer
var buf2 bytes.Buffer