module Awspec::Helper::Finder::Iam
Public Instance Methods
select_all_attached_policies()
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 59 def select_all_attached_policies selected = [] res = iam_client.list_policies loop do selected += res.policies.select { |p| p.attachment_count > 0 } (res.next_page? && res = res.next_page) || break end selected end
select_all_iam_groups()
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 97 def select_all_iam_groups iam_client.list_groups.map do |responce| responce.groups end.flatten end
select_all_iam_roles()
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 103 def select_all_iam_roles iam_client.list_roles.map do |responce| responce.roles end.flatten end
select_all_iam_users()
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 91 def select_all_iam_users iam_client.list_users.map do |responce| responce.users end.flatten end
select_attached_entities(policy_id)
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 71 def select_attached_entities(policy_id) policy = find_iam_policy(policy_id) iam_client.list_entities_for_policy(policy_arn: policy[:arn]) end
select_attached_groups(policy_id)
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 81 def select_attached_groups(policy_id) entities = select_attached_entities(policy_id) entities.policy_groups end
select_attached_roles(policy_id)
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 86 def select_attached_roles(policy_id) entities = select_attached_entities(policy_id) entities.policy_roles end
select_attached_users(policy_id)
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 76 def select_attached_users(policy_id) entities = select_attached_entities(policy_id) entities.policy_users end
select_iam_group_by_user_name(user_name)
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 34 def select_iam_group_by_user_name(user_name) res = iam_client.list_groups_for_user({ user_name: user_name }) res.groups end
select_policy_evaluation_results(policy_arn, action_name, resource_arn = nil, context_entries = nil)
click to toggle source
# File lib/awspec/helper/finder/iam.rb, line 22 def select_policy_evaluation_results(policy_arn, action_name, resource_arn = nil, context_entries = nil) options = { policy_source_arn: policy_arn, action_names: [action_name] } options[:resource_arns] = [resource_arn] if resource_arn options[:context_entries] = context_entries if context_entries res = iam_client.simulate_principal_policy(options) res.evaluation_results end