Last active
September 11, 2019 13:43
-
-
Save clayrisser/140ca9bdceef0c221e8f93f9bab0d71a to your computer and use it in GitHub Desktop.
Restic AWS Credentials Wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
import sys | |
from configparser import ConfigParser | |
config = ConfigParser() | |
config.read(os.path.abspath(sys.argv[1])) | |
def get_value(path, value): | |
if not len(path): | |
return value | |
path_array = path.split('.') | |
value = value[path_array.pop(0)] | |
path = '.'.join(path_array) | |
return get_value(path, value) | |
print(get_value(sys.argv[2], config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ "$AWS_PROFILE" -eq "" ]]; then | |
export AWS_PROFILE=default | |
fi | |
export AWS_SECRET_KEY_ID=$(qini $HOME/.aws/credentials $AWS_PROFILE.aws_access_key_id) | |
export AWS_SECRET_ACCESS_KEY=$(qini $HOME/.aws/credentials $AWS_PROFILE.aws_secret_access_key) | |
eval /usr/bin/restic "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python3 ./qini.py $HOME/.aws/credentials default.aws_access_key_id