Skip to content

predictr-io/aws-glue-delete-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Glue Delete Table Action

GitHub Action to delete AWS Glue Data Catalog tables.

Features

  • Delete Glue tables
  • Automatic verification that table is deleted
  • Gracefully handles non-existent tables
  • Support for cross-account catalog access
  • Comprehensive error reporting

Usage

Basic Usage

- name: Delete Glue table
  uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'my_database'
    table-name: 'my_table'

Cross-Account Table

- name: Delete table in another account
  uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'shared_database'
    table-name: 'shared_table'
    catalog-id: '987654321098'

Authentication

This action requires AWS credentials to be configured. Use the official AWS configure credentials action:

- uses: aws-actions/configure-aws-credentials@v4
  with:
    role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
    aws-region: us-east-1

- uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'my_database'
    table-name: 'my_table'

Inputs

Input Required Default Description
database-name Yes - Name of the Glue database containing the table
table-name Yes - Name of the table to delete
catalog-id No current account AWS account ID for cross-account access

Outputs

Output Description
table-name Name of the deleted table
database-name Name of the database that contained the table

Examples

Complete Workflow

name: Cleanup Glue Table
on:
  workflow_dispatch:
    inputs:
      database_name:
        description: 'Database name'
        required: true
      table_name:
        description: 'Table to delete'
        required: true

jobs:
  delete-table:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read

    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
          aws-region: us-east-1

      - name: Delete Glue table
        uses: predictr-io/aws-glue-delete-table@v0
        with:
          database-name: ${{ github.event.inputs.database_name }}
          table-name: ${{ github.event.inputs.table_name }}
        id: delete-table

      - name: Report deletion
        run: |
          echo "Table: ${{ steps.delete-table.outputs.table-name }}"
          echo "Database: ${{ steps.delete-table.outputs.database-name }}"

Cleanup Test Tables

- name: Delete test table
  uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'test_database'
    table-name: 'test_${{ github.run_id }}'

Multiple Tables

- name: Delete staging tables
  uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'analytics'
    table-name: 'staging_events'

- name: Delete temp table
  uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'analytics'
    table-name: 'temp_results'

Conditional Cleanup on PR Close

name: Cleanup on PR Close
on:
  pull_request:
    types: [closed]

jobs:
  cleanup:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read

    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
          aws-region: us-east-1

      - name: Delete PR-specific table
        uses: predictr-io/aws-glue-delete-table@v0
        with:
          database-name: 'pr_testing'
          table-name: 'pr_${{ github.event.pull_request.number }}_events'

Cleanup After Failed Tests

- name: Run integration tests
  id: tests
  run: pytest tests/integration

- name: Cleanup test table
  if: always()
  uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'test_db'
    table-name: 'test_data_${{ github.run_id }}'

IAM Permissions

The AWS credentials used by this action need the following IAM permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "glue:DeleteTable",
        "glue:GetTable"
      ],
      "Resource": [
        "arn:aws:glue:*:*:catalog",
        "arn:aws:glue:*:*:database/*",
        "arn:aws:glue:*:*:table/*/*"
      ]
    }
  ]
}

Error Handling

Non-existent Table

If the table doesn't exist, the action will:

  • Log a warning: "Table X.Y does not exist - nothing to delete"
  • Exit successfully (not an error)
  • Set outputs with table and database names

This makes the action idempotent and safe to run multiple times.

Permission Errors

If credentials lack necessary permissions:

  • Action will fail with AWS SDK error
  • Error details include HTTP status and error code
  • Check IAM permissions match requirements above

Database Not Found

If the database doesn't exist:

  • Action will fail with EntityNotFoundException
  • Ensure database exists before attempting to delete tables

Common Use Cases

1. Cleanup Test Data

- uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'integration_tests'
    table-name: 'temp_results'

2. Environment Teardown

- uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'ephemeral_${{ github.sha }}'
    table-name: 'events'

3. Replace Table Pattern

# Delete old table
- uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'analytics'
    table-name: 'events'

# Create new table with updated schema
- uses: predictr-io/aws-glue-create-table@v0
  with:
    database-name: 'analytics'
    table-name: 'events'
    table-input: '{"Name": "events", ...}'

4. Selective Cleanup (Keep Database)

# Delete individual tables but keep database
- uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'my_database'
    table-name: 'old_table_1'

- uses: predictr-io/aws-glue-delete-table@v0
  with:
    database-name: 'my_database'
    table-name: 'old_table_2'

Verification

After deletion, the action polls GetTable to verify the table no longer exists:

  • Max 10 attempts with 1s delay
  • Logs verification progress
  • Ensures eventual consistency is handled

Related Actions

  • aws-glue-create-table - Create or update Glue tables
  • aws-glue-create-database - Create Glue databases
  • aws-glue-delete-database - Delete Glue databases (with cascade option for all tables)

License

MIT

About

GitHub Action to delete AWS Glue Data Catalog tables

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •