Skip to content

Instantly share code, notes, and snippets.

@konami99
Last active November 11, 2022 09:35
Show Gist options
  • Save konami99/558462b5f6a1716382f7e7ebc54ccf0a to your computer and use it in GitHub Desktop.
Save konami99/558462b5f6a1716382f7e7ebc54ccf0a to your computer and use it in GitHub Desktop.
Invoking Step Functions from Lambda
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