0
0

PythonのLambda Layerを作成する方法

Posted at

フォルダ直下構成

以下の構成が必要なようです
pythonディレクトリ内に必要なライブラリをインストールする必要があります
lambda_layer.PNG

実際の作り方

1.任意のディレクトリ内にpythonディレクトリを作成する
2.pythonディレクトリに必要なライブラリをインストールする

pip install boto3 -t python  

3.pythonディレクトリをzip化

zip -r layer.zip ./python

4.手順3でzip化したものをlayerとして登録する
AWS Lambda Layersでライブラリを共通化

CloudFormationで作成する場合

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
    S3BucketName:
        Type: String
        Description: S3バケット名
        Default: Lambda
Resources:
  PythonLambdaLayer:
    Type: AWS::Lambda::LayerVersion
    Properties:
      LayerName: Python-Layer
      Description: Python Lambda Layer 
      CompatibleArchitectures: 
        - arm64
      CompatibleRuntimes: 
        - python3.10
      Content: 
        S3Bucket: !Ref S3BucketName
        S3Key: Lambda/layer/init_process/layer.zip # ここは自身のもので修正してください
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