miam 0.2.4.beta4 → 0.2.4.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bffde3d3eb017df693ff9b01e5a1e068c291f591
4
- data.tar.gz: d8b2b31b09fff592caf96f49cc3fdc85119eef03
3
+ metadata.gz: d8f1bb0af1a2fc50488600724625331227f2d140
4
+ data.tar.gz: d3d47fde2bcaa09e111128288ae7df5b503d0672
5
5
  SHA512:
6
- metadata.gz: 92e4cddac25cd0c9877afee666cc25d590c547d13a48bdbbb4a90dd5d2641a5826104b0d006db7b3091b19d2e96fc9fbd1de4a125b21c809c10dbe7103f42a71
7
- data.tar.gz: 4c21822a4c9faca209454eb281262eefa348b8057dff9162c7707adea8e619461b20f221bcfbbf20c6af58d1e1285b0f84531f18c0d0cabada8b11eece8ff721
6
+ metadata.gz: 94f5a8bbe72365205d570058894105b69a21be1f9bff0037ce026ca89d140eb2de6f40fa6f7a02cd4fd71cf3d54341fcdb052646335dbcf087f12b5c6dd35f97
7
+ data.tar.gz: 9c2a71d660f36313d38cae51b048e828aa20bd1c2d666b77ff67a6f1b8a7537164df49196eb6fba1c3801d97dfa87695cac087d1ea5116f6623dbc86ec7ac097
data/.travis.yml CHANGED
@@ -10,3 +10,4 @@ env:
10
10
  - secure: "Ec8bwSfp06anSzLJpGhkKjPz9EocMwl7H8t2LKoI3bKV/cz9JU0GhhUdUUmg3mCFH9+8/YGLzcbFKcxZIqnDK7ukdgTGsnGDevnctis0QwM7/nKHdkaK8JWhCx41TUXOqoiCKkNEnm1EbDtrILt4rJwb0BGXGnPjv6nLAyvdE2Y="
11
11
  - secure: "Ky5Dpxc7SIqbQ4Y10m/jik/rVdeGMeh1439m3KB+tiV/Bz1hhWv4+If150ajLjbmWCZBPMLhxrTL0EePoyqYXpOGHvINvYM+/XCPcpP4iYkaTzr1MVIOMpa8A8aAOOgQWoGOwfyWoxfrYzv/TRvtMietnm+dZwVcbbkQ4ut7oa4="
12
12
  - AWS_REGION=ap-northeast-1
13
+ - DEBUG=1
data/lib/miam/client.rb CHANGED
@@ -452,7 +452,7 @@ class Miam::Client
452
452
  log(:warn, "ManagedPolicy `#{policy_name}`: 'path' cannot be updated", :color => :yellow)
453
453
  end
454
454
 
455
- updated = walk_managed_policy(policy_name, expected_attrs[:document], actual_attrs[:document]) || updated
455
+ updated = walk_managed_policy(policy_name, actual_attrs[:path], expected_attrs[:document], actual_attrs[:document]) || updated
456
456
  else
457
457
  @driver.create_managed_policy(policy_name, expected_attrs)
458
458
  updated = true
@@ -462,13 +462,13 @@ class Miam::Client
462
462
  updated
463
463
  end
464
464
 
465
- def walk_managed_policy(policy_name, expected_document, actual_document)
465
+ def walk_managed_policy(policy_name, policy_path, expected_document, actual_document)
466
466
  updated = false
467
467
  expected_document.sort_array!
468
468
  actual_document.sort_array!
469
469
 
470
470
  if expected_document != actual_document
471
- @driver.update_managed_policy(policy_name, expected_document, actual_document)
471
+ @driver.update_managed_policy(policy_name, policy_path, expected_document, actual_document)
472
472
  updated = true
473
473
  end
474
474
 
@@ -479,7 +479,7 @@ class Miam::Client
479
479
  updated = false
480
480
 
481
481
  actual.each do |policy_name, actual_attrs|
482
- @driver.delete_managed_policy(policy_name)
482
+ @driver.delete_managed_policy(policy_name, actual_attrs[:path])
483
483
  updated = true
484
484
  end
485
485
 
data/lib/miam/driver.rb CHANGED
@@ -377,12 +377,12 @@ class Miam::Driver
377
377
  end
378
378
  end
379
379
 
380
- def delete_managed_policy(policy_name)
380
+ def delete_managed_policy(policy_name, policy_path)
381
381
  log(:info, "Delete ManagedPolicy `#{policy_name}`", :color => :red)
382
382
 
383
383
  unless_dry_run do
384
384
  policy_versions = @iam.list_policy_versions(
385
- :policy_arn => policy_arn(policy_name),
385
+ :policy_arn => policy_arn(policy_name, policy_path),
386
386
  :max_items => MAX_POLICY_VERSIONS
387
387
  )
388
388
 
@@ -390,24 +390,24 @@ class Miam::Driver
390
390
  pv.is_default_version
391
391
  }.each {|pv|
392
392
  @iam.delete_policy_version(
393
- :policy_arn => policy_arn(policy_name),
393
+ :policy_arn => policy_arn(policy_name, policy_path),
394
394
  :version_id => pv.version_id
395
395
  )
396
396
  }
397
397
 
398
398
  @iam.delete_policy(
399
- :policy_arn => policy_arn(policy_name)
399
+ :policy_arn => policy_arn(policy_name, policy_path)
400
400
  )
401
401
  end
402
402
  end
403
403
 
404
- def update_managed_policy(policy_name, policy_document, old_policy_document)
404
+ def update_managed_policy(policy_name, policy_path, policy_document, old_policy_document)
405
405
  log(:info, "Update ManagedPolicy `#{policy_name}`", :color => :green)
406
406
  log(:info, Miam::Utils.diff(old_policy_document, policy_document, :color => @options[:color]), :color => false)
407
407
 
408
408
  unless_dry_run do
409
409
  policy_versions = @iam.list_policy_versions(
410
- :policy_arn => policy_arn(policy_name),
410
+ :policy_arn => policy_arn(policy_name, policy_path),
411
411
  :max_items => MAX_POLICY_VERSIONS
412
412
  )
413
413
 
@@ -417,13 +417,13 @@ class Miam::Driver
417
417
  }.sort_by {|pv| pv.version_id[1..-1].to_i }.first
418
418
 
419
419
  @iam.delete_policy_version(
420
- :policy_arn => policy_arn(policy_name),
420
+ :policy_arn => policy_arn(policy_name, policy_path),
421
421
  :version_id => delete_policy_version.version_id
422
422
  )
423
423
  end
424
424
 
425
425
  @iam.create_policy_version(
426
- :policy_arn => policy_arn(policy_name),
426
+ :policy_arn => policy_arn(policy_name, policy_path),
427
427
  :policy_document => encode_document(policy_document),
428
428
  set_as_default: true
429
429
  )
@@ -460,7 +460,7 @@ class Miam::Driver
460
460
  @account_id ||= @iam.get_user.user.arn.split(':').fetch(4)
461
461
  end
462
462
 
463
- def policy_arn(policy_name)
464
- "arn:aws:iam::#{account_id}:policy/#{policy_name}"
463
+ def policy_arn(policy_name, policy_path)
464
+ File.join("arn:aws:iam::#{account_id}:policy", policy_path, policy_name)
465
465
  end
466
466
  end
data/lib/miam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Miam
2
- VERSION = '0.2.4.beta4'
2
+ VERSION = '0.2.4.beta5'
3
3
  end
data/miam.gemspec CHANGED
@@ -8,8 +8,6 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Miam::VERSION
9
9
  spec.authors = ['Genki Sugawara']
10
10
  spec.email = ['sgwr_dts@yahoo.co.jp']
11
- spec.summary = %q{TODO: Write a short summary. Required.}
12
- spec.description = %q{TODO: Write a longer description. Optional.}
13
11
  spec.summary = %q{Miam is a tool to manage IAM.}
14
12
  spec.description = %q{Miam is a tool to manage IAM. It defines the state of IAM using DSL, and updates IAM according to DSL.}
15
13
  spec.homepage = 'http://miam.codenize.tools/'
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.beta4
4
+ version: 0.2.4.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core