Skip to content

Instantly share code, notes, and snippets.

@jnahelou
Created September 27, 2018 10:37
Show Gist options
  • Save jnahelou/2497084266d0372e752a58154d874913 to your computer and use it in GitHub Desktop.
Save jnahelou/2497084266d0372e752a58154d874913 to your computer and use it in GitHub Desktop.
Dump all Vault KV
#!/usr/bin/perl -w
use strict;
use JSON -support_by_pp;
use Data::Dumper;
# Don't forget to login to vault first
sub rec {
my ($path) = @_;
my $json = JSON->new->pretty;
my $json_text = `vault list -format=json $path`;
my $json_object = $json->decode($json_text);
for my $item( @{$json_object} ){
if (substr($item, -1) eq "/") {
#It's a folder, deep dive into
rec("$path$item")
} else {
#It's a key, let's read it
print `vault read -format=json $path$item`
}
}
}
rec("secret/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment