【发布时间】:2023-03-28 17:44:01
【问题描述】:
我使用 zip method 部署我的无服务器功能。
我正在尝试使用以下代码加密文件:
import boto3
import gnupg
def lambda_handler(event, context):
s3=boto3.resource('s3')
s3.meta.client.download_file('my_bucket','plain.txt','/tmp/plain.txt')
s3.meta.client.download_file('my_bucket','public.key','/tmp/public.key')
key_data = open('/tmp/public.key').read()
gpg = gnupg.GPG('/tmp')
priv_key = gpg.import_keys(key_data)
with open('/tmp/plain.txt','rb') as a_file:
gpg.encrypt_file(a_file,key_data,output='plain.txt.gpg')
return 'ok'
但我收到以下错误:
"errorMessage": "Unable to run gpg (/tmp) - it may not be available."
从无服务器运行 gpg 的正确方法是什么?
【问题讨论】:
-
您究竟是如何使用 .zip 文件导入库的?究竟是什么错误?生成的文件夹结构是什么?
-
我在您的评论@gshpychka 之后更新了问题
-
您是如何将依赖项打包到 zip 文件中的?生成的文件夹结构是什么?
标签: python-3.x aws-lambda boto3 gnupg python-gnupgp