I have a start_execution command to start a step function via my lambda function (python):
if event['Records'][0]['eventName'] == 'INSERT':
filename, source, destination_bucket_name, filekey = parse_file_info_from_trigger(event)
response = client.start_execution(
stateMachineArn='aws:states:.......',
input = "{\"first_name\" : \"test\"}"
)
else:
logger.info(f'This is not an Insert event')
How can I pass the above extracted variables (filename, source etc) into the input of the start-execution command?
I tried this:
response = step_function.start_execution(
stateMachineArn=state_machine_zip_files_arn,
input = str({ "filename": f"{filename}", "filetype": f"{filetype}", "unixtimestamp": f"{unixtimestamp}",
"masterclient": f"{masterclient}", "source_bucket_name": f"{source_bucket_name}" ,
"destination_bucket_name": f"{destination_bucket_name}", "filekey": f"{filekey}","this is a test string": f"teststring"})
)
but it gives me an error that:
Unable to start_execution for state machine: An error occurred (InvalidExecutionInput) when calling the StartExecution operation: Invalid State Machine Execution Input: 'Unexpected character (''' (code 39)): was expecting double-quote to start field name'
CodePudding user response:
The expected format of input
is a str
. You should convert your dict into a str as following: json.dumps(your_input_data)
.