StreamConsumerProps Struct
Properties for a Kinesis Stream Consumer.
| Source | aws-kinesis/lib/stream-consumer.ts |
|---|---|
| Type last changed |
Example
ts
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);
python
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
)
stream_consumer = kinesis.StreamConsumer(self, "MyStreamConsumer",
stream_consumer_name="MyStreamConsumer",
stream=stream
)
# give lambda permissions to read stream via the stream consumer
stream_consumer.grant_read(lambda_role)
java
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();
StreamConsumer streamConsumer = StreamConsumer.Builder.create(this, "MyStreamConsumer")
.streamConsumerName("MyStreamConsumer")
.stream(stream)
.build();
// give lambda permissions to read stream via the stream consumer
streamConsumer.grantRead(lambdaRole);
csharp
// 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
});
var streamConsumer = new StreamConsumer(this, "MyStreamConsumer", new StreamConsumerProps {
StreamConsumerName = "MyStreamConsumer",
Stream = stream
});
// give lambda permissions to read stream via the stream consumer
streamConsumer.GrantRead(lambdaRole);
go
// 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,
})
streamConsumer := kinesis.NewStreamConsumer(this, jsii.String("MyStreamConsumer"), &StreamConsumerProps{
StreamConsumerName: jsii.String("MyStreamConsumer"),
Stream: Stream,
})
// give lambda permissions to read stream via the stream consumer
streamConsumer.grantRead(lambdaRole)