Socket
Book a DemoInstallSign in
Socket

aws_config

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws_config

0.1.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

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

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

FAQs

Package last updated on 09 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.