Created
January 18, 2017 12:00
-
-
Save dmitrygusev/abbb1de20aec23c8516dd3272eb629dd to your computer and use it in GitHub Desktop.
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
import re | |
import os | |
import sys | |
from subprocess import Popen, PIPE | |
scriptpath=os.path.dirname(os.path.abspath(__file__)) | |
decrypt=os.path.join(scriptpath, 'decrypt') | |
input_str = sys.stdin.read() | |
def my_replace(match): | |
match = match.group(1) | |
p = Popen([decrypt, match], stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
output, err = p.communicate() | |
if p.returncode != 0: | |
raise ValueError('Error decrypting "'+ match +'"\n' + err) | |
return output | |
print re.sub(r'aws:kms:[^:]+:(.*)', my_replace, input_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment