ruby-on-railsrubyamazon-web-servicesfog

Fog AWS: How to get account ID


Using fog library of ruby how can I get the account ID of the current authentication? I use access_key_id and secret_access_key to authenticate.


Solution

  • You can get this info through get-caller-identity API of STS service.

    In Ruby:

    Aws::STS::Client.new(your_oprions).get_caller_identity[:account]