Created
June 12, 2020 05:04
-
-
Save famousgarkin/81ec2dd6b2de35b5e653d4724d3dbff4 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
# https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/filter/core.py | |
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kms.html | |
import boto3 | |
import base64 | |
kms = boto3.client('kms', region_name='eu-central-1') | |
def aws_kms_decrypt(ciphertext): | |
''' | |
:param ciphertext: Base64 encoded ciphertext from AWS KMS encrypt | |
:return plaintext decrypted from given ciphertext | |
''' | |
return kms.decrypt(CiphertextBlob=base64.b64decode(ciphertext)).get('Plaintext') | |
class FilterModule(object): | |
def filters(self): | |
return { | |
'aws_kms_decrypt': aws_kms_decrypt, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment