Created
October 2, 2018 15:14
-
-
Save chloegrace94/3e5fe3371a1fc84804cca09d46585a9c to your computer and use it in GitHub Desktop.
How to decrypt an AWS Lambda environment variable
This file contains hidden or 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 boto3 # AWS SDK for Python | |
import os | |
from base64 import b64decode | |
# Retrieve environment variables | |
encrypted_environment_variable_a = os.environ['a'] | |
encrypted_environment_variable_b = os.environ['b'] | |
# KMS Client | |
kms = boto3.client('kms') | |
# Decrypt encrypted environment variables | |
decrypted_variable_a = boto3.client('kms').decrypt(CiphertextBlob=b64decode(encrypted_environment_variable_a))['Plaintext'].decode('utf-8') | |
decrypted_variable_b = boto3.client('kms').decrypt(CiphertextBlob=b64decode(encrypted_environment_variable_b))['Plaintext'].decode('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks mate !!