diff --git a/lib/train/transports/aws.rb b/lib/train/transports/aws.rb index f2b1f144..0d9e2eea 100644 --- a/lib/train/transports/aws.rb +++ b/lib/train/transports/aws.rb @@ -62,9 +62,8 @@ def uri def unique_identifier # use aws account id - client = aws_client(::Aws::IAM::Client) - arn = client.get_user.user.arn - arn.split(':')[4] + client = aws_client(::Aws::STS::Client) + client.get_caller_identity.account end end end diff --git a/test/unit/transports/aws_test.rb b/test/unit/transports/aws_test.rb index 92e910ca..db06d636 100644 --- a/test/unit/transports/aws_test.rb +++ b/test/unit/transports/aws_test.rb @@ -98,26 +98,23 @@ def initialize(hash) end describe 'unique_identifier' do - class AwsArn - def arn - 'arn:aws:iam::158551926027:user/test-fixture-maker' - end - end - class AwsUser - def user - AwsArn.new + class AwsCallerId + def account + "123456789012" end end - class AwsClient - def get_user - AwsUser.new + class StsClient + def get_caller_identity + AwsCallerId.new end end + it 'returns an account id' do - connection.stubs(:aws_client).returns(AwsClient.new) - connection.unique_identifier.must_equal '158551926027' + connection.stubs(:aws_client).returns(StsClient.new) + connection.unique_identifier.must_equal '123456789012' end end + end