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?

AWS SAM で Lambda Powertools for Python のレイヤー

template.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
  FunctionRuntime:
    Type: String
    Default: python3.11
    Description: "Lambda関数のランタイム"

Globals:
  Function:
    Runtime: !Ref FunctionRuntime  # Lambda関数のランタイム
    Layers:
      # https://docs.powertools.aws.dev/lambda/python/latest/#extra-dependencies
      # Powertools for AWS Lambda (Python) レイヤー
      - Fn::Join: 
        - "-"
        - - Fn::Sub: "arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV3"
          - Fn::Join: ["", !Split [".", !Ref FunctionRuntime]]
          - "x86_64:5"
      - !Ref PythonBaseLayer  # 自分の使用するレイヤー

Resources:
  PythonBaseLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: python-base-layer  # レイヤーの名前
      ContentUri: layer/python-base-layer  # レイヤーのコンテンツURI
      CompatibleRuntimes:
        - !Ref FunctionRuntime  # 対応するランタイム
      RetentionPolicy: Delete  # レイヤーの保持ポリシー
    Metadata:
      BuildMethod: makefile
      BuildArchitecture: x86_64

  PythonBaseLayerPermission:
    Type: AWS::Lambda::LayerVersionPermission
    Properties:
      Action: lambda:GetLayerVersion  # アクション: レイヤーのバージョン取得
      LayerVersionArn: !Ref PythonBaseLayer  # 対象のレイヤーARN
      Principal: !Ref AWS::AccountId  # アクセスを許可するプリンシパル
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?