Search code examples
amazon-web-servicespaginationaws-sdkamazon-rdsaws-sdk-go

AWS-sdk no paginators for rds cluster


I just found out that I can get a max of 100 records for DBClusterSnapshots, luckily AWS supports pagination where you can get a list by page. I was going over the documentation for aws-sdk-go to see how my Operation implements pagination. Unfortunately there isn't a pagination method for my Operation.

This is the operation I want to paginate. It says in the doc that it supports pagination.

However the pagination method for my operation doesn't appear to be supported

It only supports DBSnapshotsPages but not DBClusterSnapshotsPages enter image description here


Solution

  • The AWS SDK for Go has the DescribeDBClusterSnapshots function:

    func (c *RDS) DescribeDBClusterSnapshots(input *DescribeDBClusterSnapshotsInput) (*DescribeDBClusterSnapshotsOutput, error)
    

    It accepts a parameter of DescribeDBClusterSnapshotsInput, which includes:

    Marker *string type:"string"

    An optional pagination token provided by a previous DescribeDBClusterSnapshots request. If this parameter is specified, the response includes only records beyond the marker, up to the value specified by MaxRecords.

    Therefore, your code can call DescribeDBClusterSnapshots, store the marker that is returned, then make another call to DescribeDBClusterSnapshots, passing in that value for marker. This will return the next 'page' of results.