AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  DatafyRek

  Sample SAM Template for DatafyRek

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 900
    MemorySize: 1028

    Tracing: Active
    # You can add LoggingConfig parameters such as the Logformat, Log Group, and SystemLogLevel or ApplicationLogLevel. Learn more here https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-loggingconfig.
    LoggingConfig:
      LogFormat: JSON
  Api:
    TracingEnabled: true
Resources:
  AWSRekognitionFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: aws_rekognition/
      Handler: app.lambda_handler
      Runtime: python3.9
      Policies:
        - AmazonS3FullAccess
        - AmazonRekognitionFullAccess
      Architectures:
      - x86_64
      Events:
        AWSRekognitionEvent:
          Type: S3
          Properties:
            Bucket: !Ref SrcBucket
            Events: s3:ObjectCreated:*

  SrcBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: <Bucket-name>

Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
  AWSRekognitionFunction:
    Description: "AWS Rekognition Lambda Function ARN"
    Value: !GetAtt AWSRekognitionFunction.Arn
  AWSRekognitionFunctionIamRole:
    Description: "Implicit IAM Role created for AWS Rekognition function"
    Value: !GetAtt AWSRekognitionFunctionRole.Arn
