[英]Passing Lambda Variable to Glue Script AWS
I have a lambda function that looks like this:我有一个 lambda function 看起来像这样:
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:
但是,我想将 Arguments 'inputtedData' 和 'school' 传递给这个脚本,这样当脚本启动时,这些变量就会像这样输入到我的同步数据 function 中:
def syncAttendance(inputtedData, school):
schoolName = school
Data = inputtedData
print(schoolName, Data)
syncData(inputtedData, school)
How do I receive these variables in the glue script?如何在胶水脚本中接收这些变量?
You need to use getResolvedOptions
function as follows:您需要使用
getResolvedOptions
function 如下:
import sys
from awsglue.utils import getResolvedOptions
options = ['inputtedData', 'school']
args = getResolvedOptions(sys.argv, options)
syncData(args['inputtedData'], args['school'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.