Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second tentative fix for issue #17 #24

Merged
merged 4 commits into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: ruby
rvm:
- 2.0.0
- 2.3.3
script:
- bundle install
- travis_wait bundle exec rake
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ It defines the state of IAM using DSL, and updates IAM according to DSL.
* Fix for Password Policy ([RP#22](https://github.com/winebarrel/miam/pull/22))
* Fix `--target` option for Policies ([RP#21](https://github.com/winebarrel/miam/pull/21))
* Fix for `Rate exceeded` ([PR#23](https://github.com/winebarrel/miam/pull/23))
* Fix for non-User credentials ([PR#17](https://github.com/winebarrel/miam/pull/17))

## Installation

Expand Down
3 changes: 2 additions & 1 deletion lib/miam/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ def initialize(options = {})
@options = {:format => :ruby}.merge(options)
aws_config = options.delete(:aws_config) || {}
@iam = Aws::IAM::Client.new(aws_config)
@driver = Miam::Driver.new(@iam, options)
@sts = Aws::STS::Client.new(aws_config)
@driver = Miam::Driver.new(@iam, @sts, options)
@password_manager = options[:password_manager] || Miam::PasswordManager.new('-', options)
end

Expand Down
7 changes: 5 additions & 2 deletions lib/miam/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ class Miam::Driver
MAX_POLICY_SIZE = 2048
MAX_POLICY_VERSIONS = 5

def initialize(iam, options = {})
def initialize(iam, sts, options = {})
@iam = iam
@sts = sts
@options = options
@account_id = nil
end

def create_user(user_name, attrs)
Expand Down Expand Up @@ -473,7 +475,8 @@ def unless_dry_run

def account_id
# https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
@account_id ||= @iam.get_user.user.arn.split(':').fetch(4)
# http://docs.aws.amazon.com/STS/latest/APIReference/API_GetCallerIdentity.html
@account_id ||= @sts.get_caller_identity.account
end

def policy_arn(policy_name, policy_path)
Expand Down
2 changes: 1 addition & 1 deletion lib/miam/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Miam
VERSION = '0.2.4.beta8'
VERSION = '0.2.4.beta9'
end