# S3TableStorage

Where an `S3Table` stores its data.

The two paths are mutually exclusive: a managed bucket may specify its
server-side encryption, while an existing bucket keeps its own encryption — so
an encryption choice can never be paired with a bring-your-own bucket.

Obtainable from: S3TableStorage.fromBucket, S3TableStorage.managedBucket

- 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#L67)
- Type last changed: v2.270.0 · 17 Sep 2026

## Example

TypeScript:

```ts
declare const myDatabase: glue.Database;
new glue.S3Table(this, 'MyTable', {
  storage: glue.S3TableStorage.managedBucket(glue.S3TableEncryption.s3Managed()),
  // ...
  database: myDatabase,
  columns: [{
    name: 'col1',
    type: glue.Schema.STRING,
  }],
  dataFormat: glue.DataFormat.JSON,
});
```

Python:

```python
# my_database: glue.Database

glue.S3Table(self, "MyTable",
    storage=glue.S3TableStorage.managed_bucket(glue.S3TableEncryption.s3_managed()),
    # ...
    database=my_database,
    columns=[glue.Column(
        name="col1",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.JSON
)
```

Java:

```java
Database myDatabase;

S3Table.Builder.create(this, "MyTable")
        .storage(S3TableStorage.managedBucket(S3TableEncryption.s3Managed()))
        // ...
        .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;

new S3Table(this, "MyTable", new S3TableProps {
    Storage = S3TableStorage.ManagedBucket(S3TableEncryption.S3Managed()),
    // ...
    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

glue.NewS3Table(this, jsii.String("MyTable"), &S3TableProps{
	Storage: glue.S3TableStorage_ManagedBucket(glue.S3TableEncryption_S3Managed()),
	// ...
	Database: myDatabase,
	Columns: []Column{
		&Column{
			Name: jsii.String("col1"),
			Type: glue.Schema_STRING(),
		},
	},
	DataFormat: glue.DataFormat_JSON(),
})
```

## Methods

- `fromBucket(bucket: IBucket): S3TableStorage // chainable` (static) — Store the table's data in an existing bucket. CDK does not manage the bucket's encryption.

  The bucket can be one you don't own, imported with
  `Bucket.fromBucketArn()` or `Bucket.fromBucketAttributes()`. If that bucket
  is KMS-encrypted, import it with `Bucket.fromBucketAttributes()` and supply
  the `encryptionKey` attribute. Otherwise, CDK has no reference to the key,
  which means that `S3Table.grantRead()`/`grantWrite()` will correctly grant
  S3 access but silently skip the KMS permissions on the key. As a consequence,
  at runtime, reads and writes will fail with access denied on the key.

  **Parameters**

  - `bucket` — the bucket that holds the table's data.

- `managedBucket(encryption?: S3TableEncryption): S3TableStorage // chainable` (static) — Store the table's data in a bucket created and managed by the table.

  **Parameters**

  - `encryption` — the server-side encryption for the created bucket.
