Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aws-iam-users pagination #2761

Merged
merged 3 commits into from Mar 2, 2018
Merged

Fix aws-iam-users pagination #2761

merged 3 commits into from Mar 2, 2018

Conversation

trickyearlobe
Copy link
Contributor

@trickyearlobe trickyearlobe commented Mar 1, 2018

PROBLEM: aws-iam-users resource only retrieves 100 records due to pagination
in the AWS IAM list_users function.

FIX: Iterate over all the pages using the AWS pagination variables marker
and is_truncated

Fixes #2760 and part of #2582 (which concerns additional resources)

Signed-off-by: Richard Nixon richard.nixon@btinternet.com

PROBLEM: aws-iam-users resource only retrieves 100 records due to pagination
in the AWS IAM list_users function.

FIX: Iterate over all the pages using the AWS pagination variables `marker`
and `is_truncated`

Signed-off-by: Richard Nixon <richard.nixon@btinternet.com>
@trickyearlobe trickyearlobe requested a review from a team as a code owner March 1, 2018 16:06
@clintoncwolfe clintoncwolfe self-requested a review March 1, 2018 17:06
Rubocop: Assignment Branch Condition size for fetch_from_api is too high
Rubocop: Space missing after colon
Rubocop: Use Kernel#loop with break rather than begin/end/until(or while)

Signed-off-by: Richard Nixon <richard.nixon@btinternet.com>
Copy link
Contributor

@clintoncwolfe clintoncwolfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much simpler than the approach I was going to take (in which list_users may be treated as an iterator). Unfortunately this breaks the unit tests, though the fix is simple. Since list_users is now being called with params, alter lines 106 and 131 of test/unit/resources/aws_iam_users_test.rb to read def list_users(criteria = {})

(Thanks @clintoncwolfe)

Signed-off-by: Richard Nixon <richard.nixon@btinternet.com>
@trickyearlobe
Copy link
Contributor Author

Cheers @clintoncwolfe
Next time I'll run both lint and unit before I raise the PR

@chef-ci chef-ci mentioned this pull request Mar 1, 2018
10 tasks
@clintoncwolfe
Copy link
Contributor

Thanks - looks great! I've borrowed your approach and applied it to several other resources.

@trickyearlobe
Copy link
Contributor Author

Sweet... that means I don't have to finish my generic AwsApiDepaginator :)

@jquick jquick added the Type: Enhancement Improves an existing feature label Mar 2, 2018
Copy link
Contributor

@jquick jquick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @trickyearlobe !

@jquick jquick merged commit 47e4c57 into inspec:master Mar 2, 2018
@trickyearlobe trickyearlobe deleted the fix_iam_users_paging branch March 2, 2018 17:37
@trickyearlobe trickyearlobe restored the fix_iam_users_paging branch March 2, 2018 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improves an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants