Global Secondary Indexでエラーが出るケース

com.amazonaws.AmazonServiceException: Global Secondary Index hash key not specified in Attribute Definitons.Type unknown. 
    GlobalSecondaryIndex expireDateIndex =
      new GlobalSecondaryIndex()
        .withIndexName("expireDateIndex")
        .withProvisionedThroughput(ptIndex)
        .withKeySchema(
          new KeySchemaElement().withAttributeName("expired").withKeyType(
            KeyType.HASH),
          new KeySchemaElement()
            .withAttributeName("expireDateTime")
            .withKeyType(KeyType.RANGE))
        .withProjection(
          new Projection().withProjectionType(ProjectionType.KEYS_ONLY));
    globalSecondaryIndexes.add(expireDateIndex);

のようにGlobalSecondaryIndexを定義したもののattributeDefinitionsが未定義だと上記のようなエラーが出ます。

    attributeDefinitions.add(new AttributeDefinition().withAttributeName(
      "expired").withAttributeType(ScalarAttributeType.S));
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(
      "expireDateTime").withAttributeType(ScalarAttributeType.S));

のように定義をします。