dongshi3818 2019-05-01 22:26
浏览 63
已采纳

Route53:按RecordType过滤ListResourceRecordSets

I can't get aws route53 service's ListResourceRecordSets to filter by StartRecord Type. Even with the StartRecordType filter, it returns all records (cname and A) instead of the type I select.

I also noticed I would get a validation error if StartRecordName was not included, so it seems if StartRecordType is used, then StartRecordName is required.

The code below returns all records, but does not filter as it should.

    AWSLogin(instance)

    svc := route53.New(instance.AWSSession)

    listParams := &route53.ListResourceRecordSetsInput{
        HostedZoneId: aws.String("Z2798GPJN9CUFJ"), // Required
        StartRecordName: aws.String("subdomain.subdomain.mydomain.com"),
        StartRecordType: aws.String(route53.RRTypeA),
    //  StartRecordType: aws.String(route53.RRTypeCname),
    }
    respList, err := svc.ListResourceRecordSets(listParams)

    if err != nil {
        fmt.Println(err.Error())
        return
    }

    fmt.Println("All Type "A" records:")
    fmt.Println(respList)
  • 写回答

1条回答 默认 最新

  • dpi74187 2019-05-02 18:04
    关注

    I think you've misunderstood what StartRecordName and StartRecordType do. They do not filter the list, only specify where the list begins.

    From the Service Documentation:

    If you specify both Name and Type: The results begin with the first resource record set in the list whose name is greater than or equal to Name, and whose type is greater than or equal to Type.

    So from your example I would expect all your records to be returned (up to a limit of 100), but the first record will be the A record for subdomain.subdomain.mydomain.com.

    It will then proceed (and wrap) in alphabetical order by name/type.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?