# StreamEncryption

What kind of server-side encryption to apply to this stream.

- Source: [`aws-kinesis/lib/stream.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-kinesis/lib/stream.ts#L1048)

## 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,
});

// give lambda permissions to read stream
stream.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
)

# give lambda permissions to read stream
stream.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();

// give lambda permissions to read stream
stream.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
});

// give lambda permissions to read stream
stream.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,
})

// give lambda permissions to read stream
stream.grantRead(lambdaRole)
```

## Members

| Member | Description |
| --- | --- |
| `UNENCRYPTED` | Records in the stream are not encrypted. |
| `KMS` | Server-side encryption with a KMS key managed by the user. |
| `MANAGED` | Server-side encryption with a master key managed by Amazon Kinesis. |

## Referenced by

- [`StreamProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kinesis.StreamProps.html).encryption
