Dùng boto3 gọi get_trigger để lấy metadata đầy đủ của một trigger (tên, loại, trạng thái, lịch trình, mô tả...).
Quy trình
- Import boto3, ClientError.
- Hàm nhận
trigger_name. - Tạo session, client Glue.
- Gọi
glue_client.get_trigger(Name=...). - Trả về response.
- Xử lý ngoại lệ.
Code mẫu
import boto3
from botocore.exceptions import ClientError
def lay_chi_tiet_trigger(trigger_name):
session = boto3.session.Session()
glue_client = session.client('glue')
try:
response = glue_client.get_trigger(Name=trigger_name)
return response
except ClientError as e:
raise Exception("Lỗi boto3 client: " + str(e))
except Exception as e:
raise Exception("Lỗi không mong đợi: " + str(e))
print(lay_chi_tiet_trigger('01_PythonShellTest1'))
Kết quả
{'Trigger': {'Name': '01_PythonShellTest1', 'WorkflowName': 'arn:aws:iam::1234:role/dev-edl', 'Id': 'string', 'Type': 'SCHEDULED|CONDITIONAL|ON_DEMAND', 'State': 'CREATING|CREATED|ACTIVATING|ACTIVATED|DEACTIVATING|DEACTIVATED|DELETING|UPDATING', 'Description': 'string', 'Schedule': 'string'}}