org: wilsonpage
app: songwhip

service: songwhip-batch-api-database

plugins:
  - serverless-dotenv-plugin
  - serverless-dynamodb-local

custom:
  stage: ${opt:stage, 'local'}
  deploymentName: ${self:service}-${self:custom.stage}
  tableName: ${self:custom.deploymentName}-table

  dotenv:
    path: '../../.env'

  dynamodb:
    stages:
      - local
    start:
      port: 8001
      migrate: true
      inMemory: false

provider:
  name: aws
  region: us-east-1
  stage: ${self:custom.stage}

resources:
  Resources:
    BatchTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:custom.tableName}
        AttributeDefinitions:
          - AttributeName: partitionKey
            AttributeType: S
          - AttributeName: sortKey
            AttributeType: S
        KeySchema:
          - AttributeName: partitionKey
            KeyType: HASH
          - AttributeName: sortKey
            KeyType: RANGE
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1

  Outputs:
    BatchTableArn:
      Value:
        Fn::GetAtt:
          - BatchTable
          - Arn
      Export:
        Name: ${self:custom.tableName}-arn
