# TableClientSideEncryption

Client-side encryption for an `S3Table`'s data.

Independent of the bucket's server-side encryption and of who owns the bucket:
the data is encrypted by the client before it is written to S3. When set, the
`grant*` methods also grant the relevant KMS permissions on the key.

Obtainable from: TableClientSideEncryption.kms

- Source: [`aws-glue/lib/s3-table.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-glue/lib/s3-table.ts#L115)
- Type last changed: v2.270.0 · 17 Sep 2026

## Example

TypeScript:

```ts
declare const myDatabase: glue.Database;
// KMS key is created automatically
new glue.S3Table(this, 'MyTable', {
  clientSideEncryption: glue.TableClientSideEncryption.kms(),
  // ...
  database: myDatabase,
  columns: [{
    name: 'col1',
    type: glue.Schema.STRING,
  }],
  dataFormat: glue.DataFormat.JSON,
});

// with an explicit KMS key
new glue.S3Table(this, 'MyTable', {
  clientSideEncryption: glue.TableClientSideEncryption.kms(new kms.Key(this, 'MyKey')),
  // ...
  database: myDatabase,
  columns: [{
    name: 'col1',
    type: glue.Schema.STRING,
  }],
  dataFormat: glue.DataFormat.JSON,
});
```

Python:

```python
# my_database: glue.Database

# KMS key is created automatically
glue.S3Table(self, "MyTable",
    client_side_encryption=glue.TableClientSideEncryption.kms(),
    # ...
    database=my_database,
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.JSON
)

# with an explicit KMS key
glue.S3Table(self, "MyTable",
    client_side_encryption=glue.TableClientSideEncryption.kms(kms.Key(self, "MyKey")),
    # ...
    database=my_database,
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.JSON
)
```

Java:

```java
Database myDatabase;

// KMS key is created automatically
// KMS key is created automatically
S3Table.Builder.create(this, "MyTable")
        .clientSideEncryption(TableClientSideEncryption.kms())
        // ...
        .database(myDatabase)
        .columns(List.of(Column.builder()
                .name("col1")
                .type(Schema.STRING)
                .build()))
        .dataFormat(DataFormat.JSON)
        .build();

// with an explicit KMS key
// with an explicit KMS key
S3Table.Builder.create(this, "MyTable")
        .clientSideEncryption(TableClientSideEncryption.kms(new Key(this, "MyKey")))
        // ...
        .database(myDatabase)
        .columns(List.of(Column.builder()
                .name("col1")
                .type(Schema.STRING)
                .build()))
        .dataFormat(DataFormat.JSON)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Database myDatabase;

// KMS key is created automatically
// KMS key is created automatically
new S3Table(this, "MyTable", new S3TableProps {
    ClientSideEncryption = TableClientSideEncryption.Kms(),
    // ...
    Database = myDatabase,
    Columns = new [] { new Column {
        Name = "col1",
        Type = Schema.STRING
    } },
    DataFormat = DataFormat.JSON
});

// with an explicit KMS key
// with an explicit KMS key
new S3Table(this, "MyTable", new S3TableProps {
    ClientSideEncryption = TableClientSideEncryption.Kms(new Key(this, "MyKey")),
    // ...
    Database = myDatabase,
    Columns = new [] { new Column {
        Name = "col1",
        Type = Schema.STRING
    } },
    DataFormat = DataFormat.JSON
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myDatabase Database

// KMS key is created automatically
// KMS key is created automatically
glue.NewS3Table(this, jsii.String("MyTable"), &S3TableProps{
	ClientSideEncryption: glue.TableClientSideEncryption_Kms(),
	// ...
	Database: myDatabase,
	Columns: []Column{
		&Column{
			Name: jsii.String("col1"),
			Type: glue.Schema_STRING(),
		},
	},
	DataFormat: glue.DataFormat_JSON(),
})

// with an explicit KMS key
// with an explicit KMS key
glue.NewS3Table(this, jsii.String("MyTable"), &S3TableProps{
	ClientSideEncryption: glue.TableClientSideEncryption_*Kms(kms.NewKey(this, jsii.String("MyKey"))),
	// ...
	Database: myDatabase,
	Columns: []Column{
		&Column{
			Name: jsii.String("col1"),
			Type: glue.Schema_STRING(),
		},
	},
	DataFormat: glue.DataFormat_JSON(),
})
```

## Methods

- `kms(key?: IKeyRef): TableClientSideEncryption // chainable` (static) — Client-side encryption (CSE-KMS) with an AWS KMS key managed by the account owner.

  **Parameters**

  - `key` — the KMS key used to encrypt the data.
