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
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/resources/aws/aws_iam_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,21 @@ def validate_params(raw_params)
raw_params
end

def fetch_from_api_paginated(backend)
table = []
page_marker = nil
loop do
api_result = backend.list_users(marker: page_marker)
table += api_result.users.map(&:to_h)
page_marker = api_result.marker
break unless api_result.is_truncated
end
table
end

def fetch_from_api
backend = BackendFactory.create(inspec_runner)
@table = backend.list_users.users.map(&:to_h)
@table = fetch_from_api_paginated(backend)

# TODO: lazy columns - https://github.com/chef/inspec-aws/issues/100
@table.each do |user|
Expand Down