首页 > 解决方案 > 如何在 aws lambda cutom RunTime (Shell) 中使用 aws cli 二进制文件

问题描述

无法在 Lambda 自定义运行时运行 AWS CLI,出现错误:

未找到 aws 命令

python3 -m venv lambdaVirtualEnv 
source activate lambdaVirtualEnv
pip3 install awscli
copied the aws binary and contents under the site-packages to lambdaLayerDir 
Created a lambda layer using lambdaLayerDir.zip file. 
function handler () 
{
    PATH=${PATH}:${LAMBDA_TASK_ROOT}
    echo $PATH
    EVENT_DATA=$1
    RESPONSE="{\"statusCode\": 200, \"body\": \"Hello from Lambda!\"}"
    echo $RESPONSE
    aws
}

输出:

> * Connection #0 to host 127.0.0.1 left intact
/var/task/hello.sh: line 9: aws: command not found
END RequestId: b2225b95-c53c-4271-a664-873dc19528b4
REPORT RequestId: b2225b95-c53c-4271-a664-873dc19528b4  Init Duration: 33.70 ms Duration: 431.44 ms Billed Duration: 500 ms     Memory Size: 128 MB Max Memory Used: 45 MB  
RequestId: b2225b95-c53c-4271-a664-873dc19528b4 Error: Runtime exited with error: exit status 127
Runtime.ExitError

标签: amazon-web-services

解决方案


推荐阅读