lundi 16 mai 2022

DynamoDB.create_table erroring with `ArgumentError: no such member :billing_mode`

I am trying to create a new table through the aws-sdk(2.11.31) using the DynamoDB client like so;

        new_table_definition = {
          attribute_definitions: [
            {
              attribute_name: 'user',
              attribute_type: 'S'
            },
            {
              attribute_name: 'timestamp',
              attribute_type: 'N'
            },
            {
              attribute_name: 'uuid',
              attribute_type: 'S'
            }
          ],
          key_schema: [
            {
              attribute_name: 'uuid',
              key_type: 'HASH'
            },
            {
              attribute_name: 'timestamp',
              key_type: 'RANGE'
            }
          ],
          global_secondary_indexes: [
            {
              index_name: 'user-timestamp-index',
              key_schema: [
                {
                  attribute_name: 'user',
                  key_type: 'HASH'
                },
                {
                  attribute_name: 'timestamp',
                  key_type: 'RANGE'
                }
              ],
              projection: {
                projection_type: 'KEYS_ONLY'
              },
              provisioned_throughput: {
                read_capacity_units: 0,
                write_capacity_units: 0,
              }
            }
          ],
          billing_mode: "PAY_PER_REQUEST",
          provisioned_throughput: {
            read_capacity_units: 0,
            write_capacity_units: 0
          },
          table_name: "A_NEW_TABLE"
        }
        Dynamo::Table.create(new_table_definition)

However I get the following error: ArgumentError: no such member :billing_mode

From what I understand that is the correct key and formatting for the billing mode as described in the documentation for v2 of the sdk. Removing the billing mode creates the table fine but I am then forced to go into AWS console to manually change it to On-Demand.

Ruby - 2.3.3 Rails - 3.2.22.5 aws-sdk - 2.11.31

Aucun commentaire:

Enregistrer un commentaire