AWSTemplateFormatVersion: 2010-09-09
Description: AWS Lambda Layer AL2023 of AWS SDK for Perl

Parameters:
  PerlVersion:
    Type: String
  Name:
    Type: String
  ObjectVersion:
    Type: String

Resources:
  PerlLayer:
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    Type: AWS::Lambda::LayerVersion
    Properties:
      Content:
        S3Bucket: !Sub shogo82148-lambda-perl-runtime-${AWS::Region}
        S3Key: !Sub ${Name}.zip
        S3ObjectVersion: !Ref ObjectVersion
      Description: !Sub Perl ${PerlVersion} SDK for AWS (Amazon Web Services) APIs
      LayerName: !Ref Name
      LicenseInfo: https://github.com/shogo82148/p5-aws-lambda/blob/main/LICENSE
  Permission:
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    Type: AWS::Lambda::LayerVersionPermission
    Properties:
      Action: lambda:GetLayerVersion
      LayerVersionArn: !Ref PerlLayer
      Principal: "*"
Outputs:
  PerlLayer:
    Value: !Ref PerlLayer
