miam 0.2.3 → 0.2.5.beta1
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 +5 -5
- data/.rspec +2 -1
- data/.travis.yml +6 -4
- data/README.md +8 -1
- data/bin/miam +10 -5
- data/lib/miam/client.rb +54 -13
- data/lib/miam/driver.rb +44 -14
- 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/template_helper.rb +11 -0
- data/lib/miam/version.rb +1 -1
- data/lib/miam.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 +29 -12
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,29 +1,29 @@
|
|
|
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.5.beta1
|
|
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: 2019-07-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: aws-sdk-
|
|
14
|
+
name: aws-sdk-iam
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: '1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: '1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: ruby-progressbar
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -164,6 +164,20 @@ dependencies:
|
|
|
164
164
|
- - ">="
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: '0'
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: nokogiri
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0'
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
167
181
|
description: Miam is a tool to manage IAM. It defines the state of IAM using DSL,
|
|
168
182
|
and updates IAM according to DSL.
|
|
169
183
|
email:
|
|
@@ -204,12 +218,14 @@ files:
|
|
|
204
218
|
- spec/miam/create_spec.rb
|
|
205
219
|
- spec/miam/custom_managed_policy_spec.rb
|
|
206
220
|
- spec/miam/delete_spec.rb
|
|
221
|
+
- spec/miam/exclude_spec.rb
|
|
207
222
|
- spec/miam/hash_ext_spec.rb
|
|
208
223
|
- spec/miam/ignore_login_profile_spec.rb
|
|
209
224
|
- spec/miam/rename_spec.rb
|
|
225
|
+
- spec/miam/target_spec.rb
|
|
210
226
|
- spec/miam/update_spec.rb
|
|
211
227
|
- spec/spec_helper.rb
|
|
212
|
-
homepage:
|
|
228
|
+
homepage: https://github.com/codenize-tools/miam
|
|
213
229
|
licenses:
|
|
214
230
|
- MIT
|
|
215
231
|
metadata: {}
|
|
@@ -224,12 +240,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
224
240
|
version: '0'
|
|
225
241
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
242
|
requirements:
|
|
227
|
-
- - "
|
|
243
|
+
- - ">"
|
|
228
244
|
- !ruby/object:Gem::Version
|
|
229
|
-
version:
|
|
245
|
+
version: 1.3.1
|
|
230
246
|
requirements: []
|
|
231
|
-
|
|
232
|
-
rubygems_version: 2.4.5.1
|
|
247
|
+
rubygems_version: 3.0.3
|
|
233
248
|
signing_key:
|
|
234
249
|
specification_version: 4
|
|
235
250
|
summary: Miam is a tool to manage IAM.
|
|
@@ -238,8 +253,10 @@ test_files:
|
|
|
238
253
|
- spec/miam/create_spec.rb
|
|
239
254
|
- spec/miam/custom_managed_policy_spec.rb
|
|
240
255
|
- spec/miam/delete_spec.rb
|
|
256
|
+
- spec/miam/exclude_spec.rb
|
|
241
257
|
- spec/miam/hash_ext_spec.rb
|
|
242
258
|
- spec/miam/ignore_login_profile_spec.rb
|
|
243
259
|
- spec/miam/rename_spec.rb
|
|
260
|
+
- spec/miam/target_spec.rb
|
|
244
261
|
- spec/miam/update_spec.rb
|
|
245
262
|
- spec/spec_helper.rb
|