Skip to content

Commit

Permalink
Merge pull request #659 from russellballestrini/rb-fix-kms-unicode
Browse files Browse the repository at this point in the history
Fix KMS lookup for Python2
  • Loading branch information
russellballestrini committed Sep 7, 2018
2 parents d95ab92 + 870abdf commit 11f9f5a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion stacker/lookups/handlers/kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,12 @@ def handler(value, **kwargs):
region, value = value.split("@", 1)

kms = get_session(region).client('kms')
decoded = codecs.decode(value.encode(), 'base64').decode()

# encode str value as an utf-8 bytestring for use with codecs.decode.
value = value.encode('utf-8')

# get raw but still encrypted value from base64 version.
decoded = codecs.decode(value, 'base64')

# decrypt and return the plain text raw value.
return kms.decrypt(CiphertextBlob=decoded)["Plaintext"]

0 comments on commit 11f9f5a

Please sign in to comment.