Amazon S3 Tables

Create a Table Bucket

To create an Amazon S3 Tables table bucket, use S3TablesCreateTableBucketOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

create_table_bucket = S3TablesCreateTableBucketOperator(
    task_id="create_table_bucket",
    table_bucket_name=bucket_name,
)

Create a Namespace

To create a namespace in an Amazon S3 Tables table bucket, use S3TablesCreateNamespaceOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

setup_namespace = S3TablesCreateNamespaceOperator(
    task_id="create_namespace",
    table_bucket_arn=create_table_bucket.output,
    namespace=namespace,
)

Create a Table

To create a new Iceberg table in an Amazon S3 Tables namespace you can use S3TablesCreateTableOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

create_table = S3TablesCreateTableOperator(
    task_id="create_table",
    table_bucket_arn=create_table_bucket.output,
    namespace=namespace,
    table_name=table_name,
    metadata=SCHEMA,
)

Delete a Namespace

To delete a namespace from an Amazon S3 Tables table bucket, use S3TablesDeleteNamespaceOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

delete_namespace = S3TablesDeleteNamespaceOperator(
    task_id="delete_namespace",
    table_bucket_arn=create_table_bucket.output,
    namespace=namespace,
    trigger_rule=TriggerRule.ALL_DONE,
)

Delete a Table

To delete a table from an Amazon S3 Tables namespace, use S3TablesDeleteTableOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

delete_table = S3TablesDeleteTableOperator(
    task_id="delete_table",
    table_bucket_arn=create_table_bucket.output,
    namespace=namespace,
    table_name=renamed_table_name,
    trigger_rule=TriggerRule.ALL_DONE,
)

Delete a Table Bucket

To delete an Amazon S3 Tables table bucket, use S3TablesDeleteTableBucketOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

delete_table_bucket = S3TablesDeleteTableBucketOperator(
    task_id="delete_table_bucket",
    table_bucket_arn=create_table_bucket.output,
    trigger_rule=TriggerRule.ALL_DONE,
)

Rename a Table

To rename a table in an Amazon S3 Tables namespace, use S3TablesRenameTableOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

rename_table = S3TablesRenameTableOperator(
    task_id="rename_table",
    table_bucket_arn=create_table_bucket.output,
    namespace=namespace,
    table_name=table_name,
    new_name=renamed_table_name,
)

Put a Table Bucket Policy

To set a resource policy on an Amazon S3 Tables table bucket, use S3TablesPutTableBucketPolicyOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

put_policy = S3TablesPutTableBucketPolicyOperator(
    task_id="put_table_bucket_policy",
    table_bucket_arn=create_table_bucket.output,
    resource_policy=f'{{"Version":"2012-10-17","Statement":[{{"Sid":"TestPolicy","Effect":"Allow","Principal":{{"AWS":"arn:aws:iam::{account_id}:root"}},"Action":"s3tables:GetTable","Resource":"*"}}]}}',
)

Delete a Table Bucket Policy

To delete the resource policy from an Amazon S3 Tables table bucket, use S3TablesDeleteTableBucketPolicyOperator.

tests/system/amazon/aws/example_s3_tables.py[source]

delete_policy = S3TablesDeleteTableBucketPolicyOperator(
    task_id="delete_table_bucket_policy",
    table_bucket_arn=create_table_bucket.output,
    trigger_rule=TriggerRule.ALL_DONE,
)

Reference

Was this entry helpful?