如何在AWS Lambda Cutom RunTime(Shell)中使用AWS CLI二进制文件

时间:2019-07-07 09:11:30

标签: amazon-web-services

无法在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

0 个答案:

没有答案