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:00:17 -08:00
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/kinesis-firehose-example-delivery-stream.html
2018-10-11 15:00:23 -07:00
*/
2019-02-01 20:22:26 -08:00
// snippet-start:[firehose.php.create_delivery_stream.complete]
// snippet-start:[firehose.php.create_delivery_stream.import]
2024-02-05 10:49:20 -07:00
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:22:26 -08:00
// snippet-end:[firehose.php.create_delivery_stream.import]
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
/**
* Creating an Amazon Kinesis Firehose Delivery Stream.
*
* 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:22:26 -08:00
//Create a KinesisClient
// snippet-start:[firehose.php.create_delivery_stream.main]
2018-12-17 10:39:03 -08:00
$firehoseClient = new Aws\Firehose\FirehoseClient ([
2018-10-11 15:00:23 -07:00
'profile' => 'default' ,
'version' => '2015-08-04' ,
'region' => 'us-east-2'
]);
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
$name = " my_stream_name " ;
$stream_type = " KinesisStreamAsSource " ;
$kinesis_stream = " arn:aws:kinesis:us-east-2:0123456789:stream/my_stream_name " ;
$role = " arn:aws:iam::0123456789:policy/Role " ;
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 = $firehoseClient -> createDeliveryStream ([
2018-10-11 15:00:23 -07:00
'DeliveryStreamName' => $name ,
'DeliveryStreamType' => $stream_type ,
'KinesisStreamSourceConfiguration' => [
'KinesisStreamARN' => $kinesis_stream ,
'RoleARN' => $role ,
],
]);
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:22:26 -08:00
// snippet-end:[firehose.php.create_delivery_stream.main]
// snippet-end:[firehose.php.create_delivery_stream.complete]