Skip to content

Instantly share code, notes, and snippets.

@kenzo0107
Created December 10, 2024 04:25
Show Gist options
  • Save kenzo0107/b70aef75fadfc6ad49999c73b79217e9 to your computer and use it in GitHub Desktop.
Save kenzo0107/b70aef75fadfc6ad49999c73b79217e9 to your computer and use it in GitHub Desktop.
#!/bin/sh
CATALOG_ID="AWS Account ID"
DATABASE="Glue Data Catalog Database"
IAM_ROLE="Execution IAM Role ARN"
tables=($(aws glue get-tables --catalog-id $CATALOG_ID \
--database-name $DATABASE \
--query 'TableList[*].Name' --output text))
for table in "${tables[@]}" ; do
echo "[ ${table} ]"
aws glue create-table-optimizer \
--catalog-id $CATALOG_ID \
--database-name $DATABASE \
--table-name $table \
--table-optimizer-configuration roleArn=$IAM_ROLE,enabled=true \
--type compaction
aws glue create-table-optimizer \
--catalog-id $CATALOG_ID \
--database-name $DATABASE \
--table-name $table \
--table-optimizer-configuration roleArn=$IAM_ROLE,enabled=true \
--type retention
aws glue create-table-optimizer \
--catalog-id $CATALOG_ID \
--database-name $DATABASE \
--table-name $table \
--table-optimizer-configuration roleArn=$IAM_ROLE,enabled=true \
--type orphan_file_deletion
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment