# BucketEncryption

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

- Source: [`aws-s3/lib/bucket.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L3462)
- Type last changed: v2.84.0 · 14 Jun 2023

## Example

TypeScript:

```ts
declare const application: appconfig.Application;

const bucket = new s3.Bucket(this, 'MyBucket', {
  versioned: true,
  encryption: s3.BucketEncryption.KMS,
});

new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', {
  application,
  location: appconfig.ConfigurationSource.fromBucket(bucket, 'path/to/file.json'),
});
```

Python:

```python
# application: appconfig.Application

bucket = s3.Bucket(self, "MyBucket",
    versioned=True,
    encryption=s3.BucketEncryption.KMS
)

appconfig.SourcedConfiguration(self, "MySourcedConfiguration",
    application=application,
    location=appconfig.ConfigurationSource.from_bucket(bucket, "path/to/file.json")
)
```

Java:

```java
Application application;

Bucket bucket = Bucket.Builder.create(this, "MyBucket")
        .versioned(true)
        .encryption(BucketEncryption.KMS)
        .build();

SourcedConfiguration.Builder.create(this, "MySourcedConfiguration")
        .application(application)
        .location(ConfigurationSource.fromBucket(bucket, "path/to/file.json"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Application application;

var bucket = new Bucket(this, "MyBucket", new BucketProps {
    Versioned = true,
    Encryption = BucketEncryption.KMS
});

new SourcedConfiguration(this, "MySourcedConfiguration", new SourcedConfigurationProps {
    Application = application,
    Location = ConfigurationSource.FromBucket(bucket, "path/to/file.json")
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var application Application

bucket := s3.NewBucket(this, jsii.String("MyBucket"), &BucketProps{
	Versioned: jsii.Boolean(true),
	Encryption: s3.BucketEncryption_KMS,
})

appconfig.NewSourcedConfiguration(this, jsii.String("MySourcedConfiguration"), &SourcedConfigurationProps{
	Application: Application,
	Location: appconfig.ConfigurationSource_FromBucket(bucket, jsii.String("path/to/file.json")),
})
```

## Members

| Member | Description |
| --- | --- |
| `UNENCRYPTED` deprecated | S3 applies server-side encryption with SSE-S3 for every bucket that default encryption is not configured. |
| `KMS_MANAGED` | Server-side KMS encryption with a master key managed by KMS. |
| `S3_MANAGED` | Server-side encryption with a master key managed by S3. |
| `KMS` | Server-side encryption with a KMS key managed by the user. |
| `DSSE_MANAGED` | Double server-side KMS encryption with a master key managed by KMS. |
| `DSSE` | Double server-side encryption with a KMS key managed by the user. |

## Referenced by

- [`Bucket`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html).encryption
- [`BucketAttributes`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketAttributes.html).encryption
- [`BucketBase`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketBase.html).encryption
- [`BucketProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketProps.html).encryption
- [`DefaultStagingStackOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_app-staging-synthesizer-alpha.DefaultStagingStackOptions.html).stagingBucketEncryption
- [`IBucket`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html).encryption
