Skip to content

create-table in ap-northeast-3 will fail for 'Unsupported input parameter BillingMode' #714

Open
@JiangKeshu

Description

@JiangKeshu

I'm currently using 4.0.0 and got Unsupported input parameter BillingMode error when creating table in ap-northeast-3.
Here is the error stack:

Traceback (most recent call last):
  File "/.../lib/python3.4/site-packages/pynamodb/connection/base.py", line 629, in create_table
    data = self.dispatch(CREATE_TABLE, operation_kwargs)
  File "/.../lib/python3.4/site-packages/pynamodb/connection/base.py", line 336, in dispatch
    data = self._make_api_call(operation_name, operation_kwargs)
  File "/.../lib/python3.4/site-packages/pynamodb/connection/base.py", line 439, in _make_api_call
    raise VerboseClientError(botocore_expected_format, operation_name, verbose_properties)
pynamodb.exceptions.VerboseClientError: An error occurred (ValidationException) on request (XXX) on table (my_table_name) when calling the CreateTable operation: One or more parameter values were invalid: Unsupported input parameter BillingMode

My table defination is very simple:

class MyModel(Model):
    class Meta:
        table_name = 'my_table'
        read_capacity_units = 5
        write_capacity_units = 5
    region = UnicodeAttribute(hash_key=True, null=False)
    name = UnicodeAttribute(range_key=True, null=False)
    arn = UnicodeAttribute(null=True)
    checksum = UnicodeAttribute(null=True)

This was because ap-northeast-3 doesn't support on-demand thus billing_mode is not yet supported in this region.
You can simply reproduce the error with CLI:

>> aws --region ap-northeast-3 dynamodb create-table --cli-input-json file:///tmp/Items.json

An error occurred (ValidationException) when calling the CreateTable operation: One or more parameter values were invalid: Unsupported input parameter BillingMode
>> aws --region ap-northeast-2 dynamodb create-table --cli-input-json file:///tmp/Items.json
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "Id",
                "AttributeType": "S"
            }
        ],
        "TableName": "Items",
        "KeySchema": [
            {
                "AttributeName": "Id",
                "KeyType": "HASH"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": 1572419463.816,
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 5,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:ap-northeast-2:<my account id hahaha>:table/Items",
        "TableId": "hided"
    }
}

This fix is simple (but tricky), some change like below to base.py -- creat_table() can make it work(though not perfect because ideally we should make sure PROVISIONED_THROUGHPUT presents).

        if self.region.lower() == 'ap-northeast-3':
            del operation_kwargs[BILLING_MODE]

But the tricky part is once ap-norhteast-3 start to support on-demand then we have to flip the changes back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions