本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/route53.Route53.ListResourceRecordSets方法的典型用法代碼示例。如果您正苦於以下問題:Golang Route53.ListResourceRecordSets方法的具體用法?Golang Route53.ListResourceRecordSets怎麽用?Golang Route53.ListResourceRecordSets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/aws-sdk-go/service/route53.Route53
的用法示例。
在下文中一共展示了Route53.ListResourceRecordSets方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ListAllRecordSets
// Paginate request to get all record sets.
func ListAllRecordSets(r53 *route53.Route53, id string) (rrsets []*route53.ResourceRecordSet, err error) {
req := route53.ListResourceRecordSetsInput{
HostedZoneId: &id,
}
for {
var resp *route53.ListResourceRecordSetsOutput
resp, err = r53.ListResourceRecordSets(&req)
if err != nil {
return
} else {
rrsets = append(rrsets, resp.ResourceRecordSets...)
if *resp.IsTruncated {
req.StartRecordName = resp.NextRecordName
req.StartRecordType = resp.NextRecordType
req.StartRecordIdentifier = resp.NextRecordIdentifier
} else {
break
}
}
}
// unescape wildcards
for _, rrset := range rrsets {
rrset.Name = aws.String(unescaper.Replace(*rrset.Name))
}
return
}
示例2: getNameServers
func getNameServers(zoneId string, zoneName string, r53 *route53.Route53) ([]string, error) {
resp, err := r53.ListResourceRecordSets(&route53.ListResourceRecordSetsInput{
HostedZoneId: aws.String(zoneId),
StartRecordName: aws.String(zoneName),
StartRecordType: aws.String("NS"),
})
if err != nil {
return nil, err
}
if len(resp.ResourceRecordSets) == 0 {
return nil, nil
}
ns := make([]string, len(resp.ResourceRecordSets[0].ResourceRecords))
for i := range resp.ResourceRecordSets[0].ResourceRecords {
ns[i] = *resp.ResourceRecordSets[0].ResourceRecords[i].Value
}
sort.Strings(ns)
return ns, nil
}
示例3: ListAllRecordSets
// Paginate request to get all record sets.
func ListAllRecordSets(r53 *route53.Route53, id string) (rrsets []*route53.ResourceRecordSet, err error) {
req := route53.ListResourceRecordSetsInput{
HostedZoneId: &id,
}
for {
var resp *route53.ListResourceRecordSetsOutput
resp, err = r53.ListResourceRecordSets(&req)
if err != nil {
return
} else {
rrsets = append(rrsets, resp.ResourceRecordSets...)
if *resp.IsTruncated {
req.StartRecordName = resp.NextRecordName
req.StartRecordType = resp.NextRecordType
req.StartRecordIdentifier = resp.NextRecordIdentifier
} else {
break
}
}
}
return
}
示例4: upsertRecordOnRoute53
func upsertRecordOnRoute53(ipAddress string, fqdn string, svc *route53.Route53, verbose bool) {
// Extract the domain from the fully qualified domain name
r, _ := regexp.Compile("^([^\x2E]*)\x2E(.*)$")
toks := r.FindStringSubmatch(fqdn)
domain := toks[2]
// http://docs.aws.amazon.com/sdk-for-go/api/service/route53/Route53.html#ListHostedZonesByName-instance_method
resources, err := svc.ListHostedZonesByName(&route53.ListHostedZonesByNameInput{
DNSName: aws.String(domain + "."),
MaxItems: aws.String("1"),
})
if err != nil {
fmt.Println("ERR: err.Error()", err)
os.Exit(1)
}
if len(resources.HostedZones) != 1 {
fmt.Printf("ERR: Could not find the domain %s\n", domain)
os.Exit(1)
}
if *resources.DNSName != domain+"." {
fmt.Printf("ERR: Could not find the domain %s - %s \n", domain, *resources.DNSName)
os.Exit(1)
}
zoneIDToks := strings.Split(*resources.HostedZones[0].Id, "/")
zoneID := zoneIDToks[len(zoneIDToks)-1]
resp, err := svc.ListResourceRecordSets(&route53.ListResourceRecordSetsInput{
StartRecordName: aws.String(fqdn),
StartRecordType: aws.String("A"),
HostedZoneId: aws.String(zoneID),
MaxItems: aws.String("1"),
})
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
var foundResource bool
if len(resp.ResourceRecordSets) != 1 {
foundResource = false
} else {
foundResource = *resp.ResourceRecordSets[0].Name == fqdn+"."
if foundResource {
for _, record := range resp.ResourceRecordSets[0].ResourceRecords {
if *record.Value == ipAddress {
if verbose {
fmt.Printf("INFO: %s already registered in route53 as %s\n", ipAddress, fqdn)
}
return
}
}
}
}
// Make an A-record:
resourceRecordSet := &route53.ResourceRecordSet{
Name: aws.String(fqdn + "."),
Type: aws.String("A"),
ResourceRecords: []*route53.ResourceRecord{
&route53.ResourceRecord{
Value: aws.String(ipAddress),
},
},
TTL: aws.Int64(300),
}
// Wrap it as an UPSERT
upsert := []*route53.Change{&route53.Change{
Action: aws.String("UPSERT"),
ResourceRecordSet: resourceRecordSet,
}}
// Put it into a pretty envelope with a stamp for route53#zoneId and change ticket
params := route53.ChangeResourceRecordSetsInput{
ChangeBatch: &route53.ChangeBatch{
Changes: upsert,
},
HostedZoneId: aws.String(zoneID),
}
// Post it
changeResp, err := svc.ChangeResourceRecordSets(¶ms)
if err != nil {
fmt.Println("ERR: ", err.Error(), changeResp)
os.Exit(1)
}
// Done
if verbose {
fmt.Printf("INFO: Submitted change for zoneId %s to register %s as %s\n", zoneID, ipAddress, fqdn)
}
}