Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Import and Export of Policies. #118

Open
ksquaredkey opened this issue Feb 24, 2023 · 0 comments
Open

Feature Request: Import and Export of Policies. #118

ksquaredkey opened this issue Feb 24, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ksquaredkey
Copy link

Thank you for this tool - it was very handy migrating secrets to new Vault server (fortunately, we don't care about the version history yet).

The next step of my migration was to move my Policies over in a manner very much like import/export. I was able to do that with some simple shell scripting, but would be cool to have as part of Medusa.

Putting shell script fragments here in case someone else trying to migrate might find them useful.

dump-policies.sh:

dump_dir="./dumped-policies"

policies=$(vault policy list | grep -v root)

mkdir -p "${dump_dir}"
for p in ${policies} ; do
    echo "reading policy: ${p}"
    vault policy read "${p}" > "${dump_dir}/${p}-policy-dumped.hcl"
done

load-dumped-policies.sh:

dump_dir="./dumped-policies"

policies=$(cd ${dump_dir}/ ; ls *-policy-dumped.hcl | sed -e 's/-policy-dumped.hcl//g')

for p in ${policies} ; do
    echo "writing policy: ${p}"
    vault policy write "${p}" "${dump_dir}/${p}-policy-dumped.hcl"
done
@jonasvinther jonasvinther added the enhancement New feature or request label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants