Resources:
  CustomerFilesTable:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: ${self:custom.customerFilesTable}
      AttributeDefinitions:
        - AttributeName: email
          AttributeType: S
        - AttributeName: sortkey
          AttributeType: S
        - AttributeName: s3uri
          AttributeType: S
        - AttributeName: ID
          AttributeType: S
      KeySchema:
        - AttributeName: email
          KeyType: HASH
        - AttributeName: sortkey
          KeyType: RANGE
      StreamSpecification:
        StreamViewType: NEW_AND_OLD_IMAGES
      PointInTimeRecoverySpecification:
        PointInTimeRecoveryEnabled: true
      GlobalSecondaryIndexes:
        - IndexName: ${self:custom.customerFilesIndexName}
          KeySchema:
            - AttributeName: s3uri
              KeyType: HASH
          Projection:
            ProjectionType: KEYS_ONLY
        - IndexName: ${self:custom.fileIdIndexName}
          KeySchema:
            - AttributeName: ID
              KeyType: HASH
          Projection:
            ProjectionType: INCLUDE
            NonKeyAttributes:
              - s3uri
      # Set the capacity to auto-scale
      BillingMode: PAY_PER_REQUEST