Show / Hide Table of Contents

Class Stream

A Kinesis stream.

Inheritance
object
Resource
Stream
Implements
IStream
IResource
IConstruct
IDependable
Inherited Members
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.Kinesis
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Stream : Resource, IStream, IResource, IConstruct, IDependable
Syntax (vb)
Public Class Stream Inherits Resource Implements IStream, IResource, IConstruct, IDependable
Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

Examples
var lambdaRole = new Role(this, "Role", new RoleProps {
                 AssumedBy = new ServicePrincipal("lambda.amazonaws.com"),
                 Description = "Example role..."
             });

             var stream = new Stream(this, "MyEncryptedStream", new StreamProps {
                 Encryption = StreamEncryption.KMS
             });

             // give lambda permissions to read stream
             stream.GrantRead(lambdaRole);

Synopsis

Constructors

Stream(Construct, string, IStreamProps?)

A Kinesis stream.

Properties

AutoCreatePolicy

Indicates if a stream resource policy should automatically be created upon the first call to addToResourcePolicy.

EncryptionKey

Optional KMS encryption key associated with this stream.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

StreamArn

The ARN of the stream.

StreamName

The name of the stream.

Methods

AddToResourcePolicy(PolicyStatement)

Adds a statement to the IAM resource policy associated with this stream.

FromStreamArn(Construct, string, string)

Import an existing Kinesis Stream provided an ARN.

FromStreamAttributes(Construct, string, IStreamAttributes)

Creates a Stream construct that represents an external stream.

Grant(IGrantable, params string[])

Grant the indicated permissions on this stream to the given IAM principal (Role/Group/User).

GrantRead(IGrantable)

Grant read permissions for this stream and its contents to an IAM principal (Role/Group/User).

GrantReadWrite(IGrantable)

Grants read/write permissions for this stream and its contents to an IAM principal (Role/Group/User).

GrantWrite(IGrantable)

Grant write permissions for this stream and its contents to an IAM principal (Role/Group/User).

Metric(string, IMetricOptions?)

Return stream metric based from its metric name.

MetricGetRecords(IMetricOptions?)

The number of records retrieved from the shard, measured over the specified time period.

MetricGetRecordsBytes(IMetricOptions?)

The number of bytes retrieved from the Kinesis stream, measured over the specified time period.

MetricGetRecordsIteratorAgeMilliseconds(IMetricOptions?)

The age of the last record in all GetRecords calls made against a Kinesis stream, measured over the specified time period.

MetricGetRecordsLatency(IMetricOptions?)

The number of successful GetRecords operations per stream, measured over the specified time period.

MetricGetRecordsSuccess(IMetricOptions?)

The number of successful GetRecords operations per stream, measured over the specified time period.

MetricIncomingBytes(IMetricOptions?)

The number of bytes successfully put to the Kinesis stream over the specified time period.

MetricIncomingRecords(IMetricOptions?)

The number of records successfully put to the Kinesis stream over the specified time period.

MetricPutRecordBytes(IMetricOptions?)

The number of bytes put to the Kinesis stream using the PutRecord operation over the specified time period.

MetricPutRecordLatency(IMetricOptions?)

The time taken per PutRecord operation, measured over the specified time period.

MetricPutRecordSuccess(IMetricOptions?)

The number of successful PutRecord operations per Kinesis stream, measured over the specified time period.

MetricPutRecordsBytes(IMetricOptions?)

The number of bytes put to the Kinesis stream using the PutRecords operation over the specified time period.

MetricPutRecordsFailedRecords(IMetricOptions?)

The number of records rejected due to internal failures in a PutRecords operation per Kinesis data stream, measured over the specified time period.

MetricPutRecordsLatency(IMetricOptions?)

The time taken per PutRecords operation, measured over the specified time period.

MetricPutRecordsSuccess(IMetricOptions?)

The number of PutRecords operations where at least one record succeeded, per Kinesis stream, measured over the specified time period.

MetricPutRecordsSuccessfulRecords(IMetricOptions?)

The number of successful records in a PutRecords operation per Kinesis data stream, measured over the specified time period.

MetricPutRecordsThrottledRecords(IMetricOptions?)

The number of records rejected due to throttling in a PutRecords operation per Kinesis data stream, measured over the specified time period.

MetricPutRecordsTotalRecords(IMetricOptions?)

The total number of records sent in a PutRecords operation per Kinesis data stream, measured over the specified time period.

MetricReadProvisionedThroughputExceeded(IMetricOptions?)

The number of GetRecords calls throttled for the stream over the specified time period.

MetricWriteProvisionedThroughputExceeded(IMetricOptions?)

The number of records rejected due to throttling for the stream over the specified time period.

Constructors

Stream(Construct, string, IStreamProps?)

A Kinesis stream.

public Stream(Construct scope, string id, IStreamProps? props = null)
Parameters
scope Construct
id string
props IStreamProps
Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

Examples
var lambdaRole = new Role(this, "Role", new RoleProps {
                 AssumedBy = new ServicePrincipal("lambda.amazonaws.com"),
                 Description = "Example role..."
             });

             var stream = new Stream(this, "MyEncryptedStream", new StreamProps {
                 Encryption = StreamEncryption.KMS
             });

             // give lambda permissions to read stream
             stream.GrantRead(lambdaRole);

Properties

AutoCreatePolicy

Indicates if a stream resource policy should automatically be created upon the first call to addToResourcePolicy.

protected virtual bool AutoCreatePolicy { get; }
Property Value

bool

Remarks

Set by subclasses.

EncryptionKey

Optional KMS encryption key associated with this stream.

public virtual IKey? EncryptionKey { get; }
Property Value

IKey

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

StreamArn

The ARN of the stream.

public virtual string StreamArn { get; }
Property Value

string

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

StreamName

The name of the stream.

public virtual string StreamName { get; }
Property Value

string

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

Methods

AddToResourcePolicy(PolicyStatement)

Adds a statement to the IAM resource policy associated with this stream.

public virtual IAddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)
Parameters
statement PolicyStatement
Returns

IAddToResourcePolicyResult

Remarks

If this stream was created in this stack (new Stream), a resource policy will be automatically created upon the first call to addToResourcePolicy. If the stream is imported (Stream.import), then this is a no-op.

FromStreamArn(Construct, string, string)

Import an existing Kinesis Stream provided an ARN.

public static IStream FromStreamArn(Construct scope, string id, string streamArn)
Parameters
scope Construct

The parent creating construct (usually this).

id string

The construct's name.

streamArn string

Stream ARN (i.e. arn:aws:kinesis:<region>:<account-id>:stream/Foo).

Returns

IStream

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

FromStreamAttributes(Construct, string, IStreamAttributes)

Creates a Stream construct that represents an external stream.

public static IStream FromStreamAttributes(Construct scope, string id, IStreamAttributes attrs)
Parameters
scope Construct

The parent creating construct (usually this).

id string

The construct's name.

attrs IStreamAttributes

Stream import properties.

Returns

IStream

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

Grant(IGrantable, params string[])

Grant the indicated permissions on this stream to the given IAM principal (Role/Group/User).

public virtual Grant Grant(IGrantable grantee, params string[] actions)
Parameters
grantee IGrantable
actions string[]
Returns

Grant

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

GrantRead(IGrantable)

Grant read permissions for this stream and its contents to an IAM principal (Role/Group/User).

public virtual Grant GrantRead(IGrantable grantee)
Parameters
grantee IGrantable
Returns

Grant

Remarks

If an encryption key is used, permission to ues the key to decrypt the contents of the stream will also be granted.

GrantReadWrite(IGrantable)

Grants read/write permissions for this stream and its contents to an IAM principal (Role/Group/User).

public virtual Grant GrantReadWrite(IGrantable grantee)
Parameters
grantee IGrantable
Returns

Grant

Remarks

If an encryption key is used, permission to use the key for encrypt/decrypt will also be granted.

GrantWrite(IGrantable)

Grant write permissions for this stream and its contents to an IAM principal (Role/Group/User).

public virtual Grant GrantWrite(IGrantable grantee)
Parameters
grantee IGrantable
Returns

Grant

Remarks

If an encryption key is used, permission to ues the key to encrypt the contents of the stream will also be granted.

Metric(string, IMetricOptions?)

Return stream metric based from its metric name.

public virtual Metric Metric(string metricName, IMetricOptions? props = null)
Parameters
metricName string

name of the stream metric.

props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

Can be encrypted with a KMS key.

ExampleMetadata: infused

MetricGetRecords(IMetricOptions?)

The number of records retrieved from the shard, measured over the specified time period.

public virtual Metric MetricGetRecords(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

Minimum, Maximum, and Average statistics represent the records in a single GetRecords operation for the stream in the specified time period.

average The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricGetRecordsBytes(IMetricOptions?)

The number of bytes retrieved from the Kinesis stream, measured over the specified time period.

public virtual Metric MetricGetRecordsBytes(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

Minimum, Maximum, and Average statistics represent the bytes in a single GetRecords operation for the stream in the specified time period.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricGetRecordsIteratorAgeMilliseconds(IMetricOptions?)

The age of the last record in all GetRecords calls made against a Kinesis stream, measured over the specified time period.

public virtual Metric MetricGetRecordsIteratorAgeMilliseconds(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

Age is the difference between the current time and when the last record of the GetRecords call was written to the stream. The Minimum and Maximum statistics can be used to track the progress of Kinesis consumer applications. A value of zero indicates that the records being read are completely caught up with the stream.

The metric defaults to maximum over 5 minutes, it can be changed by passing statistic and period properties.

MetricGetRecordsLatency(IMetricOptions?)

The number of successful GetRecords operations per stream, measured over the specified time period.

public virtual Metric MetricGetRecordsLatency(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricGetRecordsSuccess(IMetricOptions?)

The number of successful GetRecords operations per stream, measured over the specified time period.

public virtual Metric MetricGetRecordsSuccess(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricIncomingBytes(IMetricOptions?)

The number of bytes successfully put to the Kinesis stream over the specified time period.

public virtual Metric MetricIncomingBytes(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

This metric includes bytes from PutRecord and PutRecords operations. Minimum, Maximum, and Average statistics represent the bytes in a single put operation for the stream in the specified time period.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricIncomingRecords(IMetricOptions?)

The number of records successfully put to the Kinesis stream over the specified time period.

public virtual Metric MetricIncomingRecords(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

This metric includes record counts from PutRecord and PutRecords operations. Minimum, Maximum, and Average statistics represent the records in a single put operation for the stream in the specified time period.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordBytes(IMetricOptions?)

The number of bytes put to the Kinesis stream using the PutRecord operation over the specified time period.

public virtual Metric MetricPutRecordBytes(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordLatency(IMetricOptions?)

The time taken per PutRecord operation, measured over the specified time period.

public virtual Metric MetricPutRecordLatency(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordSuccess(IMetricOptions?)

The number of successful PutRecord operations per Kinesis stream, measured over the specified time period.

public virtual Metric MetricPutRecordSuccess(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

Average reflects the percentage of successful writes to a stream.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsBytes(IMetricOptions?)

The number of bytes put to the Kinesis stream using the PutRecords operation over the specified time period.

public virtual Metric MetricPutRecordsBytes(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsFailedRecords(IMetricOptions?)

The number of records rejected due to internal failures in a PutRecords operation per Kinesis data stream, measured over the specified time period.

public virtual Metric MetricPutRecordsFailedRecords(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

Occasional internal failures are to be expected and should be retried.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsLatency(IMetricOptions?)

The time taken per PutRecords operation, measured over the specified time period.

public virtual Metric MetricPutRecordsLatency(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsSuccess(IMetricOptions?)

The number of PutRecords operations where at least one record succeeded, per Kinesis stream, measured over the specified time period.

public virtual Metric MetricPutRecordsSuccess(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsSuccessfulRecords(IMetricOptions?)

The number of successful records in a PutRecords operation per Kinesis data stream, measured over the specified time period.

public virtual Metric MetricPutRecordsSuccessfulRecords(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsThrottledRecords(IMetricOptions?)

The number of records rejected due to throttling in a PutRecords operation per Kinesis data stream, measured over the specified time period.

public virtual Metric MetricPutRecordsThrottledRecords(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricPutRecordsTotalRecords(IMetricOptions?)

The total number of records sent in a PutRecords operation per Kinesis data stream, measured over the specified time period.

public virtual Metric MetricPutRecordsTotalRecords(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

MetricReadProvisionedThroughputExceeded(IMetricOptions?)

The number of GetRecords calls throttled for the stream over the specified time period.

public virtual Metric MetricReadProvisionedThroughputExceeded(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

The most commonly used statistic for this metric is Average.

When the Minimum statistic has a value of 1, all records were throttled for the stream during the specified time period.

When the Maximum statistic has a value of 0 (zero), no records were throttled for the stream during the specified time period.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties

MetricWriteProvisionedThroughputExceeded(IMetricOptions?)

The number of records rejected due to throttling for the stream over the specified time period.

public virtual Metric MetricWriteProvisionedThroughputExceeded(IMetricOptions? props = null)
Parameters
props IMetricOptions

properties of the metric.

Returns

Metric

Remarks

This metric includes throttling from PutRecord and PutRecords operations.

When the Minimum statistic has a non-zero value, records were being throttled for the stream during the specified time period.

When the Maximum statistic has a value of 0 (zero), no records were being throttled for the stream during the specified time period.

The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.

Implements

IStream
IResource
Constructs.IConstruct
Constructs.IDependable
Back to top Generated by DocFX