public function create(DynamoDbClient $client, string $tableName): void
    {
        try {
            $client->describeTable(['TableName' => $tableName]);
            return;
        } catch (DynamoDbException $e) {
            // table doesn't exist, create it below
        }

        try {
            $client->createTable([
                'TableName'               => $tableName,
                'AttributeDefinitions'    => [
                    ['AttributeName' => self::HASH_KEY_NAME, 'AttributeType' => 'S'],
                ],
                'KeySchema'               => [
                    ['AttributeName' => self::HASH_KEY_NAME, 'KeyType' => 'HASH'],
                ],
                'TimeToLiveSpecification' => [
                    'Enabled'       => true,
                    'AttributeName' => self::TTL_KEY_NAME,
                ],
                'ProvisionedThroughput'   => [
                    'ReadCapacityUnits'  => 2,
                    'WriteCapacityUnits' => 2,
                ],
            ]);

            $client->waitUntil('TableExists', ['TableName' => $tableName]);
        } catch (\Throwable $e) {
            throw new SchedulerOperationFailed(
                sprintf(
                    '%s::Unable to create table [%s] in region [%s].',
                    ClassUtils::getShortName($this),
                    $tableName,
                    $client->getRegion()
                ),
                Code::INTERNAL,
                $e
            );
        }
    }
public function create(DynamoDbClient $client, string $tableName): void
    {
        try {
            $client->describeTable(['TableName' => $tableName]);
            return;
        } catch (DynamoDbException $e) {
            // table doesn't exist, create it below
        }

        try {
            $client->createTable([
                'TableName'               => $tableName,
                'AttributeDefinitions'    => [
                    ['AttributeName' => self::HASH_KEY_NAME, 'AttributeType' => 'S'],
                ],
                'KeySchema'               => [
                    ['AttributeName' => self::HASH_KEY_NAME, 'KeyType' => 'HASH'],
                ],
                'TimeToLiveSpecification' => [
                    'Enabled'       => true,
                    'AttributeName' => self::TTL_KEY_NAME,
                ],
                'ProvisionedThroughput'   => [
                    'ReadCapacityUnits'  => 2,
                    'WriteCapacityUnits' => 2,
                ],
            ]);

            $client->waitUntil('TableExists', ['TableName' => $tableName]);
        } catch (\Throwable $e) {
            throw new SchedulerOperationFailed(
                sprintf(
                    '%s::Unable to create table [%s] in region [%s].',
                    ClassUtils::getShortName($this),
                    $tableName,
                    $client->getRegion()
                ),
                Code::INTERNAL,
                $e
            );
        }
    }
public function create ( DynamoDbClient $ client , string $ tableName ) : void { try { $ client -> describeTable ( [ 'TableName' => $ tableName ] ) ; return ; } catch ( DynamoDbException $ e ) { // table doesn't exist, create it below } try { $ client -> createTable ( [ 'TableName' => $ tableName , 'AttributeDefinitions' => [ [ 'AttributeName' => self :: HASH_KEY_NAME , 'AttributeType' => 'S' ] , ] , 'KeySchema' => [ [ 'AttributeName' => self :: HASH_KEY_NAME , 'KeyType' => 'HASH' ] , ] , 'TimeToLiveSpecification' => [ 'Enabled' => true , 'AttributeName' => self :: TTL_KEY_NAME , ] , 'ProvisionedThroughput' => [ 'ReadCapacityUnits' => 2 , 'WriteCapacityUnits' => 2 , ] , ] ) ; $ client -> waitUntil ( 'TableExists' , [ 'TableName' => $ tableName ] ) ; } catch ( \ Throwable $ e ) { throw new SchedulerOperationFailed ( sprintf ( '%s::Unable to create table [%s] in region [%s].' , ClassUtils :: getShortName ( $ this ) , $ tableName , $ client -> getRegion ( ) ) , Code :: INTERNAL , $ e ) ; } }
Creates a DynamoDb table with the scheduler schema.

@param DynamoDbClient $client
@param string         $tableName

@throws SchedulerOperationFailed
Creates a DynamoDb table with the scheduler schema .