Created
July 5, 2021 05:53
-
-
Save smd877/cacf0859b223fd334dabaa3d074ceb2f to your computer and use it in GitHub Desktop.
AWS LambdaでKMS復号化を行うサンプル
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 json | |
import boto3 | |
import os | |
from base64 import b64decode | |
def lambda_handler(event, context): | |
ENCRYPTED = os.environ['key1'] | |
DECRYPTED = boto3.client('kms').decrypt( | |
CiphertextBlob=b64decode(ENCRYPTED), | |
EncryptionContext={'LambdaFunctionName': os.environ['AWS_LAMBDA_FUNCTION_NAME']} | |
)['Plaintext'].decode('utf-8') | |
return { | |
'statusCode': 200, | |
'body': DECRYPTED | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment