▫️

`No xxx.zip file found in the package path you provided.` を解決する

に公開

Serverless Framework で Lambda のランタイム go1.x を provided.al2023 に更新しようとしてエラーになる

Serverless Framework バージョン: v3.40.0

serverless.yml

 service: notify

 provider:
   name: aws
-  runtime: go1.x
+  runtime: provided.al2023

 functions:
   foo:
     environment: ${self:custom.environment.${self:provider.stage}}
-    handler: bin/foo
+    handler: bootstrap
+    package:
+      artifact: bin/foo.zip
   bar:
     environment: ${self:custom.environment.${self:provider.stage}}
-    handler: bin/bar
+    handler: bootstrap
+    package:
+      artifact: bin/bar.zip

この変更ではエラーとなった。

$ sls deploy --stage staging
Deploying notify to stage staging (ap-northeast-1)

Error:
No notify.zip file found in the package path you provided.

作成した bin/foo.zipbin/bar.zip を検知してほしいのだが、なぜか notify.zip を探しているようだった。

individually: true をつけて解決する

解決策としては package.individually: true 指定すること。これにより、各関数ごとに個別の zip を使用してデプロイするようになった。

 service: notify

 provider:
   name: aws
   runtime: provided.al2023

+package:
+ individually: true

 functions:
   foo:
     environment: ${self:custom.environment.${self:provider.stage}}
     handler: bin/foo/bootstrap
     package:
       artifact: bin/foo.zip
   bar:
     environment: ${self:custom.environment.${self:provider.stage}}
     handler: bin/bar/bootstrap
     package:
       artifact: bin/bar.zip

以上です。

Progate Tech Blog

Discussion