"""Event handling logic.""" import json import boto3 from src import config def trigger_stfn(input): """Trigger step function for content match audio.""" kwargs = { 'stateMachineArn': config.STEP_FN_ARN, 'input': json.dumps(input), 'name': f'asset-final-id-{input.get("asset_final_id")}' } stepfn_client = boto3.client('stepfunctions', config.AWS_REGION) try: response = stepfn_client.start_execution(**kwargs) except stepfn_client.exceptions.ExecutionAlreadyExists as e: return {'executionArn': str(e)} return response