"""Amazon Step Functions connector.""" import json import boto3 from timed_release import config def get_step_function_client(): """Get step function client. Returns: boto3.client.stepfunctions: scheduler client. """ return boto3.client('stepfunctions', region_name=config.AWS_REGION) def execute_step_function(arn=None, name=None, **kwargs): """Execute a step function with a provided ARN, optional name. Kwargs: arn (str): the ARN for the step function name (str): the name of the step function **kwargs (dict): parameters to serialize JSON, pass to input Return: dict: containing attributes related to execution """ return get_step_function_client() \ .start_execution( stateMachineArn=arn, name=name, input=json.dumps(kwargs) )