title: Serverless Framework Dynamo DB Table Resource Definition with Sort Key
body: <p>I have some code in my serverless.yml like this currently.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>My goal is to create a table with primary key userId, sort key visitId and have fields for comments, attachments, ph &amp; ch.  When I try to <code>sls deploy</code> I get the following error.</p>
  
  <p>Serverless Error ---------------------------------------</p>
  
  <p>An error occurred: visitsTable - Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p><strong>Edit: Another attempt I tried</strong></p>
  
  <pre><code>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
          KeySchema:
            - AttributeName: userId
              KeyType: HASH
            - AttributeName: visitId
              KeyType: RANGE
          ProvisionedThroughput:
              ReadCapacityUnits: 5
              WriteCapacityUnits: 5
  </code></pre>