createGlobalTable method

Future<CreateGlobalTableOutput> createGlobalTable({
  1. required String globalTableName,
  2. required List<Replica> replicationGroup,
})

Creates a global table from an existing table. A global table creates a replication relationship between two or more DynamoDB tables with the same table name in the provided Regions. If you want to add a new replica table to a global table, each of the following conditions must be true:

  • The table must have the same primary key as all of the other replicas.
  • The table must have the same name as all of the other replicas.
  • The table must have DynamoDB Streams enabled, with the stream containing both the new and the old images of the item.
  • None of the replica tables in the global table can contain any data.
If global secondary indexes are specified, then the following conditions must also be met:
  • The global secondary indexes must have the same name.
  • The global secondary indexes must have the same hash key and sort key (if present).
If local secondary indexes are specified, then the following conditions must also be met:
  • The local secondary indexes must have the same name.
  • The local secondary indexes must have the same hash key and sort key (if present).

Implementation

Future<CreateGlobalTableOutput> createGlobalTable({
  required String globalTableName,
  required List<Replica> replicationGroup,
}) async {
  ArgumentError.checkNotNull(globalTableName, 'globalTableName');
  _s.validateStringLength(
    'globalTableName',
    globalTableName,
    3,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(replicationGroup, 'replicationGroup');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.CreateGlobalTable'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'GlobalTableName': globalTableName,
      'ReplicationGroup': replicationGroup,
    },
  );

  return CreateGlobalTableOutput.fromJson(jsonResponse.body);
}