def account_number
      return @account_number if @account_number

      begin
        my_arn = AWS::IAM.new(
          access_key_id: @access_key_id,
          secret_access_key: @secret_access_key
        ).client.get_user[:user][:arn]
      rescue AWS::IAM::Errors::AccessDenied => e
        my_arn = e.message.split[1]
      end

      @account_number = my_arn.split(':')[4]
    end
def account_number
      return @account_number if @account_number

      begin
        my_arn = AWS::IAM.new(
          access_key_id: @access_key_id,
          secret_access_key: @secret_access_key
        ).client.get_user[:user][:arn]
      rescue AWS::IAM::Errors::AccessDenied => e
        my_arn = e.message.split[1]
      end

      @account_number = my_arn.split(':')[4]
    end
def account_number return @account_number if @account_number begin my_arn = AWS :: IAM . new ( access_key_id : @access_key_id , secret_access_key : @secret_access_key ) . client . get_user [ :user ] [ :arn ] rescue AWS :: IAM :: Errors :: AccessDenied => e my_arn = e . message . split [ 1 ] end @account_number = my_arn . split ( ':' ) [ 4 ] end
unfortunately, this appears to be the only way to get your account number
unfortunately this appears to be the only way to get your account number