Class: Miam::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/miam/exporter.rb

Constant Summary collapse

AWS_MANAGED_POLICY_PREFIX =
'arn:aws:iam::aws:'
AWS_CN_MANAGED_POLICY_PREFIX =
'arn:aws-cn:iam::aws:'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iam, options = {}) ⇒ Exporter

Returns a new instance of Exporter.



10
11
12
13
14
15
# File 'lib/miam/exporter.rb', line 10

def initialize(iam, options = {})
  @iam = iam
  @options = options
  @mutex = Mutex.new
  @concurrency = options[:export_concurrency] || 16
end

Class Method Details

.export(iam, options = {}) ⇒ Object



6
7
8
# File 'lib/miam/exporter.rb', line 6

def self.export(iam, options = {})
  self.new(iam, options).export
end

Instance Method Details

#exportObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/miam/exporter.rb', line 17

def export
   = 

  users = [:user_detail_list]
  groups = [:group_detail_list]
  roles = [:role_detail_list]
  policies = [:policies]
  instance_profiles = list_instance_profiles
  group_users = {}
  instance_profile_roles = {}

  unless @options[:no_progress]
    progress_total = users.length + groups.length + roles.length + instance_profiles.length

    @progressbar = ProgressBar.create(
                     :format => ' %bᗧ%i %p%%',
                     :progress_mark  => ' ',
                     :remainder_mark => '',
                     :total => progress_total,
                     :output => $stderr)
  end

  expected = {
    :users => export_users(users, group_users),
    :groups => export_groups(groups),
    :roles => export_roles(roles, instance_profile_roles),
    :instance_profiles => export_instance_profiles(instance_profiles),
    :policies => export_policies(policies),
  }

  [expected, group_users, instance_profile_roles]
end