Dynamo Db Table Resource Definition Example with Sort Key

I have some code in my serverless.yml like this currently.

resources:
  Resources:
    uploadBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:service}-${self:custom.stage}-uploads
    visitsTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:custom.visitsTable}
        AttributeDefinitions:
          - AttributeName: userId
            AttributeType: S
          - AttributeName: visitId
            AttributeType: S
          - AttributeName: comments
            AttributeType: S
          - AttributeName: attachments
            AttributeType: S
          - AttributeName: ph
            AttributeType: N
          - AttributeName: ch
            AttributeType: N
        KeySchema:
          - AttributeName: userId
            KeyType: HASH
          - AttributeName: visitId
            KeyType: HASH
        ProvisionedThroughput:
            ReadCapacityUnits: 5
            WriteCapacityUnits: 5

My goal is to create a table with primary key userId, sort key visitId and have fields for comments, attachments, ph & ch. When I try to sls deploy I get the following error.

Serverless Error ---------------------------------------

An error occurred: visitsTable - Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes.

What am I doing wrong here?

I figured out what it was, apparently you are only supposed to define the keys and not the other attributes. Got my answer here, https://stackoverflow.com/questions/47385177/serverless-framework-dynamo-db-table-resource-definition-with-sort-key/47385697?noredirect=1#comment81725074_47385697

Something to remember here is that NoSQL databases do not have predefined schema other than the keys with which to represent the item. All other attributes (“columns”) are optional and thus do not need to be declared beforehand.