Stream L2 construct
A Kinesis stream.
Can be encrypted with a KMS key.
Example
const lambdaRole = new iam.Role(this, 'Role', {
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
description: 'Example role...',
});
const stream = new kinesis.Stream(this, 'MyEncryptedStream', {
encryption: kinesis.StreamEncryption.KMS,
});
// give lambda permissions to read stream
stream.grantRead(lambdaRole);
lambda_role = iam.Role(self, "Role",
assumed_by=iam.ServicePrincipal("lambda.amazonaws.com"),
description="Example role..."
)
stream = kinesis.Stream(self, "MyEncryptedStream",
encryption=kinesis.StreamEncryption.KMS
)
# give lambda permissions to read stream
stream.grant_read(lambda_role)
Role lambdaRole = Role.Builder.create(this, "Role")
.assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
.description("Example role...")
.build();
Stream stream = Stream.Builder.create(this, "MyEncryptedStream")
.encryption(StreamEncryption.KMS)
.build();
// give lambda permissions to read stream
stream.grantRead(lambdaRole);
// Install: dotnet add package Amazon.CDK.Lib
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);
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
lambdaRole := iam.NewRole(this, jsii.String("Role"), &RoleProps{
AssumedBy: iam.NewServicePrincipal(jsii.String("lambda.amazonaws.com")),
Description: jsii.String("Example role..."),
})
stream := kinesis.NewStream(this, jsii.String("MyEncryptedStream"), &StreamProps{
Encryption: kinesis.StreamEncryption_KMS,
})
// give lambda permissions to read stream
stream.grantRead(lambdaRole)
Initializer
new Stream(scope: Construct, id: string, props?: StreamProps)
Stream(scope: Construct, id: str, props: typing.Optional[StreamProps] = None)
new Stream(Construct scope, String id, StreamProps props)
new Stream(Construct scope, string id, StreamProps? props = null)
NewStream(Scope Construct, Id *string, Props StreamProps)
Construct Props
encryptionStreamEncryptionencryptionStreamEncryptionencryptionStreamEncryptionEncryptionStreamEncryptionEncryptionStreamEncryption= StreamEncryption.KMS if encrypte…#If you choose KMS, you can specify a KMS key via encryptionKey. If encryption key is not specified, a key will automatically be created.
default
Default: StreamEncryption.KMS if encrypted Streams are supported in the region or StreamEncryption.UNENCRYPTED otherwise. StreamEncryption.KMS if an encryption key is supplied through the encryptionKey property
encryptionKeyIKeyencryption_keyIKeyencryptionKeyIKeyEncryptionKeyIKeyEncryptionKeyIKey= Kinesis Data Streams master key …#The 'encryption' property must be set to "Kms".
default
Default: Kinesis Data Streams master key ('/alias/aws/kinesis'). If encryption is set to StreamEncryption.KMS and this property is undefined, a new KMS key will be created and associated with this stream.
removalPolicyRemovalPolicyremoval_policyRemovalPolicyremovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicy= RemovalPolicy.RETAIN#retentionPeriodDurationretention_periodDurationretentionPeriodDurationRetentionPeriodDurationRetentionPeriodDuration= Duration.hours(24)#Can only be provided if streamMode is Provisioned.
shardLevelMetricsShardLevelMetrics[]shard_level_metricstyping.List[ShardLevelMetrics]shardLevelMetricsList<ShardLevelMetrics>ShardLevelMetricsShardLevelMetrics[]ShardLevelMetrics*[]ShardLevelMetrics= undefined - AWS Kinesis default …#default
Default: undefined - AWS Kinesis default is disabled
streamModeStreamModestream_modeStreamModestreamModeStreamModeStreamModeStreamModeStreamModeStreamMode= StreamMode.PROVISIONED#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#streamRefStreamReferencestream_refStreamReferencestreamRefStreamReferenceStreamRefStreamReferenceStreamRefStreamReferencerequired#Methods
addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResultdef add_to_resource_policy(self, statement: PolicyStatement) -> AddToResourcePolicyResultpublic AddToResourcePolicyResult addToResourcePolicy(PolicyStatement statement)public AddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)func AddToResourcePolicy(Statement PolicyStatement) AddToResourcePolicyResult#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.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromStreamArn(scope: Construct, id: string, streamArn: string): IStream@staticmethod def from_stream_arn(scope: Construct, id: str, stream_arn: str) -> IStreampublic static IStream fromStreamArn(Construct scope, String id, String streamArn)public static IStream FromStreamArn(Construct scope, string id, string streamArn)func FromStreamArn(Scope Construct, Id *string, StreamArn *string) IStreamstatic#3 parameters
Parameters
scopescopescopescopeScope— The parent creating construct (usuallythis).ididididId— The construct's name.streamArnstream_arnstreamArnstreamArnStreamArn— Stream ARN (i.e. arn:aws:kinesis:<region>:<account-id>:stream/Foo).
fromStreamAttributes(scope: Construct, id: string, attrs: StreamAttributes): IStream@staticmethod def from_stream_attributes(scope: Construct, id: str, attrs: StreamAttributes) -> IStreampublic static IStream fromStreamAttributes(Construct scope, String id, StreamAttributes attrs)public static IStream FromStreamAttributes(Construct scope, string id, StreamAttributes attrs)func FromStreamAttributes(Scope Construct, Id *string, Attrs StreamAttributes) IStreamstatic#3 parameters
Parameters
scopescopescopescopeScope— The parent creating construct (usuallythis).ididididId— The construct's name.attrsattrsattrsattrsAttrs— Stream import properties.
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#[disable-awslint:no-grants]
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#If an encryption key is used, permission to ues the key to decrypt the contents of the stream will also be granted.
[disable-awslint:no-grants]
grantReadWrite(grantee: IGrantable): Grantdef grant_read_write(self, grantee: IGrantable) -> Grantpublic Grant grantReadWrite(IGrantable grantee)public Grant GrantReadWrite(IGrantable grantee)func GrantReadWrite(Grantee IGrantable) Grant#If an encryption key is used, permission to use the key for encrypt/decrypt will also be granted.
[disable-awslint:no-grants]
grantWrite(grantee: IGrantable): Grantdef grant_write(self, grantee: IGrantable) -> Grantpublic Grant grantWrite(IGrantable grantee)public Grant GrantWrite(IGrantable grantee)func GrantWrite(Grantee IGrantable) Grant#If an encryption key is used, permission to ues the key to encrypt the contents of the stream will also be granted.
[disable-awslint:no-grants]
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#2 parameters
Parameters
metricNamemetric_namemetricNamemetricNameMetricName— name of the stream metric.propspropspropspropsProps— properties of the metric.
metricGetRecords(props?: MetricOptions): Metricdef metric_get_records(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricGetRecords(MetricOptions props)public Metric MetricGetRecords(MetricOptions? props = null)func MetricGetRecords(Props MetricOptions) Metric#notes · 1 parameter
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.
Parameters
propspropspropspropsProps— properties of the metric.
metricGetRecordsBytes(props?: MetricOptions): Metricdef metric_get_records_bytes(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricGetRecordsBytes(MetricOptions props)public Metric MetricGetRecordsBytes(MetricOptions? props = null)func MetricGetRecordsBytes(Props MetricOptions) Metric#notes · 1 parameter
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.
Parameters
propspropspropspropsProps— properties of the metric.
metricGetRecordsIteratorAgeMilliseconds(props?: MetricOptions): Metricdef metric_get_records_iterator_age_milliseconds(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricGetRecordsIteratorAgeMilliseconds(MetricOptions props)public Metric MetricGetRecordsIteratorAgeMilliseconds(MetricOptions? props = null)func MetricGetRecordsIteratorAgeMilliseconds(Props MetricOptions) Metric#notes · 1 parameter
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.
Parameters
propspropspropspropsProps— properties of the metric.
metricGetRecordsLatency(props?: MetricOptions): Metricdef metric_get_records_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricGetRecordsLatency(MetricOptions props)public Metric MetricGetRecordsLatency(MetricOptions? props = null)func MetricGetRecordsLatency(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricGetRecordsSuccess(props?: MetricOptions): Metricdef metric_get_records_success(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricGetRecordsSuccess(MetricOptions props)public Metric MetricGetRecordsSuccess(MetricOptions? props = null)func MetricGetRecordsSuccess(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricIncomingBytes(props?: MetricOptions): Metricdef metric_incoming_bytes(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricIncomingBytes(MetricOptions props)public Metric MetricIncomingBytes(MetricOptions? props = null)func MetricIncomingBytes(Props MetricOptions) Metric#notes · 1 parameter
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.
Parameters
propspropspropspropsProps— properties of the metric.
metricIncomingRecords(props?: MetricOptions): Metricdef metric_incoming_records(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricIncomingRecords(MetricOptions props)public Metric MetricIncomingRecords(MetricOptions? props = null)func MetricIncomingRecords(Props MetricOptions) Metric#notes · 1 parameter
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.
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordBytes(props?: MetricOptions): Metricdef metric_put_record_bytes(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordBytes(MetricOptions props)public Metric MetricPutRecordBytes(MetricOptions? props = null)func MetricPutRecordBytes(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordLatency(props?: MetricOptions): Metricdef metric_put_record_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordLatency(MetricOptions props)public Metric MetricPutRecordLatency(MetricOptions? props = null)func MetricPutRecordLatency(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsBytes(props?: MetricOptions): Metricdef metric_put_records_bytes(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsBytes(MetricOptions props)public Metric MetricPutRecordsBytes(MetricOptions? props = null)func MetricPutRecordsBytes(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsFailedRecords(props?: MetricOptions): Metricdef metric_put_records_failed_records(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsFailedRecords(MetricOptions props)public Metric MetricPutRecordsFailedRecords(MetricOptions? props = null)func MetricPutRecordsFailedRecords(Props MetricOptions) Metric#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.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsLatency(props?: MetricOptions): Metricdef metric_put_records_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsLatency(MetricOptions props)public Metric MetricPutRecordsLatency(MetricOptions? props = null)func MetricPutRecordsLatency(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsSuccess(props?: MetricOptions): Metricdef metric_put_records_success(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsSuccess(MetricOptions props)public Metric MetricPutRecordsSuccess(MetricOptions? props = null)func MetricPutRecordsSuccess(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsSuccessfulRecords(props?: MetricOptions): Metricdef metric_put_records_successful_records(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsSuccessfulRecords(MetricOptions props)public Metric MetricPutRecordsSuccessfulRecords(MetricOptions? props = null)func MetricPutRecordsSuccessfulRecords(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsThrottledRecords(props?: MetricOptions): Metricdef metric_put_records_throttled_records(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsThrottledRecords(MetricOptions props)public Metric MetricPutRecordsThrottledRecords(MetricOptions? props = null)func MetricPutRecordsThrottledRecords(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordsTotalRecords(props?: MetricOptions): Metricdef metric_put_records_total_records(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordsTotalRecords(MetricOptions props)public Metric MetricPutRecordsTotalRecords(MetricOptions? props = null)func MetricPutRecordsTotalRecords(Props MetricOptions) Metric#The metric defaults to average over 5 minutes, it can be changed by passing statistic and period properties.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricPutRecordSuccess(props?: MetricOptions): Metricdef metric_put_record_success(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricPutRecordSuccess(MetricOptions props)public Metric MetricPutRecordSuccess(MetricOptions? props = null)func MetricPutRecordSuccess(Props MetricOptions) Metric#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.
1 parameter
Parameters
propspropspropspropsProps— properties of the metric.
metricReadProvisionedThroughputExceeded(props?: MetricOptions): Metricdef metric_read_provisioned_throughput_exceeded(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricReadProvisionedThroughputExceeded(MetricOptions props)public Metric MetricReadProvisionedThroughputExceeded(MetricOptions? props = null)func MetricReadProvisionedThroughputExceeded(Props MetricOptions) Metric#notes · 1 parameter
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
Parameters
propspropspropspropsProps— properties of the metric.
metricWriteProvisionedThroughputExceeded(props?: MetricOptions): Metricdef metric_write_provisioned_throughput_exceeded(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricWriteProvisionedThroughputExceeded(MetricOptions props)public Metric MetricWriteProvisionedThroughputExceeded(MetricOptions? props = null)func MetricWriteProvisionedThroughputExceeded(Props MetricOptions) Metric#notes · 1 parameter
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.
Parameters
propspropspropspropsProps— properties of the metric.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.