# Perl port of https://github.com/awslabs/serverless-application-model/tree/master/examples/apps/s3-get-object

AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Description: >-
  An Amazon S3 trigger that retrieves metadata for the object that has been
  updated.
Parameters:
  BucketNamePrefix:
    Type: String
    Default: sam-example
Resources:
  s3getobject:
    Type: "AWS::Serverless::Function"
    Properties:
      Handler: handler.handle
      Runtime: provided.al2
      CodeUri: s3-get-object.zip
      Description: >-
        An Amazon S3 trigger that retrieves metadata for the object that has
        been updated.
      MemorySize: 128
      Timeout: 3
      Layers:
        - !Sub arn:aws:lambda:${AWS::Region}:445285296882:layer:perl-5-32-runtime-al2:1
        - !Sub arn:aws:lambda:${AWS::Region}:445285296882:layer:perl-5-32-paws-al2:1
      Policies:
        - S3CrudPolicy:
            BucketName: !Sub "${BucketNamePrefix}-get-object"
      Events:
        BucketEvent1:
          Type: S3
          Properties:
            Bucket: !Ref Bucket1
            Events:
              - "s3:ObjectCreated:*"
  Bucket1:
    Type: "AWS::S3::Bucket"
    Properties:
      BucketName: !Sub "${BucketNamePrefix}-get-object"
