python3.7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
Response: 0 Request ID: "50b03c17-4f23-4dee-b449-2d359f7b4e14" Function Logs: START RequestId: 50b03c17-4f23-4dee-b449-2d359f7b4e14 Version: $LATEST ===[environment-variables]=== PATH LD_LIBRARY_PATH LANG TZ LAMBDA_TASK_ROOT LAMBDA_RUNTIME_DIR AWS_REGION AWS_DEFAULT_REGION AWS_LAMBDA_LOG_GROUP_NAME AWS_LAMBDA_LOG_STREAM_NAME AWS_LAMBDA_FUNCTION_NAME AWS_LAMBDA_FUNCTION_MEMORY_SIZE AWS_LAMBDA_FUNCTION_VERSION _AWS_XRAY_DAEMON_ADDRESS _AWS_XRAY_DAEMON_PORT AWS_XRAY_DAEMON_ADDRESS AWS_XRAY_CONTEXT_MISSING AWS_EXECUTION_ENV _HANDLER AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN _X_AMZN_TRACE_ID ===[runtime directory:/var/runtime]=== python_dateutil-2.7.5.dist-info docutils-0.14.dist-info lambda_runtime_marshaller.py s3transfer-0.1.13.dist-info test_bootstrap.py runtime-release bootstrap.py six-1.11.0.dist-info urllib3-1.24.1.dist-info s3transfer lambda_runtime_exception.py botocore dateutil bin docutils six.py botocore-1.12.42.dist-info urllib3 lambda_runtime_client.py boto3-1.9.42.dist-info boto3 bootstrap test_lambda_runtime_client.py jmespath __pycache__ test_lambda_runtime_marshaller.py jmespath-0.9.3.dist-info ===[amazon linux version]=== Amazon Linux AMI release 2017.03 0 END RequestId: 50b03c17-4f23-4dee-b449-2d359f7b4e14 REPORT RequestId: 50b03c17-4f23-4dee-b449-2d359f7b4e14 Duration: 109.71 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 55 MB |
python3.6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
Response: { "errorMessage": "[Errno 2] No such file or directory: 'cat /etc/system-release': 'cat /etc/system-release'", "errorType": "FileNotFoundError", "stackTrace": [ [ "/var/task/lambda_function.py", 22, "lambda_handler", "ret = subprocess.call(cmd)" ], [ "/var/lang/lib/python3.6/subprocess.py", 287, "call", "with Popen(*popenargs, **kwargs) as p:" ], [ "/var/lang/lib/python3.6/subprocess.py", 729, "__init__", "restore_signals, start_new_session)" ], [ "/var/lang/lib/python3.6/subprocess.py", 1364, "_execute_child", "raise child_exception_type(errno_num, err_msg, err_filename)" ] ] } Request ID: "310363ce-1c33-4c07-9d31-9b445790422e" Function Logs: START RequestId: 310363ce-1c33-4c07-9d31-9b445790422e Version: $LATEST ===[environment-variables]=== PATH LD_LIBRARY_PATH LANG TZ LAMBDA_TASK_ROOT LAMBDA_RUNTIME_DIR AWS_REGION AWS_DEFAULT_REGION AWS_LAMBDA_LOG_GROUP_NAME AWS_LAMBDA_LOG_STREAM_NAME AWS_LAMBDA_FUNCTION_NAME AWS_LAMBDA_FUNCTION_MEMORY_SIZE AWS_LAMBDA_FUNCTION_VERSION _AWS_XRAY_DAEMON_ADDRESS _AWS_XRAY_DAEMON_PORT AWS_XRAY_DAEMON_ADDRESS AWS_XRAY_CONTEXT_MISSING _X_AMZN_TRACE_ID AWS_EXECUTION_ENV _HANDLER AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_SECURITY_TOKEN PYTHONPATH ===[runtime directory:/var/runtime]=== liblambdaruntime.so docutils-0.14.dist-info botocore-1.10.74.dist-info s3transfer-0.1.13.dist-info six-1.11.0.dist-info boto3-1.7.74.dist-info s3transfer botocore liblambdalog.so dateutil awslambda docutils six.py boto3 liblambdaio.so jmespath __pycache__ python_dateutil-2.7.3.dist-info jmespath-0.9.3.dist-info liblambdaipc.so ===[amazon linux version]=== [Errno 2] No such file or directory: 'cat /etc/system-release': 'cat /etc/system-release': FileNotFoundError Traceback (most recent call last): File "/var/task/lambda_function.py", line 22, in lambda_handler ret = subprocess.call(cmd) File "/var/lang/lib/python3.6/subprocess.py", line 287, in call with Popen(*popenargs, **kwargs) as p: File "/var/lang/lib/python3.6/subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "/var/lang/lib/python3.6/subprocess.py", line 1364, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'cat /etc/system-release': 'cat /etc/system-release' END RequestId: 310363ce-1c33-4c07-9d31-9b445790422e REPORT RequestId: 310363ce-1c33-4c07-9d31-9b445790422e Duration: 50.25 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 49 MB |
Python2.7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
Response: { "stackTrace": [ [ "/var/task/lambda_function.py", 24, "lambda_handler", "ret = subprocess.call(cmd)" ], [ "/usr/lib64/python2.7/subprocess.py", 523, "call", "return Popen(*popenargs, **kwargs).wait()" ], [ "/usr/lib64/python2.7/subprocess.py", 711, "__init__", "errread, errwrite)" ], [ "/usr/lib64/python2.7/subprocess.py", 1343, "_execute_child", "raise child_exception" ] ], "errorType": "OSError", "errorMessage": "[Errno 2] No such file or directory" } Request ID: "098c848f-87e7-45dd-89fd-4b79d0767907" Function Logs: START RequestId: 098c848f-87e7-45dd-89fd-4b79d0767907 Version: $LATEST ===[environment-variables]=== _HANDLER AWS_LAMBDA_FUNCTION_VERSION LAMBDA_TASK_ROOT PATH LD_LIBRARY_PATH LANG TZ AWS_REGION AWS_XRAY_CONTEXT_MISSING AWS_SESSION_TOKEN AWS_SECURITY_TOKEN LAMBDA_RUNTIME_DIR PYTHONPATH AWS_LAMBDA_FUNCTION_MEMORY_SIZE _AWS_XRAY_DAEMON_PORT _AWS_XRAY_DAEMON_ADDRESS AWS_LAMBDA_LOG_GROUP_NAME AWS_LAMBDA_LOG_STREAM_NAME AWS_ACCESS_KEY_ID _X_AMZN_TRACE_ID AWS_DEFAULT_REGION AWS_SECRET_ACCESS_KEY AWS_EXECUTION_ENV AWS_XRAY_DAEMON_ADDRESS AWS_LAMBDA_FUNCTION_NAME ===[runtime directory:/var/runtime]=== liblambdaruntime.so docutils-0.14.dist-info botocore-1.10.74.dist-info futures-3.2.0.dist-info s3transfer-0.1.13.dist-info six-1.11.0.dist-info boto3-1.7.74.dist-info s3transfer botocore liblambdalog.so dateutil six.pyc awslambda bin docutils six.py boto3 liblambdaio.so jmespath concurrent python_dateutil-2.7.3.dist-info jmespath-0.9.3.dist-info liblambdaipc.so ===[amazon linux version]=== [Errno 2] No such file or directory: OSError Traceback (most recent call last): File "/var/task/lambda_function.py", line 24, in lambda_handler ret = subprocess.call(cmd) File "/usr/lib64/python2.7/subprocess.py", line 523, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/usr/lib64/python2.7/subprocess.py", line 1343, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory END RequestId: 098c848f-87e7-45dd-89fd-4b79d0767907 REPORT RequestId: 098c848f-87e7-45dd-89fd-4b79d0767907 Duration: 93.64 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 42 MB |
2.7でもboto3-1.7.74.dist-info
- Lambda pythonバージョン
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/python-programming-model.html
boto3 s3 署名バージョン対応
1.5.71 (Botocore)、1.4.6 (Boto3) にアップグレード。 |
pythonコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# -*- coding: utf-8 -*- import os import subprocess def lambda_handler(event, context): # 環境変数一覧を取得 print("===[environment-variables]===") for env in os.environ: print(env) #ランタイムの格納されているディレクトリを確認 rtdir = os.environ.get("LAMBDA_RUNTIME_DIR") print("\n===[runtime directory:"+rtdir+"]===") #ディレクトリ内を表示 files = os.listdir(rtdir) for file in files: print(file) # amazon linux version print("\n===[amazon linux version]===") cmd = "cat /etc/system-release"; ret = subprocess.call(cmd) print(ret) cmd = "ls -la /etc/system*"; ret = subprocess.call(cmd) print(ret) return 0 |
https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/UsingAWSSDK.html
すべての AWS リージョンでは、AWS SDK はデフォルトで署名バージョン 4 を使用してリクエストを認証します。2016 年 5 月以前にリリースされた AWS SDK を使用する場合、次の表に示すように、署名バージョン 4 のリクエストが必要になることがあります。
[s3] use-sigv4 = True
5af85bf0