0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ServerlssFramework でLambdaコンテナをデプロイ

Last updated at Posted at 2023-02-01

概要

Lambdaの関数コードをコンテナイメージでデプロイすることができますが、
今回はServerlessFrameworkを使って簡単にクラウド環境にデプロイする手順を書き記します。

手順

1.サンプルコードを作成

$ serverless create --template aws-python-docker --path aws-python-docker-demo
✔ Project successfully created in "aws-python-docker-demo" from "aws-python-docker" template (3s)

2.デプロイコマンド実行

$ serverless deploy

Deploying aws-python-docker-demo to stage dev (ap-northeast-1)

✔ Service deployed to stack aws-python-docker-demo-dev (187s)

functions:
  hello: aws-python-docker-demo-dev-hello

3.確認

LambdaとECRそれぞれにデプロイされていることが確認できました。

Lambda
image.png
ECR
image.png

ハマりポイント

  • Runtime.InvalidEntrypoint エラーが発生した
    • M1 Macで環境構築したため、コンテナイメージがarm64アーキテクチャでビルドされたのが原因でした。 serverless.yml にアーキテクチャを指定することで解決しました。
serverlss.yml
provider:
  name: aws
  ecr:
    images:
      appimage:
        path: ./
  stage: dev
  region: ap-northeast-1
  architecture: arm64 <- ここ

関連記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?