For security reasons I want to put some encrypted environmental variables in my lambda function, which includes pandas, numpy,psycopg2 and sklearn as extra python packages.
The function works smoothly but when I introduce the following code for the decrypting the variables it stops working:
import os
from base64 import b64decode
keys = {}
def get_variables(variable):
encrypted = os.environ[f'{variable}']
decrypted = boto3.client('kms').decrypt(CiphertextBlob=b64decode(encrypted))['Plaintext']
keys[variable] = str(decrypted, 'utf-8')
for variable in ['dbname','port','user','password','host']:
get_variables(variable)
def lambda_handler(event,context):
code
result = keys['password']
return result
Specifically, the part that is breaking everything is this line
result = keys['password']
The code is correct because I have tested it in another Lambda function (plus it is based on the example provided by lambda itself), and the error I get is the following:
/var/task/sklearn/externals/joblib/_multiprocessing_helpers.py:38: UserWarning: [Errno 38] Function not implemented. joblib will operate in serial mode
warnings.warn('%s. joblib will operate in serial mode' % (e,))
I have no idea what to do for solving it.