Project

aws_config

0.06
Low commit activity in last 3 years
No release in over a year
AWSConfig is a parser for AWS_CONFIG_FILE used in aws-cli.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3
>= 0
>= 0
 Project Readme

Build Status

AWSConfig

AWSConfig is a parser for AWS_CONFIG_FILE used in aws-cli.

Installation

Add this line to your application's Gemfile:

gem 'aws_config'

And then execute:

$ bundle

Or install it yourself as:

$ gem install aws_config

Usage

It parses ~/.aws/config and ~/.aws/credentials by default.

If your aws config files look like this:

Credentials file

  [default]
  aws_access_key_id=DefaultAccessKey01
  aws_secret_access_key=Default/Secret/Access/Key/02

  [testing]
  aws_access_key_id=TestingAccessKey03
  aws_secret_access_key=Testing/Secret/Access/Key/04

Config file

  [default]
  # Optional, to define default region for this profile.
  region=us-west-1
  source_profile=default

  [profile testing]
  role_arn=arn:example:283671836
  region=us-west-2
  source_profile=testing

  [profile with_mfa]
  source_profile=testing
  region=ap-southeast-2
  mfa_serial=arn:mfa_device:151235152134

you can access it like:

  require "aws_config"

  puts AWSConfig.default.aws_access_key_id    #=> DefaultAccessKey01
  puts AWSConfig.default.region               #=> Default/Secret/Access/Key/02

also you can do like hashes:

  puts AWSConfig["default"]["aws_access_key_id"]  #=> DefaultAccessKey01
  puts AWSConfig["default"]["region"]             #=> Default/Secret/Access/Key/02

If your config contains chained profiles using the source_profile property, you can still access the source profiles properties from the top i.e

  require "aws_config"

  puts AWSConfig.with_mfa.role_arn #=> arn:example:283671836
  puts AWSConfig.with_mfa.region   #=> ap-southeast-2

If you want to use with aws-sdk-ruby, you can configure like:

  AWS.config(AWSConfig.default.config_hash)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request