0
votes

I am currently creating a table in DynamoDB using the AWS cli. The command I'm using is

aws dynamodb create-table --cli-input-json file://.feature_promotions-dynamodb.json  --endpoint-url http://localhost:8000

Based on the docs for create-table, I should be able to set the billing-mode to PAY_PER_REQUEST without having to set the provisioned throughput, but every time run the command I get back the following error:

An error occurred (ValidationException) when calling the CreateTable operation: No provisioned throughput specified for the table

I upgraded awscli yesterday to

aws-cli/1.16.90 Python/3.7.2 Darwin/18.2.0 botocore/1.12.80

Other than that, I'm out of ideas on how to fix it. My workaround currently is to just create the table with a provisioned throughput and then go to the console to change it, but this seems unnecessary. Ultimately I'd like to be able to run this command in a bash script without having to later fix the table settings in the AWS console.

Below is the JSON file I load in the create-table command. "BillingMode": "PAY_PER_REQUEST" attribute and value are set after "AttributeDefinition" and I would expect this to work without any error. If I remove the billing mode line, and add the following attribute to the file

"ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
      }

it creates the table without any errors.

{
  "TableName": "dev.feature_promotions",
  "AttributeDefinitions": [
    {
      "AttributeName": "display_title",
      "AttributeType": "S"
    },
    {
      "AttributeName": "end_date",
      "AttributeType": "N"
    },
    {
      "AttributeName": "id",
      "AttributeType": "N"
    },
    {
      "AttributeName": "partner_id",
      "AttributeType": "N"
    },
    {
      "AttributeName": "start_date",
      "AttributeType": "N"
    },
    {
      "AttributeName": "view_scope_id",
      "AttributeType": "N"
    }
  ],
  "BillingMode": "PAY_PER_REQUEST",
  "KeySchema": [
    {
      "AttributeName": "id",
      "KeyType": "HASH"
    }
  ],
  "GlobalSecondaryIndexes": [
    {
      "IndexName": "start_date-index",
      "KeySchema": [
        {
          "AttributeName": "start_date",
          "KeyType": "HASH"
        },
        {
          "AttributeName": "id",
          "KeyType": "RANGE"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
      }
    },
    {
      "IndexName": "display_title-index",
      "KeySchema": [
        {
          "AttributeName": "display_title",
          "KeyType": "HASH"
        },
        {
          "AttributeName": "id",
          "KeyType": "RANGE"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
      }
    },
    {
      "IndexName": "end_date-index",
      "KeySchema": [
        {
          "AttributeName": "end_date",
          "KeyType": "HASH"
        },
        {
          "AttributeName": "id",
          "KeyType": "RANGE"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
      }
    },
    {
      "IndexName": "partner_id-index",
      "KeySchema": [
        {
          "AttributeName": "partner_id",
          "KeyType": "HASH"
        },
        {
          "AttributeName": "id",
          "KeyType": "RANGE"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
      }
    },
    {
      "IndexName": "view_scope_id-index",
      "KeySchema": [
        {
          "AttributeName": "view_scope_id",
          "KeyType": "HASH"
        },
        {
          "AttributeName": "id",
          "KeyType": "RANGE"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
      }
    }
  ],
  "StreamSpecification": {
    "StreamEnabled": true,
    "StreamViewType": "NEW_AND_OLD_IMAGES"
  },
  "SSESpecification": {
    "Enabled": true,
    "SSEType": "AES256",
    "KMSMasterKeyId": ""
  }
}

What am I doing wrong?

1

1 Answers

2
votes

You can only use one of "BillingMode": "PAY_PER_REQUEST" or ProvisionedThroughput on a table or GSI. You need to remove ProvisionedThroughput on any on-demand resources.

EDIT: To be clear, you can't use ProvisionedThroughput on the indexes of a table that is on-demand. To fix this, just remove all instances of ProvisionedThroughput. Your indexes will then also be on-demand.