# StreamConsumerProps

Properties for a Kinesis Stream Consumer.

Used as props by: [StreamConsumer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kinesis.StreamConsumer.html)

- Source: [`aws-kinesis/lib/stream-consumer.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-kinesis/lib/stream-consumer.ts#L158)
- Type last changed: v2.180.0 · 21 Feb 2025

## Example

TypeScript:

```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:

```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:

```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);
```

C# / .NET:

```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);
```

Golang:

```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)
```

## Properties

- `stream`: [IStream](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kinesis.IStream.html) (required) — The Kinesis data stream to associate this consumer with.

- `streamConsumerName`: string (required) — The name of the stream consumer.
