2021年4月30日星期五

Error while creating dynamodb table using boto3 ("botocore.exceptions.ClientError")

I am trying to create a dynamodb table using boto3. But I am getting the following error:

"botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the CreateTable operation: Invalid KeySchema: The first KeySchemaElement is not a HASH key type"

More info: I don't have any global table existing in my account.

Code I tried with:

import boto3    client = boto3.client('dynamodb')    response = client.create_table(      AttributeDefinitions=[          {              'AttributeName': 'student_id',              'AttributeType': 'N'          },          {              'AttributeName': 'student_name',              'AttributeType': 'S'          },          {              'AttributeName': 'course_id',              'AttributeType': 'S'          }      ],      TableName='students',      KeySchema=[          {              'AttributeName': 'student_name',              'KeyType': 'HASH'          },  {              'AttributeName': 'student_id',              'KeyType': 'RANGE'          },      ],      LocalSecondaryIndexes=[          {              'IndexName': 'course_id',              'KeySchema': [                  {                      'AttributeName': 'course_id',                      'KeyType': 'RANGE'                  }              ],              'Projection': {                  'ProjectionType': 'ALL'              }          },      ],      BillingMode='PAY_PER_REQUEST',    )  
https://stackoverflow.com/questions/67342188/error-while-creating-dynamodb-table-using-boto3-botocore-exceptions-clienterro May 01, 2021 at 09:40AM

没有评论:

发表评论