diff --git a/go.mod b/go.mod index e0b410cfa..1034d3403 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/rebuy-de/aws-nuke/v2 go 1.19 require ( - github.com/aws/aws-sdk-go v1.44.295 + github.com/aws/aws-sdk-go v1.44.307 github.com/fatih/color v1.15.0 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index e679694a0..7f3829b60 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV8Y= -github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.307 h1:2R0/EPgpZcFSUwZhYImq/srjaOrOfLv5MNRzrFyAM38= +github.com/aws/aws-sdk-go v1.44.307/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/resources/elasticache-usergroups.go b/resources/elasticache-usergroups.go index 50208e2ef..8b3dcc613 100644 --- a/resources/elasticache-usergroups.go +++ b/resources/elasticache-usergroups.go @@ -18,18 +18,34 @@ func init() { func ListElasticacheUserGroups(sess *session.Session) ([]Resource, error) { svc := elasticache.New(sess) - params := &elasticache.DescribeUserGroupsInput{MaxRecords: aws.Int64(100)} - resp, err := svc.DescribeUserGroups(params) - if err != nil { - return nil, err - } var resources []Resource - for _, userGroup := range resp.UserGroups { - resources = append(resources, &ElasticacheUserGroup{ - svc: svc, - groupId: userGroup.UserGroupId, - }) + var marker *string // Marker for pagination + + for { + params := &elasticache.DescribeUserGroupsInput{ + MaxRecords: aws.Int64(100), + Marker: marker, + } + resp, err := svc.DescribeUserGroups(params) + if err != nil { + return nil, err + } + + for _, userGroup := range resp.UserGroups { + resources = append(resources, &ElasticacheUserGroup{ + svc: svc, + groupId: userGroup.UserGroupId, + }) + } + // If there are more results, the response will have a Marker. + // Set the marker for the next iteration. + if resp.Marker != nil { + marker = resp.Marker + } else { + // No more results, break the loop. + break + } } return resources, nil diff --git a/resources/elasticache-users.go b/resources/elasticache-users.go index ff8c864ea..01ca23762 100644 --- a/resources/elasticache-users.go +++ b/resources/elasticache-users.go @@ -22,19 +22,35 @@ func init() { func ListElasticacheUsers(sess *session.Session) ([]Resource, error) { svc := elasticache.New(sess) - params := &elasticache.DescribeUsersInput{MaxRecords: aws.Int64(100)} - resp, err := svc.DescribeUsers(params) - if err != nil { - return nil, err - } var resources []Resource - for _, user := range resp.Users { - resources = append(resources, &ElasticacheUser{ - svc: svc, - userId: user.UserId, - userName: user.UserName, - }) + var marker *string // Marker for pagination + + for { + params := &elasticache.DescribeUsersInput{ + MaxRecords: aws.Int64(100), + Marker: marker, + } + resp, err := svc.DescribeUsers(params) + if err != nil { + return nil, err + } + + for _, user := range resp.Users { + resources = append(resources, &ElasticacheUser{ + svc: svc, + userId: user.UserId, + userName: user.UserName, + }) + } + // If there are more results, the response will have a Marker. + // Set the marker for the next iteration. + if resp.Marker != nil { + marker = resp.Marker + } else { + // No more results, break the loop. + break + } } return resources, nil