Last active
November 11, 2022 09:35
-
-
Save konami99/558462b5f6a1716382f7e7ebc54ccf0a to your computer and use it in GitHub Desktop.
Invoking Step Functions from Lambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
sfn = boto3.client('stepfunctions') | |
def lambda_handler(event, context): | |
sfn_st = "arn:aws:states:ap-southeast-2:123456789:stateMachine:StepFunctionArn" | |
data = [] | |
for unicorn in unicorns_to_feed: | |
obj = {} | |
obj["id"] = unicorn['id'] | |
obj["last_fed"] = unicorn['last_fed'] | |
data.append(obj) | |
sfn_input = {} | |
sfn_input["UnicornsToFeed"] = data | |
sfn_input = json.dumps(sfn_input) | |
start_execution_response = sfn.start_execution( | |
stateMachineArn=sfn_st, | |
input=sfn_input | |
) | |
response={} | |
response['executionArn'] = start_execution_response['executionArn'] | |
return { | |
'statusCode': 200, | |
'body': json.dumps(response) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment