Skip to content

Commit

Permalink
fix: pagination issue when listing accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
word committed Aug 25, 2022
1 parent fe72e0f commit 2378e0e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
= Changelog

== 1.6.1

* fix: pagination problem when listing accounts in an OU.

== 1.6.0

* fix: pass the default AWS provider explicitly from tfctl generated configuration.
Expand Down
31 changes: 17 additions & 14 deletions lib/tfctl/aws_org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ def accounts(org_units)

parent_id = aws_ou_ids[ou_path]

@aws_org_client.list_accounts_for_parent(parent_id: parent_id).accounts.each do |account|
next unless account.status == 'ACTIVE'

output[:accounts] << {
name: account.name,
id: account.id,
arn: account.arn,
email: account.email,
ou_path: ou_path.to_s,
ou_parents: ou_path.to_s.split('/'),
profiles: [],
}
@aws_org_client.list_accounts_for_parent(parent_id: parent_id).each do |response|
response.accounts.each do |account|
next unless account.status == 'ACTIVE'

output[:accounts] << {
name: account.name,
id: account.id,
arn: account.arn,
email: account.email,
ou_path: ou_path.to_s,
ou_parents: ou_path.to_s.split('/'),
profiles: [],
}
end
end

end
output
end
Expand Down Expand Up @@ -71,8 +74,8 @@ def aws_ou_list_children(parent_id, parent_name)
@aws_org_client.list_children(
child_type: 'ORGANIZATIONAL_UNIT',
parent_id: parent_id,
).each do |resp|
resp.children.each do |child|
).each do |response|
response.children.each do |child|

begin
ou = @aws_org_client.describe_organizational_unit(
Expand Down
2 changes: 1 addition & 1 deletion lib/tfctl/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Tfctl
VERSION = '1.6.0'
VERSION = '1.6.1'
end

0 comments on commit 2378e0e

Please sign in to comment.