How to use Boto3 to update the details of a workflow in AWS Glue Catalog

In this article, we will see how to update the details of a workflow in AWS Glue Catalog using the boto3 library in Python.

What is AWS Glue Workflow?

An AWS Glue workflow is a visual representation of a multi-job ETL process. You can use workflows to design complex ETL operations that involve multiple crawlers, jobs, and triggers. The update_workflow function allows you to modify workflow properties like description and default run properties.

Problem Statement

Use boto3 library in Python to update details of a workflow that is created in your AWS Glue account.

Required Parameters

  • workflow_name − The name of the workflow to update (required)

  • description − Updated description for the workflow (optional)

  • default_run_properties − Default properties for workflow runs (optional)

Implementation Steps

Follow these steps to update a workflow in AWS Glue ?

Step 1: Import Required Libraries

Import boto3 and botocore exceptions to handle AWS service errors ?

import boto3
from botocore.exceptions import ClientError

Step 2: Create AWS Session and Client

Create an AWS session using boto3. Ensure region_name is configured in your default profile or pass it explicitly ?

session = boto3.session.Session()
glue_client = session.client('glue')

Step 3: Update Workflow Details

Call update_workflow method with the workflow name and optional parameters ?

def update_workflow_details(workflow_name, description=None, default_run_properties=None):
    session = boto3.session.Session()
    glue_client = session.client('glue')
    
    try:
        response = glue_client.update_workflow(
            Name=workflow_name,
            Description=description,
            DefaultRunProperties=default_run_properties or {}
        )
        return response
    except ClientError as e:
        raise Exception(f"boto3 client error in update_workflow_details: {str(e)}")
    except Exception as e:
        raise Exception(f"Unexpected error in update_workflow_details: {str(e)}")

Complete Example

Here's a complete example that updates a workflow's description ?

import boto3
from botocore.exceptions import ClientError

def update_workflow_details(workflow_name, description=None, default_run_properties=None):
    session = boto3.session.Session()
    glue_client = session.client('glue')
    
    try:
        response = glue_client.update_workflow(
            Name=workflow_name,
            Description=description,
            DefaultRunProperties=default_run_properties or {}
        )
        return response
    except ClientError as e:
        raise Exception(f"boto3 client error: {str(e)}")
    except Exception as e:
        raise Exception(f"Unexpected error: {str(e)}")

# Update workflow with new description
result = update_workflow_details('my-etl-workflow', 'Updated workflow description')
print(result)

Sample Output

The function returns metadata about the updated workflow ?

{
    'Name': 'my-etl-workflow', 
    'ResponseMetadata': {
        'RequestId': 'b328d064-24ab-48c4-b058-852387a3d474', 
        'HTTPStatusCode': 200, 
        'HTTPHeaders': {
            'date': 'Sat, 27 Feb 2021 13:57:37 GMT', 
            'content-type': 'application/x-amz-json-1.1', 
            'content-length': '2655', 
            'connection': 'keep-alive', 
            'x-amzn-requestid': 'b328d064-24ab-48c4-b058-852387a3d474'
        }, 
        'RetryAttempts': 0
    }
}

Key Points

  • The workflow must exist in your AWS account before updating

  • Only workflow name is required; description and default run properties are optional

  • The function returns workflow metadata upon successful update

  • Proper error handling ensures graceful failure management

Conclusion

The update_workflow method in boto3 allows you to modify AWS Glue workflow properties programmatically. Use proper error handling and ensure your AWS credentials are configured correctly for successful execution.

Updated on: 2026-03-25T18:51:46+05:30

372 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements