Skip to content Skip to sidebar Skip to footer

How Can I Use A Lambda Function To Call A Glue Function (etl) When A Text File Is Loaded To An S3 Bucket

I am trying to set up a lambda function that activates a Glue function when a .txt file is uploaded to an S3 bucket, I am using python 3.7 So far I have this: from __future__ impor

Solution 1:

I manage to do it like this:

from __future__ import print_function
import json
import boto3

client = boto3.client('glue')

def lambda_handler(event, context):
    response = client.start_job_run(JobName = 'GLUE_CODE_NAME')

Later I will post the S3 event


Solution 2:

You can configure an S3 Event Notification that will trigger this Lambda function when PUT object actions is called on an S3 prefix.

https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-event-notifications.html

This lambda function can then trigger the StartJobRun action of Glue API.

https://docs.aws.amazon.com/glue/latest/webapi/API_StartJobRun.html


Post a Comment for "How Can I Use A Lambda Function To Call A Glue Function (etl) When A Text File Is Loaded To An S3 Bucket"