Skip to content

Instantly share code, notes, and snippets.

@crsimmons
Created May 17, 2018 16:52
Show Gist options
  • Save crsimmons/d5ab438afa93c1dd1074cbf63778e74b to your computer and use it in GitHub Desktop.
Save crsimmons/d5ab438afa93c1dd1074cbf63778e74b to your computer and use it in GitHub Desktop.
Extract all credhub parameters into a yaml file in a format compatible with credhub import
require 'json'
require 'yaml'
json = JSON.parse(`credhub find -j`)
output = {
'credentials' => json['credentials'].map do |cred|
name = cred['name']
credential = JSON.parse(`credhub get -n #{name} -j`)
{
'name' => credential['name'],
'type' => 'value',
'value' => credential['value']
}
end
}.to_yaml.gsub('---', '')
File.write('credential_backup.yml', output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment