Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import re
import os
import sys
from subprocess import Popen, PIPE
decrypt=os.path.join(scriptpath, 'decrypt')
input_str =
def my_replace(match):
match =
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