// Snapshots is a wrapper for (*ec2.EC2).DescribeSnapshotsPages. // // If call succeeds but no snapshots were found, it returns non-nil // *NotFoundError error. func (c *Client) Snapshots() ([]*ec2.Snapshot, error) { var snapshots []*ec2.Snapshot var params ec2.DescribeSnapshotsInput if c.MaxResults != 0 { params.MaxResults = aws.Int64(c.MaxResults) } var page int err := c.EC2.DescribeSnapshotsPages(¶ms, func(resp *ec2.DescribeSnapshotsOutput, _ bool) bool { page++ c.Log.Debug("received %d snapshots (page=%d)", len(resp.Snapshots), page) snapshots = append(snapshots, resp.Snapshots...) return true }) if err != nil { return nil, awsError(err) } if len(snapshots) == 0 { return nil, newNotFoundError("Snapshot", errors.New("no snapshots found")) } return snapshots, nil }