Skip to content

Awskeyring as a Gem.

Tristan edited this page Jul 15, 2019 · 2 revisions

Using Awskeyring as a Gem

Awskeyring has been created to also be used as a Gem (ruby Library) that can be embedded in other applications. The interactions with the AWS API are all contained in a module and documented on Ruby Doc. An example repo called Vaulttool show's how this can be done.

Example snippet

A short example is taking an array of AWS credentials and outputing a string that exports them for your console to interpret.

def put_env_string(cred)
  env_var = Awskeyring::Awsapi.get_env_array(cred)
  env_var.each { |var, value| puts "export #{var}=\"#{value}\"" }
  Awskeyring::Awsapi::AWS_ENV_VARS.each { |key| puts "unset #{key}" unless env_var.key?(key) }
end
Clone this wiki locally