Class: Cumulus::IAM::IamGroups
Overview
Public: Manager class for IAM Groups
Instance Method Summary
collapse
Methods inherited from IamResource
#diff, #diff_one, #list, #migrate, #sync, #sync_one
Constructor Details
#initialize(iam) ⇒ IamGroups
Returns a new instance of IamGroups.
15
16
17
18
19
|
# File 'lib/iam/manager/IamGroups.rb', line 15
def initialize(iam)
super(iam)
@type = "group"
@migration_dir = "groups"
end
|
Instance Method Details
#aws_resources ⇒ Object
33
34
35
|
# File 'lib/iam/manager/IamGroups.rb', line 33
def aws_resources
@aws_groups ||= init_aws_groups
end
|
#create(difference) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/iam/manager/IamGroups.rb', line 43
def create(difference)
@iam.create_group({
:group_name => difference.local.name
})
resource = Aws::IAM::Group.new(difference.local.name, { :client => @iam })
add_users(resource, difference.local.users)
resource
end
|
#empty_config ⇒ Object
69
70
71
|
# File 'lib/iam/manager/IamGroups.rb', line 69
def empty_config
GroupConfig.new
end
|
#init_aws_groups ⇒ Object
37
38
39
40
41
|
# File 'lib/iam/manager/IamGroups.rb', line 37
def init_aws_groups
@iam.list_groups().groups.map do |group|
Aws::IAM::Group.new(group.group_name, { :client => @iam })
end
end
|
#local_resources ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/iam/manager/IamGroups.rb', line 21
def local_resources
local = {}
Loader.groups.each do |group|
local[group.name] = group
end
local
end
|
#migrate_additional(configs_to_aws) ⇒ Object
73
74
75
76
77
|
# File 'lib/iam/manager/IamGroups.rb', line 73
def migrate_additional(configs_to_aws)
configs_to_aws.map do |config, resource|
config.users = resource.users.map { |u| u.name }
end
end
|
#one_local(name) ⇒ Object
29
30
31
|
# File 'lib/iam/manager/IamGroups.rb', line 29
def one_local(name)
Loader.group(name)
end
|
#update(resource, diffs) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/iam/manager/IamGroups.rb', line 52
def update(resource, diffs)
super(resource, diffs)
if diffs.size == 1 and diffs[0].type == Common::DiffChange::ADD
puts Colors.blue("\tadding users...")
add_users(resource, diffs[0].local.users)
else
diffs.each do |diff|
if diff.type == IamChange::USER
puts Colors.blue("\tupdating users...")
add_users(resource, diff.added_users)
diff.removed_users.each { |u| resource.remove_user({ :user_name => u }) }
end
end
end
end
|