# BucketEncryptionProperty

Specifies default encryption for a bucket using server-side encryption with Amazon S3-managed keys (SSE-S3), AWS KMS-managed keys (SSE-KMS), or dual-layer server-side encryption with KMS-managed keys (DSSE-KMS).

For information about the Amazon S3 default encryption feature, see [Amazon S3 Default Encryption for S3 Buckets](https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html) in the *Amazon S3 User Guide* .

- Source: Generated at build time
- Type last changed: v2.93.0 · 23 Aug 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_s3 as s3 } from 'aws-cdk-lib';
const bucketEncryptionProperty: s3.CfnBucket.BucketEncryptionProperty = {
  serverSideEncryptionConfiguration: [{
    blockedEncryptionTypes: {
      encryptionType: ['encryptionType'],
    },
    bucketKeyEnabled: false,
    serverSideEncryptionByDefault: {
      sseAlgorithm: 'sseAlgorithm',

      // the properties below are optional
      kmsMasterKeyId: 'kmsMasterKeyId',
    },
  }],
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_s3 as s3

bucket_encryption_property = s3.CfnBucket.BucketEncryptionProperty(
    server_side_encryption_configuration=[s3.CfnBucket.ServerSideEncryptionRuleProperty(
        blocked_encryption_types=s3.CfnBucket.BlockedEncryptionTypesProperty(
            encryption_type=["encryptionType"]
        ),
        bucket_key_enabled=False,
        server_side_encryption_by_default=s3.CfnBucket.ServerSideEncryptionByDefaultProperty(
            sse_algorithm="sseAlgorithm",

            # the properties below are optional
            kms_master_key_id="kmsMasterKeyId"
        )
    )]
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.s3.*;

BucketEncryptionProperty bucketEncryptionProperty = BucketEncryptionProperty.builder()
        .serverSideEncryptionConfiguration(List.of(ServerSideEncryptionRuleProperty.builder()
                .blockedEncryptionTypes(BlockedEncryptionTypesProperty.builder()
                        .encryptionType(List.of("encryptionType"))
                        .build())
                .bucketKeyEnabled(false)
                .serverSideEncryptionByDefault(ServerSideEncryptionByDefaultProperty.builder()
                        .sseAlgorithm("sseAlgorithm")

                        // the properties below are optional
                        .kmsMasterKeyId("kmsMasterKeyId")
                        .build())
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.S3;

var bucketEncryptionProperty = new BucketEncryptionProperty {
    ServerSideEncryptionConfiguration = new [] { new ServerSideEncryptionRuleProperty {
        BlockedEncryptionTypes = new BlockedEncryptionTypesProperty {
            EncryptionType = new [] { "encryptionType" }
        },
        BucketKeyEnabled = false,
        ServerSideEncryptionByDefault = new ServerSideEncryptionByDefaultProperty {
            SseAlgorithm = "sseAlgorithm",

            // the properties below are optional
            KmsMasterKeyId = "kmsMasterKeyId"
        }
    } }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

bucketEncryptionProperty := &BucketEncryptionProperty{
	ServerSideEncryptionConfiguration: []interface{}{
		&ServerSideEncryptionRuleProperty{
			BlockedEncryptionTypes: &BlockedEncryptionTypesProperty{
				EncryptionType: []*string{
					jsii.String("encryptionType"),
				},
			},
			BucketKeyEnabled: jsii.Boolean(false),
			ServerSideEncryptionByDefault: &ServerSideEncryptionByDefaultProperty{
				SseAlgorithm: jsii.String("sseAlgorithm"),

				// the properties below are optional
				KmsMasterKeyId: jsii.String("kmsMasterKeyId"),
			},
		},
	},
}
```

## Properties

- `serverSideEncryptionConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnBucket.ServerSideEncryptionRuleProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.CfnBucket.ServerSideEncryptionRuleProperty.html)[] (required) — Specifies the default server-side-encryption configuration.
