質問編集履歴
4
見出しを作成
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,7 +130,7 @@
|
|
130
130
|
lambda_function.pyは1つ上の階層にあります。
|
131
131
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/acc46952-4424-4d0b-9b0d-6dd6071ccdd6.png)
|
132
132
|
|
133
|
-
ローカルにpsycopg2をインストールし、レイヤー化
|
133
|
+
### ローカルにpsycopg2をインストールし、レイヤー化
|
134
134
|
```ここに言語を入力
|
135
135
|
pip install psycopg2
|
136
136
|
Requirement already satisfied: psycopg2 in /Users/hiro/.pyenv/versions/3.10.6/lib/python3.10/site-packages (2.9.9)
|
3
補足の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,3 +130,36 @@
|
|
130
130
|
lambda_function.pyは1つ上の階層にあります。
|
131
131
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/acc46952-4424-4d0b-9b0d-6dd6071ccdd6.png)
|
132
132
|
|
133
|
+
ローカルにpsycopg2をインストールし、レイヤー化
|
134
|
+
```ここに言語を入力
|
135
|
+
pip install psycopg2
|
136
|
+
Requirement already satisfied: psycopg2 in /Users/hiro/.pyenv/versions/3.10.6/lib/python3.10/site-packages (2.9.9)
|
137
|
+
```
|
138
|
+
すでに入っていたので、対象フォルダまで移動し、フォルダ内をzip化
|
139
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/8f2c231f-0f8f-429d-b185-09d1bd5139e5.png)
|
140
|
+
新規でラムダ関数を作成し、lambda_function.pyを作成
|
141
|
+
Zipからレイヤーを作成し、ラムダ関数と紐づけてテスト実行→エラー
|
142
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/2a4e8aca-2b19-49b8-9639-71d000f5ab4a.png)
|
143
|
+
```ここに言語を入力
|
144
|
+
Test Event Name
|
145
|
+
test
|
146
|
+
|
147
|
+
Response
|
148
|
+
{
|
149
|
+
"errorMessage": "Unable to import module 'lambda_function': No module named 'psycopg2'",
|
150
|
+
"errorType": "Runtime.ImportModuleError",
|
151
|
+
"requestId": "33e6915a-072d-4525-95d6-56a280be654c",
|
152
|
+
"stackTrace": []
|
153
|
+
}
|
154
|
+
|
155
|
+
Function Logs
|
156
|
+
START RequestId: 33e6915a-072d-4525-95d6-56a280be654c Version: $LATEST
|
157
|
+
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
|
158
|
+
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'psycopg2'
|
159
|
+
Traceback (most recent call last):END RequestId: 33e6915a-072d-4525-95d6-56a280be654c
|
160
|
+
REPORT RequestId: 33e6915a-072d-4525-95d6-56a280be654c Duration: 9.15 ms Billed Duration: 10 ms Memory Size: 128 MB Max Memory Used: 30 MB Init Duration: 73.11 ms
|
161
|
+
|
162
|
+
Request ID
|
163
|
+
33e6915a-072d-4525-95d6-56a280be654c
|
164
|
+
```
|
165
|
+
|
2
画像の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -127,4 +127,6 @@
|
|
127
127
|
|
128
128
|
```
|
129
129
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/987083a5-3d02-4af5-94b7-8d88b0bec62c.png)
|
130
|
+
lambda_function.pyは1つ上の階層にあります。
|
131
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/acc46952-4424-4d0b-9b0d-6dd6071ccdd6.png)
|
130
132
|
|
1
補足の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -103,3 +103,28 @@
|
|
103
103
|
|
104
104
|
### 補足
|
105
105
|
ランタイムのPythonのバージョンは合わせております。
|
106
|
+
|
107
|
+
再実施するも以下の通りにエラーが発生
|
108
|
+
※s3からのアップではなく、Zipからのアップにて実行しています。
|
109
|
+
```ここに言語を入力
|
110
|
+
Test Event Name
|
111
|
+
(unsaved) test event
|
112
|
+
|
113
|
+
Response
|
114
|
+
{
|
115
|
+
"errorMessage": "Unable to import module 'lambda_function': No module named 'psycopg2'",
|
116
|
+
"errorType": "Runtime.ImportModuleError",
|
117
|
+
"requestId": "38f35630-ad38-4e74-89de-bd7eced628e0",
|
118
|
+
"stackTrace": []
|
119
|
+
}
|
120
|
+
|
121
|
+
Function Logs
|
122
|
+
START RequestId: 38f35630-ad38-4e74-89de-bd7eced628e0 Version: $LATEST
|
123
|
+
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
|
124
|
+
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'psycopg2'
|
125
|
+
Traceback (most recent call last):END RequestId: 38f35630-ad38-4e74-89de-bd7eced628e0
|
126
|
+
REPORT RequestId: 38f35630-ad38-4e74-89de-bd7eced628e0 Duration: 1.77 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 31 MB
|
127
|
+
|
128
|
+
```
|
129
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-05-16/987083a5-3d02-4af5-94b7-8d88b0bec62c.png)
|
130
|
+
|