miam 0.2.3 → 0.2.4.beta18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -1
- data/.travis.yml +6 -4
- data/README.md +8 -1
- data/bin/miam +3 -1
- data/lib/miam/client.rb +54 -13
- data/lib/miam/driver.rb +43 -13
- data/lib/miam/dsl/context/role.rb +5 -1
- data/lib/miam/dsl/context.rb +5 -1
- data/lib/miam/dsl/converter.rb +17 -3
- data/lib/miam/exporter.rb +8 -4
- data/lib/miam/password_manager.rb +23 -4
- data/lib/miam/version.rb +1 -1
- data/miam.gemspec +3 -4
- data/spec/miam/attach_detach_policy_spec.rb +4 -4
- data/spec/miam/create_spec.rb +3 -3
- data/spec/miam/delete_spec.rb +6 -6
- data/spec/miam/exclude_spec.rb +252 -0
- data/spec/miam/hash_ext_spec.rb +2 -2
- data/spec/miam/ignore_login_profile_spec.rb +3 -3
- data/spec/miam/rename_spec.rb +6 -6
- data/spec/miam/target_spec.rb +185 -0
- data/spec/miam/update_spec.rb +97 -11
- data/spec/spec_helper.rb +5 -2
- metadata +30 -6
data/spec/miam/update_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
describe 'update' do
|
|
2
2
|
let(:dsl) do
|
|
3
3
|
<<-RUBY
|
|
4
|
-
user "bob", :path=>"/
|
|
4
|
+
user "bob", :path=>"/developer/" do
|
|
5
5
|
login_profile :password_reset_required=>true
|
|
6
6
|
|
|
7
7
|
groups(
|
|
@@ -74,7 +74,7 @@ describe 'update' do
|
|
|
74
74
|
let(:expected) do
|
|
75
75
|
{:users=>
|
|
76
76
|
{"bob"=>
|
|
77
|
-
{:path=>"/
|
|
77
|
+
{:path=>"/developer/",
|
|
78
78
|
:groups=>["Admin", "SES"],
|
|
79
79
|
:attached_managed_policies=>[],
|
|
80
80
|
:policies=>
|
|
@@ -122,6 +122,7 @@ describe 'update' do
|
|
|
122
122
|
"Principal"=>{"Service"=>"ec2.amazonaws.com"},
|
|
123
123
|
"Action"=>"sts:AssumeRole"}]},
|
|
124
124
|
:instance_profiles=>["my-instance-profile"],
|
|
125
|
+
:max_session_duration=>3600,
|
|
125
126
|
:attached_managed_policies=>[],
|
|
126
127
|
:policies=>
|
|
127
128
|
{"role-policy"=>
|
|
@@ -149,7 +150,7 @@ describe 'update' do
|
|
|
149
150
|
context 'when update policy' do
|
|
150
151
|
let(:update_policy_dsl) do
|
|
151
152
|
<<-RUBY
|
|
152
|
-
user "bob", :path=>"/
|
|
153
|
+
user "bob", :path=>"/developer/" do
|
|
153
154
|
login_profile :password_reset_required=>true
|
|
154
155
|
|
|
155
156
|
groups(
|
|
@@ -236,7 +237,7 @@ describe 'update' do
|
|
|
236
237
|
context 'when update path' do
|
|
237
238
|
let(:update_path_dsl) do
|
|
238
239
|
<<-RUBY
|
|
239
|
-
user "bob", :path=>"/
|
|
240
|
+
user "bob", :path=>"/developer/" do
|
|
240
241
|
login_profile :password_reset_required=>true
|
|
241
242
|
|
|
242
243
|
groups(
|
|
@@ -320,7 +321,7 @@ describe 'update' do
|
|
|
320
321
|
context 'when update path (role, instance_profile)' do
|
|
321
322
|
let(:cannot_update_path_dsl) do
|
|
322
323
|
<<-RUBY
|
|
323
|
-
user "bob", :path=>"/
|
|
324
|
+
user "bob", :path=>"/developer/" do
|
|
324
325
|
login_profile :password_reset_required=>true
|
|
325
326
|
|
|
326
327
|
groups(
|
|
@@ -409,7 +410,7 @@ describe 'update' do
|
|
|
409
410
|
context 'when update assume_role_policy' do
|
|
410
411
|
let(:update_assume_role_policy_dsl) do
|
|
411
412
|
<<-RUBY
|
|
412
|
-
user "bob", :path=>"/
|
|
413
|
+
user "bob", :path=>"/developer/" do
|
|
413
414
|
login_profile :password_reset_required=>true
|
|
414
415
|
|
|
415
416
|
groups(
|
|
@@ -492,7 +493,7 @@ describe 'update' do
|
|
|
492
493
|
context 'when update groups' do
|
|
493
494
|
let(:update_groups_dsl) do
|
|
494
495
|
<<-RUBY
|
|
495
|
-
user "bob", :path=>"/
|
|
496
|
+
user "bob", :path=>"/developer/" do
|
|
496
497
|
login_profile :password_reset_required=>true
|
|
497
498
|
|
|
498
499
|
groups(
|
|
@@ -580,7 +581,7 @@ describe 'update' do
|
|
|
580
581
|
context 'when update login_profile' do
|
|
581
582
|
let(:update_login_profile_dsl) do
|
|
582
583
|
<<-RUBY
|
|
583
|
-
user "bob", :path=>"/
|
|
584
|
+
user "bob", :path=>"/developer/" do
|
|
584
585
|
login_profile :password_reset_required=>false
|
|
585
586
|
|
|
586
587
|
groups(
|
|
@@ -663,7 +664,7 @@ describe 'update' do
|
|
|
663
664
|
context 'when delete login_profile' do
|
|
664
665
|
let(:delete_login_profile_dsl) do
|
|
665
666
|
<<-RUBY
|
|
666
|
-
user "bob", :path=>"/
|
|
667
|
+
user "bob", :path=>"/developer/" do
|
|
667
668
|
groups(
|
|
668
669
|
"Admin",
|
|
669
670
|
"SES"
|
|
@@ -744,7 +745,7 @@ describe 'update' do
|
|
|
744
745
|
context 'when delete policy' do
|
|
745
746
|
let(:delete_policy_dsl) do
|
|
746
747
|
<<-RUBY
|
|
747
|
-
user "bob", :path=>"/
|
|
748
|
+
user "bob", :path=>"/developer/" do
|
|
748
749
|
login_profile :password_reset_required=>true
|
|
749
750
|
|
|
750
751
|
groups(
|
|
@@ -807,7 +808,7 @@ describe 'update' do
|
|
|
807
808
|
context 'when update instance_profiles' do
|
|
808
809
|
let(:update_instance_profiles_dsl) do
|
|
809
810
|
<<-RUBY
|
|
810
|
-
user "bob", :path=>"/
|
|
811
|
+
user "bob", :path=>"/developer/" do
|
|
811
812
|
login_profile :password_reset_required=>true
|
|
812
813
|
|
|
813
814
|
groups(
|
|
@@ -888,4 +889,89 @@ describe 'update' do
|
|
|
888
889
|
expect(export).to eq expected
|
|
889
890
|
end
|
|
890
891
|
end
|
|
892
|
+
|
|
893
|
+
context 'when update role max_session_duration' do
|
|
894
|
+
let(:update_instance_profiles_dsl) do
|
|
895
|
+
<<-RUBY
|
|
896
|
+
user "bob", :path=>"/developer/" do
|
|
897
|
+
login_profile :password_reset_required=>true
|
|
898
|
+
|
|
899
|
+
groups(
|
|
900
|
+
"Admin",
|
|
901
|
+
"SES"
|
|
902
|
+
)
|
|
903
|
+
|
|
904
|
+
policy "S3" do
|
|
905
|
+
{"Statement"=>
|
|
906
|
+
[{"Action"=>
|
|
907
|
+
["s3:Get*",
|
|
908
|
+
"s3:List*"],
|
|
909
|
+
"Effect"=>"Allow",
|
|
910
|
+
"Resource"=>"*"}]}
|
|
911
|
+
end
|
|
912
|
+
end
|
|
913
|
+
|
|
914
|
+
user "mary", :path=>"/staff/" do
|
|
915
|
+
policy "S3" do
|
|
916
|
+
{"Statement"=>
|
|
917
|
+
[{"Action"=>
|
|
918
|
+
["s3:Get*",
|
|
919
|
+
"s3:List*"],
|
|
920
|
+
"Effect"=>"Allow",
|
|
921
|
+
"Resource"=>"*"}]}
|
|
922
|
+
end
|
|
923
|
+
end
|
|
924
|
+
|
|
925
|
+
group "Admin", :path=>"/admin/" do
|
|
926
|
+
policy "Admin" do
|
|
927
|
+
{"Statement"=>[{"Effect"=>"Allow", "Action"=>"*", "Resource"=>"*"}]}
|
|
928
|
+
end
|
|
929
|
+
end
|
|
930
|
+
|
|
931
|
+
group "SES", :path=>"/ses/" do
|
|
932
|
+
policy "ses-policy" do
|
|
933
|
+
{"Statement"=>
|
|
934
|
+
[{"Effect"=>"Allow", "Action"=>"ses:SendRawEmail", "Resource"=>"*"}]}
|
|
935
|
+
end
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
role "my-role", :path=>"/any/" do
|
|
939
|
+
instance_profiles(
|
|
940
|
+
"my-instance-profile"
|
|
941
|
+
)
|
|
942
|
+
|
|
943
|
+
max_session_policy 43200
|
|
944
|
+
|
|
945
|
+
assume_role_policy_document do
|
|
946
|
+
{"Version"=>"2012-10-17",
|
|
947
|
+
"Statement"=>
|
|
948
|
+
[{"Sid"=>"",
|
|
949
|
+
"Effect"=>"Allow",
|
|
950
|
+
"Principal"=>{"Service"=>"ec2.amazonaws.com"},
|
|
951
|
+
"Action"=>"sts:AssumeRole"}]}
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
policy "role-policy" do
|
|
955
|
+
{"Statement"=>
|
|
956
|
+
[{"Action"=>
|
|
957
|
+
["s3:Get*",
|
|
958
|
+
"s3:List*"],
|
|
959
|
+
"Effect"=>"Allow",
|
|
960
|
+
"Resource"=>"*"}]}
|
|
961
|
+
end
|
|
962
|
+
end
|
|
963
|
+
|
|
964
|
+
instance_profile "my-instance-profile", :path=>"/profile/"
|
|
965
|
+
RUBY
|
|
966
|
+
end
|
|
967
|
+
|
|
968
|
+
subject { client }
|
|
969
|
+
|
|
970
|
+
it do
|
|
971
|
+
updated = apply(subject) { update_instance_profiles_dsl }
|
|
972
|
+
expect(updated).to be_truthy
|
|
973
|
+
expected[:roles]["my-role"][:max_session_duration] = 43200
|
|
974
|
+
expect(export).to eq expected
|
|
975
|
+
end
|
|
976
|
+
end
|
|
891
977
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -67,14 +67,17 @@ def tempfile(content, options = {})
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def apply(cli = client)
|
|
70
|
-
tempfile(yield) do |f|
|
|
70
|
+
result = tempfile(yield) do |f|
|
|
71
71
|
begin
|
|
72
72
|
cli.apply(f.path)
|
|
73
|
-
rescue Aws::IAM::Errors::EntityTemporarilyUnmodifiable
|
|
73
|
+
rescue Aws::IAM::Errors::EntityTemporarilyUnmodifiable, Aws::IAM::Errors::Throttling, Aws::IAM::Errors::NoSuchEntity
|
|
74
74
|
sleep 3
|
|
75
75
|
retry
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
+
|
|
79
|
+
sleep ENV['APPLY_WAIT'].to_i
|
|
80
|
+
result
|
|
78
81
|
end
|
|
79
82
|
|
|
80
83
|
def export(options = {})
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: miam
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.4.beta18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Genki Sugawara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-09-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-core
|
|
@@ -17,6 +17,9 @@ dependencies:
|
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 2.0.42
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '3'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -24,6 +27,9 @@ dependencies:
|
|
|
24
27
|
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 2.0.42
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: ruby-progressbar
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -164,6 +170,20 @@ dependencies:
|
|
|
164
170
|
- - ">="
|
|
165
171
|
- !ruby/object:Gem::Version
|
|
166
172
|
version: '0'
|
|
173
|
+
- !ruby/object:Gem::Dependency
|
|
174
|
+
name: nokogiri
|
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
|
176
|
+
requirements:
|
|
177
|
+
- - ">="
|
|
178
|
+
- !ruby/object:Gem::Version
|
|
179
|
+
version: '0'
|
|
180
|
+
type: :development
|
|
181
|
+
prerelease: false
|
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
183
|
+
requirements:
|
|
184
|
+
- - ">="
|
|
185
|
+
- !ruby/object:Gem::Version
|
|
186
|
+
version: '0'
|
|
167
187
|
description: Miam is a tool to manage IAM. It defines the state of IAM using DSL,
|
|
168
188
|
and updates IAM according to DSL.
|
|
169
189
|
email:
|
|
@@ -204,12 +224,14 @@ files:
|
|
|
204
224
|
- spec/miam/create_spec.rb
|
|
205
225
|
- spec/miam/custom_managed_policy_spec.rb
|
|
206
226
|
- spec/miam/delete_spec.rb
|
|
227
|
+
- spec/miam/exclude_spec.rb
|
|
207
228
|
- spec/miam/hash_ext_spec.rb
|
|
208
229
|
- spec/miam/ignore_login_profile_spec.rb
|
|
209
230
|
- spec/miam/rename_spec.rb
|
|
231
|
+
- spec/miam/target_spec.rb
|
|
210
232
|
- spec/miam/update_spec.rb
|
|
211
233
|
- spec/spec_helper.rb
|
|
212
|
-
homepage:
|
|
234
|
+
homepage: https://github.com/codenize-tools/miam
|
|
213
235
|
licenses:
|
|
214
236
|
- MIT
|
|
215
237
|
metadata: {}
|
|
@@ -224,12 +246,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
224
246
|
version: '0'
|
|
225
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
248
|
requirements:
|
|
227
|
-
- - "
|
|
249
|
+
- - ">"
|
|
228
250
|
- !ruby/object:Gem::Version
|
|
229
|
-
version:
|
|
251
|
+
version: 1.3.1
|
|
230
252
|
requirements: []
|
|
231
253
|
rubyforge_project:
|
|
232
|
-
rubygems_version: 2.
|
|
254
|
+
rubygems_version: 2.6.14.1
|
|
233
255
|
signing_key:
|
|
234
256
|
specification_version: 4
|
|
235
257
|
summary: Miam is a tool to manage IAM.
|
|
@@ -238,8 +260,10 @@ test_files:
|
|
|
238
260
|
- spec/miam/create_spec.rb
|
|
239
261
|
- spec/miam/custom_managed_policy_spec.rb
|
|
240
262
|
- spec/miam/delete_spec.rb
|
|
263
|
+
- spec/miam/exclude_spec.rb
|
|
241
264
|
- spec/miam/hash_ext_spec.rb
|
|
242
265
|
- spec/miam/ignore_login_profile_spec.rb
|
|
243
266
|
- spec/miam/rename_spec.rb
|
|
267
|
+
- spec/miam/target_spec.rb
|
|
244
268
|
- spec/miam/update_spec.rb
|
|
245
269
|
- spec/spec_helper.rb
|