简体   繁体   中英

How can I Pass arguments from AWS Lambda to AWS Step Function?

I have a Lambda code written in Python 3.6

  for record in event['Records']:
        filename_from_event = record['s3']['configurationId']
        filename = record['s3']['object']['key']
        bucket = record['s3']['bucket']['name']
        filename_folder = filename[0:filename.rfind("/")]
        filename_key = filename[filename.rfind("/")+1:]
        bucket_arr=bucket.split("-")
        path_arr=filename.split("/")
        proc=path_arr[0].upper()
        env=bucket_arr[2].upper()
        source=path_arr[2].upper()
        src_orch_json=proc+"/Common/Config/"+proc+"_"+source+"_Orch.json"
        input_json = get_step_input(bucket, src_orch_json)
        response = sf.start_execution(
            stateMachineArn='arn:aws:states:abc:stateMachine:xyz',
            name='xyz_' + env + '_' + proc + '_' + source,
            input=input_json
            )

Now, my objective is to pass arguments,ie, proc, env and source to step function during start_execution.

How I can I do this and catch the arguments within the step function so that in turn it can pass again these parameters to the sequence of steps within it?

presuming you have basic understanding of step functions. you should be returning a json object if you wants to pass multiple arguments to step function.

在input_json中我有{“env”:“dev”,“proc”:“load”},这两个参数必须在下一步Lambda代码中解析。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM