-
Notifications
You must be signed in to change notification settings - Fork 23
/
hosted_zone.go
50 lines (40 loc) · 971 Bytes
/
hosted_zone.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package route53
import (
"fmt"
awsroute53 "github.com/aws/aws-sdk-go/service/route53"
)
type HostedZone struct {
client hostedZonesClient
id *string
identifier string
recordSets recordSets
}
func NewHostedZone(client hostedZonesClient, id, name *string, recordSets recordSets) HostedZone {
return HostedZone{
client: client,
id: id,
identifier: *name,
recordSets: recordSets,
}
}
func (h HostedZone) Delete() error {
r, err := h.recordSets.Get(h.id)
if err != nil {
return fmt.Errorf("Get Record Sets: %s", err)
}
err = h.recordSets.Delete(h.id, h.identifier, r)
if err != nil {
return fmt.Errorf("Delete Record Sets: %s", err)
}
_, err = h.client.DeleteHostedZone(&awsroute53.DeleteHostedZoneInput{Id: h.id})
if err != nil {
return fmt.Errorf("Delete: %s", err)
}
return nil
}
func (h HostedZone) Name() string {
return h.identifier
}
func (h HostedZone) Type() string {
return "Route53 Hosted Zone"
}