Skip to content

Commit

Permalink
Wrap error from account alias permissions error
Browse files Browse the repository at this point in the history
Per envato#362, the returned error message doesn't explain why the IAM
permission was required. While the wrapped error doesn't mention the
specific permission, the original MissingIamPermissionsError can still
be seen in --trace output, as it is registered as the Error#cause
  • Loading branch information
liamdawson committed Oct 4, 2021
1 parent 7c4361c commit 5729d7d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/stack_master/identity.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module StackMaster
class Identity
AllowedAccountAliasesError = Class.new(StandardError)
MissingIamPermissionsError = Class.new(StandardError)

def running_in_account?(accounts)
accounts.nil? ||
accounts.empty? ||
contains_account_id?(accounts) ||
contains_account_alias?(accounts)
rescue MissingIamPermissionsError
raise AllowedAccountAliasesError, "Unable to validate whether the current AWS account is allowed"
end

def account
Expand Down

0 comments on commit 5729d7d

Please sign in to comment.