pyspark.streaming.kinesis.KinesisUtils.createStream

static KinesisUtils.createStream(ssc: pyspark.streaming.context.StreamingContext, kinesisAppName: str, streamName: str, endpointUrl: str, regionName: str, initialPositionInStream: str, checkpointInterval: int, storageLevel: pyspark.storagelevel.StorageLevel = StorageLevel(True, True, False, False, 2), awsAccessKeyId: Optional[str] = None, awsSecretKey: Optional[str] = None, decoder: Union[Callable[[Optional[bytes]], T], Callable[[Optional[bytes]], Optional[str]]] = <function utf8_decoder>, stsAssumeRoleArn: Optional[str] = None, stsSessionName: Optional[str] = None, stsExternalId: Optional[str] = None) → Union[pyspark.streaming.dstream.DStream[Union[T, str, None]], pyspark.streaming.dstream.DStream[T]][source]

Create an input stream that pulls messages from a Kinesis stream. This uses the Kinesis Client Library (KCL) to pull messages from Kinesis.

Parameters
sscStreamingContext

StreamingContext object

kinesisAppNamestr

Kinesis application name used by the Kinesis Client Library (KCL) to update DynamoDB

streamNamestr

Kinesis stream name

endpointUrlstr

Url of Kinesis service (e.g., https://kinesis.us-east-1.amazonaws.com)

regionNamestr

Name of region used by the Kinesis Client Library (KCL) to update DynamoDB (lease coordination and checkpointing) and CloudWatch (metrics)

initialPositionInStreamint

In the absence of Kinesis checkpoint info, this is the worker’s initial starting position in the stream. The values are either the beginning of the stream per Kinesis’ limit of 24 hours (InitialPositionInStream.TRIM_HORIZON) or the tip of the stream (InitialPositionInStream.LATEST).

checkpointIntervalint

Checkpoint interval(in seconds) for Kinesis checkpointing. See the Kinesis Spark Streaming documentation for more details on the different types of checkpoints.

storageLevelpyspark.StorageLevel, optional

Storage level to use for storing the received objects (default is StorageLevel.MEMORY_AND_DISK_2)

awsAccessKeyIdstr, optional

AWS AccessKeyId (default is None. If None, will use DefaultAWSCredentialsProviderChain)

awsSecretKeystr, optional

AWS SecretKey (default is None. If None, will use DefaultAWSCredentialsProviderChain)

decoderfunction, optional

A function used to decode value (default is utf8_decoder)

stsAssumeRoleArnstr, optional

ARN of IAM role to assume when using STS sessions to read from the Kinesis stream (default is None).

stsSessionNamestr, optional

Name to uniquely identify STS sessions used to read from Kinesis stream, if STS is being used (default is None).

stsExternalIdstr, optional

External ID that can be used to validate against the assumed IAM role’s trust policy, if STS is being used (default is None).

Returns
A DStream object

Notes

The given AWS credentials will get saved in DStream checkpoints if checkpointing is enabled. Make sure that your checkpoint directory is secure.