Firehose client

This page contains examples with the Firehose client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.

The Firehose package could be installed with Composer.

composer require async-aws/firehose

A new client object may be instantiated by:

use AsyncAws\Firehose\FirehoseClient; $firehose = new FirehoseClient();

The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:

use AsyncAws\Firehose\FirehoseClient; $firehose = new FirehoseClient([ 'accessKeyId' => 'my_access_key', 'accessKeySecret' => 'my_access_secret', 'region' => 'eu-central-1', ]);

For all available options, see the configuration reference.


Put record

use AsyncAws\Firehose\FirehoseClient; use AsyncAws\Firehose\Input\PutRecordInbound; use AsyncAws\Firehose\ValueObject\Record; $firehose = new FirehoseClient(); $output = $firehose->putRecord(new PutRecordInbound([ 'DeliveryStreamName' => 'example_stream', 'Record' => new Record([ 'Data' => '{"message": "foo"}', ]), ])); echo sprintf("Record id: %s\n", $output->getRecordId());

Put record batch

use AsyncAws\Firehose\FirehoseClient; use AsyncAws\Firehose\Input\PutRecordBatchInbound; use AsyncAws\Firehose\ValueObject\Record; $firehose = new FirehoseClient(); $output = $firehose->putRecordBatch(new PutRecordBatchInbound([ 'DeliveryStreamName' => 'example_stream', 'Records' => [ new Record([ 'Data' => '{"message": "foo"}', ]), new Record([ 'Data' => '{"message": "bar"}', ]), ], ])); echo sprintf("Failed count: %d\n", $response->getFailedPutCount()); foreach ($output->getRequestResponses() as $response) { echo sprintf("Record id: %s\n", $response->getRecordId()); }

The source code to this page is found on GitHub.