pgp decryption and lambda

0

I try to use pgp encyption/decryption using lambda and found https://www.youtube.com/watch?v=N3R1SScBS9E&ab_channel=AmazonWebServices github: https://github.com/aws-samples/pgp-decryption-for-transfer-family?sc_channel=EL&sc_campaign=Demo_2022_vid&sc_medium=YouTube&sc_content=N3R1SScBS9E&sc_detail=MIGRATION_TRANSFER&sc_country=US basically i run setupenviroment.sh that create a lambda layer. I then create a very basic lambda funciton

import gnupg import json def lambda_handler(event, context): gpg = gnupg.GPG(gnupghome='/tmp', gpgbinary='/opt/python/gpg', options=['--trust-model', 'always'])

but i am keep getting error START RequestId: 72c1cffb-12ea-47f6-9d7f-dad91503e8b2 Version: $LATEST [ERROR] 2023-01-04T16:13:00.757Z 72c1cffb-12ea-47f6-9d7f-dad91503e8b2 Unable to run gpg (/opt/python/gpg) - it may not be available. Traceback (most recent call last): File "/opt/python/lib/python3.8/site-packages/gnupg.py", line 941, in init p = self._open_subprocess(['--version']) File "/opt/python/lib/python3.8/site-packages/gnupg.py", line 1007, in _open_subprocess result = Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE, startupinfo=si, env=self.env) File "/var/lang/lib/python3.8/subprocess.py", line 858, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/var/lang/lib/python3.8/subprocess.py", line 1704, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/opt/python/gpg'[ERROR] OSError: Unable to run gpg (/opt/python/gpg) - it may not be available. Traceback (most recent call last):   File "/var/task/lambda_function.py", line 5, in lambda_handler     gpg = gnupg.GPG(gnupghome='/tmp', gpgbinary='/opt/python/gpg', options=['--trust-model', 'always'])   File "/opt/python/lib/python3.8/site-packages/gnupg.py", line 945, in init     raise OSError(msg)END RequestId: 72c1cffb-12ea-47f6-9d7f-dad91503e8b2

jsonp80
asked a year ago268 views
1 Answer
0

My initial thought is that the construction of the Lambda Layer isn't correct. Have a look at the documentation - and the thing there that has tripped me up in the past is that you must create a directory called python and all the libraries must be installed in that directory. When you create the ZIP file you have to include that directory in the path.

profile pictureAWS
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions