2018-10-11 15:00:23 -07:00
< ? php
2018-12-28 10:35:52 -08:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2018-10-11 15:00:23 -07:00
// SPDX-License-Identifier: Apache-2.0
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
/*
2019-02-02 17:12:28 -08:00
* ABOUT THIS PHP SAMPLE: This sample is part of the AWS SDK for PHP Developer Guide topic at
2019-02-02 17:06:53 -08:00
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/kinesis-example-shard.html
2019-02-01 20:26:30 -08:00
*
2018-10-11 15:00:23 -07:00
*/
2019-02-01 20:26:30 -08:00
// snippet-start:[kinesis.php.update_data_stream_shards.complete]
// snippet-start:[kinesis.php.update_data_stream_shards.import]
2018-10-11 15:00:23 -07:00
require 'vendor/autoload.php' ;
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
use Aws\Exception\AwsException ;
2024-02-05 10:49:20 -07:00
2019-02-01 20:26:30 -08:00
// snippet-end:[kinesis.php.update_data_stream_shards.import]
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
/**
* Updating number of shards in an Amazon Kinesis Data Stream.
* Remember you can only increase shards to be double current shard count.
*
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
2024-02-05 10:49:20 -07:00
2019-02-01 20:26:30 -08:00
//Create a KinesisClient
// snippet-start:[kinesis.php.update_data_stream_shards.main]
2018-12-17 10:39:03 -08:00
$kinesisClient = new Aws\Kinesis\KinesisClient ([
2018-10-11 15:00:23 -07:00
'profile' => 'default' ,
'version' => '2013-12-02' ,
'region' => 'us-east-2'
]);
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
$name = " my_stream_name " ;
$totalshards = 4 ;
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
try {
2018-12-17 10:39:03 -08:00
$result = $kinesisClient -> UpdateShardCount ([
2018-10-11 15:00:23 -07:00
'ScalingType' => 'UNIFORM_SCALING' ,
'StreamName' => $name ,
'TargetShardCount' => $totalshards
]);
var_dump ( $result );
} catch ( AwsException $e ) {
// output error message if fails
echo $e -> getMessage ();
echo " \n " ;
}
2024-02-05 10:49:20 -07:00
2019-02-01 20:26:30 -08:00
// snippet-end:[kinesis.php.update_data_stream_shards.main]
// snippet-end:[kinesis.php.update_data_stream_shards.complete]