in migration/bring-your-own-s3-tables/bring_your_own_s3_table_bucket.py [0:0]
def _create_glue_catalog(glue_client, table_bucket_arn, execute_flag):
s3_table_bucket_account_id = table_bucket_arn.split(':')[4]
s3_table_bucket_region = table_bucket_arn.split(':')[3]
# Create catalog configuration
catalog_input = {
"Name": "s3tablescatalog",
"CatalogInput": {
"FederatedCatalog": {
"Identifier": f"arn:aws:s3tables:{s3_table_bucket_region}:{s3_table_bucket_account_id}:bucket/*",
"ConnectionName": "aws:s3tables"
},
"CreateDatabaseDefaultPermissions": [],
"CreateTableDefaultPermissions": []
}
}
if execute_flag:
# Create catalog
try:
glue_client.create_catalog(
**catalog_input
)
print(f"Successfully created glue catalog 's3tablescatalog'\n")
except ClientError as e:
if e.response['Error']['Code'] == 'AlreadyExistsException':
print(f"Successfully created glue catalog 's3tablescatalog'\n")
else:
raise e
else:
print(f"Skip creating glue catalog 's3tablescatalog', set --execute flag to True to do the actual update\n")