0

I have a lambda function that looks like this:

client = boto3.client('glue')

glueJobName = "Python Glue Script"
inputtedData = "A1B2C3D4E5"
school = "testing"

def lambda_handler(event, context):
    response = client.start_job_run(JobName = glueJobName, Arguments = {'==inputtedData': inputtedData, '--school': school})
    return response

This starts running my glue job which contains a script. However, I want to pass the Arguments 'inputtedData' and 'school' to this script, so that when the script starts, these variables will be inputted into my syncData function like this:

def syncAttendance(inputtedData, school):

   schoolName = school
   Data = inputtedData
   print(schoolName, Data)


syncData(inputtedData, school)

How do I receive these variables in the glue script?

1
  • Note the typo in your '==inputtedData' Commented Nov 27, 2020 at 12:44

1 Answer 1

2

You need to use getResolvedOptions function as follows:

import sys
from awsglue.utils import getResolvedOptions

options = ['inputtedData', 'school']
args = getResolvedOptions(sys.argv, options)

syncData(args['inputtedData'], args['school'])
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, do I put this at the top of the python glue job script?
It doesn't matter where you put args = getResolvedOptions(sys.argv, options). It just needs to be executed before you call your syncData

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.