AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A function is triggered off an upload to a bucket. It logs the content type of the uploaded object.
Resources:
  ProcessorFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs6.10
      CodeUri: src/
      Policies: AmazonS3ReadOnlyAccess
      Events:
        PhotoUpload:
          Type: S3
          Properties:
            Bucket: !Ref Bucket
            Events: s3:ObjectCreated:*

  Bucket:
    Type: AWS::S3::Bucket

Outputs:

    S3Bucket:
      Description: "S3 Bucket name that will trigger a Lambda function upon new objects insertion"
      Value: !Ref Bucket
