AWS CloudFormation を使用したレイヤー - AWS Lambda

AWS CloudFormation を使用したレイヤー

AWS CloudFormation を使用してレイヤーを作成し、そのレイヤーを Lambda 関数に関連付けることができます。次のテンプレートの例では、my-lambda-layer という名前のレイヤーを作成し、そのレイヤーを Layers プロパティを使用して Lambda 関数にアタッチします。

--- Description: CloudFormation Template for Lambda Function with Lambda Layer Resources: MyLambdaLayer: Type: AWS::Lambda::LayerVersion Properties: LayerName: my-lambda-layer Description: My Lambda Layer Content: S3Bucket: DOC-EXAMPLE-BUCKET S3Key: my-layer.zip CompatibleRuntimes: - python3.9 - python3.10 - python3.11 MyLambdaFunction: Type: AWS::Lambda::Function Properties: FunctionName: my-lambda-function Runtime: python3.9 Handler: index.handler Timeout: 10 Policies: - AWSLambdaBasicExecutionRole - AWSLambda_ReadOnlyAccess - AWSXrayWriteOnlyAccess Layers: - !Ref MyLambdaLayer