class StreamConsumer (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Kinesis.StreamConsumer |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awskinesis#StreamConsumer |
![]() | software.amazon.awscdk.services.kinesis.StreamConsumer |
![]() | aws_cdk.aws_kinesis.StreamConsumer |
![]() | aws-cdk-lib » aws_kinesis » StreamConsumer |
Implements
IConstruct
, IDependable
, IResource
, IStream
A Kinesis Stream Consumer.
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,
});
const streamConsumer = new kinesis.StreamConsumer(this, 'MyStreamConsumer', {
streamConsumerName: 'MyStreamConsumer',
stream,
});
// give lambda permissions to read stream via the stream consumer
streamConsumer.grantRead(lambdaRole);
Initializer
new StreamConsumer(scope: Construct, id: string, props: StreamConsumerProps)
Parameters
- scope
Construct
- id
string
- props
Stream
Consumer Props
Construct Props
Name | Type | Description |
---|---|---|
stream | IStream | The Kinesis data stream to associate this consumer with. |
stream | string | The name of the stream consumer. |
stream
Type:
IStream
The Kinesis data stream to associate this consumer with.
streamConsumerName
Type:
string
The name of the stream consumer.
Properties
Name | Type | Description |
---|---|---|
auto | boolean | Indicates if a resource policy should automatically be created upon the first call to addToResourcePolicy . |
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
stream | IStream | The Kinesis data stream this consumer is associated with. |
stream | string | The Amazon Resource Name (ARN) of the stream consumer. |
stream | string | The name of the stream consumer. |
autoCreatePolicy
Type:
boolean
Indicates if a resource policy should automatically be created upon the first call to addToResourcePolicy
.
Set by subclasses.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
stream
Type:
IStream
The Kinesis data stream this consumer is associated with.
streamConsumerArn
Type:
string
The Amazon Resource Name (ARN) of the stream consumer.
streamConsumerName
Type:
string
The name of the stream consumer.
Methods
Name | Description |
---|---|
add | Adds a statement to the IAM resource policy associated with this stream consumer. |
apply | Apply the given removal policy to this resource. |
grant(grantee, ...actions) | Grant the indicated permissions on this stream consumer to the given IAM principal (Role/Group/User). |
grant | Grant read permissions for this stream consumer and its associated stream to an IAM principal (Role/Group/User). |
to | Returns a string representation of this construct. |
static from | Imports an existing Kinesis Stream Consumer by its arn. |
static from | Imports an existing Kinesis Stream Consumer by its attributes. |
addToResourcePolicy(statement)
public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult
Parameters
- statement
Policy
Statement
Returns
Adds a statement to the IAM resource policy associated with this stream consumer.
If this stream consumer was created in this stack (new StreamConsumer
), a resource policy
will be automatically created upon the first call to addToResourcePolicy
. If
the stream is imported (StreamConsumer.from
), then this is a no-op.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
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
).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantable
- actions
string
Returns
Grant the indicated permissions on this stream consumer to the given IAM principal (Role/Group/User).
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant read permissions for this stream consumer and its associated stream to an IAM principal (Role/Group/User).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromStreamConsumerArn(scope, id, streamConsumerArn)
public static fromStreamConsumerArn(scope: Construct, id: string, streamConsumerArn: string): IStreamConsumer
Parameters
- scope
Construct
— the Construct scope. - id
string
— the ID of the construct. - streamConsumerArn
string
— the arn of the existing stream consumer.
Returns
Imports an existing Kinesis Stream Consumer by its arn.
static fromStreamConsumerAttributes(scope, id, attrs)
public static fromStreamConsumerAttributes(scope: Construct, id: string, attrs: StreamConsumerAttributes): IStreamConsumer
Parameters
- scope
Construct
— the Construct scope. - id
string
— the ID of the construct. - attrs
Stream
— the attributes of the existing stream consumer.Consumer Attributes
Returns
Imports an existing Kinesis Stream Consumer by its attributes.